Esempio n. 1
0
 /**
  * any plugin updates available
  *
  * @return bool true if plugin updates are available
  */
 public static function plugin_updates_available()
 {
     $update_data = wp_get_update_data();
     $count = absint($update_data['counts']['plugins']);
     if ($count) {
         return true;
     }
     return false;
 }
 protected function result()
 {
     // pass an option to do it conditional;
     wp_update_themes();
     $update_data = wp_get_update_data();
     if (!isset($update_data['counts'])) {
         return new WP_Error('get_update_data_error', __('There was an error while getting the update data for this site.', 'jetpack'), 500);
     }
     $result = $update_data['counts'];
     include ABSPATH . WPINC . '/version.php';
     // $wp_version;
     $result['wp_version'] = isset($wp_version) ? $wp_version : null;
     $result['jp_version'] = JETPACK__VERSION;
     return $result;
 }
 protected function result()
 {
     wp_update_themes();
     wp_update_plugins();
     $update_data = wp_get_update_data();
     if (!isset($update_data['counts'])) {
         return new WP_Error('get_update_data_error', __('There was an error while getting the update data for this site.', 'jetpack'), 500);
     }
     $result = $update_data['counts'];
     include ABSPATH . WPINC . '/version.php';
     // $wp_version;
     $result['wp_version'] = isset($wp_version) ? $wp_version : null;
     if (!empty($result['wordpress'])) {
         $cur = get_preferred_from_update_core();
         if (isset($cur->response) && $cur->response === 'upgrade') {
             $result['wp_update_version'] = $cur->current;
         }
     }
     $result['jp_version'] = JETPACK__VERSION;
     return $result;
 }
 /**
  * Get number of plugin updates available.
  *
  * @since 4.3.0
  *
  * @return mixed|WP_Error Number of plugin updates available. Otherwise, a WP_Error instance with the corresponding error.
  */
 public static function get_plugin_update_count()
 {
     $updates = wp_get_update_data();
     if (isset($updates['counts']) && isset($updates['counts']['plugins'])) {
         $count = $updates['counts']['plugins'];
         if (0 == $count) {
             $response = array('code' => 'success', 'message' => esc_html__('All plugins are up-to-date. Keep up the good work!', 'jetpack'), 'count' => 0);
         } else {
             $response = array('code' => 'updates-available', 'message' => esc_html(sprintf(_n('%s plugin need updating.', '%s plugins need updating.', $count, 'jetpack'), $count)), 'count' => $count);
         }
         return rest_ensure_response($response);
     }
     return new WP_Error('not_found', esc_html__('Could not check updates for plugins on this site.', 'jetpack'), array('status' => 404));
 }
 function admin_bar_menu()
 {
     global $wp_admin_bar;
     $GetData = $this->get_flit_data('admin_bar_menu');
     if (!empty($GetData["UPFN"])) {
         unset($GetData["UPFN"]);
         if (is_array($GetData)) {
             // admin bar initialize nodes
             $All_Nodes = $wp_admin_bar->get_nodes();
             foreach ($All_Nodes as $node) {
                 if ($node->id != 'top-secondary') {
                     $wp_admin_bar->remove_node($node->id);
                 }
             }
             $SettingNodes = $GetData;
             $user_id = get_current_user_id();
             $current_user = wp_get_current_user();
             $profile_url = get_edit_profile_url($user_id);
             $update_data = wp_get_update_data();
             $activated_plugin = $this->ActivatedPlugin;
             $other_plugin = $this->OtherPluginMenu;
             // all nodes adjustment
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $key => $node) {
                         if (strstr($node["id"], 'custom_node')) {
                             if (!empty($node["group"])) {
                                 $node["meta"]["class"] = 'ab-sub-secondary';
                             } else {
                                 $node["href"] = $this->val_replace($node["href"]);
                             }
                         } elseif ($node["id"] == 'view-post_type') {
                             if (is_admin()) {
                                 if (!empty($All_Nodes['preview'])) {
                                     $node["href"] = $All_Nodes['preview']->href;
                                     $node["meta"] = $All_Nodes['preview']->meta;
                                 } elseif (!empty($All_Nodes['view'])) {
                                     $node["href"] = $All_Nodes['view']->href;
                                     $node["meta"] = $All_Nodes['view']->meta;
                                 } else {
                                     unset($SettingNodes[$Boxtype][$node_type][$key]);
                                     continue;
                                 }
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif ($node["id"] == 'edit-post_type') {
                             if (!empty($All_Nodes["edit"])) {
                                 //$node["title"] = $All_Nodes["edit"]->title;
                                 $node["href"] = $All_Nodes["edit"]->href;
                                 $node["id"] = $All_Nodes["edit"]->id;
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif ($node["id"] == 'search') {
                             if (!empty($All_Nodes["search"])) {
                                 $node["title"] = $All_Nodes["search"]->title;
                                 $node["id"] = $All_Nodes["search"]->id;
                                 $node["href"] = "";
                                 $node["meta"]["class"] = $All_Nodes["search"]->meta["class"];
                             } else {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             }
                         } elseif (!empty($All_Nodes[$node["id"]])) {
                             if ($node["id"] == 'search') {
                                 $node["href"] = $All_Nodes[$node["id"]]->href;
                                 $node["title"] = $All_Nodes[$node["id"]]->title;
                             } else {
                                 $node["href"] = $All_Nodes[$node["id"]]->href;
                             }
                         } else {
                             unset($SettingNodes[$Boxtype][$node_type][$key]);
                             continue;
                         }
                         if (!empty($All_Nodes[$node["id"]]->meta["title"])) {
                             $node["meta"]["title"] = $All_Nodes[$node["id"]]->meta["title"];
                         }
                         if ($Boxtype == 'right' && $node_type == 'main') {
                             $node["parent"] = "top-secondary";
                         }
                         if (strstr($node["title"], '[comment_count]')) {
                             if (!current_user_can('edit_posts')) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[comment_count]', '<span class="ab-icon"></span><span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-[comment_count]">[comment_count_format]</span>', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_total]')) {
                             if (!$update_data['counts']['total']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_total]', '<span class="ab-icon"></span><span class="ab-label">[update_total_format]</span>', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_plugins]')) {
                             if (!$update_data['counts']['plugins']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_plugins]', '[update_plugins_format]', $node["title"]);
                             }
                         }
                         if (strstr($node["title"], '[update_themes]')) {
                             if (!$update_data['counts']['themes']) {
                                 unset($SettingNodes[$Boxtype][$node_type][$key]);
                                 continue;
                             } else {
                                 $node["title"] = str_replace('[update_themes]', '[update_themes_format]', $node["title"]);
                             }
                         }
                         if ($node["id"] == 'logout') {
                             $node["href"] = wp_logout_url();
                         }
                         if ($node["id"] == 'my-account') {
                             $avatar = get_avatar($user_id, 16);
                             $class = empty($avatar) ? '' : 'with-avatar';
                             $node["meta"]["class"] = $class;
                         }
                         if (!isset($node["group"])) {
                             $node["group"] = "";
                         }
                         $node["title"] = $this->val_replace($node["title"]);
                         $SettingNodes[$Boxtype][$node_type][$key] = $node;
                     }
                 }
             }
             // other plugin nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $key => $node) {
                         if (!empty($activated_plugin)) {
                             if ($node["id"] == 'bp-notifications') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'page_list') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'post_list') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             } elseif ($node["id"] == 'languages') {
                                 foreach ($All_Nodes as $default_node_id => $default_node) {
                                     if ($default_node->parent == $node["id"]) {
                                         $subnode_type = '';
                                         if ($node_type == 'main') {
                                             $subnode_type = 'sub';
                                         } elseif ($node_type == 'sub') {
                                             $subnode_type = 'sub2';
                                         } elseif ($node_type == 'sub2') {
                                             $subnode_type = 'sub3';
                                         } elseif ($node_type == 'sub3') {
                                             $subnode_type = 'sub4';
                                         }
                                         if (!empty($subnode_type)) {
                                             $SettingNodes[$Boxtype][$subnode_type][] = (array) $default_node;
                                         }
                                     }
                                 }
                             }
                             foreach ($activated_plugin as $plugin_slug => $v) {
                                 if (!empty($other_plugin["admin_bar"][$plugin_slug]) && array_key_exists($node["id"], $other_plugin["admin_bar"][$plugin_slug])) {
                                     $SettingNodes[$Boxtype][$node_type][$key]["title"] = $All_Nodes[$node["id"]]->title;
                                     $SettingNodes[$Boxtype][$node_type][$key]["href"] = $All_Nodes[$node["id"]]->href;
                                 }
                             }
                         }
                     }
                 }
             }
             // add main nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     if ($node_type == 'main') {
                         foreach ($nodes as $node_id => $node) {
                             $args = array("id" => $node["id"], "title" => stripslashes($node["title"]), "href" => $node["href"], "parent" => $node["parent"], "group" => $node["group"], "meta" => $node["meta"]);
                             $wp_admin_bar->add_menu($args);
                             unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                         }
                     }
                 }
             }
             // add all nodes
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     if ($node_type != 'main') {
                         foreach ($nodes as $node_id => $node) {
                             if (empty($node["group"])) {
                                 $args = array("id" => $node["id"], "title" => stripslashes($node["title"]), "href" => $node["href"], "parent" => $node["parent"], "group" => false, "meta" => $node["meta"]);
                                 $wp_admin_bar->add_menu($args);
                                 unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                             }
                         }
                     }
                 }
             }
             // add groups
             foreach ($SettingNodes as $Boxtype => $allnodes) {
                 foreach ($allnodes as $node_type => $nodes) {
                     foreach ($nodes as $node_id => $node) {
                         if (!empty($node["group"])) {
                             $args = array("id" => $node["id"], "parent" => $node["parent"], "meta" => $node["meta"]);
                             $wp_admin_bar->add_group($args);
                             unset($SettingNodes[$Boxtype][$node_type][$node_id]);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Calculates available updates and saves them to a Jetpack Option
  * Update data is saved in the following schema:
  *
  * array (
  *      'plugins'                       => (int) number of plugin updates available
  *      'themes'                        => (int) number of theme updates available
  *      'wordpress'                     => (int) number of wordpress core updates available
  *      'translations'                  => (int) number of translation updates available
  *      'total'                         => (int) total of all available updates
  *      'wp_version'                    => (string) the current version of WordPress that is running
  *      'wp_update_version'             => (string) the latest available version of WordPress, only present if a WordPress update is needed
  *      'site_is_version_controlled'    => (bool) is the site under version control
  * )
  */
 function save_update_data()
 {
     global $wp_version;
     $update_data = wp_get_update_data();
     // Stores the individual update counts as well as the total count.
     if (isset($update_data['counts'])) {
         $updates = $update_data['counts'];
     }
     // Stores the current version of WordPress.
     $updates['wp_version'] = $wp_version;
     // If we need to update WordPress core, let's find the latest version number.
     if (!empty($updates['wordpress'])) {
         $cur = get_preferred_from_update_core();
         if (isset($cur->response) && 'upgrade' === $cur->response) {
             $updates['wp_update_version'] = $cur->current;
         }
     }
     $updates['site_is_version_controlled'] = (bool) $this->is_version_controlled();
     Jetpack_Options::update_option('updates', $updates);
 }
Esempio n. 7
0
 /**
  * Display admin bar updates for WordPress 3.3
  *
  * @param WP_Admin_Bar instance
  * @param integer $count
  * @param string $title
  * @return void
  */
 private function wp_admin_bar_updates_menu($wp_admin_bar, $count = 0, $title = '')
 {
     if (!$count or !$title) {
         return;
     }
     $update_data = wp_get_update_data();
     $update_data['counts']['total'] += $count;
     if (!$update_data['title']) {
         $update_data['title'] = $title;
     } else {
         $update_data['title'] .= ", {$title}";
     }
     $update_title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n($update_data['counts']['total']) . '</span>';
     $update_node = $wp_admin_bar->get_node('updates');
     // Does the update menu already exist?
     if (!$update_node) {
         $wp_admin_bar->add_menu(array('id' => 'updates', 'title' => $update_title, 'href' => network_admin_url('update-core.php'), 'meta' => array('title' => $update_data['title'])));
         return;
     }
     // Update existing menu
     $update_node->title = $update_title;
     $update_node->meta['title'] = $update_data['title'];
     $wp_admin_bar->add_menu($update_node);
 }
				<# if ( data.actions.activate ) { #>
					<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php 
echo $aria_label;
?>
"><?php 
_e('Activate');
?>
</a>
				<# } #>
				<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php 
_e('Live Preview');
?>
</a>
			</div>

			<# if ( ! data.active && data.actions['delete'] ) { #>
				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php 
_e('Delete');
?>
</a>
			<# } #>
		</div>
	</div>
</script>

<?php 
wp_print_request_filesystem_credentials_modal();
wp_print_admin_notice_templates();
wp_print_update_row_templates();
wp_localize_script('updates', '_wpUpdatesItemCounts', array('totals' => wp_get_update_data()));
require ABSPATH . 'wp-admin/admin-footer.php';
Esempio n. 9
0
/**
 * Provide an update link if theme/plugin/core updates are available.
 *
 * @since 3.1.0
 */
function wp_admin_bar_updates_menu($wp_admin_bar)
{
    $update_data = wp_get_update_data();
    if (!$update_data['counts']['total']) {
        return;
    }
    $update_title = "<span title='{$update_data['title']}'>";
    $update_title .= sprintf(__('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_data['counts']['total']) . '</span>');
    $update_title .= '</span>';
    $wp_admin_bar->add_menu(array('id' => 'updates', 'title' => $update_title, 'href' => network_admin_url('update-core.php')));
}
 /**
  * jetpack_updates is saved in the following schema:
  *
  * array (
  *      'plugins'                       => (int) Number of plugin updates available.
  *      'themes'                        => (int) Number of theme updates available.
  *      'wordpress'                     => (int) Number of WordPress core updates available.
  *      'translations'                  => (int) Number of translation updates available.
  *      'total'                         => (int) Total of all available updates.
  *      'wp_update_version'             => (string) The latest available version of WordPress, only present if a WordPress update is needed.
  * )
  * @return array
  */
 public static function get_updates()
 {
     $update_data = wp_get_update_data();
     // Stores the individual update counts as well as the total count.
     if (isset($update_data['counts'])) {
         $updates = $update_data['counts'];
     }
     // If we need to update WordPress core, let's find the latest version number.
     if (!empty($updates['wordpress'])) {
         $cur = get_preferred_from_update_core();
         if (isset($cur->response) && 'upgrade' === $cur->response) {
             $updates['wp_update_version'] = $cur->current;
         }
     }
     return isset($updates) ? $updates : array();
 }
 /**
  *
  * @global string $status
  * @global array  $plugins
  * @global array  $totals
  * @global int    $page
  * @global string $orderby
  * @global string $order
  * @global string $s
  */
 public function prepare_items()
 {
     global $status, $plugins, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order'));
     /**
      * Filters the full array of plugins to list in the Plugins list table.
      *
      * @since 3.0.0
      *
      * @see get_plugins()
      *
      * @param array $all_plugins An array of plugins to display in the list table.
      */
     $all_plugins = apply_filters('all_plugins', get_plugins());
     $plugins = array('all' => $all_plugins, 'search' => array(), 'active' => array(), 'inactive' => array(), 'recently_activated' => array(), 'upgrade' => array(), 'mustuse' => array(), 'dropins' => array());
     $screen = $this->screen;
     if (!is_multisite() || $screen->in_admin('network') && current_user_can('manage_network_plugins')) {
         /**
          * Filters whether to display the advanced plugins list table.
          *
          * There are two types of advanced plugins - must-use and drop-ins -
          * which can be used in a single site or Multisite network.
          *
          * The $type parameter allows you to differentiate between the type of advanced
          * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'.
          *
          * @since 3.0.0
          *
          * @param bool   $show Whether to show the advanced plugins for the specified
          *                     plugin type. Default true.
          * @param string $type The plugin type. Accepts 'mustuse', 'dropins'.
          */
         if (apply_filters('show_advanced_plugins', true, 'mustuse')) {
             $plugins['mustuse'] = get_mu_plugins();
         }
         /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
         if (apply_filters('show_advanced_plugins', true, 'dropins')) {
             $plugins['dropins'] = get_dropins();
         }
         if (current_user_can('update_plugins')) {
             $current = get_site_transient('update_plugins');
             foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
                 if (isset($current->response[$plugin_file])) {
                     $plugins['all'][$plugin_file]['update'] = true;
                     $plugins['upgrade'][$plugin_file] = $plugins['all'][$plugin_file];
                 }
             }
         }
     }
     if (!$screen->in_admin('network')) {
         $show = current_user_can('manage_network_plugins');
         /**
          * Filters whether to display network-active plugins alongside plugins active for the current site.
          *
          * This also controls the display of inactive network-only plugins (plugins with
          * "Network: true" in the plugin header).
          *
          * Plugins cannot be network-activated or network-deactivated from this screen.
          *
          * @since 4.4.0
          *
          * @param bool $show Whether to show network-active plugins. Default is whether the current
          *                   user can manage network plugins (ie. a Super Admin).
          */
         $show_network_active = apply_filters('show_network_active_plugins', $show);
     }
     set_transient('plugin_slugs', array_keys($plugins['all']), DAY_IN_SECONDS);
     if ($screen->in_admin('network')) {
         $recently_activated = get_site_option('recently_activated', array());
     } else {
         $recently_activated = get_option('recently_activated', array());
     }
     foreach ($recently_activated as $key => $time) {
         if ($time + WEEK_IN_SECONDS < time()) {
             unset($recently_activated[$key]);
         }
     }
     if ($screen->in_admin('network')) {
         update_site_option('recently_activated', $recently_activated);
     } else {
         update_option('recently_activated', $recently_activated);
     }
     $plugin_info = get_site_transient('update_plugins');
     foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) {
         // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
         if (isset($plugin_info->response[$plugin_file])) {
             $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data);
             // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
             if (isset($plugins['upgrade'][$plugin_file])) {
                 $plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data);
             }
         } elseif (isset($plugin_info->no_update[$plugin_file])) {
             $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data);
             // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
             if (isset($plugins['upgrade'][$plugin_file])) {
                 $plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data);
             }
         }
         // Filter into individual sections
         if (is_multisite() && !$screen->in_admin('network') && is_network_only_plugin($plugin_file) && !is_plugin_active($plugin_file)) {
             if ($show_network_active) {
                 // On the non-network screen, show inactive network-only plugins if allowed
                 $plugins['inactive'][$plugin_file] = $plugin_data;
             } else {
                 // On the non-network screen, filter out network-only plugins as long as they're not individually active
                 unset($plugins['all'][$plugin_file]);
             }
         } elseif (!$screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) {
             if ($show_network_active) {
                 // On the non-network screen, show network-active plugins if allowed
                 $plugins['active'][$plugin_file] = $plugin_data;
             } else {
                 // On the non-network screen, filter out network-active plugins
                 unset($plugins['all'][$plugin_file]);
             }
         } elseif (!$screen->in_admin('network') && is_plugin_active($plugin_file) || $screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) {
             // On the non-network screen, populate the active list with plugins that are individually activated
             // On the network-admin screen, populate the active list with plugins that are network activated
             $plugins['active'][$plugin_file] = $plugin_data;
         } else {
             if (isset($recently_activated[$plugin_file])) {
                 // Populate the recently activated list with plugins that have been recently activated
                 $plugins['recently_activated'][$plugin_file] = $plugin_data;
             }
             // Populate the inactive list with plugins that aren't activated
             $plugins['inactive'][$plugin_file] = $plugin_data;
         }
     }
     if (strlen($s)) {
         $status = 'search';
         $plugins['search'] = array_filter($plugins['all'], array($this, '_search_callback'));
     }
     $totals = array();
     foreach ($plugins as $type => $list) {
         $totals[$type] = count($list);
     }
     if (empty($plugins[$status]) && !in_array($status, array('all', 'search'))) {
         $status = 'all';
     }
     $this->items = array();
     foreach ($plugins[$status] as $plugin_file => $plugin_data) {
         // Translate, Don't Apply Markup, Sanitize HTML
         $this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true);
     }
     $total_this_page = $totals[$status];
     $js_plugins = array();
     foreach ($plugins as $key => $list) {
         $js_plugins[$key] = array_keys((array) $list);
     }
     wp_localize_script('updates', '_wpUpdatesItemCounts', array('plugins' => $js_plugins, 'totals' => wp_get_update_data()));
     if (!$orderby) {
         $orderby = 'Name';
     } else {
         $orderby = ucfirst($orderby);
     }
     $order = strtoupper($order);
     uasort($this->items, array($this, '_order_callback'));
     $plugins_per_page = $this->get_items_per_page(str_replace('-', '_', $screen->id . '_per_page'), 999);
     $start = ($page - 1) * $plugins_per_page;
     if ($total_this_page > $plugins_per_page) {
         $this->items = array_slice($this->items, $start, $plugins_per_page);
     }
     $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $plugins_per_page));
 }
 /**
  * Move update core menu after options menu.
  */
 public function admin_menu()
 {
     global $menu;
     $update = wp_get_update_data();
     $name = __('Updates', 'admin-menu-tabs');
     $position = 81;
     if ($update['counts']['total']) {
         $name .= sprintf(' <span class="update-plugins count-%s"><span class="plugin-count">%s</span></span>', $update['counts']['total'], $update['counts']['total']);
     }
     while (isset($menu[$position])) {
         $position++;
     }
     add_menu_page($name, $name, 'update_core', 'update-core.php', '', '', $position);
 }
 /**
  * Calculates available updates and saves them to a Jetpack Option
  *
  * jetpack_updates is saved in the following schema:
  *
  * array (
  *      'plugins'                       => (int) Number of plugin updates available.
  *      'themes'                        => (int) Number of theme updates available.
  *      'wordpress'                     => (int) Number of WordPress core updates available.
  *      'translations'                  => (int) Number of translation updates available.
  *      'total'                         => (int) Total of all available updates.
  *      'wp_update_version'             => (string) The latest available version of WordPress, only present if a WordPress update is needed.
  * )
  *
  * jetpack_update_details is saved in the following schema:
  *
  * array (
  *      'update_core'       => (array) The contents of the update_core transient.
  *      'update_themes'     => (array) The contents of the update_themes transient.
  *      'update_plugins'    => (array) The contents of the update_plugins transient.
  * )
  *
  */
 function save_update_data()
 {
     if (!current_user_can('update_plugins') || !current_user_can('update_core') || !current_user_can('update_themes')) {
         // `wp_get_updated_data` will not return useful information if a user does not have the capabilities.
         // We should should therefore bail to avoid saving incomplete data.
         return;
     }
     $update_data = wp_get_update_data();
     // Stores the individual update counts as well as the total count.
     if (isset($update_data['counts'])) {
         $updates = $update_data['counts'];
     }
     // If we need to update WordPress core, let's find the latest version number.
     if (!empty($updates['wordpress'])) {
         $cur = get_preferred_from_update_core();
         if (isset($cur->response) && 'upgrade' === $cur->response) {
             $updates['wp_update_version'] = $cur->current;
         }
     }
     Jetpack_Options::update_option('updates', $updates);
     // Let's also store and sync more details about what updates are needed.
     $update_details = array('update_core' => get_site_transient('update_core'), 'update_plugins' => get_site_transient('update_plugins'), 'update_themes' => get_site_transient('update_themes'));
     Jetpack_Options::update_option('update_details', $update_details);
 }
Esempio n. 14
0
 private function val_replace($str)
 {
     if (!empty($str)) {
         $update_data = wp_get_update_data();
         $awaiting_mod = wp_count_comments();
         $awaiting_mod = $awaiting_mod->moderated;
         $current_user = wp_get_current_user();
         if (is_multisite()) {
             $current_site = get_current_site();
         }
         if (strstr($str, '[comment_count]')) {
             if (current_user_can('edit_posts')) {
                 $str = str_replace('[comment_count]', '<span class="ab-icon"></span><span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-[comment_count]">[comment_count_format]</span>', $str);
             }
         }
         if (strstr($str, '[update_total]')) {
             if ($update_data['counts']['total']) {
                 $str = str_replace('[update_total]', '<span class="ab-icon"></span><span class="ab-label">[update_total_format]</span>', $str);
             }
         }
         if (strstr($str, '[update_plugins]')) {
             if ($update_data['counts']['plugins']) {
                 $str = str_replace('[update_plugins]', '[update_plugins_format]', $str);
             }
         }
         if (strstr($str, '[update_themes]')) {
             if ($update_data['counts']['themes']) {
                 $str = str_replace('[update_themes]', '[update_themes_format]', $str);
             }
         }
         if (strstr($str, '[blog_url]')) {
             $str = str_replace('[blog_url]', home_url(), $str);
         }
         if (strstr($str, '[template_directory_uri]')) {
             $str = str_replace('[template_directory_uri]', get_template_directory_uri(), $str);
         }
         if (strstr($str, '[stylesheet_directory_uri]')) {
             $str = str_replace('[stylesheet_directory_uri]', get_stylesheet_directory_uri(), $str);
         }
         if (strstr($str, '[blog_name]')) {
             $str = str_replace('[blog_name]', get_bloginfo('name'), $str);
         }
         if (strstr($str, '[update_total]')) {
             $str = str_replace('[update_total]', $update_data["counts"]["total"], $str);
         }
         if (strstr($str, '[update_total_format]')) {
             $str = str_replace('[update_total_format]', number_format_i18n($update_data["counts"]["total"]), $str);
         }
         if (strstr($str, '[update_plugins]')) {
             $str = str_replace('[update_plugins]', $update_data["counts"]["plugins"], $str);
         }
         if (strstr($str, '[update_plugins_format]')) {
             $str = str_replace('[update_plugins_format]', number_format_i18n($update_data["counts"]["plugins"]), $str);
         }
         if (strstr($str, '[update_themes]')) {
             $str = str_replace('[update_themes]', $update_data["counts"]["themes"], $str);
         }
         if (strstr($str, '[update_themes_format]')) {
             $str = str_replace('[update_themes_format]', number_format_i18n($update_data["counts"]["themes"]), $str);
         }
         if (strstr($str, '[comment_count]')) {
             $str = str_replace('[comment_count]', $awaiting_mod, $str);
         }
         if (strstr($str, '[comment_count_format]')) {
             $str = str_replace('[comment_count_format]', number_format_i18n($awaiting_mod), $str);
         }
         if (strstr($str, '[user_name]')) {
             $str = str_replace('[user_name]', '<span class="display-name">' . $current_user->display_name . '</span>', $str);
         }
         if (strstr($str, '[user_login]')) {
             $str = str_replace('[user_login]', '<span class=\'username\'>' . $current_user->user_login . '</span>', $str);
         }
         if (strstr($str, '[avatar16]')) {
             if (function_exists('bp_core_fetch_avatar')) {
                 $avatar16 = bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'type' => 'thumb', 'width' => 16, 'height' => 16, 'class' => 'friend-avatar', 'html' => true));
             } else {
                 $avatar16 = get_avatar(get_the_author_meta($current_user->user_login), 16);
             }
             $str = str_replace('[avatar16]', $avatar16, $str);
         }
         if (strstr($str, '[avatar64]')) {
             if (function_exists('bp_core_fetch_avatar')) {
                 $avatar64 = bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'type' => 'full', 'width' => 64, 'height' => 64, 'class' => 'friend-avatar', 'html' => true));
             } else {
                 $avatar64 = get_avatar(get_the_author_meta($current_user->user_login), 64);
             }
             $str = str_replace('[avatar64]', $avatar64, $str);
         }
         if (is_multisite()) {
             if (strstr($str, '[site_name]')) {
                 $str = str_replace('[site_name]', esc_attr($current_site->site_name), $str);
             }
             if (strstr($str, '[site_url]')) {
                 $protocol = is_ssl() ? 'https://' : 'http://';
                 $str = str_replace('[site_url]', $protocol . esc_attr($current_site->domain), $str);
             }
         }
     }
     return $str;
 }
 /**
  *
  * @global string $status
  * @global array $totals
  * @global int $page
  * @global string $orderby
  * @global string $order
  * @global string $s
  */
 public function prepare_items()
 {
     global $status, $totals, $page, $orderby, $order, $s;
     wp_reset_vars(array('orderby', 'order', 's'));
     $themes = array('all' => apply_filters('all_themes', wp_get_themes()), 'search' => array(), 'enabled' => array(), 'disabled' => array(), 'upgrade' => array(), 'broken' => $this->is_site_themes ? array() : wp_get_themes(array('errors' => true)));
     if ($this->is_site_themes) {
         $themes_per_page = $this->get_items_per_page('site_themes_network_per_page');
         $allowed_where = 'site';
     } else {
         $themes_per_page = $this->get_items_per_page('themes_network_per_page');
         $allowed_where = 'network';
     }
     $maybe_update = current_user_can('update_themes') && !$this->is_site_themes && ($current = get_site_transient('update_themes'));
     foreach ((array) $themes['all'] as $key => $theme) {
         if ($this->is_site_themes && $theme->is_allowed('network')) {
             unset($themes['all'][$key]);
             continue;
         }
         if ($maybe_update && isset($current->response[$key])) {
             $themes['all'][$key]->update = true;
             $themes['upgrade'][$key] = $themes['all'][$key];
         }
         $filter = $theme->is_allowed($allowed_where, $this->site_id) ? 'enabled' : 'disabled';
         $themes[$filter][$key] = $themes['all'][$key];
     }
     if ($s) {
         $status = 'search';
         $themes['search'] = array_filter(array_merge($themes['all'], $themes['broken']), array($this, '_search_callback'));
     }
     $totals = array();
     foreach ($themes as $type => $list) {
         $totals[$type] = count($list);
     }
     if (empty($themes[$status]) && !in_array($status, array('all', 'search'))) {
         $status = 'all';
     }
     $this->items = $themes[$status];
     WP_Theme::sort_by_name($this->items);
     $this->has_items = !empty($themes['all']);
     $total_this_page = $totals[$status];
     wp_localize_script('updates', '_wpUpdatesItemCounts', array('themes' => $totals, 'totals' => wp_get_update_data()));
     if ($orderby) {
         $orderby = ucfirst($orderby);
         $order = strtoupper($order);
         if ($orderby === 'Name') {
             if ('ASC' === $order) {
                 $this->items = array_reverse($this->items);
             }
         } else {
             uasort($this->items, array($this, '_order_callback'));
         }
     }
     $start = ($page - 1) * $themes_per_page;
     if ($total_this_page > $themes_per_page) {
         $this->items = array_slice($this->items, $start, $themes_per_page, true);
     }
     $this->set_pagination_args(array('total_items' => $total_this_page, 'per_page' => $themes_per_page));
 }
/**
 * Add admin submenu items to the "Site Name" menu.
 *
 * @since 4.4.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_toolbar_experiments_ab_admin_menu($wp_admin_bar)
{
    $wp_admin_bar->add_group(array('parent' => 'site-name', 'id' => 'admin'));
    // Post types.
    $cpts = (array) get_post_types(array('show_in_admin_bar' => true), 'objects');
    if (isset($cpts['post']) && current_user_can($cpts['post']->cap->edit_posts)) {
        $menu_icon = '<span class="ab-icon dashicons-admin-post"></span>';
        $actions['edit.php'] = array($cpts['post']->labels->name, 'edit-posts', $menu_icon);
    }
    if (isset($cpts['attachment']) && current_user_can('edit_posts')) {
        $menu_icon = '<span class="ab-icon dashicons-admin-media"></span>';
        $actions['upload.php'] = array($cpts['attachment']->labels->name, 'edit-media', $menu_icon);
    }
    if (isset($cpts['page']) && current_user_can($cpts['page']->cap->edit_posts)) {
        $menu_icon = '<span class="ab-icon dashicons-admin-page"></span>';
        $actions['edit.php?post_type=page'] = array($cpts['page']->labels->name, 'edit-pages', $menu_icon);
    }
    unset($cpts['post'], $cpts['page'], $cpts['attachment']);
    // Add any additional custom post types.
    foreach ($cpts as $cpt) {
        if (!current_user_can($cpt->cap->edit_posts)) {
            continue;
        }
        if (is_string($cpt->menu_icon)) {
            // Special handling for data:image/svg+xml and Dashicons.
            if (0 === strpos($cpt->menu_icon, 'dashicons-')) {
                $menu_icon = '<span class="ab-icon ' . $cpt->menu_icon . '"></span>';
            } elseif (0 === strpos($cpt->menu_icon, 'data:image/svg+xml;base64,')) {
                $menu_icon = '<span class="ab-icon"><img src="' . $cpt->menu_icon . '"></span>';
            } else {
                $menu_icon = '<span class="ab-icon"><img src="' . esc_url($cpt->menu_icon) . '"></span>';
            }
        } else {
            $menu_icon = '<span class="ab-icon dashicons-admin-post"></span>';
        }
        $key = 'edit.php?post_type=' . $cpt->name;
        $actions[$key] = array($cpt->labels->menu_name, 'edit-' . $cpt->name, $menu_icon);
    }
    if ($actions) {
        foreach ($actions as $link => $action) {
            list($title, $id, $menu_icon) = $action;
            $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => $id, 'title' => $menu_icon . '<span class="ab-label">' . $title . '</span>', 'href' => admin_url($link)));
        }
    }
    // Comments
    if (current_user_can('edit_posts')) {
        $awaiting_mod = wp_count_comments();
        $awaiting_mod = $awaiting_mod->moderated;
        $icon = '<span class="ab-icon dashicons-admin-comments"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'comments', 'title' => $icon . '<span class="ab-label">' . sprintf(__('Comments %s'), "<span class='awaiting-mod count-{$awaiting_mod}'><span class='pending-count'>" . number_format_i18n($awaiting_mod) . "</span></span>") . '</span>', 'href' => admin_url('edit-comments.php')));
    }
    // Appearance.
    if (current_user_can('switch_themes') || current_user_can('edit_theme_options')) {
        $icon = '<span class="ab-icon dashicons-admin-appearance"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'themes', 'title' => $icon . '<span class="ab-label">' . __('Appearance') . '</span>', 'href' => admin_url('themes.php')));
    }
    // Plugins.
    if (current_user_can('activate_plugins')) {
        if (!is_multisite() && current_user_can('update_plugins')) {
            $update_data = wp_get_update_data();
            $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>";
        } else {
            $count = '';
        }
        $icon = '<span class="ab-icon dashicons-admin-plugins"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'plugins', 'title' => $icon . '<span class="ab-label">' . sprintf(__('Plugins %s'), $count) . '</span>', 'href' => admin_url('plugins.php')));
    }
    // Users.
    if (current_user_can('list_users')) {
        $icon = '<span class="ab-icon dashicons-admin-users"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'edit-users', 'title' => $icon . '<span class="ab-label">' . __('Users') . '</span>', 'href' => admin_url('users.php')));
    }
    // Tools.
    if (current_user_can('edit_posts')) {
        $icon = '<span class="ab-icon dashicons-admin-tools"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'tools', 'title' => $icon . '<span class="ab-label">' . __('Tools') . '</span>', 'href' => admin_url('tools.php')));
    }
    // Settings.
    if (current_user_can('manage_options')) {
        $icon = '<span class="ab-icon dashicons-admin-settings"></span>';
        $wp_admin_bar->add_menu(array('parent' => 'admin', 'id' => 'settings', 'title' => $icon . '<span class="ab-label">' . __('Settings') . '</span>', 'href' => admin_url('options.php')));
    }
}
Esempio n. 17
0
/**
 * Provide an update link if theme/plugin/core updates are available.
 *
 * @since 3.1.0
 *
 * @param WP_Admin_Bar $wp_admin_bar
 */
function wp_admin_bar_updates_menu($wp_admin_bar)
{
    $update_data = wp_get_update_data();
    if (!$update_data['counts']['total']) {
        return;
    }
    $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n($update_data['counts']['total']) . '</span>';
    $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
    $wp_admin_bar->add_menu(array('id' => 'updates', 'title' => $title, 'href' => network_admin_url('update-core.php'), 'meta' => array('title' => $update_data['title'])));
}
 /**
  * Collects the necessary information to return for a site's response.
  *
  * @return (array)
  */
 public function build_current_site_response()
 {
     global $wpdb, $wp_version;
     $response_format = self::$site_format;
     $is_user_logged_in = is_user_logged_in();
     $visible = array();
     if ($is_user_logged_in) {
         $current_user = wp_get_current_user();
         $visible = get_user_meta($current_user->ID, 'blog_visibility', true);
         if (!is_array($visible)) {
             $visible = array();
         }
     }
     $blog_id = (int) $this->api->get_blog_id_for_output();
     $is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id);
     $site_url = get_option('siteurl');
     if ($is_jetpack) {
         remove_filter('option_stylesheet', 'fix_theme_location');
         if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) {
             add_filter('set_url_scheme', array($this, 'force_http'), 10, 3);
         }
     }
     foreach (array_keys($response_format) as $key) {
         switch ($key) {
             case 'ID':
                 $response[$key] = $blog_id;
                 break;
             case 'name':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
                 break;
             case 'description':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES);
                 break;
             case 'URL':
                 $response[$key] = (string) home_url();
                 break;
             case 'jetpack':
                 $response[$key] = $is_jetpack;
                 // jetpack magic affects this value
                 break;
             case 'is_private':
                 if (defined('IS_WPCOM') && IS_WPCOM) {
                     $public_setting = get_option('blog_public');
                     if (-1 == $public_setting) {
                         $response[$key] = true;
                     } else {
                         $response[$key] = false;
                     }
                 } else {
                     $response[$key] = false;
                     // magic
                 }
                 break;
             case 'visible':
                 if ($is_user_logged_in) {
                     $is_visible = true;
                     if (isset($visible[$blog_id])) {
                         $is_visible = $visible[$blog_id];
                     }
                     // null and true are visible
                     $response[$key] = $is_visible;
                 }
                 break;
             case 'post_count':
                 if ($is_user_logged_in) {
                     $response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'");
                 }
                 break;
             case 'lang':
                 if ($is_user_logged_in) {
                     $response[$key] = (string) get_bloginfo('language');
                 }
                 break;
             case 'icon':
                 if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) {
                     $domain = blavatar_domain(home_url());
                     if (blavatar_exists($domain)) {
                         $response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico')));
                     } else {
                         // This is done so that we can access the updated blavatar on .com via the /me/sites endpoint
                         if (is_jetpack_site()) {
                             $site_icon_url = get_option('jetpack_site_icon_url');
                             if ($site_icon_url) {
                                 $response[$key] = array('img' => (string) jetpack_photon_url($site_icon_url, array(), 'https'), 'ico' => (string) jetpack_photon_url($site_icon_url, array('w' => 16), 'https'));
                             }
                         }
                     }
                 } elseif (function_exists('jetpack_site_icon_url') && function_exists('jetpack_photon_url')) {
                     $response[$key] = array('img' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 80), array('w' => 80), 'https'), 'ico' => (string) jetpack_photon_url(jetpack_site_icon_url(get_current_blog_id(), 16), array('w' => 16), 'https'));
                 }
                 break;
             case 'logo':
                 // Set an empty response array.
                 $response[$key] = array('id' => (int) 0, 'sizes' => array(), 'url' => '');
                 // Get current site logo values.
                 $logo = get_option('site_logo');
                 // Update the response array if there's a site logo currenty active.
                 if ($logo && 0 != $logo['id']) {
                     $response[$key]['id'] = $logo['id'];
                     $response[$key]['url'] = $logo['url'];
                     foreach ($logo['sizes'] as $size => $properties) {
                         $response[$key]['sizes'][$size] = $properties;
                     }
                 }
                 break;
             case 'subscribers_count':
                 if (function_exists('wpcom_subs_total_wpcom_subscribers')) {
                     $total_wpcom_subs = wpcom_subs_total_wpcom_subscribers(array('blog_id' => $blog_id));
                     $response[$key] = $total_wpcom_subs;
                 } else {
                     $response[$key] = 0;
                     // magic
                 }
                 break;
             case 'is_following':
                 $response[$key] = (bool) $this->api->is_following($blog_id);
                 break;
             case 'options':
                 // Figure out if the blog supports VideoPress, have to do some extra checking for JP blogs
                 $has_videopress = false;
                 if (get_option('video_upgrade') == '1') {
                     $has_videopress = true;
                 } else {
                     if (class_exists('Jetpack_Options')) {
                         $videopress = Jetpack_Options::get_option('videopress', array());
                         if ($videopress['blog_id'] > 0) {
                             $has_videopress = true;
                         }
                     }
                 }
                 // deprecated - see separate endpoint. get a list of supported post formats
                 $all_formats = get_post_format_strings();
                 $supported = get_theme_support('post-formats');
                 $supported_formats = array();
                 if (isset($supported[0])) {
                     foreach ($supported[0] as $format) {
                         $supported_formats[$format] = $all_formats[$format];
                     }
                 }
                 // determine if sharing buttons should be visible by default
                 $default_sharing_status = false;
                 if (class_exists('Sharing_Service')) {
                     $ss = new Sharing_Service();
                     $blog_services = $ss->get_blog_services();
                     $default_sharing_status = !empty($blog_services['visible']);
                 }
                 $is_mapped_domain = false;
                 if (function_exists('get_primary_redirect')) {
                     $primary_redirect = strtolower(get_primary_redirect());
                     if (false === strpos($primary_redirect, '.wordpress.com')) {
                         $is_mapped_domain = true;
                     }
                 }
                 $is_redirect = false;
                 if (function_exists('get_primary_domain_mapping_record')) {
                     if (get_primary_domain_mapping_record()->type == 1) {
                         $is_redirect = true;
                     }
                 }
                 if (function_exists('get_mime_types')) {
                     $allowed_file_types = get_mime_types();
                 } else {
                     // http://codex.wordpress.org/Uploading_Files
                     $mime_types = get_allowed_mime_types();
                     foreach ($mime_types as $type => $mime_type) {
                         $extras = explode('|', $type);
                         foreach ($extras as $extra) {
                             $allowed_file_types[] = $extra;
                         }
                     }
                 }
                 if (function_exists('get_blog_details')) {
                     $blog_details = get_blog_details();
                     if (!empty($blog_details->registered)) {
                         $registered_date = $blog_details->registered;
                     }
                 }
                 $response[$key] = array('timezone' => (string) get_option('timezone_string'), 'gmt_offset' => (double) get_option('gmt_offset'), 'videopress_enabled' => $has_videopress, 'login_url' => wp_login_url(), 'admin_url' => get_admin_url(), 'is_mapped_domain' => $is_mapped_domain, 'is_redirect' => $is_redirect, 'unmapped_url' => get_site_url($blog_id), 'featured_images_enabled' => current_theme_supports('post-thumbnails'), 'theme_slug' => get_option('stylesheet'), 'header_image' => get_theme_mod('header_image_data'), 'background_color' => get_theme_mod('background_color'), 'image_default_link_type' => get_option('image_default_link_type'), 'image_thumbnail_width' => (int) get_option('thumbnail_size_w'), 'image_thumbnail_height' => (int) get_option('thumbnail_size_h'), 'image_thumbnail_crop' => get_option('thumbnail_crop'), 'image_medium_width' => (int) get_option('medium_size_w'), 'image_medium_height' => (int) get_option('medium_size_h'), 'image_large_width' => (int) get_option('large_size_w'), 'image_large_height' => (int) get_option('large_size_h'), 'post_formats' => $supported_formats, 'allowed_file_types' => $allowed_file_types, 'show_on_front' => get_option('show_on_front'), 'default_likes_enabled' => (bool) apply_filters('wpl_is_enabled_sitewide', !get_option('disabled_likes')), 'default_sharing_status' => (bool) $default_sharing_status, 'default_comment_status' => 'closed' == get_option('default_comment_status') ? false : true, 'default_ping_status' => 'closed' == get_option('default_ping_status') ? false : true, 'software_version' => $wp_version, 'created_at' => !empty($registered_date) ? $this->format_date($registered_date) : '0000-00-00T00:00:00+00:00');
                 if ('page' === get_option('show_on_front')) {
                     $response['options']['page_on_front'] = (int) get_option('page_on_front');
                     $response['options']['page_for_posts'] = (int) get_option('page_for_posts');
                 }
                 if ($is_jetpack) {
                     $response['options']['jetpack_version'] = get_option('jetpack_version');
                     // If we are not on WPCOM, force WordPress to re-calculate available updates.
                     if (!defined('IS_WPCOM') || !IS_WPCOM) {
                         wp_get_update_data();
                     }
                     $response['options']['updates'] = Jetpack_Options::get_option('updates', array());
                     if (get_option('jetpack_main_network_site')) {
                         $response['options']['main_network_site'] = (string) rtrim(get_option('jetpack_main_network_site'), '/');
                     }
                     // Sites have to prove that they are not main_network site.
                     // If the sync happends right then we should be able to see that we are not dealing with a network site
                     $response['options']['is_multi_network'] = (bool) get_option('jetpack_is_main_network', true);
                     $response['options']['is_multi_site'] = (bool) get_option('jetpack_is_multi_site', true);
                 }
                 if (!current_user_can('edit_posts')) {
                     unset($response[$key]);
                 }
                 break;
             case 'meta':
                 $xmlrpc_scheme = apply_filters('wpcom_json_api_xmlrpc_scheme', parse_url(get_option('home'), PHP_URL_SCHEME));
                 $xmlrpc_url = site_url('xmlrpc.php', $xmlrpc_scheme);
                 $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_site_link($blog_id), 'help' => (string) $this->get_site_link($blog_id, 'help'), 'posts' => (string) $this->get_site_link($blog_id, 'posts/'), 'comments' => (string) $this->get_site_link($blog_id, 'comments/'), 'xmlrpc' => (string) $xmlrpc_url));
                 break;
         }
     }
     if ($is_jetpack) {
         add_filter('option_stylesheet', 'fix_theme_location');
         if ('https' !== parse_url($site_url, PHP_URL_SCHEME)) {
             remove_filter('set_url_scheme', array($this, 'force_http'), 10, 3);
         }
     }
     return $response;
 }
Esempio n. 19
0
		if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
			$submenu['themes.php'][10] = array(__('Menus'), 'edit_theme_options', 'nav-menus.php' );
}

// Add 'Editor' to the bottom of the Appearance menu.
if ( ! is_multisite() )
	add_action('admin_menu', '_add_themes_utility_last', 101);
function _add_themes_utility_last() {
	// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook
	add_submenu_page('themes.php', _x('Editor', 'theme editor'), _x('Editor', 'theme editor'), 'edit_themes', 'theme-editor.php');
}

$count = '';
if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
	if ( ! isset( $update_data ) )
		$update_data = wp_get_update_data();
	$count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>";
}

$menu[65] = array( sprintf( __('Plugins %s'), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'none' );

$submenu['plugins.php'][5]  = array( __('Installed Plugins'), 'activate_plugins', 'plugins.php' );

	if ( ! is_multisite() ) {
		/* translators: add new plugin */
		$submenu['plugins.php'][10] = array( _x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php' );
		$submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugins', 'plugin-editor.php' );
	}

unset( $update_data );
 public function callback($path = '', $_blog_id = 0)
 {
     $error = $this->validate_call($_blog_id, array('must_pass' => 1, 'capabilities' => array('update_plugins', 'update_themes', 'update_core')), false);
     if (is_wp_error($error)) {
         return $error;
     }
     $update_data = wp_get_update_data();
     if (!isset($update_data['counts'])) {
         return new WP_Error('get_update_data_error', __('There was an error while getting the update data for this site.', 'jetpack'), 500);
     }
     return $update_data['counts'];
 }