protected function validate_input($plugin)
 {
     if (is_wp_error($error = parent::validate_input($plugin))) {
         return $error;
     }
     if (is_wp_error($error = $this->validate_network_wide())) {
         return $error;
     }
     $args = $this->input();
     // find out what plugin, or plugins we are dealing with
     // validate the requested plugins
     if (!isset($plugin) || empty($plugin)) {
         if (!$args['plugins'] || empty($args['plugins'])) {
             return new WP_Error('missing_plugin', __('You are required to specify a plugin.', 'jetpack'), 400);
         }
         if (is_array($args['plugins'])) {
             $this->plugins = $args['plugins'];
         } else {
             $this->plugins[] = $args['plugins'];
         }
     } else {
         $this->bulk = false;
         $this->plugins[] = urldecode($plugin);
     }
     if (is_wp_error($error = $this->validate_plugins())) {
         return $error;
     }
     return true;
 }
 public function callback($path = '', $blog_id = 0, $object = null)
 {
     Jetpack_JSON_API_Endpoint::validate_input($object);
     switch ($this->action) {
         case 'update':
             $this->needed_capabilities = 'update_plugins';
             break;
         case 'install':
             $this->needed_capabilities = 'install_plugins';
             break;
     }
     if (isset($args['autoupdate'])) {
         $this->needed_capabilities = 'update_plugins';
     }
     return parent::callback($path, $blog_id, $object);
 }
 /**
  * Walks through either the submitted theme or list of themes and creates the global array
  * @param $theme
  *
  * @return bool
  */
 protected function validate_input($theme)
 {
     $args = $this->input();
     // lets set what themes were requested, and validate them
     if (!isset($theme) || empty($theme)) {
         if (!$args['themes'] || empty($args['themes'])) {
             return new WP_Error('missing_theme', __('You are required to specify a theme to update.', 'jetpack'), 400);
         }
         if (is_array($args['themes'])) {
             $this->themes = $args['themes'];
         } else {
             $this->themes[] = $args['themes'];
         }
     } else {
         $this->themes[] = urldecode($theme);
         $this->bulk = false;
     }
     if (is_wp_error($error = $this->validate_themes())) {
         return error;
     }
     return parent::validate_input($theme);
 }
コード例 #4
0
 protected function validate_call($_blog_id, $capability, $check_manage_active = true)
 {
     parent::validate_call($_blog_id, $capability, false);
 }