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:
Mike Jolley 2018-02-08 12:41:12 +00:00 committed by GitHub
commit 399e5d2ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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();

View File

@ -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();
}
}