Inventory_Presser_Options::maybe_flush_permalinks( mixed $old_value, mixed $value )

maybe_flush_permalinks


Description Description

If the additional listing pages settings are changed, or the switch is on and the array of pages is different, flush rewrite rules


Top ↑

Parameters Parameters

$option

(string) (Required)

$old_value

(mixed) (Required)

$value

(mixed) (Required)


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-dealership-options.php

	public function maybe_flush_permalinks( $old_value, $value )
	{
		//Did the additional listings pages settings change?
		if ( ( ! isset( $old_value['additional_listings_pages'] ) && isset( $value['additional_listings_pages'] ) )
			|| ( isset( $old_value['additional_listings_pages'] ) && ! isset( $value['additional_listings_pages'] ) )
			|| ( isset( $old_value['additional_listings_pages'] ) && isset( $value['additional_listings_pages'] ) && $old_value['additional_listings_pages'] !== $value['additional_listings_pages'] ) )
		{
			if( ! is_multisite() )
			{
				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();
			}
		}
	}