Merge pull request #18851 from woocommerce/update/avoid-extra-unneeded-query
Avoid unnecessary query to wp_options on every request
This commit is contained in:
commit
399e5d2ddf
|
@ -80,7 +80,7 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
|
|||
self::check_download_folder_protection();
|
||||
|
||||
// Clear any unwanted data and flush rules.
|
||||
add_option( 'woocommerce_queue_flush_rewrite_rules', 'true' );
|
||||
update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
|
||||
WC()->query->init_query_vars();
|
||||
WC()->query->add_endpoints();
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ class WC_Post_types {
|
|||
|
||||
// If theme support changes, we may need to flush permalinks since some are changed based on this flag.
|
||||
if ( update_option( 'current_theme_supports_woocommerce', current_theme_supports( 'woocommerce' ) ? 'yes' : 'no' ) ) {
|
||||
add_option( 'woocommerce_queue_flush_rewrite_rules', 'true' );
|
||||
update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
|
||||
}
|
||||
|
||||
register_post_type( 'product',
|
||||
|
@ -511,8 +511,8 @@ class WC_Post_types {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
public static function maybe_flush_rewrite_rules() {
|
||||
if ( 'true' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) {
|
||||
delete_option( 'woocommerce_queue_flush_rewrite_rules' );
|
||||
if ( 'yes' === get_option( 'woocommerce_queue_flush_rewrite_rules' ) ) {
|
||||
update_option( 'woocommerce_queue_flush_rewrite_rules', 'no' );
|
||||
self::flush_rewrite_rules();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue