Inventory_Presser_Plugin::flush_rewrite( boolean $network_wide )

Flushes rewrite rules.


Parameters Parameters

$network_wide

(boolean) (Required) True if this plugin is being Network Activated or Network Deactivated by the multisite admin.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: inventory-presser.php

	public static function flush_rewrite( $network_wide ) {
		self::create_post_type();

		if ( ! is_multisite() || ! $network_wide ) {
			flush_rewrite_rules();
			return;
		}

		$sites = get_sites(
			array(
				'network' => 1,
				'limit'   => 1000,
			)
		);
		foreach ( $sites as $site ) {
			switch_to_blog( $site->blog_id );
			global $wp_rewrite;
			$wp_rewrite->init(); // important...
			$wp_rewrite->flush_rules();
			restore_current_blog();
		}
	}