本文整理汇总了PHP中wp_get_sites函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_sites函数的具体用法?PHP wp_get_sites怎么用?PHP wp_get_sites使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_sites函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fromLte150807
/**
* Before we changed errors and blog-specific storage on a MS network.
*
* @since 151002 Improving multisite compat.
*/
protected function fromLte150807()
{
if (version_compare($this->prev_version, '150807', '<=')) {
delete_site_option(GLOBAL_NS . '_errors');
// No longer necessary.
if (is_multisite() && is_array($child_blogs = wp_get_sites())) {
$current_site = get_current_site();
// Current site.
foreach ($child_blogs as $_child_blog) {
switch_to_blog($_child_blog['blog_id']);
delete_option(GLOBAL_NS . '_errors');
delete_option(GLOBAL_NS . '_notices');
delete_option(GLOBAL_NS . '_options');
delete_option(GLOBAL_NS . '_apc_warning_bypass');
if ((int) $_child_blog['blog_id'] !== (int) $current_site->blog_id) {
wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_auto_cache');
wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_cleanup');
}
restore_current_blog();
// Restore current blog.
}
unset($_child_blog);
// Housekeeping.
}
if (is_array($existing_options = get_site_option(GLOBAL_NS . '_options'))) {
if (isset($existing_options['admin_bar_enable'])) {
$this->plugin->options['cache_clear_admin_bar_enable'] = $existing_options['admin_bar_enable'];
$this->plugin->updateOptions($this->plugin->options, false);
// Save/update options.
}
}
}
}
开发者ID:arobbins,项目名称:sblog,代码行数:38,代码来源:VsUpgrades.php
示例2: get_sites
/**
* Query for our sites
*
* @since 1.0.1
*/
public function get_sites()
{
if (empty($this->sites)) {
$this->sites = wp_get_sites(array('deleted' => false));
}
return $this->sites;
}
开发者ID:nicoladj77,项目名称:WDS-Active-Plugin-Data,代码行数:12,代码来源:wds-active-plugin-data.php
示例3: awf_uninstall_arabic_webfonts_plugin
/**
* The uninstalling process.
*
* @since 1.0
*/
function awf_uninstall_arabic_webfonts_plugin()
{
if (function_exists('is_multisite') && is_multisite()) {
// check permission
if (false == is_super_admin()) {
return;
}
// get all sites in network
$sites = wp_get_sites();
foreach ($sites as $site) {
switch_to_blog($site['blog_id']);
// delete custom post type
awf_delete_custom_post_type();
// remove all theme mods
awf_remove_all_theme_mods();
restore_current_blog();
}
} else {
if (!current_user_can('activate_plugins')) {
return;
}
// delete custom post type
awf_delete_custom_post_type();
// remove all theme mods
awf_remove_all_theme_mods();
}
}
开发者ID:jozoor,项目名称:Arabic-Webfonts,代码行数:32,代码来源:uninstall.php
示例4: maybeUninstall
/**
* Maybe uninstall.
*
* @since 160524 Uninstall utils.
*/
public function maybeUninstall()
{
// See: <https://core.trac.wordpress.org/ticket/14955>
if ($this->App->Config->§specs['§type'] !== 'plugin') {
return;
// For plugins only at this time.
} elseif (!defined('WP_UNINSTALL_PLUGIN')) {
return;
// Not applicable.
} elseif ($this->s::conflictsExist()) {
return;
// Stop on conflicts.
} elseif (!$this->App->Config->§uninstall) {
return;
// Not uninstalling.
}
$this->site_counter = 0;
// Initialize site counter.
if ($this->Wp->is_multisite) {
// For each site in the network.
foreach (($sites = wp_get_sites()) ? $sites : [] as $_site) {
++$this->site_counter;
switch_to_blog($_site['blog_id']);
$this->uninstall();
restore_current_blog();
}
// unset($_site);
} else {
++$this->site_counter;
$this->uninstall();
}
}
开发者ID:websharks,项目名称:wp-sharks-core,代码行数:37,代码来源:Uninstaller.php
示例5: get_blogs
/**
* Returns an array of all sites in the current network.
* The array index is the blog-ID and the array value the blog title.
*
* @since 1.0.0
* @param bool $only_public By default only public sites are returned.
* @return array
*/
public static function get_blogs($only_public = true)
{
static $List = array();
$key = $only_public ? 'public' : 'all';
if (!isset($List['_cache'])) {
$List['_cache'] = array();
}
if (!isset($List[$key])) {
$args = array('limit' => 0, 'public' => true, 'spam' => false, 'deleted' => false);
if ($only_public) {
$args['archived'] = false;
$args['mature'] = false;
}
$sites = wp_get_sites($args);
$List[$key] = array();
foreach ($sites as $site_data) {
$blog_id = $site_data['blog_id'];
if (isset($List['_cache'][$blog_id])) {
$title = $List['_cache'][$blog_id];
} else {
switch_to_blog($blog_id);
$title = get_bloginfo('title');
$List['_cache'][$blog_id] = $title;
restore_current_blog();
}
$List[$key][$blog_id] = $title;
}
}
return $List[$key];
}
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:38,代码来源:class-ms-helper-settings.php
示例6: __download_monitor_install
/**
* Plugin activation hook.
* When site is multisite and plugin is network activated, installer will run for each blog
*
* @param bool $network_wide
*/
function __download_monitor_install($network_wide = false)
{
// Load installer functions
require_once plugin_dir_path(DLM_PLUGIN_FILE_INSTALLER) . 'includes/class-dlm-installer.php';
// DLM Installer
$installer = new DLM_Installer();
// check if
if (!function_exists('is_plugin_active_for_network')) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
// check if it's multisite
if (is_multisite() && true == $network_wide) {
// get websites
$sites = wp_get_sites();
// loop
if (count($sites) > 0) {
foreach ($sites as $site) {
// switch to blog
switch_to_blog($site['blog_id']);
// run installer on blog
$installer->install();
// restore current blog
restore_current_blog();
}
}
} else {
// no multisite so do normal install
$installer->install();
}
}
开发者ID:garysims,项目名称:bbmp3downloader,代码行数:36,代码来源:installer-functions.php
示例7: sites_listing_shortcode
function sites_listing_shortcode($atts)
{
extract(shortcode_atts(array('network_id' => 1, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => -1, 'offset' => 0), $atts));
$options = array('network_id' => $network_id, 'public' => $public, 'archived' => $archived, 'mature' => $mature, 'spam' => $spam, 'deleted' => $deleted, 'limit' => $limit);
$sites = wp_get_sites($options);
ob_start();
if (!empty($sites)) {
?>
<ul class="sites-listing"> <?
foreach($sites as $site)
switch_to_blog( $site['blog_id'] ); ?>
<li id="site-<?php
echo $site['blog_id'];
?>
">
<a href="<?php
echo get_bloginfo('url');
?>
"><?php
echo get_bloginfo('name');
?>
</a>
</li><?
restore_current_blog();
endforeach; ?>
</ul> <?php
}
ob_end_flush();
}
开发者ID:JudeRosario,项目名称:wp-swissarmyknife,代码行数:29,代码来源:lists-using-shortcodes.php
示例8: bf_msn__admin_settings_sidebar_metabox_html
function bf_msn__admin_settings_sidebar_metabox_html()
{
global $post, $buddyforms, $wpdb;
if ($post->post_type != 'buddyforms') {
return;
}
$buddyform = get_post_meta(get_the_ID(), '_buddyforms_options', true);
$form_setup = array();
$args = array('network_id' => $wpdb->siteid, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 100, 'offset' => 0);
$sites = wp_get_sites();
$msn_sites['off'] = 'Disabled';
foreach ($sites as $key => $site) {
$msn_sites[$site['blog_id']] = $site['path'];
}
$msn_enabled = 'off';
if (isset($buddyform['msn_enabled'])) {
$msn_enabled = $buddyform['msn_enabled'];
}
$form_setup[] = new Element_Select("<b>" . __('Enable', 'buddyforms') . "</b>", "buddyforms_options[msn_enabled]", $msn_sites, array('value' => $msn_enabled, 'shortDesc' => __('Link this form to form to a site in the network.', 'buddyforms')));
foreach ($form_setup as $key => $field) {
echo '<div class="buddyforms_field_label">' . $field->getLabel() . '</div>';
echo '<div class="buddyforms_field_description">' . $field->getShortDesc() . '</div>';
echo '<div class="buddyforms_form_field">' . $field->render() . '</div>';
}
}
开发者ID:BuddyForms,项目名称:BuddyForms-Multisite-Network,代码行数:25,代码来源:loader.php
示例9: list_network_sites
function list_network_sites($atts)
{
// Start by getting an array of information of all sites in the network.
$info = array('network_id' => null, 'public' => null, 'archived' => null, 'mature' => null, 'spam' => null, 'deleted' => null, 'limit' => 100, 'offset' => 0);
$siteInfos = wp_get_sites($info);
// Use shortcode atts to determine list type, then begin the output variable $list with the right <li> tag.
$listType = shortcode_atts(array('list' => "unordered"), $atts);
if ($listType['list'] == "unordered") {
$list = "<ul>";
} else {
if ($listType['list'] == "ordered") {
$list = "<ol>";
} else {
$list = "Error: Incorrect shortcode was used. Please contact admin.";
return $list;
}
}
// Add the list content.
foreach ($siteInfos as $siteInfo) {
$blog_details = get_blog_details($siteInfo['blog_id']);
$list .= "<li><a href='{$blog_details->siteurl}'>{$blog_details->blogname}</a></li>";
}
// Close the list tag.
if ($listType['list'] == "unordered") {
$list .= "</ul>";
} else {
$list .= "</ol>";
}
return $list;
}
开发者ID:amychan331,项目名称:personalProject-shortcut,代码行数:30,代码来源:list_network_sites.php
示例10: uninstall
static function uninstall()
{
global $wpdb;
if (is_multisite()) {
// Cleanup Network install
foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
switch_to_blog($blog['blog_id']);
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
delete_option('gadash_options');
delete_transient('ga_dash_lasterror');
delete_transient('ga_dash_refresh_token');
delete_transient('ga_dash_gapi_errors');
restore_current_blog();
}
delete_site_option('gadash_network_options');
delete_site_transient('ga_dash_refresh_token');
} else {
// Cleanup Single install
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'");
$sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'");
delete_option('gadash_options');
delete_transient('ga_dash_lasterror');
delete_transient('ga_dash_refresh_token');
delete_transient('ga_dash_gapi_errors');
}
}
开发者ID:nickhype,项目名称:HackeyWalk-site-backup,代码行数:31,代码来源:uninstall.php
示例11: get
function get($empty, $arg, $requete)
{
$is_result = apply_filters('eventpost_multisite_get', $empty, $arg, $requete);
if ($is_result != $empty) {
return $is_result;
}
if (!is_array($arg) || !isset($arg['blogs']) || '' == $arg['blogs']) {
return $empty;
}
//print_r($arg);
$blog_ids = array();
if ($arg['blogs'] == 'all') {
$blogs = wp_get_sites(array('limit' => 0));
foreach ($blogs as $blog) {
$blog_ids[] = $blog['blog_id'];
}
} elseif (!empty($arg['blogs'])) {
$blog_ids = apply_filters('eventpost_multisite_blogids', explode(',', $arg['blogs']));
} else {
return $empty;
}
global $EventPost, $wpdb;
$all_events = array();
foreach ($blog_ids as $blog_id) {
switch_to_blog($blog_id);
$query = new WP_Query($requete);
$events = $wpdb->get_col($query->request);
foreach ($events as $k => $event) {
$all_events[] = $EventPost->retreive($event);
}
restore_current_blog();
}
return $all_events;
}
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:34,代码来源:multisite.php
示例12: get_all_posts
function get_all_posts()
{
$sites = wp_get_sites();
foreach ($sites as $site) {
switch_to_blog($site['blog_id']);
get_all_posts_on_site();
}
}
开发者ID:tsDaenor,项目名称:ops3-g02,代码行数:8,代码来源:data-export-csv.php
示例13: __construct
/**
* Constructor
*
* @param Inpsyde_Property_List_Interface $plugin_data
* @param wpdb $wpdb
* @param Mlp_Version_Number_Interface $current_version
* @param Mlp_Version_Number_Interface $last_version
* @return Mlp_Update_Plugin_Data
*/
public function __construct(Inpsyde_Property_List_Interface $plugin_data, wpdb $wpdb, Mlp_Version_Number_Interface $current_version, Mlp_Version_Number_Interface $last_version)
{
$this->plugin_data = $plugin_data;
$this->last_version = $last_version;
$this->current_version = $current_version;
$this->wpdb = $wpdb;
$this->all_sites = wp_get_sites();
}
开发者ID:luisarn,项目名称:multilingual-press,代码行数:17,代码来源:Mlp_Update_Plugin_Data.php
示例14: do_sync
public static function do_sync()
{
global $wpdb;
$debug_mode = defined('KIGO_DEBUG') && KIGO_DEBUG;
// Do not log into New Relic, because this function is slow and we know why
if (extension_loaded('newrelic')) {
newrelic_ignore_transaction();
}
//Check that cron is "enabled" and that the secret is correct
if (!defined('KIGO_CRON_SECRET') || !isset($_GET[self::GET_PARAM_CRON_SECRET]) || $_GET[self::GET_PARAM_CRON_SECRET] !== KIGO_CRON_SECRET) {
self::log(array('message' => 'Missing/Invalid cron secret', 'info' => $_SERVER));
self::handle_logs($debug_mode);
exit;
}
// Ensure that no other cron will run concurrently by acquiring an advisory lock (at MySQL database)
if (!$wpdb->get_var($wpdb->prepare('SELECT GET_LOCK(%s, 0)', self::ADV_LOCK_PROCESSING))) {
self::log('Previous cron execution is not finished, could not acquire cron lock');
self::handle_logs($debug_mode);
exit;
}
$prevTimeTotal = microtime(true);
if (is_multisite()) {
require_once dirname(__FILE__) . '/ext/class-zebra-curl.php';
// Change the default value of wp_is_large_network necessary if # of sites reach the 10000
add_filter('wp_is_large_network', array('Kigo_Network_Cron', 'custom_wp_is_large_network'), 1, 3);
// Initialize the list of sites
$sites = wp_get_sites(array('limit' => self::CUSTOM_WP_IS_LARGE_NETWORK, 'deleted' => 0, 'archived' => 0));
shuffle($sites);
// Filter the sites, not to trigger a sync for site where the solution data have not been updated since X months
self::filter_old_sites($sites);
self::log(array('nb_sites' => count($sites)));
//Do the Zebra cURL call (asynchronous calls)
$curl = new Zebra_cURL();
$curl->option(CURLOPT_TIMEOUT, self::CURL_TIMEOUT);
$curl->threads = self::CURL_PARALLEL_CALLS;
//Prepare URLs to be called
$urls = array_map(array('Kigo_Network_Cron', 'generate_curl_urls'), $sites);
$urls = array_filter($urls, function ($url) {
return is_string($url);
});
$curl->get($urls, array('Kigo_Network_Cron', 'zebra_curl_callback'));
} else {
set_error_handler(array('Kigo_Network_Cron', 'php_error_handler'));
// Add our custom handler for wp_die() because some functions die on error, and we don't want the script to die !
add_filter('wp_die_ajax_handler', array('Kigo_Network_Cron', 'kigo_cron_wp_die_handler_filter'));
$site_cron = new Kigo_Site_Cron();
self::log($site_cron->sync_entities() ? true : $site_cron->_errors);
restore_error_handler();
}
self::log(array('total_execution_time' => microtime(true) - $prevTimeTotal));
if (!$wpdb->query($wpdb->prepare('SELECT RELEASE_LOCK(%s)', self::ADV_LOCK_PROCESSING))) {
self::log('Could not release cron lock');
}
// Echo the logs in debug mode or send them by mail
self::handle_logs($debug_mode);
exit;
}
开发者ID:alfiedawes,项目名称:WP-InstaSites,代码行数:57,代码来源:class-kigo-cron.php
示例15: __construct
/**
* Class constructor.
*
* @since 141111 First documented version.
*/
public function __construct()
{
parent::__construct();
if ($this->plugin->enable_hooks) {
return;
// Not a good idea.
}
$this->plugin->setup();
// Setup.
if (!defined('WP_UNINSTALL_PLUGIN')) {
return;
// Disallow.
}
if (empty($GLOBALS[GLOBAL_NS . '_uninstalling'])) {
return;
// Expecting uninstall file.
}
if ($this->plugin->options['uninstall_safeguards_enable']) {
return;
// Nothing to do here; safeguarding.
}
if (!current_user_can($this->plugin->uninstall_cap)) {
return;
// Extra layer of security.
}
if (!current_user_can($this->plugin->cap)) {
return;
// Extra layer of security.
}
$this->deleteOptions();
$this->deleteNotices();
$this->deleteInstallTime();
$this->deleteOptionKeys();
$this->deleteTransientKeys();
$this->deletePostMetaKeys();
$this->deleteUserMetaKeys();
$this->clearCronHooks();
$this->dropDbTables();
if (is_multisite() && is_array($child_blogs = wp_get_sites())) {
foreach ($child_blogs as $_child_blog) {
switch_to_blog($_child_blog['blog_id']);
$this->deleteOptions();
$this->deleteNotices();
$this->deleteInstallTime();
$this->deleteOptionKeys();
$this->deleteTransientKeys();
$this->deletePostMetaKeys();
$this->deleteUserMetaKeys();
$this->clearCronHooks();
$this->dropDbTables();
restore_current_blog();
}
}
unset($_child_blog);
// Housekeeping.
}
开发者ID:websharks,项目名称:comment-mail,代码行数:61,代码来源:Uninstaller.php
示例16: set_blog_ids
/**
* Set the blog id(s) for a site
*/
private function set_blog_ids()
{
$blog_ids = array(1);
if (function_exists('is_multisite') && is_multisite()) {
$args = array('limit' => false, 'spam' => 0, 'deleted' => 0, 'archived' => 0);
$blogs = wp_get_sites($args);
$blog_ids = wp_list_pluck($blogs, 'blog_id');
}
$this->blog_ids = $blog_ids;
}
开发者ID:sohel4r,项目名称:wordpress_4_1_1,代码行数:13,代码来源:wp-aws-uninstall.php
示例17: get_multisites
public function get_multisites()
{
$multisites = wp_get_sites();
$this->load_included_site_ids();
$result = [];
foreach ($multisites as $blog) {
$result[] = $this->prepare_item($blog);
}
return $result;
}
开发者ID:elordin,项目名称:cms,代码行数:10,代码来源:RestApi_Multisites.php
示例18: login_radius_update_old_blogs
public function login_radius_update_old_blogs($oldConfig)
{
global $loginradius_api_settings;
if (isset($loginradius_api_settings['multisite_config']) && $loginradius_api_settings['multisite_config'] == '1') {
$settings = get_option('LoginRadius_share_settings');
$blogs = wp_get_sites();
foreach ($blogs as $blog) {
update_blog_option($blog['blog_id'], 'LoginRadius_share_settings', $settings);
}
}
}
开发者ID:selectSIFISO,项目名称:.comsite,代码行数:11,代码来源:lr-social-share-admin.php
示例19: set_duplicable_option
/**
* Set 'mucd_duplicable' option to "yes" for the list of blogs, other to "no"
* @since 0.2.0
* @param array $blogs list of blogs we want the option set to "yes"
*/
public static function set_duplicable_option($blogs)
{
$network_blogs = wp_get_sites(array('limit' => MUCD_MAX_NUMBER_OF_SITE));
foreach ($network_blogs as $blog) {
if (in_array($blog['blog_id'], $blogs)) {
update_blog_option($blog['blog_id'], 'mucd_duplicable', "yes");
} else {
update_blog_option($blog['blog_id'], 'mucd_duplicable', "no");
}
}
}
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:16,代码来源:option.php
示例20: get_sites
public function get_sites()
{
$sites = wp_get_sites();
$pages = array();
foreach ($sites as $site) {
switch_to_blog($site['blog_id']);
$pages[] = array('blog_id' => $site['blog_id'], 'pages' => get_pages());
restore_current_blog();
}
$this->sites = $pages;
}
开发者ID:ryan2407,项目名称:Vision,代码行数:11,代码来源:index.php
注:本文中的wp_get_sites函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论