Esempio n. 1
0
/**
 * Gets the network's site and user counts.
 *
 * @since MU 1.0
 * @uses get_blog_count()
 * @uses get_user_count()
 *
 * @return array Site and user count for the network.
 */
function get_sitestats()
{
    global $wpdb;
    $stats['blogs'] = get_blog_count();
    $stats['users'] = get_user_count();
    return $stats;
}
Esempio n. 2
0
/**
 * Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the
 * WordPress server at api.wordpress.org server. Will only check if WordPress
 * isn't installing.
 *
 * @package WordPress
 * @since 2.3.0
 * @uses $wp_version Used to check against the newest WordPress version.
 *
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
 */
function wp_version_check()
{
    if (defined('WP_INSTALLING')) {
        return;
    }
    global $wp_version, $wpdb, $wp_local_package, $wpmu_version, $current_site;
    $php_version = phpversion();
    $current = get_transient('update_core');
    if (!is_object($current)) {
        $current = new stdClass();
        $current->updates = array();
        $current->version_checked = $wp_version;
    }
    $locale = apply_filters('core_version_check_locale', get_locale());
    // Update last_checked for current to prevent multiple blocking requests if request hangs
    $current->last_checked = time();
    set_transient('update_core', $current);
    if (method_exists($wpdb, 'db_version')) {
        $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
    } else {
        $mysql_version = 'N/A';
    }
    $local_package = isset($wp_local_package) ? $wp_local_package : '';
    $url = "http://api.wordpress.org/core/version-check/1.3-mu/?version={$wp_version}&wpmu_version={$wpmu_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}&blogs=" . get_blog_count() . "&users=" . get_user_count();
    $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress MU/' . $wpmu_version . '; ' . apply_filters('currentsite_on_version_check', 'http://' . $current_site->domain . $current_site->path));
    $response = wp_remote_get($url, $options);
    if (is_wp_error($response)) {
        return false;
    }
    if (200 != $response['response']['code']) {
        return false;
    }
    $body = trim($response['body']);
    $body = str_replace(array("\r\n", "\r"), "\n", $body);
    $new_options = array();
    foreach (explode("\n\n", $body) as $entry) {
        $returns = explode("\n", $entry);
        $new_option = new stdClass();
        $new_option->response = esc_attr($returns[0]);
        if (isset($returns[1])) {
            $new_option->url = esc_url($returns[1]);
        }
        if (isset($returns[2])) {
            $new_option->package = esc_url($returns[2]);
        }
        if (isset($returns[3])) {
            $new_option->current = esc_attr($returns[3]);
        }
        if (isset($returns[4])) {
            $new_option->locale = esc_attr($returns[4]);
        }
        $new_options[] = $new_option;
    }
    $updates = new stdClass();
    $updates->updates = $new_options;
    $updates->last_checked = time();
    $updates->version_checked = $wp_version;
    set_transient('update_core', $updates);
}
Esempio n. 3
0
/**
 * Gets the network's site and user counts.
 *
 * @since MU 1.0
 * @uses get_blog_count()
 * @uses get_user_count()
 *
 * @return array Site and user count for the network.
 */
function get_sitestats() {
	global $wpdb;

	$stats = array(
		'blogs' => get_blog_count(),
		'users' => get_user_count(),
	);

	return $stats;
}
	function prepare_items() {
		global $usersearch, $role, $wpdb, $mode;

		$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';

		$users_per_page = $this->get_items_per_page( 'users_network_per_page' );

		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';

		$paged = $this->get_pagenum();

		$args = array(
			'number' => $users_per_page,
			'offset' => ( $paged-1 ) * $users_per_page,
			'search' => $usersearch,
			'blog_id' => 0,
			'fields' => 'all_with_meta'
		);

		$args['search'] = ltrim($args['search'], '*');

		if ( $role == 'super' ) {
			$logins = implode( "', '", get_super_admins() );
			$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
		}

		// If the network is large and a search is not being performed, show only the latest users with no paging in order
		// to avoid expensive count queries.
		if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
			if ( !isset($_REQUEST['orderby']) )
				$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
			if ( !isset($_REQUEST['order']) )
				$_GET['order'] = $_REQUEST['order'] = 'DESC';
			$args['count_total'] = false;
		}

		if ( isset( $_REQUEST['orderby'] ) )
			$args['orderby'] = $_REQUEST['orderby'];

		if ( isset( $_REQUEST['order'] ) )
			$args['order'] = $_REQUEST['order'];

		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];

		// Query the user IDs for this page
		$wp_user_search = new WP_User_Query( $args );

		$this->items = $wp_user_search->get_results();

		$this->set_pagination_args( array(
			'total_items' => $wp_user_search->get_total(),
			'per_page' => $users_per_page,
		) );
	}
function get_sitestats()
{
    global $wpdb;
    $stats['blogs'] = get_blog_count();
    $count_ts = get_site_option("get_user_count_ts");
    if (time() - $count_ts > 3600) {
        $count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->users}");
        update_site_option("user_count", $count);
        update_site_option("user_count_ts", time());
    } else {
        $count = get_site_option("user_count");
    }
    $stats['users'] = $count;
    return $stats;
}
	/**
	 * @ticket 22917
	 */
	function test_enable_live_network_site_counts_filter() {
		$site_count_start = get_blog_count();
		// false for large networks by default
		add_filter( 'enable_live_network_counts', '__return_false' );
		$this->factory->blog->create_many( 4 );

		// count only updated when cron runs, so unchanged
		$this->assertEquals( $site_count_start, (int) get_blog_count() );

		add_filter( 'enable_live_network_counts', '__return_true' );
		$site_ids = $this->factory->blog->create_many( 4 );

		$this->assertEquals( $site_count_start + 9, (int) get_blog_count() );

		//clean up
		remove_filter( 'enable_live_network_counts', '__return_false' );
		remove_filter( 'enable_live_network_counts', '__return_true' );
		foreach ( $site_ids as $site_id ) {
			wpmu_delete_blog( $site_id, true );
		}
	}
/**
 * Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the
 * WordPress server at api.wordpress.org server. Will only check if WordPress
 * isn't installing.
 *
 * @since 2.3.0
 * @global string $wp_version Used to check against the newest WordPress version.
 * @global wpdb   $wpdb
 * @global string $wp_local_package
 *
 * @param array $extra_stats Extra statistics to report to the WordPress.org API.
 * @param bool  $force_check Whether to bypass the transient cache and force a fresh update check. Defaults to false, true if $extra_stats is set.
 */
function wp_version_check($extra_stats = array(), $force_check = false)
{
    if (wp_installing()) {
        return;
    }
    global $wp_version, $wpdb, $wp_local_package;
    // include an unmodified $wp_version
    include ABSPATH . WPINC . '/version.php';
    $php_version = phpversion();
    $current = get_site_transient('update_core');
    $translations = wp_get_installed_translations('core');
    // Invalidate the transient when $wp_version changes
    if (is_object($current) && $wp_version != $current->version_checked) {
        $current = false;
    }
    if (!is_object($current)) {
        $current = new stdClass();
        $current->updates = array();
        $current->version_checked = $wp_version;
    }
    if (!empty($extra_stats)) {
        $force_check = true;
    }
    // Wait 60 seconds between multiple version check requests
    $timeout = 60;
    $time_not_changed = isset($current->last_checked) && $timeout > time() - $current->last_checked;
    if (!$force_check && $time_not_changed) {
        return;
    }
    /**
     * Filter the locale requested for WordPress core translations.
     *
     * @since 2.8.0
     *
     * @param string $locale Current locale.
     */
    $locale = apply_filters('core_version_check_locale', get_locale());
    // Update last_checked for current to prevent multiple blocking requests if request hangs
    $current->last_checked = time();
    set_site_transient('update_core', $current);
    if (method_exists($wpdb, 'db_version')) {
        $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
    } else {
        $mysql_version = 'N/A';
    }
    if (is_multisite()) {
        $user_count = get_user_count();
        $num_blogs = get_blog_count();
        $wp_install = network_site_url();
        $multisite_enabled = 1;
    } else {
        $user_count = count_users();
        $user_count = $user_count['total_users'];
        $multisite_enabled = 0;
        $num_blogs = 1;
        $wp_install = home_url('/');
    }
    $query = array('version' => $wp_version, 'php' => $php_version, 'locale' => $locale, 'mysql' => $mysql_version, 'local_package' => isset($wp_local_package) ? $wp_local_package : '', 'blogs' => $num_blogs, 'users' => $user_count, 'multisite_enabled' => $multisite_enabled, 'initial_db_version' => get_site_option('initial_db_version'));
    $post_body = array('translations' => wp_json_encode($translations));
    if (is_array($extra_stats)) {
        $post_body = array_merge($post_body, $extra_stats);
    }
    $url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query($query, null, '&');
    if ($ssl = wp_http_supports(array('ssl'))) {
        $url = set_url_scheme($url, 'https');
    }
    $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'headers' => array('wp_install' => $wp_install, 'wp_blog' => home_url('/')), 'body' => $post_body);
    $response = wp_remote_post($url, $options);
    if ($ssl && is_wp_error($response)) {
        trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.') . ' ' . __('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE);
        $response = wp_remote_post($http_url, $options);
    }
    if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
        return;
    }
    $body = trim(wp_remote_retrieve_body($response));
    $body = json_decode($body, true);
    if (!is_array($body) || !isset($body['offers'])) {
        return;
    }
    $offers = $body['offers'];
    foreach ($offers as &$offer) {
        foreach ($offer as $offer_key => $value) {
            if ('packages' == $offer_key) {
                $offer['packages'] = (object) array_intersect_key(array_map('esc_url', $offer['packages']), array_fill_keys(array('full', 'no_content', 'new_bundled', 'partial', 'rollback'), ''));
            } elseif ('download' == $offer_key) {
                $offer['download'] = esc_url($value);
            } else {
                $offer[$offer_key] = esc_html($value);
            }
        }
        $offer = (object) array_intersect_key($offer, array_fill_keys(array('response', 'download', 'locale', 'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email', 'support_email', 'new_files'), ''));
    }
    $updates = new stdClass();
    $updates->updates = $offers;
    $updates->last_checked = time();
    $updates->version_checked = $wp_version;
    if (isset($body['translations'])) {
        $updates->translations = $body['translations'];
    }
    set_site_transient('update_core', $updates);
    if (!empty($body['ttl'])) {
        $ttl = (int) $body['ttl'];
        if ($ttl && time() + $ttl < wp_next_scheduled('wp_version_check')) {
            // Queue an event to re-run the update check in $ttl seconds.
            wp_schedule_single_event(time() + $ttl, 'wp_version_check');
        }
    }
    // Trigger a background updates check if running non-interactively, and we weren't called from the update handler.
    if (defined('DOING_CRON') && DOING_CRON && !doing_action('wp_maybe_auto_update')) {
        do_action('wp_maybe_auto_update');
    }
}
Esempio n. 8
0
/**
 * Whether or not we have a large network.
 *
 * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
 * Plugins can alter this criteria  using the 'wp_is_large_network' filter.
 *
 * @since 3.3.0
 * @param string $using 'sites or 'users'.  Default is 'sites'.
 * @return bool True if the network meets the criteria for large. False otherwise.
 */
function wp_is_large_network( $using = 'sites' ) {
	if ( 'users' == $using ) {
		$count = get_user_count();
		return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
	}

	$count = get_blog_count();
	return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
}
 /**
  * Diagnostic information for the support tab
  *
  * @param bool $escape
  *
  * @return string
  */
 function output_diagnostic_info($escape = true)
 {
     global $table_prefix;
     global $wpdb;
     $output = 'site_url(): ';
     $output .= esc_html(site_url());
     $output .= "\r\n";
     $output .= 'home_url(): ';
     $output .= esc_html(home_url());
     $output .= "\r\n";
     $output .= 'Database Name: ';
     $output .= esc_html($wpdb->dbname);
     $output .= "\r\n";
     $output .= 'Table Prefix: ';
     $output .= esc_html($table_prefix);
     $output .= "\r\n";
     $output .= 'WordPress: ';
     $output .= get_bloginfo('version', 'display');
     if (is_multisite()) {
         $output .= ' Multisite';
         $output .= "\r\n";
         $output .= 'Multisite Site Count: ';
         $output .= esc_html(get_blog_count());
     }
     $output .= "\r\n";
     $output .= 'Web Server: ';
     $output .= esc_html(!empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '');
     $output .= "\r\n";
     $output .= 'PHP: ';
     if (function_exists('phpversion')) {
         $output .= esc_html(phpversion());
     }
     $output .= "\r\n";
     $output .= 'MySQL: ';
     $output .= esc_html($wpdb->db_version());
     $output .= "\r\n";
     $output .= 'ext/mysqli: ';
     $output .= empty($wpdb->use_mysqli) ? 'no' : 'yes';
     $output .= "\r\n";
     $output .= 'PHP Memory Limit: ';
     if (function_exists('ini_get')) {
         $output .= esc_html(ini_get('memory_limit'));
     }
     $output .= "\r\n";
     $output .= 'WP Memory Limit: ';
     $output .= esc_html(WP_MEMORY_LIMIT);
     $output .= "\r\n";
     $output .= 'Memory Usage: ';
     $output .= size_format(memory_get_usage(true));
     $output .= "\r\n";
     $output .= 'Blocked External HTTP Requests: ';
     if (!defined('WP_HTTP_BLOCK_EXTERNAL') || !WP_HTTP_BLOCK_EXTERNAL) {
         $output .= 'None';
     } else {
         $accessible_hosts = defined('WP_ACCESSIBLE_HOSTS') ? WP_ACCESSIBLE_HOSTS : '';
         if (empty($accessible_hosts)) {
             $output .= 'ALL';
         } else {
             $output .= 'Partially (Accessible Hosts: ' . esc_html($accessible_hosts) . ')';
         }
     }
     $output .= "\r\n";
     $output .= 'WP Locale: ';
     $output .= esc_html(get_locale());
     $output .= "\r\n";
     $output .= 'Organize uploads by month/year: ';
     $output .= esc_html(get_option('uploads_use_yearmonth_folders') ? 'Enabled' : 'Disabled');
     $output .= "\r\n";
     $output .= 'WP_DEBUG: ';
     $output .= esc_html(defined('WP_DEBUG') && WP_DEBUG ? 'Yes' : 'No');
     $output .= "\r\n";
     $output .= 'WP_DEBUG_LOG: ';
     $output .= esc_html(defined('WP_DEBUG_LOG') && WP_DEBUG_LOG ? 'Yes' : 'No');
     $output .= "\r\n";
     $output .= 'WP_DEBUG_DISPLAY: ';
     $output .= esc_html(defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY ? 'Yes' : 'No');
     $output .= "\r\n";
     $output .= 'SCRIPT_DEBUG: ';
     $output .= esc_html(defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'Yes' : 'No');
     $output .= "\r\n";
     $output .= 'WP Max Upload Size: ';
     $output .= esc_html(size_format(wp_max_upload_size()));
     $output .= "\r\n";
     $output .= 'PHP Time Limit: ';
     if (function_exists('ini_get')) {
         $output .= esc_html(ini_get('max_execution_time'));
     }
     $output .= "\r\n";
     $output .= 'PHP Error Log: ';
     if (function_exists('ini_get')) {
         $output .= esc_html(ini_get('error_log'));
     }
     $output .= "\r\n";
     $output .= 'WP Cron: ';
     $output .= esc_html(defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'Disabled' : 'Enabled');
     $output .= "\r\n";
     $output .= 'fsockopen: ';
     if (function_exists('fsockopen')) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'allow_url_fopen: ';
     $allow_url_fopen = ini_get('allow_url_fopen');
     if (empty($allow_url_fopen)) {
         $output .= 'Disabled';
     } else {
         $output .= 'Enabled';
     }
     $output .= "\r\n";
     $output .= 'OpenSSL: ';
     if ($this->open_ssl_enabled()) {
         $output .= esc_html(OPENSSL_VERSION_TEXT);
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'cURL: ';
     if (function_exists('curl_init')) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'Zlib Compression: ';
     if (function_exists('gzcompress')) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'PHP GD: ';
     if ($this->gd_enabled()) {
         $gd_info = gd_info();
         $output .= isset($gd_info['GD Version']) ? esc_html($gd_info['GD Version']) : 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'Imagick: ';
     if ($this->imagick_enabled()) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'Basic Auth: ';
     if (isset($_SERVER['REMOTE_USER']) || isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['REDIRECT_REMOTE_USER'])) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n";
     $output .= 'Proxy: ';
     if (defined('WP_PROXY_HOST') || defined('WP_PROXY_PORT')) {
         $output .= 'Enabled';
     } else {
         $output .= 'Disabled';
     }
     $output .= "\r\n\r\n";
     $media_counts = $this->diagnostic_media_counts();
     $output .= 'Media Files: ';
     $output .= number_format_i18n($media_counts['all']);
     $output .= "\r\n";
     $output .= 'Media Files on S3: ';
     $output .= number_format_i18n($media_counts['s3']);
     $output .= "\r\n";
     $output .= 'Number of Image Sizes: ';
     $sizes = count(get_intermediate_image_sizes());
     $output .= number_format_i18n($sizes);
     $output .= "\r\n\r\n";
     $output .= 'Names and Dimensions of Image Sizes: ';
     $output .= "\r\n";
     $size_details = $this->get_image_sizes_details();
     $output .= $size_details;
     $output .= "\r\n";
     $output .= 'WP_CONTENT_DIR: ';
     $output .= esc_html(defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : 'Not defined');
     $output .= "\r\n";
     $output .= 'WP_CONTENT_URL: ';
     $output .= esc_html(defined('WP_CONTENT_URL') ? WP_CONTENT_URL : 'Not defined');
     $output .= "\r\n";
     $output .= 'UPLOADS: ';
     $output .= esc_html(defined('UPLOADS') ? UPLOADS : 'Not defined');
     $output .= "\r\n";
     $output .= 'WP_PLUGIN_DIR: ';
     $output .= esc_html(defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : 'Not defined');
     $output .= "\r\n";
     $output .= 'WP_PLUGIN_URL: ';
     $output .= esc_html(defined('WP_PLUGIN_URL') ? WP_PLUGIN_URL : 'Not defined');
     $output .= "\r\n\r\n";
     $output .= 'AWS_USE_EC2_IAM_ROLE: ';
     $output .= esc_html(defined('AWS_USE_EC2_IAM_ROLE') ? AWS_USE_EC2_IAM_ROLE : 'Not defined');
     $output .= "\r\n";
     $output .= 'AS3CF_BUCKET: ';
     $output .= esc_html(defined('AS3CF_BUCKET') ? AS3CF_BUCKET : 'Not defined');
     $output .= "\r\n";
     $output .= 'AS3CF_ASSETS_BUCKET: ';
     $output .= esc_html(defined('AS3CF_ASSETS_BUCKET') ? AS3CF_ASSETS_BUCKET : 'Not defined');
     $output .= "\r\n";
     $output .= 'AS3CF_REGION: ';
     $output .= esc_html(defined('AS3CF_REGION') ? AS3CF_REGION : 'Not defined');
     $output .= "\r\n\r\n";
     $output .= 'Bucket: ';
     $output .= $this->get_setting('bucket');
     $output .= "\r\n";
     $output .= 'Region: ';
     $region = $this->get_setting('region');
     if (!is_wp_error($region)) {
         $output .= $region;
     }
     $output .= "\r\n";
     $output .= 'Copy Files to S3: ';
     $output .= $this->on_off('copy-to-s3');
     $output .= "\r\n";
     $output .= 'Rewrite File URLs: ';
     $output .= $this->on_off('serve-from-s3');
     $output .= "\r\n";
     $output .= "\r\n";
     $output .= 'URL Preview: ';
     $output .= $this->get_url_preview($escape);
     $output .= "\r\n";
     $output .= "\r\n";
     $output .= 'Domain: ';
     $output .= $this->get_setting('domain');
     $output .= "\r\n";
     $output .= 'Enable Path: ';
     $output .= $this->on_off('enable-object-prefix');
     $output .= "\r\n";
     $output .= 'Custom Path: ';
     $output .= $this->get_setting('object-prefix');
     $output .= "\r\n";
     $output .= 'Use Year/Month: ';
     $output .= $this->on_off('use-yearmonth-folders');
     $output .= "\r\n";
     $output .= 'Force HTTPS: ';
     $output .= $this->on_off('force-https');
     $output .= "\r\n";
     $output .= 'Remove Files From Server: ';
     $output .= $this->on_off('remove-local-file');
     $output .= "\r\n";
     $output .= 'Object Versioning: ';
     $output .= $this->on_off('object-versioning');
     $output .= "\r\n\r\n";
     $output = apply_filters('as3cf_diagnostic_info', $output);
     if (has_action('as3cf_diagnostic_info')) {
         $output .= "\r\n";
     }
     $theme_info = wp_get_theme();
     $output .= "Active Theme Name: " . esc_html($theme_info->get('Name')) . "\r\n";
     $output .= "Active Theme Folder: " . esc_html(basename($theme_info->get_stylesheet_directory())) . "\r\n";
     if ($theme_info->get('Template')) {
         $output .= "Parent Theme Folder: " . esc_html($theme_info->get('Template')) . "\r\n";
     }
     if (!file_exists($theme_info->get_stylesheet_directory())) {
         $output .= "WARNING: Active Theme Folder Not Found\r\n";
     }
     $output .= "\r\n";
     $output .= "Active Plugins:\r\n";
     $active_plugins = (array) get_option('active_plugins', array());
     $plugin_details = array();
     if (is_multisite()) {
         $network_active_plugins = wp_get_active_network_plugins();
         $active_plugins = array_map(array($this, 'remove_wp_plugin_dir'), $network_active_plugins);
     }
     foreach ($active_plugins as $plugin) {
         $plugin_details[] = $this->get_plugin_details(WP_PLUGIN_DIR . '/' . $plugin);
     }
     asort($plugin_details);
     $output .= implode('', $plugin_details);
     $mu_plugins = wp_get_mu_plugins();
     if ($mu_plugins) {
         $mu_plugin_details = array();
         $output .= "\r\n";
         $output .= "Must-use Plugins:\r\n";
         foreach ($mu_plugins as $mu_plugin) {
             $mu_plugin_details[] = $this->get_plugin_details($mu_plugin);
         }
         asort($mu_plugin_details);
         $output .= implode('', $mu_plugin_details);
     }
     return $output;
 }
Esempio n. 10
0
    check_admin_referer('wpseo-network-restore');
    if (isset($_POST['wpseo_ms']['restoreblog']) && is_numeric($_POST['wpseo_ms']['restoreblog'])) {
        $restoreblog = (int) WPSEO_Option::validate_int($_POST['wpseo_ms']['restoreblog']);
        $blog = get_blog_details($restoreblog);
        if ($blog) {
            WPSEO_Options::reset_ms_blog($restoreblog);
            add_settings_error('wpseo_ms', 'settings_updated', sprintf(__('%s restored to default SEO settings.', 'wordpress-seo'), esc_html($blog->blogname)), 'updated');
        } else {
            add_settings_error('wpseo_ms', 'settings_updated', sprintf(__('Blog %s not found.', 'wordpress-seo'), esc_html($restoreblog)), 'error');
        }
        unset($restoreblog);
    }
}
/* Set up selectbox dropdowns for smaller networks (usability) */
$use_dropdown = true;
if (get_blog_count() > 100) {
    $use_dropdown = false;
} else {
    $sites = wp_get_sites(array('deleted' => 0));
    if (is_array($sites) && $sites !== array()) {
        $dropdown_input = array('-' => __('None', 'wordpress-seo'));
        foreach ($sites as $site) {
            $dropdown_input[$site['blog_id']] = $site['blog_id'] . ': ' . $site['domain'];
            $blog_states = array();
            if ($site['public'] === '1') {
                $blog_states[] = __('public', 'wordpress-seo');
            }
            if ($site['archived'] === '1') {
                $blog_states[] = __('archived', 'wordpress-seo');
            }
            if ($site['mature'] === '1') {
Esempio n. 11
0
function wp_network_dashboard_right_now()
{
    $actions = array();
    if (current_user_can('create_sites')) {
        $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __('Create a New Site') . '</a>';
    }
    if (current_user_can('create_users')) {
        $actions['create-user'] = '******' . network_admin_url('user-new.php') . '">' . __('Create a New User') . '</a>';
    }
    $c_users = get_user_count();
    $c_blogs = get_blog_count();
    $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users));
    $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs));
    $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text);
    if ($actions) {
        echo '<ul class="subsubsub">';
        foreach ($actions as $class => $action) {
            $actions[$class] = "\t<li class='{$class}'>{$action}";
        }
        echo implode(" |</li>\n", $actions) . "</li>\n";
        echo '</ul>';
    }
    ?>
	<br class="clear" />

	<p class="youhave"><?php 
    echo $sentence;
    ?>
</p>
	<?php 
    do_action('wpmuadminresult', '');
    ?>

	<form name="searchform" action="<?php 
    echo network_admin_url('users.php');
    ?>
" method="get">
		<p>
			<input type="text" name="s" value="" size="17" />
			<?php 
    submit_button(__('Search Users'), 'button', 'submit', false, array('id' => 'submit_users'));
    ?>
		</p>
	</form>

	<form name="searchform" action="<?php 
    echo network_admin_url('sites.php');
    ?>
" method="get">
		<p>
			<input type="text" name="s" value="" size="17" />
			<?php 
    submit_button(__('Search Sites'), 'button', 'submit', false, array('id' => 'submit_sites'));
    ?>
		</p>
	</form>
<?php 
    do_action('mu_rightnow_end');
    do_action('mu_activity_box_end');
}
 /**
  * Get additional stat data to sync to WPCOM
  */
 function get_additional_stat_data($prefix = '')
 {
     $return["{$prefix}themes"] = Jetpack::get_parsed_theme_data();
     $return["{$prefix}plugins-extra"] = Jetpack::get_parsed_plugin_data();
     $return["{$prefix}users"] = count_users();
     $return["{$prefix}site-count"] = 0;
     if (function_exists('get_blog_count')) {
         $return["{$prefix}site-count"] = get_blog_count();
     }
     return $return;
 }
Esempio n. 13
0
 /**
  * Calls over to the api using wp_remote_post
  *
  * @param string $action 'check_ip', 'check_key', or 'failed_attempt'
  * @param array  $request Any custom data to post to the api
  *
  * @return array
  */
 function protect_call($action = 'check_ip', $request = array())
 {
     global $wp_version, $wpdb, $current_user;
     $api_key = get_site_option('jetpack_protect_key');
     $user_agent = "WordPress/{$wp_version} | Jetpack/" . constant('JETPACK__VERSION');
     $request['action'] = $action;
     $request['ip'] = jetpack_protect_get_ip();
     $request['host'] = $this->get_local_host();
     $request['headers'] = json_encode($this->get_headers());
     $request['jetpack_version'] = constant('JETPACK__VERSION');
     $request['wordpress_version'] = strval($wp_version);
     $request['api_key'] = $api_key;
     $request['multisite'] = "0";
     if (is_multisite()) {
         $request['multisite'] = get_blog_count();
     }
     $args = array('body' => $request, 'user-agent' => $user_agent, 'httpversion' => '1.0', 'timeout' => 15);
     $response_json = wp_remote_post($this->get_api_host(), $args);
     $this->last_response_raw = $response_json;
     $headers = $this->get_headers();
     $header_hash = md5(json_encode($headers));
     $transient_name = 'jpp_li_' . $header_hash;
     $this->delete_transient($transient_name);
     if (is_array($response_json)) {
         $response = json_decode($response_json['body'], true);
     }
     if (isset($response['blocked_attempts']) && $response['blocked_attempts']) {
         update_site_option('jetpack_protect_blocked_attempts', $response['blocked_attempts']);
     }
     if (isset($response['status']) && !isset($response['error'])) {
         $response['expire'] = time() + $response['seconds_remaining'];
         $this->set_transient($transient_name, $response, $response['seconds_remaining']);
         $this->delete_transient('brute_use_math');
     } else {
         // Fallback to Math Captcha if no response from API host
         $this->set_transient('brute_use_math', 1, 600);
         $response['status'] = 'ok';
         $response['math'] = true;
     }
     if (isset($response['error'])) {
         update_site_option('jetpack_protect_error', $response['error']);
     } else {
         delete_site_option('jetpack_protect_error');
     }
     return $response;
 }
 function refresh_updates($local_projects = false)
 {
     global $wpdb, $current_site, $wp_version;
     if (defined('WP_INSTALLING')) {
         return false;
     }
     //reset flag if it's set
     update_site_option('wdp_un_refresh_updates_flag', 0);
     if (!is_array($local_projects)) {
         $local_projects = $this->get_projects();
     }
     set_site_transient('wpmudev_local_projects', $local_projects, 60 * 5);
     $api_key = $this->get_apikey();
     $projects = '';
     foreach ($local_projects as $pid => $project) {
         $projects .= "&p[{$pid}]=" . $project['version'];
     }
     //get WP/BP version string to help with support
     $wp = is_multisite() ? "WordPress Multisite {$wp_version}" : "WordPress {$wp_version}";
     if (defined('BP_VERSION')) {
         $wp .= ', BuddyPress ' . BP_VERSION;
     }
     //add blog count if multisite
     $blog_count = is_multisite() ? get_blog_count() : 1;
     $url = $this->server_url . '?action=check&un-version=' . $this->version . '&wp=' . urlencode($wp) . '&bcount=' . $blog_count . '&domain=' . urlencode(network_site_url()) . '&key=' . urlencode($api_key) . $projects;
     $options = array('timeout' => 15, 'user-agent' => 'UN Client/' . $this->version);
     $response = wp_remote_get($url, $options);
     if (wp_remote_retrieve_response_code($response) == 200) {
         $data = $response['body'];
         if ($data != 'error') {
             $data = unserialize($data);
             if (is_array($data)) {
                 set_site_transient('wpmudev_updates_data', $data, 60 * 60 * 12);
                 update_site_option('wdp_un_last_run', time());
                 //reset hiding permissions in case of membership change
                 if (!$data['membership'] || $data['membership'] == 'free') {
                     //free member
                     update_site_option('wdp_un_hide_upgrades', 0);
                     update_site_option('wdp_un_hide_notices', 0);
                     update_site_option('wdp_un_hide_releases', 0);
                 } else {
                     if (is_numeric($data['membership'])) {
                         //single
                         update_site_option('wdp_un_hide_notices', 0);
                         update_site_option('wdp_un_hide_releases', 0);
                     }
                 }
                 $this->calculate_upgrades($local_projects);
                 return $data;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     } else {
         //for network errors, set last run to 6 hours in past so it doesn't retry every single pageload (in case of server connection issues)
         set_site_transient('wpmudev_updates_data', array(), 60 * 60 * 6);
         return false;
     }
 }
 function prepare_items()
 {
     global $s, $mode, $wpdb, $current_site;
     $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode'];
     $per_page = $this->get_items_per_page('sites_network_per_page');
     $pagenum = $this->get_pagenum();
     $s = isset($_REQUEST['s']) ? stripslashes(trim($_REQUEST['s'])) : '';
     $wild = '';
     if (false !== strpos($s, '*')) {
         $wild = '%';
         $s = trim($s, '*');
     }
     $like_s = esc_sql(like_escape($s));
     $large_network = false;
     // If the network is large and a search is not being performed, show only the latest blogs with no paging in order
     // to avoid expensive count queries.
     if (!$s && get_blog_count() >= 10000) {
         if (!isset($_REQUEST['orderby'])) {
             $_GET['orderby'] = $_REQUEST['orderby'] = '';
         }
         if (!isset($_REQUEST['order'])) {
             $_GET['order'] = $_REQUEST['order'] = 'DESC';
         }
         $large_network = true;
     }
     $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
     if (empty($s)) {
         // Nothing to do.
     } elseif (preg_match('/^[0-9]+\\./', $s)) {
         // IP address
         $reg_blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}{$wild}' )");
         if (!$reg_blog_ids) {
             $reg_blog_ids = array(0);
         }
         $query = "SELECT *\n\t\t\t\tFROM {$wpdb->blogs}\n\t\t\t\tWHERE site_id = '{$wpdb->siteid}'\n\t\t\t\tAND {$wpdb->blogs}.blog_id IN (" . implode(', ', $reg_blog_ids) . ")";
     } else {
         if (is_numeric($s)) {
             $query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )";
         } elseif (is_subdomain_install()) {
             $blog_s = str_replace('.' . $current_site->domain, '', $like_s);
             $blog_s .= $wild . '.' . $current_site->domain;
             $query .= " AND ( {$wpdb->blogs}.domain LIKE '{$blog_s}' ) ";
         } else {
             if ($like_s != trim('/', $current_site->path)) {
                 $blog_s = $current_site->path . $like_s . $wild . '/';
             } else {
                 $blog_s = $like_s;
             }
             $query .= " AND  ( {$wpdb->blogs}.path LIKE '{$blog_s}' )";
         }
     }
     $order_by = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : '';
     if ($order_by == 'registered') {
         $query .= ' ORDER BY registered ';
     } elseif ($order_by == 'lastupdated') {
         $query .= ' ORDER BY last_updated ';
     } elseif ($order_by == 'blogname') {
         if (is_subdomain_install()) {
             $query .= ' ORDER BY domain ';
         } else {
             $query .= ' ORDER BY path ';
         }
     } elseif ($order_by == 'blog_id') {
         $query .= ' ORDER BY blog_id ';
     } else {
         $order_by = null;
     }
     if (isset($order_by)) {
         $order = isset($_REQUEST['order']) && 'DESC' == strtoupper($_REQUEST['order']) ? "DESC" : "ASC";
         $query .= $order;
     }
     // Don't do an unbounded count on large networks
     if (!$large_network) {
         $total = $wpdb->get_var(str_replace('SELECT *', 'SELECT COUNT( blog_id )', $query));
     }
     $query .= " LIMIT " . intval(($pagenum - 1) * $per_page) . ", " . intval($per_page);
     $this->items = $wpdb->get_results($query, ARRAY_A);
     if ($large_network) {
         $total = count($this->items);
     }
     $this->set_pagination_args(array('total_items' => $total, 'per_page' => $per_page));
 }
Esempio n. 16
0
<div class="wrap">

	<?php 
if (is_network_admin()) {
    ?>

		<?php 
    $site_count = sprintf(_n('1 site', '%d sites', get_blog_count(), 'stream'), get_blog_count());
    printf('<h2>%s (%s)<a href="%s" class="add-new-h2">%s</a></h2>', esc_html__('Stream Reports', 'stream'), $site_count, esc_url($add_url), esc_html__('New Report', 'stream'));
    ?>

	<?php 
} else {
    ?>

		<h2><?php 
    esc_html_e('Stream Reports', 'stream');
    ?>
			<a href="<?php 
    echo esc_url($add_url);
    ?>
" class="add-new-h2">
				<?php 
    esc_html_e('New Report', 'stream');
    ?>
			</a>
		</h2>

	<?php 
}
?>
 public function blog_count()
 {
     //Only send this gauge on every hundredth request, it doesn't change often
     $sample = mt_rand() / mt_getrandmax();
     if ($sample <= 0.01) {
         $this->statsd->gauge("wordpress.blogs.count", get_blog_count());
     }
 }
Esempio n. 18
0
/**
 * Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the
 * WordPress server at api.wordpress.org server. Will only check if WordPress
 * isn't installing.
 *
 * @package WordPress
 * @since 2.3.0
 * @uses $wp_version Used to check against the newest WordPress version.
 *
 * @param array $extra_stats Extra statistics to report to the WordPress.org API.
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
 */
function wp_version_check( $extra_stats = array() ) {
	if ( defined('WP_INSTALLING') )
		return;

	global $wpdb, $wp_local_package;
	include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
	$php_version = phpversion();

	$current = get_site_transient( 'update_core' );
	$translations = wp_get_installed_translations( 'core' );

	if ( ! is_object($current) ) {
		$current = new stdClass;
		$current->updates = array();
		$current->version_checked = $wp_version;
	}

	// Wait 60 seconds between multiple version check requests
	$timeout = 60;
	$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
	if ( $time_not_changed && empty( $extra_stats ) )
		return false;

	$locale = get_locale();
	/**
	 * Filter the locale requested for WordPress core translations.
	 *
	 * @since 2.8.0
	 *
	 * @param string $locale Current locale.
	 */
	$locale = apply_filters( 'core_version_check_locale', $locale );

	// Update last_checked for current to prevent multiple blocking requests if request hangs
	$current->last_checked = time();
	set_site_transient( 'update_core', $current );

	if ( method_exists( $wpdb, 'db_version' ) )
		$mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
	else
		$mysql_version = 'N/A';

	if ( is_multisite() ) {
		$user_count = get_user_count();
		$num_blogs = get_blog_count();
		$wp_install = network_site_url();
		$multisite_enabled = 1;
	} else {
		$user_count = count_users();
		$user_count = $user_count['total_users'];
		$multisite_enabled = 0;
		$num_blogs = 1;
		$wp_install = home_url( '/' );
	}

	$query = array(
		'version'           => $wp_version,
		'php'               => $php_version,
		'locale'            => $locale,
		'mysql'             => $mysql_version,
		'local_package'     => isset( $wp_local_package ) ? $wp_local_package : '',
		'blogs'             => $num_blogs,
		'users'             => $user_count,
		'multisite_enabled' => $multisite_enabled,
	);

	$post_body = array(
		'translations' => json_encode( $translations ),
	);

	if ( $extra_stats )
		$post_body = array_merge( $post_body, $extra_stats );

	$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
	if ( wp_http_supports( array( 'ssl' ) ) )
		$url = set_url_scheme( $url, 'https' );

	$options = array(
		'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
		'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
		'headers' => array(
			'wp_install' => $wp_install,
			'wp_blog' => home_url( '/' )
		),
		'body' => $post_body,
	);

	$response = wp_remote_post( $url, $options );

	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
		return false;

	$body = trim( wp_remote_retrieve_body( $response ) );
	$body = json_decode( $body, true );

	if ( ! is_array( $body ) || ! isset( $body['offers'] ) )
		return false;

	$offers = $body['offers'];

	foreach ( $offers as &$offer ) {
		foreach ( $offer as $offer_key => $value ) {
			if ( 'packages' == $offer_key )
				$offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ),
					array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial', 'rollback' ), '' ) );
			elseif ( 'download' == $offer_key )
				$offer['download'] = esc_url( $value );
			else
				$offer[ $offer_key ] = esc_html( $value );
		}
		$offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale',
			'packages', 'current', 'version', 'php_version', 'mysql_version', 'new_bundled', 'partial_version', 'notify_email' ), '' ) );
	}

	$updates = new stdClass();
	$updates->updates = $offers;
	$updates->last_checked = time();
	$updates->version_checked = $wp_version;

	if ( isset( $body['translations'] ) )
		$updates->translations = $body['translations'];

	set_site_transient( 'update_core',  $updates);
}
Esempio n. 19
0
	function test_create_and_delete_blog() {
		global $wpdb;

		$blog_ids = $this->factory->blog->create_many( 4 );
		foreach ( $blog_ids as $blog_id ) {
			$this->assertInternalType( 'int', $blog_id );
			$prefix = $wpdb->get_blog_prefix( $blog_id );

			// $get_all = false
			$details = get_blog_details( $blog_id, false );
			$this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) );

			// get_id_from_blogname(), see #20950
			$this->assertEquals( $blog_id, get_id_from_blogname( $details->path ) );
			$this->assertEquals( $blog_id, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );

			// get_blog_id_from_url()
			$this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) );
			$key = md5( $details->domain . $details->path );
			$this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) );

			// These are empty until get_blog_details() is called with $get_all = true
			$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
			$key = md5( $details->domain . $details->path );
			$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );

			// $get_all = true should propulate the full blog-details cache and the blog slug lookup cache
			$details = get_blog_details( $blog_id, true );
			$this->assertEquals( $details, wp_cache_get( $blog_id, 'blog-details' ) );
			$this->assertEquals( $details, wp_cache_get( $key, 'blog-lookup' ) );

			foreach ( $wpdb->tables( 'blog', false ) as $table ) {
				$suppress = $wpdb->suppress_errors();
				$table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
				$wpdb->suppress_errors( $suppress );
				$this->assertNotEmpty( $table_fields );
				$result = $wpdb->get_results( "SELECT * FROM $prefix$table LIMIT 1" );
				if ( 'commentmeta' == $table || 'links' == $table )
					$this->assertEmpty( $result );
				else
					$this->assertNotEmpty( $result );
			}
		}

		// update the blog count cache to use get_blog_count()
		wp_update_network_counts();
		$this->assertEquals( 4 + 1, (int) get_blog_count() );

		$drop_tables = false;
		// delete all blogs
		foreach ( $blog_ids as $blog_id ) {
			// drop tables for every second blog
			$drop_tables = ! $drop_tables;
			$details = get_blog_details( $blog_id, false );

			wpmu_delete_blog( $blog_id, $drop_tables );

			$this->assertEquals( false, wp_cache_get( 'get_id_from_blogname_' . trim( $details->path, '/' ), 'blog-details' ) );
			$this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) );
			$this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) );
			$key = md5( $details->domain . $details->path );
			$this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) );
			$this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) );

			$prefix = $wpdb->get_blog_prefix( $blog_id );
			foreach ( $wpdb->tables( 'blog', false ) as $table ) {
				$suppress = $wpdb->suppress_errors();
				$table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
				$wpdb->suppress_errors( $suppress );
				if ( $drop_tables )
					$this->assertEmpty( $table_fields );
				else
					$this->assertNotEmpty( $table_fields, $prefix . $table );
			}
		}

		// update the blog count cache to use get_blog_count()
		wp_update_network_counts();
		$this->assertEquals( 1, get_blog_count() );
	}
Esempio n. 20
0
 public static function stream_page()
 {
     $page_title = __('Stream Records', 'stream');
     echo '<div class="wrap">';
     if (is_network_admin()) {
         $site_count = sprintf(_n('1 site', '%d sites', get_blog_count(), 'stream'), get_blog_count());
         printf('<h2>%s (%s)</h2>', __('Stream Records', 'stream'), $site_count);
         // xss ok
     } else {
         printf('<h2>%s</h2>', __('Stream Records', 'stream'));
         // xss ok
     }
     self::$list_table->prepare_items();
     self::$list_table->display();
     echo '</div>';
 }
Esempio n. 21
0
/**
 * Whether or not we have a large network.
 *
 * The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
 * Plugins can alter this criteria using the 'wp_is_large_network' filter.
 *
 * @since 3.3.0
 * @param string $using 'sites or 'users'. Default is 'sites'.
 * @return bool True if the network meets the criteria for large. False otherwise.
 */
function wp_is_large_network($using = 'sites')
{
    if ('users' == $using) {
        $count = get_user_count();
        /**
         * Filter whether the network is considered large.
         *
         * @since 3.3.0
         *
         * @param bool   $is_large_network Whether the network has more than 10000 users or sites.
         * @param string $component        The component to count. Accepts 'users', or 'sites'.
         * @param int    $count            The count of items for the component.
         */
        return apply_filters('wp_is_large_network', $count > 10000, 'users', $count);
    }
    $count = get_blog_count();
    /** This filter is documented in wp-includes/ms-functions.php */
    return apply_filters('wp_is_large_network', $count > 10000, 'sites', $count);
}
Esempio n. 22
0
 /**
  * The site count of a network should change when a site is fully deleted.
  */
 function test_blog_count_after_wpmu_delete_blog_drop_true()
 {
     $blog_id = self::factory()->blog->create();
     // Delete the site and force a table drop.
     wpmu_delete_blog($blog_id, true);
     // update the blog count cache to use get_blog_count()
     wp_update_network_counts();
     $this->assertEquals(1, get_blog_count());
 }
Esempio n. 23
0
/**
 * Check WordPress version against the newest version.
 *
 * The WordPress version, PHP version, and Locale is sent. Checks against the
 * WordPress server at api.wordpress.org server. Will only check if WordPress
 * isn't installing.
 *
 * @package WordPress
 * @since 2.3.0
 * @uses $wp_version Used to check against the newest WordPress version.
 *
 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
 */
function wp_version_check()
{
    if (defined('WP_INSTALLING')) {
        return;
    }
    global $wpdb, $wp_local_package;
    include ABSPATH . WPINC . '/version.php';
    // include an unmodified $wp_version
    $php_version = phpversion();
    $current = get_site_transient('update_core');
    if (!is_object($current)) {
        $current = new stdClass();
        $current->updates = array();
        $current->version_checked = $wp_version;
    }
    $locale = apply_filters('core_version_check_locale', get_locale());
    // Update last_checked for current to prevent multiple blocking requests if request hangs
    $current->last_checked = time();
    set_site_transient('update_core', $current);
    if (method_exists($wpdb, 'db_version')) {
        $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
    } else {
        $mysql_version = 'N/A';
    }
    if (is_multisite()) {
        $user_count = get_user_count();
        $num_blogs = get_blog_count();
        $wp_install = network_site_url();
        $multisite_enabled = 1;
    } else {
        $user_count = count_users();
        $multisite_enabled = 0;
        $num_blogs = 1;
        $wp_install = home_url('/');
    }
    $local_package = isset($wp_local_package) ? $wp_local_package : '';
    $url = "http://api.wordpress.org/core/version-check/1.6/?version={$wp_version}&php={$php_version}&locale={$locale}&mysql={$mysql_version}&local_package={$local_package}&blogs={$num_blogs}&users={$user_count['total_users']}&multisite_enabled={$multisite_enabled}";
    $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'headers' => array('wp_install' => $wp_install, 'wp_blog' => home_url('/')));
    $response = wp_remote_get($url, $options);
    if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
        return false;
    }
    $body = trim(wp_remote_retrieve_body($response));
    if (!($body = maybe_unserialize($body))) {
        return false;
    }
    if (!isset($body['offers'])) {
        return false;
    }
    $offers = $body['offers'];
    foreach ($offers as &$offer) {
        foreach ($offer as $offer_key => $value) {
            if ('packages' == $offer_key) {
                $offer['packages'] = (object) array_intersect_key(array_map('esc_url', $offer['packages']), array_fill_keys(array('full', 'no_content', 'new_bundled', 'partial'), ''));
            } elseif ('download' == $offer_key) {
                $offer['download'] = esc_url($value);
            } else {
                $offer[$offer_key] = esc_html($value);
            }
        }
        $offer = (object) array_intersect_key($offer, array_fill_keys(array('response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled', 'partial_version'), ''));
    }
    $updates = new stdClass();
    $updates->updates = $offers;
    $updates->last_checked = time();
    $updates->version_checked = $wp_version;
    set_site_transient('update_core', $updates);
}
 /**
  * Contacts the API to get the latest API updates data.
  *
  * Returns the available update details if things are working out.
  * In case the API call fails the function returns boolean false and does
  * not update the update
  *
  * @since  1.0.0
  * @internal Function only is public because it's an action handler.
  * @param  bool|array $local_projects Optional array of local projects.
  * @return array|bool
  */
 public function refresh_membership_data($local_projects = false)
 {
     global $wp_version;
     $res = false;
     /*
     		Note: This endpoint does not require an API key.
     */
     if (defined('WP_INSTALLING')) {
         return false;
     }
     // Clear the "Force data update" flag to avoid infinite loop.
     WPMUDEV_Dashboard::$site->set_option('refresh_remote_flag', 0);
     if (!is_array($local_projects)) {
         $local_projects = WPMUDEV_Dashboard::$site->get_cached_projects();
     }
     if (!function_exists('is_plugin_active')) {
         include_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     $blog_projects = array();
     /*
     Disabled, implementation not finished because of low priority.
     
     $blog_projects = WPMUDEV_Dashboard::$site->get_option( 'blog_active_projects' );
     if ( ! is_array( $blog_projects ) ) {
     	$blog_projects = array();
     	WPMUDEV_Dashboard::$site->set_option( 'blog_active_projects', array() );
     }
     */
     $projects = array();
     $theme = wp_get_theme();
     $ms_allowed = $theme->get_allowed();
     foreach ($local_projects as $pid => $item) {
         if (!empty($blog_projects[$pid])) {
             // This project is activated on a blog!
             $active = true;
         } else {
             if (is_multisite()) {
                 if ('theme' == $item['type']) {
                     $slug = dirname($item['filename']);
                     $active = !empty($ms_allowed[$slug]) || ($theme->stylesheet == $slug || $theme->template == $slug);
                     //network enabled or on main site
                 } else {
                     $active = is_plugin_active_for_network($item['filename']) || is_plugin_active($item['filename']);
                     //network or main site
                 }
             } else {
                 if ('theme' == $item['type']) {
                     $slug = dirname($item['filename']);
                     // If the theme is available on main site it's "active".
                     $active = $theme->stylesheet == $slug || $theme->template == $slug;
                 } else {
                     $active = is_plugin_active($item['filename']);
                 }
             }
         }
         $extra = '';
         /**
          * Collect extra data from individual plugins.
          *
          * @since  4.0.0
          * @api    wpmudev_api_project_extra_data-$pid
          * @param  string $extra Default extra data is an empty string.
          */
         $extra = apply_filters("wpmudev_api_project_extra_data-{$pid}", $extra);
         $extra = apply_filters('wpmudev_api_project_extra_data', $extra, $pid);
         $projects[$pid] = array('version' => $item['version'], 'active' => $active ? true : false, 'extra' => $extra);
     }
     /**
      * Allows modification of the plugin data that is sent to the server.
      *
      * @since  4.0.0
      * @api    wpmudev_api_project_data
      * @param  array $projects The whole array of project details.
      */
     $projects = apply_filters('wpmudev_api_project_data', $projects);
     // Get WP/BP version string to help with support.
     $wp_ver = '';
     if (is_multisite()) {
         $wp_ver = "WordPress Multisite {$wp_version}";
         $blog_count = get_blog_count();
     } else {
         $wp_ver = "WordPress {$wp_version}";
         $blog_count = 1;
     }
     if (defined('BP_VERSION')) {
         $wp_ver .= ', BuddyPress ' . BP_VERSION;
     }
     // Get a list of pending WP updates of non-WPMUDEV themes/plugins.
     $repo_updates = $this->get_repo_updates_infos();
     $response = WPMUDEV_Dashboard::$api->call_auth('updates', array('blog_count' => $blog_count, 'wp_version' => $wp_ver, 'projects' => json_encode($projects), 'domain' => network_site_url(), 'admin_url' => network_admin_url(), 'home_url' => network_home_url(), 'repo_updates' => $repo_updates), 'POST');
     if (200 == wp_remote_retrieve_response_code($response)) {
         $data = $response['body'];
         if ('error' != $data) {
             $data = json_decode($data, true);
             if (is_array($data)) {
                 if (empty($data['membership'])) {
                     WPMUDEV_Dashboard::$site->logout();
                 }
                 // Default order to display plugins is the order in the array.
                 if (isset($data['projects'])) {
                     $pos = 1;
                     foreach ($data['projects'] as $id => $project) {
                         $data['projects'][$id]['_order'] = $pos;
                         $pos += 1;
                     }
                 }
                 // Remove projects that are not accessible for current member.
                 $data = $this->strip_unavailable_projects($data);
                 WPMUDEV_Dashboard::$site->set_option('updates_data', $data);
                 WPMUDEV_Dashboard::$site->set_option('last_run_updates', time());
                 $this->calculate_upgrades($local_projects);
                 $this->enqueue_notices($data);
                 $res = $data;
             } else {
                 $this->parse_api_error('Error unserializing remote response.');
             }
         } else {
             $this->parse_api_error('API returned general error.');
             WPMUDEV_Dashboard::$site->logout();
         }
     } else {
         $this->parse_api_error($response);
         /*
          * For network errors, set last run to 1 hour in future so it
          * doesn't retry every single pageload (in case of server
          * connection issues)
          */
         WPMUDEV_Dashboard::$site->set_option('last_run_updates', time() + HOUR_IN_SECONDS);
     }
     return $res;
 }
Esempio n. 25
0
 * @package WordPress
 * @subpackage Multisite
 * @since 3.0.0
 */
require_once './admin.php';
if (!is_multisite()) {
    wp_die(__('Multisite support is not enabled.'));
}
if (!current_user_can('manage_network')) {
    wp_die(__('You do not have permission to access this page.'));
}
$title = __('Network Admin');
$parent_file = 'ms-admin.php';
require_once './admin-header.php';
$c_users = get_user_count();
$c_blogs = get_blog_count();
$user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users));
$blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs));
$sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text);
?>

<div class="wrap">
	<?php 
screen_icon();
?>
	<h2><?php 
echo esc_html($title);
?>
</h2>

	<ul class="subsubsub">
 function updates_check()
 {
     global $wp_version;
     $local_projects = array();
     //----------------------------------------------------------------------------------//
     //plugins directory
     //----------------------------------------------------------------------------------//
     $plugins_root = WP_PLUGIN_DIR;
     if (empty($plugins_root)) {
         $plugins_root = ABSPATH . 'wp-content/plugins';
     }
     $plugins_dir = @opendir($plugins_root);
     $plugin_files = array();
     if ($plugins_dir) {
         while (($file = readdir($plugins_dir)) !== false) {
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             if (is_dir($plugins_root . '/' . $file)) {
                 $plugins_subdir = @opendir($plugins_root . '/' . $file);
                 if ($plugins_subdir) {
                     while (($subfile = readdir($plugins_subdir)) !== false) {
                         if (substr($subfile, 0, 1) == '.') {
                             continue;
                         }
                         if (substr($subfile, -4) == '.php') {
                             $plugin_files[] = "{$file}/{$subfile}";
                         }
                     }
                 }
             } else {
                 if (substr($file, -4) == '.php') {
                     $plugin_files[] = $file;
                 }
             }
         }
     }
     @closedir($plugins_dir);
     @closedir($plugins_subdir);
     if ($plugins_dir && !empty($plugin_files)) {
         foreach ($plugin_files as $plugin_file) {
             if (is_readable("{$plugins_root}/{$plugin_file}")) {
                 unset($data);
                 $data = $this->get_id_plugin("{$plugins_root}/{$plugin_file}");
                 if (isset($data['id']) && !empty($data['id'])) {
                     $local_projects[$data['id']]['type'] = 'plugin';
                     $local_projects[$data['id']]['version'] = $data['version'];
                     $local_projects[$data['id']]['filename'] = $plugin_file;
                 }
             }
         }
     }
     //----------------------------------------------------------------------------------//
     // mu-plugins directory
     //----------------------------------------------------------------------------------//
     $mu_plugins_root = WPMU_PLUGIN_DIR;
     if (empty($mu_plugins_root)) {
         $mu_plugins_root = ABSPATH . 'wp-content/mu-plugins';
     }
     if (is_dir($mu_plugins_root) && ($mu_plugins_dir = @opendir($mu_plugins_root))) {
         while (($file = readdir($mu_plugins_dir)) !== false) {
             if (substr($file, -4) == '.php') {
                 if (is_readable("{$mu_plugins_root}/{$file}")) {
                     unset($data);
                     $data = $this->get_id_plugin("{$mu_plugins_root}/{$file}");
                     if (isset($data['id']) && !empty($data['id'])) {
                         $local_projects[$data['id']]['type'] = 'mu-plugin';
                         $local_projects[$data['id']]['version'] = $data['version'];
                         $local_projects[$data['id']]['filename'] = $file;
                     }
                 }
             }
         }
         @closedir($mu_plugins_dir);
     }
     //----------------------------------------------------------------------------------//
     // wp-content directory
     //----------------------------------------------------------------------------------//
     $content_plugins_root = WP_CONTENT_DIR;
     if (empty($content_plugins_root)) {
         $content_plugins_root = ABSPATH . 'wp-content';
     }
     $content_plugins_dir = @opendir($content_plugins_root);
     $content_plugin_files = array();
     if ($content_plugins_dir) {
         while (($file = readdir($content_plugins_dir)) !== false) {
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             if (!is_dir($content_plugins_root . '/' . $file)) {
                 if (substr($file, -4) == '.php') {
                     $content_plugin_files[] = $file;
                 }
             }
         }
     }
     @closedir($content_plugins_dir);
     if ($content_plugins_dir && !empty($content_plugin_files)) {
         foreach ($content_plugin_files as $content_plugin_file) {
             if (is_readable("{$content_plugins_root}/{$content_plugin_file}")) {
                 unset($data);
                 $data = $this->get_id_plugin("{$content_plugins_root}/{$content_plugin_file}");
                 if (isset($data['id']) && !empty($data['id'])) {
                     $local_projects[$data['id']]['type'] = 'drop-in';
                     $local_projects[$data['id']]['version'] = $data['version'];
                     $local_projects[$data['id']]['filename'] = $content_plugin_file;
                 }
             }
         }
     }
     //----------------------------------------------------------------------------------//
     //themes directory
     //----------------------------------------------------------------------------------//
     $themes_root = WP_CONTENT_DIR . '/themes';
     if (empty($themes_root)) {
         $themes_root = ABSPATH . 'wp-content/themes';
     }
     $themes_dir = @opendir($themes_root);
     $themes_files = array();
     $local_themes = array();
     if ($themes_dir) {
         while (($file = readdir($themes_dir)) !== false) {
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             if (is_dir($themes_root . '/' . $file)) {
                 $themes_subdir = @opendir($themes_root . '/' . $file);
                 if ($themes_subdir) {
                     while (($subfile = readdir($themes_subdir)) !== false) {
                         if (substr($subfile, 0, 1) == '.') {
                             continue;
                         }
                         if (substr($subfile, -4) == '.css') {
                             $themes_files[] = "{$file}/{$subfile}";
                         }
                     }
                 }
             } else {
                 if (substr($file, -4) == '.css') {
                     $themes_files[] = $file;
                 }
             }
         }
     }
     @closedir($themes_dir);
     @closedir($themes_subdir);
     if ($themes_dir && !empty($themes_files)) {
         foreach ($themes_files as $themes_file) {
             //skip child themes
             if (strpos($themes_file, '-child') !== false) {
                 continue;
             }
             if (is_readable("{$themes_root}/{$themes_file}")) {
                 unset($data);
                 $data = $this->get_id_plugin("{$themes_root}/{$themes_file}");
                 if (isset($data['id']) && !empty($data['id'])) {
                     $local_projects[$data['id']]['type'] = 'theme';
                     $local_projects[$data['id']]['filename'] = substr($themes_file, 0, strpos($themes_file, '/'));
                     //keep record of all themes for 133 themepack
                     if ($data['id'] == $this->theme_pack) {
                         $local_themes[$themes_file]['id'] = $data['id'];
                         $local_themes[$themes_file]['filename'] = substr($themes_file, 0, strpos($themes_file, '/'));
                         $local_themes[$themes_file]['version'] = $data['version'];
                         //increment 133 theme pack version to lowest in all of them
                         if (isset($local_projects[$data['id']]['version']) && version_compare($data['version'], $local_projects[$data['id']]['version'], '<')) {
                             $local_projects[$data['id']]['version'] = $data['version'];
                         } else {
                             if (!isset($local_projects[$data['id']]['version'])) {
                                 $local_projects[$data['id']]['version'] = $data['version'];
                             }
                         }
                     } else {
                         $local_projects[$data['id']]['version'] = $data['version'];
                     }
                 }
             }
         }
     }
     update_site_option('wdp_un_local_themes', $local_themes);
     update_site_option('wdp_un_local_projects', $local_projects);
     //now check the API
     $projects = '';
     foreach ($local_projects as $pid => $project) {
         $projects .= "&p[{$pid}]=" . $project['version'];
     }
     //get WP/BP version string to help with support
     $wp = is_multisite() ? "WordPress Multisite {$wp_version}" : "WordPress {$wp_version}";
     if (defined('BP_VERSION')) {
         $wp .= ', BuddyPress ' . BP_VERSION;
     }
     //add blog count if multisite
     $blog_count = is_multisite() ? get_blog_count() : 1;
     $url = $this->server_url . '?action=check&un-version=3.3.3&wp=' . urlencode($wp) . '&bcount=' . $blog_count . '&domain=' . urlencode(network_site_url()) . $projects;
     $options = array('timeout' => 15, 'user-agent' => 'Dashboard Notification/' . $this->version);
     $response = wp_remote_get($url, $options);
     if (wp_remote_retrieve_response_code($response) == 200) {
         $data = $response['body'];
         if ($data != 'error') {
             $data = unserialize($data);
             if (is_array($data)) {
                 //we've made it here with no errors, now check for available updates
                 $remote_projects = isset($data['projects']) ? $data['projects'] : array();
                 $updates = array();
                 //check for updates
                 if (is_array($remote_projects)) {
                     foreach ($remote_projects as $id => $remote_project) {
                         if (isset($local_projects[$id]) && is_array($local_projects[$id])) {
                             //match
                             $local_version = $local_projects[$id]['version'];
                             $remote_version = $remote_project['version'];
                             if (version_compare($remote_version, $local_version, '>')) {
                                 //add to array
                                 $updates[$id] = $local_projects[$id];
                                 $updates[$id]['url'] = $remote_project['url'];
                                 $updates[$id]['instructions_url'] = $remote_project['instructions_url'];
                                 $updates[$id]['support_url'] = $remote_project['support_url'];
                                 $updates[$id]['name'] = $remote_project['name'];
                                 $updates[$id]['thumbnail'] = $remote_project['thumbnail'];
                                 $updates[$id]['version'] = $local_version;
                                 $updates[$id]['new_version'] = $remote_version;
                                 $updates[$id]['changelog'] = $remote_project['changelog'];
                                 $updates[$id]['autoupdate'] = $remote_project['autoupdate'];
                             }
                         }
                     }
                     //record results
                     update_site_option('wdp_un_updates_available', $updates);
                 } else {
                     return false;
                 }
             }
         }
     }
 }
Esempio n. 27
0
/**
 * @since 3.1.0
 */
function wp_network_dashboard_right_now()
{
    $actions = array();
    if (current_user_can('create_sites')) {
        $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __('Create a New Site') . '</a>';
    }
    if (current_user_can('create_users')) {
        $actions['create-user'] = '******' . network_admin_url('user-new.php') . '">' . __('Create a New User') . '</a>';
    }
    $c_users = get_user_count();
    $c_blogs = get_blog_count();
    $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users));
    $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs));
    $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text);
    if ($actions) {
        echo '<ul class="subsubsub">';
        foreach ($actions as $class => $action) {
            $actions[$class] = "\t<li class='{$class}'>{$action}";
        }
        echo implode(" |</li>\n", $actions) . "</li>\n";
        echo '</ul>';
    }
    ?>
	<br class="clear" />

	<p class="youhave"><?php 
    echo $sentence;
    ?>
</p>


	<?php 
    /**
     * Fires in the Network Admin 'Right Now' dashboard widget
     * just before the user and site search form fields.
     *
     * @since MU
     *
     * @param null $unused
     */
    do_action('wpmuadminresult', '');
    ?>

	<form action="<?php 
    echo network_admin_url('users.php');
    ?>
" method="get">
		<p>
			<label class="screen-reader-text" for="search-users"><?php 
    _e('Search Users');
    ?>
</label>
			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
			<?php 
    submit_button(__('Search Users'), 'button', false, false, array('id' => 'submit_users'));
    ?>
		</p>
	</form>

	<form action="<?php 
    echo network_admin_url('sites.php');
    ?>
" method="get">
		<p>
			<label class="screen-reader-text" for="search-sites"><?php 
    _e('Search Sites');
    ?>
</label>
			<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
			<?php 
    submit_button(__('Search Sites'), 'button', false, false, array('id' => 'submit_sites'));
    ?>
		</p>
	</form>
<?php 
    /**
     * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
     *
     * @since MU
     */
    do_action('mu_rightnow_end');
    /**
     * Fires at the end of the 'Right Now' widget in the Network Admin dashboard.
     *
     * @since MU
     */
    do_action('mu_activity_box_end');
}
 static function schedule_initial_sync($new_version = null, $old_version = null)
 {
     $initial_sync_config = array('options' => true, 'network_options' => true, 'functions' => true, 'constants' => true);
     if ($old_version && version_compare($old_version, '4.2', '<')) {
         $initial_sync_config['users'] = 'initial';
     }
     // we need this function call here because we have to run this function
     // reeeeally early in init, before WP_CRON_LOCK_TIMEOUT is defined.
     wp_functionality_constants();
     if (is_multisite()) {
         // stagger initial syncs for multisite blogs so they don't all pile on top of each other
         $time_offset = rand() / getrandmax() * self::INITIAL_SYNC_MULTISITE_INTERVAL * get_blog_count();
     } else {
         $time_offset = 1;
     }
     self::schedule_full_sync($initial_sync_config, $time_offset);
 }
Esempio n. 29
0
        /**
         * Filter whether to attempt to perform the multisite DB upgrade routine.
         *
         * In single site, the user would be redirected to wp-admin/upgrade.php.
         * In multisite, the DB upgrade routine is automatically fired, but only
         * when this filter returns true.
         *
         * If the network is 50 sites or less, it will run every time. Otherwise,
         * it will throttle itself to reduce load.
         *
         * @since 3.0.0
         *
         * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true.
         */
    } elseif (apply_filters('do_mu_upgrade', true)) {
        $c = get_blog_count();
        /*
         * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load:
         * attempt to do no more than threshold value, with some +/- allowed.
         */
        if ($c <= 50 || $c > 50 && mt_rand(0, (int) ($c / 50)) == 1) {
            require_once ABSPATH . WPINC . '/http.php';
            $response = wp_remote_get(admin_url('upgrade.php?step=1'), array('timeout' => 120, 'httpversion' => '1.1'));
            /** This action is documented in wp-admin/network/upgrade.php */
            do_action('after_mu_upgrade', $response);
            unset($response);
        }
        unset($c);
    }
}
require_once ABSPATH . 'wp-admin/includes/admin.php';
Esempio n. 30
0
 /**
  * Get plugin update information from server
  * 
  * @global string $wp_version
  * @global object $wpdb
  * @return boolean
  */
 function get_info()
 {
     global $wp_version, $wpdb;
     list($plugin_name, $plugin_version) = $this->get_current_plugin_info();
     if (is_multisite()) {
         $user_count = get_user_count();
         $num_blogs = get_blog_count();
         $wp_install = network_site_url();
         $multisite_enabled = 1;
     } else {
         $user_count = count_users();
         $multisite_enabled = 0;
         $num_blogs = 1;
         $wp_install = home_url('/');
     }
     $locale = apply_filters('core_version_check_locale', get_locale());
     if (method_exists($wpdb, 'db_version')) {
         $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version());
     } else {
         $mysql_version = 'N/A';
     }
     $license = $this->get_license_key();
     $params = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), 'body' => array('name' => $plugin_name, 'slug' => self::slug, 'type' => 'plugin', 'version' => $plugin_version, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'action' => 'theme_check', 'locale' => $locale, 'mysql' => $mysql_version, 'blogs' => $num_blogs, 'users' => $user_count['total_users'], 'multisite_enabled' => $multisite_enabled, 'site_url' => $wp_install, 'license' => isset($license['key']) ? $license['key'] : '', 'license_email' => isset($license['email']) ? $license['email'] : '', 'product_id' => self::product_id));
     $response = wp_remote_post(self::base_url . '?action=wedevs_update_check', $params);
     $update = wp_remote_retrieve_body($response);
     if (is_wp_error($response) || $response['response']['code'] != 200) {
         return false;
     }
     return json_decode($update);
 }