| 1 | 156a157,161 |
|---|
| 2 | > |
|---|
| 3 | > // Extensions for Plugin management |
|---|
| 4 | > 'wp.getPluginList' => 'this:wp_getPluginList', |
|---|
| 5 | > 'wp.activatePlugin' => 'this:wp_activatePlugin', |
|---|
| 6 | > 'wp.deactivatePlugin' => 'this:wp_deactivatePlugin', |
|---|
| 7 | 1335a1341,1361 |
|---|
| 8 | > |
|---|
| 9 | > /** |
|---|
| 10 | > * Retrieve list of plugins |
|---|
| 11 | > * |
|---|
| 12 | > * @since 3.0.0 |
|---|
| 13 | > * |
|---|
| 14 | > * @param array $args Method parameters. |
|---|
| 15 | > * @return array |
|---|
| 16 | > */ |
|---|
| 17 | > function wp_getPluginList($args) { |
|---|
| 18 | > $this->escape( $args ); |
|---|
| 19 | > |
|---|
| 20 | > $blog_id = (int) $args[0]; |
|---|
| 21 | > $username = $args[1]; |
|---|
| 22 | > $password = $args[2]; |
|---|
| 23 | > |
|---|
| 24 | > if ( !$user = $this->login($username, $password) ) |
|---|
| 25 | > return $this->error; |
|---|
| 26 | > |
|---|
| 27 | > if ( ! current_user_can('activate_plugins') ) |
|---|
| 28 | > return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) ); |
|---|
| 29 | 1336a1363,1426 |
|---|
| 30 | > do_action('xmlrpc_call', 'wp.getPluginList'); |
|---|
| 31 | > return get_plugins( ); |
|---|
| 32 | > } |
|---|
| 33 | > |
|---|
| 34 | > /** |
|---|
| 35 | > * Activate a plugin |
|---|
| 36 | > * |
|---|
| 37 | > * @since 3.0.0 |
|---|
| 38 | > * |
|---|
| 39 | > * @param array $args Method parameters. |
|---|
| 40 | > * @return boolean |
|---|
| 41 | > */ |
|---|
| 42 | > function wp_activatePlugin($args) { |
|---|
| 43 | > $this->escape( $args ); |
|---|
| 44 | > |
|---|
| 45 | > $blog_id = (int) $args[0]; // Not used for now |
|---|
| 46 | > $username = $args[1]; |
|---|
| 47 | > $password = $args[2]; |
|---|
| 48 | > $plugin = $args[3]; |
|---|
| 49 | > |
|---|
| 50 | > if ( !$user = $this->login($username, $password) ) |
|---|
| 51 | > return $this->error; |
|---|
| 52 | > |
|---|
| 53 | > if ( ! current_user_can('activate_plugins') ) |
|---|
| 54 | > return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) ); |
|---|
| 55 | > |
|---|
| 56 | > do_action('xmlrpc_call', 'wp.activatePlugin'); |
|---|
| 57 | > |
|---|
| 58 | > if (gettype(activate_plugin( $plugin, $redirect = '')) == 'WP_Error') { |
|---|
| 59 | > return false; |
|---|
| 60 | > } else { |
|---|
| 61 | > return true; |
|---|
| 62 | > } |
|---|
| 63 | > } |
|---|
| 64 | > |
|---|
| 65 | > /** |
|---|
| 66 | > * Deactivate a plugin |
|---|
| 67 | > * |
|---|
| 68 | > * @since 3.0.0 |
|---|
| 69 | > * |
|---|
| 70 | > * @param array $args Method parameters. |
|---|
| 71 | > * @return boolean |
|---|
| 72 | > */ |
|---|
| 73 | > function wp_deactivatePlugin($args) { |
|---|
| 74 | > $this->escape( $args ); |
|---|
| 75 | > |
|---|
| 76 | > $blog_id = (int) $args[0]; // Not used for now |
|---|
| 77 | > $username = $args[1]; |
|---|
| 78 | > $password = $args[2]; |
|---|
| 79 | > $plugin = $args[3]; |
|---|
| 80 | > |
|---|
| 81 | > if ( !$user = $this->login($username, $password) ) |
|---|
| 82 | > return $this->error; |
|---|
| 83 | > |
|---|
| 84 | > if ( ! current_user_can('activate_plugins') ) |
|---|
| 85 | > return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) ); |
|---|
| 86 | > |
|---|
| 87 | > do_action('xmlrpc_call', 'wp.deactivatePlugin'); |
|---|
| 88 | > |
|---|
| 89 | > $plugin = array($plugin); |
|---|
| 90 | > deactivate_plugins( $plugin, true ); |
|---|
| 91 | > return true; |
|---|
| 92 | > } |
|---|
| 93 | > |
|---|