Make WordPress Core

Ticket #10789: xmlrpc.php.plugins.diff

File xmlrpc.php.plugins.diff, 3.6 KB (added by dklon, 15 years ago)

XML-RPC plugin functions and get_plugin_data() mod for plugin.php

  • wp-admin/includes/plugin.php

     
    8181                'TextDomain' => 'Text Domain',
    8282                'DomainPath' => 'Domain Path',
    8383                'Network' => 'Network',
     84                'Active' => False,
    8485                // Site Wide Only is deprecated in favor of Network.
    8586                '_sitewide' => 'Site Wide Only',
    8687        );
     
    9798
    9899        //For backward compatibility by default Title is the same as Name.
    99100        $plugin_data['Title'] = $plugin_data['Name'];
     101       
     102        $plugin_data['Active'] = is_plugin_active(plugin_basename( $plugin_file ) );
    100103
    101104        if ( $markup || $translate )
    102105                $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
  • xmlrpc.php

     
    154154                        'wp.editComment'                => 'this:wp_editComment',
    155155                        'wp.newComment'                 => 'this:wp_newComment',
    156156                        'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
     157                       
     158                        // Extensions for Plugin management
     159                        'wp.getPluginList' => 'this:wp_getPluginList',
     160                        'wp.activatePlugin' => 'this:wp_activatePlugin',
     161                        'wp.deactivatePlugin' => 'this:wp_deactivatePlugin',
    157162
     163
    158164                        // Blogger API
    159165                        'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
    160166                        'blogger.getUserInfo' => 'this:blogger_getUserInfo',
     
    13331339
    13341340                return get_comment_statuses( );
    13351341        }
     1342       
     1343        /**
     1344         * Retrieve list of plugins
     1345         *
     1346         * @since 3.0.0
     1347         *
     1348         * @param array $args Method parameters.
     1349         * @return array
     1350         */
     1351        function wp_getPluginList($args) {
     1352                $this->escape( $args );
    13361353
     1354                $blog_id        = (int) $args[0];
     1355                $username       = $args[1];
     1356                $password       = $args[2];
     1357       
     1358                if ( !$user = $this->login($username, $password) )
     1359                        return $this->error;
     1360                       
     1361                if ( ! current_user_can('activate_plugins') )
     1362                        return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) );
     1363
     1364                do_action('xmlrpc_call', 'wp.getPluginList');
     1365                return get_plugins( );
     1366        }
     1367       
    13371368        /**
     1369         * Activate a plugin
     1370         *
     1371         * @since 3.0.0
     1372         *
     1373         * @param array $args Method parameters.
     1374         * @return boolean
     1375         */
     1376        function wp_activatePlugin($args) {
     1377                $this->escape( $args );
     1378               
     1379                $blog_id        = (int) $args[0];       // Not used for now
     1380                $username       = $args[1];
     1381                $password       = $args[2];
     1382                $plugin     = $args[3];
     1383               
     1384                if ( !$user = $this->login($username, $password) )
     1385                        return $this->error;
     1386                       
     1387                if ( ! current_user_can('activate_plugins') )
     1388                        return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) );
     1389
     1390                do_action('xmlrpc_call', 'wp.activatePlugin');
     1391
     1392                if (gettype(activate_plugin( $plugin, $redirect = '')) == 'WP_Error') {
     1393                        return false;
     1394                } else {
     1395                        return true;
     1396                }
     1397        }
     1398       
     1399        /**
     1400         * Deactivate a plugin
     1401         *
     1402         * @since 3.0.0
     1403         *
     1404         * @param array $args Method parameters.
     1405         * @return boolean
     1406         */
     1407        function wp_deactivatePlugin($args) {
     1408                $this->escape( $args );
     1409               
     1410                $blog_id        = (int) $args[0];       // Not used for now
     1411                $username       = $args[1];
     1412                $password       = $args[2];
     1413                $plugin     = $args[3];
     1414               
     1415                if ( !$user = $this->login($username, $password) )
     1416                        return $this->error;
     1417                       
     1418                if ( ! current_user_can('activate_plugins') )
     1419                        return new IXR_Error( 403, __( 'You are not allowed access to details about plugins.' ) );
     1420               
     1421                do_action('xmlrpc_call', 'wp.deactivatePlugin');
     1422
     1423                $plugin = array($plugin);
     1424                deactivate_plugins( $plugin, true );
     1425                return true;
     1426        }
     1427
     1428
     1429        /**
    13381430         * Retrieve comment count.
    13391431         *
    13401432         * @since 2.5.0