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


PHP restore_current_blog函数代码示例

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


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

示例1: __construct

 /**
  * Widget constructor
  *
  * @param WP_Piwik $wpPiwik
  *        	current WP-Piwik object
  * @param WP_Piwik\Settings $settings
  *        	current WP-Piwik settings
  * @param string $pageId
  *        	WordPress page ID (default: dashboard)
  * @param string $context
  *        	WordPress meta box context (defualt: side)
  * @param string $priority
  *        	WordPress meta box priority (default: default)
  * @param array $params
  *        	widget parameters (default: empty array)
  * @param boolean $isShortcode
  *        	is the widget shown inline? (default: false)
  */
 public function __construct($wpPiwik, $settings, $pageId = 'dashboard', $context = 'side', $priority = 'default', $params = array(), $isShortcode = false)
 {
     self::$wpPiwik = $wpPiwik;
     self::$settings = $settings;
     $this->pageId = $pageId;
     $this->context = $context;
     $this->priority = $priority;
     if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin() && isset($_GET['wpmu_show_stats'])) {
         switch_to_blog((int) $_GET['wpmu_show_stats']);
         $this->blogId = get_current_blog_id();
         restore_current_blog();
     }
     $this->isShortcode = $isShortcode;
     $prefix = $this->pageId == 'dashboard' ? self::$settings->getGlobalOption('plugin_display_name') . ' - ' : '';
     $this->configure($prefix, $params);
     if (is_array($this->method)) {
         foreach ($this->method as $method) {
             $this->apiID[$method] = \WP_Piwik\Request::register($method, $this->parameter);
             self::$wpPiwik->log("Register request: " . $this->apiID[$method]);
         }
     } else {
         $this->apiID[$this->method] = \WP_Piwik\Request::register($this->method, $this->parameter);
         self::$wpPiwik->log("Register request: " . $this->apiID[$this->method]);
     }
     if ($this->isShortcode) {
         return;
     }
     add_meta_box($this->getName(), $this->title, array($this, 'show'), $pageId, $this->context, $this->priority);
 }
开发者ID:braekling,项目名称:WP-Piwik,代码行数:47,代码来源:Widget.php

示例2: activate_for_blog

 function activate_for_blog($blog_id)
 {
     switch_to_blog($blog_id);
     self::_install_posts_table();
     self::install_role_caps();
     restore_current_blog();
 }
开发者ID:boatlmz,项目名称:wp-access-areas,代码行数:7,代码来源:class-undisclosedinstall.php

示例3: importend

function importend()
{
    global $wpdb, $shortname;
    #make custom fields image paths point to sampledata/sample_images folder
    $sample_images_postmeta = $wpdb->get_results($wpdb->prepare("SELECT meta_id, meta_value FROM {$wpdb->postmeta} WHERE meta_value REGEXP %s", 'http://et_sample_images.com'));
    if ($sample_images_postmeta) {
        foreach ($sample_images_postmeta as $postmeta) {
            $template_dir = get_template_directory_uri();
            if (is_multisite()) {
                switch_to_blog(1);
                $main_siteurl = site_url();
                restore_current_blog();
                $template_dir = $main_siteurl . '/wp-content/themes/' . get_template();
            }
            preg_match('/http:\\/\\/et_sample_images.com\\/([^.]+).jpg/', $postmeta->meta_value, $matches);
            $image_path = $matches[1];
            $local_image = preg_replace('/http:\\/\\/et_sample_images.com\\/([^.]+).jpg/', $template_dir . '/sampledata/sample_images/$1.jpg', $postmeta->meta_value);
            $local_image = preg_replace('/s:55:/', 's:' . strlen($template_dir . '/sampledata/sample_images/' . $image_path . '.jpg') . ':', $local_image);
            $wpdb->update($wpdb->postmeta, array('meta_value' => esc_url_raw($local_image)), array('meta_id' => $postmeta->meta_id), array('%s'));
        }
    }
    if (!isset($_POST['importepanel'])) {
        return;
    }
    $importedOptions = array($shortname . '_logo' => '', $shortname . '_favicon' => '', $shortname . '_bgcolor' => '', $shortname . '_bgtexture_url' => 'Default', $shortname . '_bgimage' => '', $shortname . '_header_font' => 'Kreon', $shortname . '_header_font_color' => '', $shortname . '_body_font' => 'Droid Sans', $shortname . '_body_font_color' => '', $shortname . '_show_twitter_icon' => 'on', $shortname . '_show_rss_icon' => 'on', $shortname . '_show_facebook_icon' => 'on', $shortname . '_twitter_url' => '#', $shortname . '_rss_url' => '', $shortname . '_facebook_url' => '#', $shortname . '_catnum_posts' => '6', $shortname . '_archivenum_posts' => '5', $shortname . '_searchnum_posts' => '5', $shortname . '_tagnum_posts' => '5', $shortname . '_date_format' => 'M j, Y', $shortname . '_new_thumb_method' => 'on', $shortname . '_show_control_panel' => 'on', $shortname . '_display_blurbs' => 'on', $shortname . '_display_media' => 'on', $shortname . '_quote' => 'on', $shortname . '_quote_one' => 'Chameleon is an extremely versatile theme with a myriad of options and styles', $shortname . '_quote_two' => 'Aliquam venenatis enim in mi iaculis in tempor lectus tempor et convallis erat pellentesque', $shortname . '_home_page_1' => 'About', $shortname . '_home_page_2' => 'What I Do', $shortname . '_home_page_3' => 'Who I Am', $shortname . '_posts_media' => '10', $shortname . '_exlcats_media' => array(13), $shortname . '_homepage_posts' => '7', $shortname . '_featured' => 'on', $shortname . '_duplicate' => 'on', $shortname . '_slider_type' => 'cycle', $shortname . '_feat_cat' => 'Featured', $shortname . '_featured_num' => '3', $shortname . '_slider_autospeed' => '7000', $shortname . '_menupages' => array(724), $shortname . '_enable_dropdowns' => 'on', $shortname . '_home_link' => 'on', $shortname . '_sort_pages' => 'post_title', $shortname . '_order_page' => 'asc', $shortname . '_tiers_shown_pages' => '3', $shortname . '_menucats' => array(14, 15, 1), $shortname . '_enable_dropdowns_categories' => 'on', $shortname . '_categories_empty' => 'on', $shortname . '_tiers_shown_categories' => '3', $shortname . '_sort_cat' => 'name', $shortname . '_order_cat' => 'asc', $shortname . '_postinfo2' => array('author', 'date', 'categories', 'comments'), $shortname . '_thumbnails' => 'on', $shortname . '_show_postcomments' => 'on', $shortname . '_postinfo1' => array('author', 'date', 'categories', 'comments'), $shortname . '_thumbnails_index' => 'on', $shortname . '_child_cssurl' => '', $shortname . '_color_mainfont' => '', $shortname . '_color_mainlink' => '', $shortname . '_color_pagelink' => '', $shortname . '_color_pagelink_active' => '', $shortname . '_color_headings' => '', $shortname . '_color_sidebar_links' => '', $shortname . '_footer_text' => '', $shortname . '_color_footerlinks' => '', $shortname . '_seo_home_titletext' => '', $shortname . '_seo_home_descriptiontext' => '', $shortname . '_seo_home_keywordstext' => '', $shortname . '_seo_home_type' => 'BlogName | Blog description', $shortname . '_seo_home_separate' => ' | ', $shortname . '_seo_single_field_title' => 'seo_title', $shortname . '_seo_single_field_description' => 'seo_description', $shortname . '_seo_single_field_keywords' => 'seo_keywords', $shortname . '_seo_single_type' => 'Post title | BlogName', $shortname . '_seo_single_separate' => ' | ', $shortname . '_seo_index_type' => 'Category name | BlogName', $shortname . '_seo_index_separate' => ' | ', $shortname . '_integrate_header_enable' => 'on', $shortname . '_integrate_body_enable' => 'on', $shortname . '_integrate_singletop_enable' => 'on', $shortname . '_integrate_singlebottom_enable' => 'on', $shortname . '_integration_head' => '', $shortname . '_integration_body' => '', $shortname . '_integration_single_top' => '', $shortname . '_integration_single_bottom' => '', $shortname . '_468_image' => '', $shortname . '_468_url' => '', $shortname . '_468_adsense' => '');
    foreach ($importedOptions as $key => $value) {
        if ($value != '') {
            update_option($key, $value);
        }
    }
    update_option($shortname . '_use_pages', 'false');
}
开发者ID:iinspiration,项目名称:theme,代码行数:32,代码来源:import_settings.php

示例4: tearDown

 function tearDown()
 {
     parent::tearDown();
     if (defined('IS_WPCOM') && IS_WPCOM) {
         restore_current_blog();
     }
 }
开发者ID:iamtakashi,项目名称:jetpack,代码行数:7,代码来源:test_interface.jetpack-sync-replicastore.php

示例5: widget

 /**
  * load widget
  *
  * @name    widget
  * @author  Cleber Santos <oclebersantos@gmail.com>
  * @since   2014-10-27
  * @updated 2014-10-27
  * @param   array $args - widget structure
  * @param   array $instance - widget data
  * @return  void
  */
 function widget($args, $instance)
 {
     global $wpdb, $post;
     $blog_id = !empty($instance['blog']) ? $instance['blog'] : 1;
     if (function_exists('switch_to_blog')) {
         switch_to_blog($blog_id);
     }
     // pega o link do blog
     $blog_url = get_bloginfo('url');
     print $args['before_widget'];
     if (!empty($instance['title'])) {
         print $args['before_head'];
         print "<a href='{$blog_url}' title='click para ver todas as tags'>" . $args['before_title'] . $instance['title'] . $args['after_title'] . "</a>";
         print $args['after_head'];
     }
     print $args['before_body'];
     if (function_exists('wp_tag_cloud')) {
         $tags = wp_tag_cloud('format=array&smallest=8&largest=25');
         // remove /blog/ do link
         foreach ($tags as $tag) {
             $tag = str_replace('/blog/', '/', $tag);
             echo $tag;
         }
     }
     print $args['after_body'];
     print $args['after_widget'];
     if (function_exists('restore_current_blog')) {
         restore_current_blog();
     }
 }
开发者ID:CoordCulturaDigital-Minc,项目名称:cdigital2014,代码行数:41,代码来源:widget-global-tags.php

示例6: jquery_install_site

function jquery_install_site($site, $user)
{
    $sites = jquery_sites();
    $details = $sites[$site];
    if (strpos($site, '/')) {
        list($domain, $path) = explode('/', $site, 2);
        $path = '/' . trim($path, '/') . '/';
    } else {
        $domain = $site;
        $path = '/';
    }
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    if (1 !== $details['blog_id']) {
        $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, $path, 1);
        if ($blog_id != $details['blog_id']) {
            wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
        }
        switch_to_blog($blog_id);
        install_blog($blog_id, $details['options']['blogname']);
        add_user_to_blog($blog_id, $user->ID, 'administrator');
    }
    $options = array_merge($default_options, $details['options']);
    foreach ($options as $option => $value) {
        update_option($option, $value);
    }
    delete_option('rewrite_rules');
    restore_current_blog();
}
开发者ID:hryniu555,项目名称:jquery-wp-content,代码行数:29,代码来源:install.php

示例7: test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files

	/**
	 * When a site is deleted with wpmu_delete_blog(), only the files associated with
	 * that site should be removed. When wpmu_delete_blog() is run a second time, nothing
	 * should change with upload directories.
	 */
	function test_upload_directories_after_multiple_wpmu_delete_blog_with_ms_files() {
		$filename = rand_str().'.jpg';
		$contents = rand_str();

		// Upload a file to the main site on the network.
		$file1 = wp_upload_bits( $filename, null, $contents );

		$blog_id = $this->factory->blog->create();

		switch_to_blog( $blog_id );
		$file2 = wp_upload_bits( $filename, null, $contents );
		restore_current_blog();

		wpmu_delete_blog( $blog_id, true );

		// The file on the main site should still exist. The file on the deleted site should not.
		$this->assertTrue( file_exists( $file1['file'] ) );
		$this->assertFalse( file_exists( $file2['file'] ) );

		wpmu_delete_blog( $blog_id, true );

		// The file on the main site should still exist. The file on the deleted site should not.
		$this->assertTrue( file_exists( $file1['file'] ) );
		$this->assertFalse( file_exists( $file2['file'] ) );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:ms-files-rewriting.php

示例8: activate

 /**
  * Short Description. Activation hook. 
  *
  * Long Description. Checks for multisite and creates a table for each blog if necessary.
  *
  * @since    6.0.0
  */
 public static function activate($network_wide)
 {
     global $wpdb;
     // define global switched (required for switch_to_blog())
     global $switched;
     if (function_exists('is_multisite') && is_multisite()) {
         // check if it is a network activation - if so, run the activation function for each blog id
         if ($network_wide) {
             $old_blog = $wpdb->blogid;
             // Get all blog ids
             $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
             foreach ($blogids as $blog_id) {
                 switch_to_blog($blog_id);
                 self::_activate_yikes_easy_mailchimp($wpdb);
                 restore_current_blog();
             }
             switch_to_blog($old_blog);
             return;
         }
         self::_activate_yikes_easy_mailchimp($wpdb);
     } else {
         /* end network activate */
         self::_activate_yikes_easy_mailchimp($wpdb);
     }
 }
开发者ID:jzornow,项目名称:changingdenver,代码行数:32,代码来源:class-yikes-inc-easy-mailchimp-extender-activator.php

示例9: wpmuNewBlog

 /**
  * Runs activation function and sets up default WP options for new blog,
  * a.k.a. when a registered user creates a new blog
  *
  * @param int $blog_id
  * @param int $user_id
  *
  * @see add_action( 'wpmu_new_blog', ... )
  */
 function wpmuNewBlog($blog_id, $user_id)
 {
     $this->blog_id = (int) $blog_id;
     $this->user_id = (int) $user_id;
     switch_to_blog($this->blog_id);
     if (!$this->isBookSetup()) {
         $this->wpmuActivate();
         array_walk($this->opts, function ($v, $k) {
             if (empty($v)) {
                 delete_option($k);
             } else {
                 update_option($k, $v);
             }
         });
         wp_cache_flush();
     }
     // Set current metadata version to skip redundant upgrade routines
     update_option('pressbooks_metadata_version', \Pressbooks\Metadata::$currentVersion);
     flush_rewrite_rules(false);
     do_action('pressbooks_new_blog');
     restore_current_blog();
     if (is_user_logged_in()) {
         (new \Pressbooks\Catalog())->deleteCache();
         \Pressbooks\Redirect\location(get_admin_url($this->blog_id));
     }
 }
开发者ID:pressbooks,项目名称:pressbooks,代码行数:35,代码来源:class-pb-activation.php

示例10: duplicate_over_multisite

function duplicate_over_multisite($post_id_to_copy, $new_blog_id, $post_type, $post_author, $prefix, $post_status)
{
    $mdp_post = get_post($post_id_to_copy);
    $title = get_the_title($mdp_post);
    if ($prefix != '') {
        $prefix = $prefix . ' ';
    }
    $mdp_post = array('post_title' => $prefix . $title, 'post_status' => $post_status, 'post_type' => $post_type, 'post_author' => $post_author, 'post_content' => $mdp_post->post_content);
    $data = get_post_custom($mdp_post);
    $meta_values = get_post_meta($post_id_to_copy);
    switch_to_blog($new_blog_id);
    $post_id = wp_insert_post($mdp_post);
    foreach ($data as $key => $values) {
        foreach ($values as $value) {
            add_post_meta($post_id, $key, $value);
        }
    }
    foreach ($meta_values as $key => $values) {
        foreach ($values as $value) {
            if (is_serialized($value)) {
                add_post_meta($post_id, $key, unserialize($value));
            } else {
                add_post_meta($post_id, $key, $value);
            }
        }
    }
    restore_current_blog();
    return $post_id;
}
开发者ID:sergiambel,项目名称:multisite-post-duplicator,代码行数:29,代码来源:core.php

示例11: 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

示例12: mdp_plugin_activate

/**
 * 
 * Set the default options in WordPress on activation of the plugin
 * 
 * @since 0.5
 * 
 */
function mdp_plugin_activate()
{
    $type_of_activation = mpd_do_version_log();
    $mdp_default_options = mdp_get_default_options();
    $sites = mpd_wp_get_sites();
    foreach ($sites as $site) {
        $siteid = $site['blog_id'];
        switch_to_blog($siteid);
        if (!($options = get_option('mdp_settings'))) {
            $options = array();
            foreach ($mdp_default_options as $mdp_default_option => $option_value) {
                $options[$mdp_default_option] = $option_value;
            }
            update_option('mdp_settings', $options);
        } else {
            //Add default option for exsisting users with new checkboxes
            $options = get_option('mdp_settings');
            $options['mdp_copy_content_images'] = 'content-image';
            $options['mdp_default_tags_copy'] = 'tags';
            $options['mdp_default_featured_image'] = 'feat';
            $options['restrict_option_setting'] = 'none';
            $options['role_option_setting'] = 'Administrator';
            $options = apply_filters('mpd_activation_options', $options);
            update_option('mdp_settings', $options);
        }
        restore_current_blog();
    }
}
开发者ID:pdefreitas,项目名称:multisite-post-duplicator,代码行数:35,代码来源:mpd.php

示例13: jquery_install_remaining_sites

function jquery_install_remaining_sites($user)
{
    $domains = jquery_domains();
    $default_options = jquery_default_site_options();
    $default_options['admin_email'] = $user->user_email;
    foreach ($domains as $domain => $details) {
        if (1 !== $details['blog_id']) {
            $blog_id = insert_blog(JQUERY_STAGING_PREFIX . $domain, '/', 1);
            if ($blog_id != $details['blog_id']) {
                wp_die("Something went very wrong when trying to install {$domain} as site {$blog_id}-{$details['blog_id']}. Find nacin.");
            }
            switch_to_blog($blog_id);
            install_blog($blog_id, $details['options']['blogname']);
            add_user_to_blog($blog_id, $user->ID, 'administrator');
        }
        $options = array_merge($default_options, $details['options']);
        foreach ($options as $option => $value) {
            update_option($option, $value);
        }
        // Work around a superficial bug in install_blog(), fixed in WP r21172.
        $home = untrailingslashit(get_option('home'));
        $siteurl = untrailingslashit(get_option('siteurl'));
        update_option('home', 'http://example.com');
        // Please just don't ask.
        update_option('siteurl', 'http://example.com');
        update_option('home', $home);
        update_option('siteurl', $siteurl);
        flush_rewrite_rules();
        restore_current_blog();
    }
}
开发者ID:ravasthi,项目名称:web-base-template,代码行数:31,代码来源:install.php

示例14: epa_create_and_sync_post

/**
 * Create a WP post and "sync" it to Elasticsearch. We are mocking the sync
 *
 * @param array $post_args
 * @param array $post_meta
 * @param int   $site_id
 *
 * @since 0.9
 * @return int|WP_Error
 */
function epa_create_and_sync_post($post_args = array(), $post_meta = array(), $site_id = null)
{
    if ($site_id != null) {
        switch_to_blog($site_id);
    }
    $post_types = ep_get_indexable_post_types();
    $post_type_values = array_values($post_types);
    $args = wp_parse_args($post_args, array('post_type' => $post_type_values[0], 'post_status' => 'publish', 'post_title' => 'Test Post ' . time()));
    $post_id = wp_insert_post($args);
    // Quit if we have a WP_Error object
    if (is_wp_error($post_id)) {
        return $post_id;
    }
    if (!empty($post_meta)) {
        foreach ($post_meta as $key => $value) {
            // No need for sanitization here
            update_post_meta($post_id, $key, $value);
        }
    }
    // Force a re-sync
    wp_update_post(array('ID' => $post_id));
    if ($site_id != null) {
        restore_current_blog();
    }
    return $post_id;
}
开发者ID:spaarndam,项目名称:ElasticPress-Autosuggest,代码行数:36,代码来源:functions.php

示例15: get_upcoming_events

 /**
  * Gets a list of upcoming events.
  * Only the events that are not yet over will be returned.
  */
 public static function get_upcoming_events($limit = 5)
 {
     if (!eab_has_post_indexer()) {
         return array();
     }
     $limit = (int) $limit ? (int) $limit : 5;
     global $wpdb;
     $result = array();
     $count = 0;
     $pi_table = eab_pi_get_table();
     $pi_published = eab_pi_get_post_date();
     $pi_blog_id = eab_pi_get_blog_id();
     $pi_post_id = eab_pi_get_post_id();
     $raw_network_events = $wpdb->get_results("SELECT * FROM {$wpdb->base_prefix}{$pi_table} WHERE post_type='incsub_event' ORDER BY {$pi_published} DESC");
     if (!$raw_network_events) {
         return $result;
     }
     foreach ($raw_network_events as $event) {
         if ($count == $limit) {
             break;
         }
         switch_to_blog($event->{$pi_blog_id});
         $post = get_post($event->{$pi_post_id});
         $tmp_event_instance = new Eab_EventModel($post);
         $tmp_event_instance->cache_data();
         if ($tmp_event_instance->is_expired()) {
             continue;
         }
         $post->blog_id = $event->{$pi_blog_id};
         $result[] = $post;
         $count++;
         restore_current_blog();
     }
     return $result;
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:39,代码来源:class_eab_network.php


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