Пример #1
0
 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');
     }
 }
Пример #2
0
function ajaxsearchpro_priorities_get_posts()
{
    global $wpdb;
    parse_str($_POST['options'], $o);
    if (isset($wpdb->base_prefix)) {
        $_prefix = $wpdb->base_prefix;
    } else {
        $_prefix = $wpdb->prefix;
    }
    $w_post_type = '';
    $w_filter = '';
    $w_limit = (int) $o['p_asp_limit'];
    if (isset($o['blog_id']) && $o['blog_id'] != 0 && is_multisite()) {
        switch_to_blog($o['p_asp_blog']);
    }
    if ($o['p_asp_filter'] != '') {
        $w_filter = "AND {$wpdb->posts}.post_title LIKE '%" . $o['p_asp_filter'] . "%'";
    }
    if ($o['p_asp_post_type'] != 'all') {
        $w_post_type = "AND {$wpdb->posts}.post_type = '" . $o['p_asp_post_type'] . "'";
    }
    $querystr = "\r\n    \t\tSELECT\r\n          {$wpdb->posts}.post_title as title,\r\n          {$wpdb->posts}.ID as id,\r\n          {$wpdb->posts}.post_date as date,\r\n          {$wpdb->users}.user_nicename as author,\r\n          {$wpdb->posts}.post_type as post_type,\r\n          CASE WHEN " . $_prefix . "ajaxsearchpro_priorities.priority IS NULL\r\n                   THEN 100\r\n                   ELSE " . $_prefix . "ajaxsearchpro_priorities.priority\r\n          END AS priority\r\n    \t\tFROM {$wpdb->posts}\r\n        LEFT JOIN {$wpdb->users} ON {$wpdb->users}.ID = {$wpdb->posts}.post_author\r\n        LEFT JOIN " . $_prefix . "ajaxsearchpro_priorities ON (" . $_prefix . "ajaxsearchpro_priorities.post_id = {$wpdb->posts}.ID AND " . $_prefix . "ajaxsearchpro_priorities.blog_id = " . get_current_blog_id() . ")\r\n    \tWHERE\r\n          {$wpdb->posts}.ID>0 AND\r\n          {$wpdb->posts}.post_status IN ('publish', 'pending') AND\r\n          {$wpdb->posts}.post_type NOT IN ('revision', 'attachment')\r\n          {$w_post_type}\r\n          {$w_filter}\r\n        GROUP BY\r\n          {$wpdb->posts}.ID\r\n        ORDER BY " . $o['p_asp_ordering'] . "\r\n        LIMIT {$w_limit}";
    echo "!!PASPSTART!!" . json_encode($wpdb->get_results($querystr, OBJECT)) . '!!PASPEND!!';
    if (is_multisite()) {
        restore_current_blog();
    }
    die;
}
 /**
  * load widget
  *
  * @name    widget
  * @author  Cleber Santos <*****@*****.**>
  * @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();
     }
 }
 /**
  * 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];
 }
Пример #5
0
 /**
  * insert default CSS into option
  */
 public static function propagate_default_global_css($networkwide = false)
 {
     $css = self::get_default_global_css();
     if (function_exists('is_multisite') && is_multisite() && $networkwide) {
         //do for each existing site
         global $wpdb;
         $old_blog = $wpdb->blogid;
         // Get all blog ids and create tables
         $blogids = $wpdb->get_col("SELECT blog_id FROM " . $wpdb->blogs);
         foreach ($blogids as $blog_id) {
             switch_to_blog($blog_id);
             if (get_option('tp_eg_custom_css_imported', 'false') == 'true') {
                 continue;
             }
             update_option('tp_eg_custom_css_imported', 'true');
             self::set_global_css_styles($css);
         }
         switch_to_blog($old_blog);
         //go back to correct blog
     } else {
         if (get_option('tp_eg_custom_css_imported', 'false') == 'false') {
             update_option('tp_eg_custom_css_imported', 'true');
             self::set_global_css_styles($css);
         }
     }
 }
Пример #6
0
 static function run_installer()
 {
     global $wpdb;
     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 (isset($_GET['networkwide']) && $_GET['networkwide'] == 1) {
             $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);
                 AIOWPSecurity_Installer::create_db_tables();
                 AIOWPSecurity_Configure_Settings::add_option_values();
             }
             AIOWPSecurity_Installer::create_db_backup_dir();
             //Create a backup dir in the WP uploads directory
             switch_to_blog($old_blog);
             return;
         }
     }
     AIOWPSecurity_Installer::create_db_tables();
     AIOWPSecurity_Configure_Settings::add_option_values();
     AIOWPSecurity_Installer::create_db_backup_dir();
     //Create a backup dir in the WP uploads directory
     AIOWPSecurity_Installer::miscellaneous_tasks();
 }
Пример #7
0
function liquidizer_table_uninstall()
{
    if (!current_user_can('activate_plugins')) {
        return;
    }
    check_admin_referer('bulk-plugins');
    if (__FILE__ != WP_UNINSTALL_PLUGIN) {
        return;
    }
    if (!is_multisite()) {
        delete_option('liquidizer_lite_wp_table');
        delete_option('liquidizer_lite_wp_which_table_element');
        delete_option('liquidizer_lite_wp_table_width');
    } else {
        global $wpdb;
        $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
        $original_blog_id = get_current_blog_id();
        foreach ($blog_ids as $blog_id) {
            switch_to_blog($blog_id);
            delete_option('liquidizer_lite_wp_table');
            delete_option('liquidizer_lite_wp_which_table_element');
            delete_option('liquidizer_lite_wp_table_width');
        }
        switch_to_blog($original_blog_id);
    }
}
Пример #8
0
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();
}
Пример #9
0
 /**
  * @group signup
  */
 public function test_wp_idea_stream_users_signup_child_blog()
 {
     if (!is_multisite()) {
         $this->markTestSkipped(__METHOD__ . ' is a multisite-only test.');
     }
     if (function_exists('buddypress')) {
         $this->markTestSkipped('wp_idea_stream_users_signup_user() is not used when BuddyPress is activated.');
     }
     $registration = get_site_option('registration');
     update_site_option('registration', 'user');
     $b = $this->factory->blog->create();
     switch_to_blog($b);
     add_filter('wp_idea_stream_allow_signups', '__return_true');
     $this->post_signup_form(array('user_login' => 'barfoo', 'user_email' => '*****@*****.**'));
     wp_idea_stream_users_signup_user(false);
     remove_filter('wp_idea_stream_allow_signups', '__return_true');
     preg_match('/<(.+?)>/', $GLOBALS['phpmailer']->mock_sent[0]['body'], $match);
     $activate_url = explode('?', $match[1]);
     $this->assertSame(wp_login_url(), $activate_url[0], 'The activate url must be the one of the child blog');
     $user = get_user_by('email', '*****@*****.**');
     $this->assertTrue(!empty($user->ID), 'The user must be created');
     restore_current_blog();
     update_site_option('registration', $registration);
     global $wpdb;
     $signup_data = $wpdb->get_row("SELECT activated, meta FROM {$wpdb->signups} WHERE user_email = '*****@*****.**' AND active = 1");
     $this->assertTrue(!empty($signup_data->activated), 'The signup must be activated');
     $this->assertEquals(array('add_to_blog' => $b, 'new_role' => 'subscriber'), maybe_unserialize($signup_data->meta));
 }
Пример #10
0
 /**
  * Table body
  * @param string $column_name
  * @param int $item_id
  */
 public function td($column_name, $item_id)
 {
     if ('mslscol' == $column_name) {
         $blogs = MslsBlogCollection::instance()->get();
         if ($blogs) {
             $mydata = MslsOptions::create($item_id);
             foreach ($blogs as $blog) {
                 switch_to_blog($blog->userblog_id);
                 $language = $blog->get_language();
                 $icon = MslsAdminIcon::create();
                 $icon->set_language($language);
                 if ($mydata->has_value($language)) {
                     $flag_url = MslsOptions::instance()->get_url('images/link_edit.png');
                     $icon->set_href($mydata->{$language})->set_src($flag_url);
                 } else {
                     $flag_url = MslsOptions::instance()->get_url('images/link_add.png');
                     $icon->set_src($flag_url);
                 }
                 echo $icon;
                 // xss ok
                 restore_current_blog();
             }
         }
     }
 }
function scoper_requested_file_rule_expire()
{
    if (scoper_get_option('file_filtering')) {
        if ($key = scoper_get_option('file_filtering_regen_key')) {
            if (!empty($_GET['key']) && $key == $_GET['key']) {
                // user must store their own non-null key before this will work
                global $wpdb;
                if (IS_MU_RS) {
                    $blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
                    $orig_blog_id = $GLOBALS['blog_id'];
                    foreach ($blog_ids as $id) {
                        switch_to_blog($id);
                        scoper_query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_rs_file_key'");
                    }
                } else {
                    scoper_query("DELETE FROM {$wpdb->postmeta} WHERE meta_key = '_rs_file_key'");
                }
                scoper_expire_file_rules();
                if (IS_MU_RS) {
                    _e("File attachment access keys and rewrite rules will be regenerated for each site at next access.", 'scoper');
                } else {
                    _e("File attachment access keys and rewrite rules were regenerated.", 'scoper');
                }
            } else {
                _e('Invalid argument.', 'scoper');
            }
        } else {
            _e('Please configure File Filtering options!', 'scoper');
        }
    } else {
        _e('The function is disabled.', 'scoper');
    }
    exit(0);
}
 /**
  * Create and switch to a new test book
  */
 private function _book()
 {
     $blog_id = $this->factory->blog->create();
     switch_to_blog($blog_id);
     switch_theme('donham');
     // Pick a theme with some built-in $supported_languages
 }
Пример #13
0
 public function ajax_add_multisite_page()
 {
     switch_to_blog($_POST['blogId']);
     $post = get_post($_POST['ids'][0]);
     $url = get_permalink($post->ID);
     restore_current_blog();
     $item_ids = wp_update_nav_menu_item(0, 0, array('menu-item-title' => esc_attr($post->post_title), 'menu-item-type' => 'custom', 'menu-item-url' => $url));
     foreach ((array) $item_ids as $menu_item_id) {
         $menu_obj = get_post($menu_item_id);
         if (!empty($menu_obj->ID)) {
             $menu_obj = wp_setup_nav_menu_item($menu_obj);
             // don't show "(pending)" in ajax-added items
             $menu_obj->label = $menu_obj->title;
             $menu_items[] = $menu_obj;
         }
     }
     // Needed to get the Walker up and running
     require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
     // This gets the HTML to returns it to the menu
     if (!empty($menu_items)) {
         $args = array('after' => '', 'before' => '', 'link_after' => '', 'link_before' => '', 'walker' => new Walker_Nav_Menu_Edit());
         echo walk_nav_menu_tree($menu_items, 0, (object) $args);
     }
     exit;
 }
Пример #14
0
 /**
  * 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));
     }
 }
 /**
  * Change the label of the blog
  */
 function change($blogs)
 {
     if (0 == count($blogs)) {
         return $blogs;
     }
     foreach ($blogs as &$blog) {
         $hash = md5(time());
         if ($hash === get_blog_option($blog->userblog_id, 'admin_label', $hash)) {
             /**
              * Allow superadmins to setup an admin label
              */
             switch_to_blog($blog->userblog_id);
             update_option('admin_label', '');
             restore_current_blog();
         } else {
             if ($admin_label = get_blog_option($blog->userblog_id, 'admin_label')) {
                 /**
                  * Set the admin label
                  */
                 $blog->blogname = $admin_label;
             }
         }
     }
     return $blogs;
 }
function bf_msn_the_loop_edit_permalink($permalink, $page_id)
{
    restore_current_blog();
    $permalink = get_permalink($page_id);
    switch_to_blog(2);
    return $permalink;
}
 /**
  * Updates the trasher setting of the post with the given ID as well as all related posts.
  *
  * @since   3.0.0
  * @wp-hook save_post
  *
  * @param int     $post_id Post ID.
  * @param WP_post $post    Post object.
  *
  * @return int The number of posts updated.
  */
 public function update_settings($post_id, WP_Post $post)
 {
     if (!$this->nonce->is_valid()) {
         return 0;
     }
     if (!in_array($post->post_status, ['publish', 'draft'], true)) {
         return 0;
     }
     $value = array_key_exists(TrasherSettingRepository::META_KEY, $_POST) ? (bool) $_POST[TrasherSettingRepository::META_KEY] : false;
     if (!$this->setting_repository->update($post_id, $value)) {
         return 0;
     }
     $current_site_id = get_current_blog_id();
     $related_posts = $this->content_relations->get_relations($current_site_id, $post_id, 'post');
     unset($related_posts[$current_site_id]);
     if (!$related_posts) {
         return 1;
     }
     $updated_posts = 1;
     array_walk($related_posts, function ($post_id, $site_id) use(&$updated_posts, $value) {
         switch_to_blog($site_id);
         $updated_posts += $this->setting_repository->update($post_id, $value);
         restore_current_blog();
     });
     return $updated_posts;
 }
Пример #18
0
 /**
  * Shortcode that renders `content-message.php` for a single message. By default
  * it displays the latest message.
  *
  * ### Shortcode attributes:
  * - `campus` integer The blog id to pull from (default: current)
  * - `id` integer The message id to show (default: latest message)
  *
  * @param array $attrs Shortcode attributes
  * @return string
  */
 public function singleMessage($attrs = array())
 {
     $attrs = shortcode_atts(array('campus' => $this->theme->info('id'), 'id' => null), $attrs);
     if ($attrs['campus'] !== $this->theme->info('id')) {
         switch_to_blog($attrs['campus']);
     }
     global $post;
     $_post = $post;
     $options = array('post_type' => $this->options['slug'], 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => 1);
     if (!empty($attrs['id'])) {
         $options['p'] = $attrs['id'];
     }
     $post = get_posts($options);
     ob_start();
     if (count($post) > 0) {
         $post = $post[0];
         get_template_part('content', 'message');
     }
     $out = ob_get_clean();
     if ($attrs['campus'] !== $this->theme->info('id')) {
         restore_current_blog();
     }
     $post = $_post;
     return $out;
 }
 function activate_for_blog($blog_id)
 {
     switch_to_blog($blog_id);
     self::_install_posts_table();
     self::install_role_caps();
     restore_current_blog();
 }
	/**
	 * 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'] ) );
	}
Пример #21
0
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');
}
Пример #22
0
 public function test_get_site_in_switched_state_returns_switched_site()
 {
     switch_to_blog(self::$site_ids['wordpress.org/foo/']);
     $site = get_site();
     restore_current_blog();
     $this->assertEquals(self::$site_ids['wordpress.org/foo/'], $site->id);
 }
 /**
  * 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;
 }
/**
 * This function used to install required tables in the database on time of activation.
 * @author Flipper Code <*****@*****.**>
 * @version 1.0.0
 * @package Maps
 */
function wpgmp_network_propagate($network_wide)
{
    if (is_multisite() && $network_wide) {
        // See if being activated on the entire network or one blog
        global $wpdb;
        // Get this so we can switch back to it later
        $currentblog = $wpdb->blogid;
        // For storing the list of activated blogs
        $activated = array();
        // Get all blogs in the network and activate plugin on each one
        $sql = "SELECT blog_id FROM {$wpdb->blogs}";
        $blog_ids = $wpdb->get_col($wpdb->prepare($sql, null));
        foreach ($blog_ids as $blog_id) {
            switch_to_blog($blog_id);
            wpgmp_activation();
        }
        // Switch back to the current blog
        switch_to_blog($currentblog);
        // Store the array for a later function
        update_site_option('wpgmp_activated', $activated);
    } else {
        // Running on a single blog
        wpgmp_activation();
    }
}
Пример #25
0
 public static function getOne($id, $blog_id = false, $get_meta = false, $atts = array())
 {
     global $wpdb;
     if ($blog_id && is_multisite()) {
         switch_to_blog($blog_id);
     }
     if (!is_numeric($id)) {
         $id = FrmDb::get_var($wpdb->posts, array('post_name' => $id, 'post_type' => 'frm_display', 'post_status !' => 'trash'), 'ID');
         if (is_multisite() && empty($id)) {
             return false;
         }
     }
     $post = get_post($id);
     if (!$post || $post->post_type != 'frm_display' || $post->post_status == 'trash') {
         $args = array('post_type' => 'frm_display', 'meta_key' => 'frm_old_id', 'meta_value' => $id, 'numberposts' => 1, 'post_status' => 'publish');
         $posts = get_posts($args);
         if ($posts) {
             $post = reset($posts);
         }
     }
     if ($post && $post->post_status == 'trash') {
         return false;
     }
     if ($post && $get_meta) {
         $check_post = isset($atts['check_post']) ? $atts['check_post'] : false;
         $post = FrmProDisplaysHelper::setup_edit_vars($post, $check_post);
     }
     if ($blog_id && is_multisite()) {
         restore_current_blog();
     }
     return $post;
 }
Пример #26
0
 function install()
 {
     global $wpdb;
     include_once 'admin/install.php';
     $this->remove_transients();
     if (is_multisite()) {
         $network = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : "";
         $activate = isset($_GET['action']) ? $_GET['action'] : "";
         $isNetwork = $network == '/wp-admin/network/plugins.php' ? true : false;
         $isActivation = $activate == 'deactivate' ? false : true;
         if ($isNetwork and $isActivation) {
             $old_blog = $wpdb->blogid;
             $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs}", NULL));
             foreach ($blogids as $blog_id) {
                 switch_to_blog($blog_id);
                 nggallery_install($this);
             }
             switch_to_blog($old_blog);
             return;
         }
     }
     // remove the update message
     delete_option('ngg_update_exists');
     nggallery_install($this);
 }
Пример #27
0
 function get_views()
 {
     global $wp_roles, $role;
     if ($this->is_site_users) {
         $url = 'site-users.php?id=' . $this->site_id;
         switch_to_blog($this->site_id);
         $users_of_blog = count_users();
         restore_current_blog();
     } else {
         $url = 'users.php';
         $users_of_blog = count_users();
     }
     $total_users = $users_of_blog['total_users'];
     $avail_roles =& $users_of_blog['avail_roles'];
     unset($users_of_blog);
     $current_role = false;
     $class = empty($role) ? ' class="current"' : '';
     $role_links = array();
     $role_links['all'] = "<a href='{$url}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users'), number_format_i18n($total_users)) . '</a>';
     foreach ($wp_roles->get_names() as $this_role => $name) {
         if (!isset($avail_roles[$this_role])) {
             continue;
         }
         $class = '';
         if ($this_role == $role) {
             $current_role = $role;
             $class = ' class="current"';
         }
         $name = translate_user_role($name);
         /* translators: User role name with count */
         $name = sprintf(__('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n($avail_roles[$this_role]));
         $role_links[$this_role] = "<a href='" . esc_url(add_query_arg('role', $this_role, $url)) . "'{$class}>{$name}</a>";
     }
     return $role_links;
 }
function relevanssi_wpml_filter($data)
{
    $use_filter = get_option('relevanssi_wpml_only_current');
    if ('on' == $use_filter) {
        //save current blog language
        $lang = get_bloginfo('language');
        $filtered_hits = array();
        foreach ($data[0] as $hit) {
            if (isset($hit->blog_id)) {
                switch_to_blog($hit->blog_id);
            }
            global $sitepress;
            if (function_exists('icl_object_id') && $sitepress->is_translated_post_type($hit->post_type)) {
                if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) {
                    $filtered_hits[] = $hit;
                }
            } elseif (function_exists('icl_object_id') && function_exists('pll_is_translated_post_type')) {
                if (pll_is_translated_post_type($hit->post_type)) {
                    if ($hit->ID == icl_object_id($hit->ID, $hit->post_type, false, ICL_LANGUAGE_CODE)) {
                        $filtered_hits[] = $hit;
                    }
                }
            } elseif (get_bloginfo('language') == $lang) {
                $filtered_hits[] = $hit;
            }
            if (isset($hit->blog_id)) {
                restore_current_blog();
            }
        }
        return array($filtered_hits, $data[1]);
    }
    return $data;
}
Пример #29
0
 /**
  * Gets the specified media and meta info from the given post.
  * NOTE: If you have the post's HTML content already and don't need image data, use extract_from_content() instead.
  *
  * @param $blog_id The ID of the blog
  * @param $post_id The ID of the post
  * @param $what_to_extract (int) A mask of things to extract, e.g. Jetpack_Media_Meta_Extractor::IMAGES | Jetpack_Media_Meta_Extractor::MENTIONS
  * @returns a structure containing metadata about the embedded things, or empty array if nothing found, or WP_Error on error
  */
 public static function extract($blog_id, $post_id, $what_to_extract = self::ALL)
 {
     // multisite?
     if (function_exists('switch_to_blog')) {
         switch_to_blog($blog_id);
     }
     $post = get_post($post_id);
     $content = $post->post_title . "\n\n" . $post->post_content;
     $char_cnt = strlen($content);
     //prevent running extraction on really huge amounts of content
     if ($char_cnt > 100000) {
         //about 20k English words
         $content = substr($content, 0, 100000);
     }
     $extracted = array();
     // Get images first, we need the full post for that
     if (self::IMAGES & $what_to_extract) {
         $extracted = self::get_image_fields($post);
         // Turn off images so we can safely call extract_from_content() below
         $what_to_extract = $what_to_extract - self::IMAGES;
     }
     if (function_exists('switch_to_blog')) {
         restore_current_blog();
     }
     // All of the other things besides images can be extracted from just the content
     $extracted = self::extract_from_content($content, $what_to_extract, $extracted);
     return $extracted;
 }
Пример #30
-10
 /**
  * Directories of sub sites on a network should not count against the same spaced used total for
  * the main site.
  */
 function test_get_space_used_main_site()
 {
     $space_used = get_space_used();
     $blog_id = $this->factory->blog->create();
     switch_to_blog($blog_id);
     // We don't rely on an initial value of 0 for space used, but should have a clean space available
     // so that we can remove any uploaded files and directories without concern of a conflict with
     // existing content directories in src.
     while (0 != get_space_used()) {
         restore_current_blog();
         $blog_id = $this->factory->blog->create();
         switch_to_blog($blog_id);
     }
     // Upload a file to the new site.
     $filename = rand_str() . '.jpg';
     $contents = rand_str();
     wp_upload_bits($filename, null, $contents);
     restore_current_blog();
     delete_transient('dirsize_cache');
     $this->assertEquals($space_used, get_space_used());
     // Switch back to the new site to remove the uploaded file.
     switch_to_blog($blog_id);
     $upload_dir = wp_upload_dir();
     $this->remove_added_uploads();
     $this->delete_folders($upload_dir['basedir']);
     restore_current_blog();
 }