コード例 #1
0
	/**
	 * Fixed incorrect meta value for multisite option for all existing feed sources
	 *
	 * @since 1.8.3
	 */
	public static function multisite_fix() {
		if ( is_multisite() ) {
			global $switched;
			$current_site_id = get_current_blog_id();
			$site_ids = array_keys( WPRSS_FTP_Utils::get_sites() );

			for( $i = 0; $i < count( $site_ids ); $i++ ) {
				$site_id = $site_ids[$i];
   				$switch_success = switch_to_blog( $site_id );
   				if ( $switch_success === FALSE ) continue;

				$feed_sources = wprss_get_all_feed_sources();

				if( $feed_sources->have_posts() ) {
					while ( $feed_sources->have_posts() ) {
						$feed_sources->the_post();

						$post_site = get_post_meta( get_the_ID(), WPRSS_FTP_Meta::META_PREFIX . 'post_site', TRUE );

						if ( $post_site === '' || $post_site === FALSE || strtolower( strval( $post_site ) ) == 'false' ) {
							update_post_meta( get_the_ID(), WPRSS_FTP_Meta::META_PREFIX . 'post_site', get_current_blog_id() );
						}

					}

					// Restore the $post global to the current post in the main query
					wp_reset_postdata();

				} // end of have_posts()

			} // End of site loop
			switch_to_blog( $current_site_id );
		} // End of multisite check
	}