当前位置: 首页>>代码示例>>PHP>>正文


PHP get_blog_count函数代码示例

本文整理汇总了PHP中get_blog_count函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blog_count函数的具体用法?PHP get_blog_count怎么用?PHP get_blog_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_blog_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_sitestats

/**
 * 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;
}
开发者ID:nightsh,项目名称:hartapoliticii,代码行数:16,代码来源:ms-functions.php

示例2: wp_version_check

/**
 * 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);
}
开发者ID:ericandrewlewis,项目名称:wordpress-mu,代码行数:72,代码来源:update.php

示例3: get_sitestats

/**
 * 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;
}
开发者ID:ramo01,项目名称:1kapp,代码行数:19,代码来源:ms-functions.php

示例4: prepare_items

	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,
		) );
	}
开发者ID:realfluid,项目名称:umbaugh,代码行数:54,代码来源:class-wp-ms-users-list-table.php

示例5: get_sitestats

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;
}
开发者ID:joelglennwright,项目名称:agencypress,代码行数:15,代码来源:wpmu-functions.php

示例6: test_enable_live_network_site_counts_filter

	/**
	 * @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 );
		}
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:24,代码来源:network.php

示例7: wp_version_check

/**
 * 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'), ''));
//.........这里部分代码省略.........
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:101,代码来源:update.php

示例8: wp_is_large_network

/**
 * 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 );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:19,代码来源:ms.php

示例9: output_diagnostic_info

 /**
  * 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";
//.........这里部分代码省略.........
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:101,代码来源:amazon-s3-and-cloudfront.php

示例10: check_admin_referer

    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') {
开发者ID:UPMediaDesign,项目名称:vidaestudiantilip,代码行数:31,代码来源:network.php

示例11: wp_network_dashboard_right_now

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'] = '<a href="' . 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');
}
开发者ID:nouphet,项目名称:rata,代码行数:60,代码来源:dashboard.php

示例12: get_additional_stat_data

 /**
  * 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;
 }
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:14,代码来源:class.jetpack.php

示例13: protect_call

 /**
  * 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;
 }
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:54,代码来源:protect.php

示例14: refresh_updates

 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;
     }
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:61,代码来源:update-notifications.php

示例15: prepare_items

 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));
 }
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:82,代码来源:class-wp-ms-sites-list-table.php


注:本文中的get_blog_count函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。