Ejemplo n.º 1
0
 // TODO Instead should just fire actions which we hook into.
 // TODO should namespace api methods?
 switch ($action) {
     // TODO should be dynamic
     case 'get_plugin_version':
         $actions[$action] = '1.1';
         break;
     case 'get_filesystem_method':
         $actions[$action] = get_filesystem_method();
         break;
     case 'get_wp_version':
         global $wp_version;
         $actions[$action] = (string) $wp_version;
         break;
     case 'get_plugins':
         $actions[$action] = _wprp_supports_plugin_upgrade() ? _wprp_get_plugins() : 'not-implemented';
         break;
     case 'upgrade_plugin':
         $actions[$action] = _wprp_upgrade_plugin((string) $_GET['plugin']);
         break;
     case 'get_themes':
         $actions[$action] = _wprp_supports_theme_upgrade() ? _wprp_get_themes() : 'not-implemented';
         break;
     case 'upgrade_theme':
         $actions[$action] = _wprp_upgrade_theme((string) $_GET['theme']);
         break;
     case 'do_backup':
     case 'delete_backup':
     case 'supports_backups':
     case 'get_backup':
         $actions[$action] = _wprp_backups_api_call($action);
Ejemplo n.º 2
0
     if (is_array(WPR_API_Request::get_arg('constants'))) {
         foreach (WPR_API_Request::get_arg('constants') as $constant) {
             if (defined($constant)) {
                 $constants[$constant] = constant($constant);
             } else {
                 $constants[$constant] = null;
             }
         }
     }
     $actions[$action] = $constants;
     break;
 case 'upgrade_core':
     $actions[$action] = _wprp_upgrade_core();
     break;
 case 'get_plugins':
     $actions[$action] = _wprp_get_plugins();
     break;
 case 'update_plugin':
 case 'upgrade_plugin':
     $api_args = array('zip_url' => esc_url_raw(WPR_API_Request::get_arg('zip_url')));
     $actions[$action] = _wprp_update_plugin(sanitize_text_field(WPR_API_Request::get_arg('plugin')), $api_args);
     break;
 case 'install_plugin':
     $api_args = array('version' => sanitize_text_field(WPR_API_Request::get_arg('version')));
     $actions[$action] = _wprp_install_plugin(sanitize_text_field(WPR_API_Request::get_arg('plugin')), $api_args);
     break;
 case 'activate_plugin':
     $actions[$action] = _wprp_activate_plugin(sanitize_text_field(WPR_API_Request::get_arg('plugin')));
     break;
 case 'deactivate_plugin':
     $actions[$action] = _wprp_deactivate_plugin(sanitize_text_field(WPR_API_Request::get_arg('plugin')));