From d853df3ae7d9b8cc0b4aef1b07ab3fa781d4fffc Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 8 Aug 2024 14:24:57 +0530 Subject: [PATCH 01/13] feat: disable purge all for import request. --- admin/class-nginx-helper-admin.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index f91289a..3fe0fa0 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -96,6 +96,10 @@ public function __construct( $plugin_name, $version ) { ); $this->options = $this->nginx_helper_settings(); + + if( $this->is_import_request() ) { + $this->options['enable_purge'] = false; + } } @@ -698,6 +702,10 @@ public function update_new_blog_options( $blog_id ) { * @global object $nginx_purger */ public function purge_all() { + + if( $this->is_import_request() ) { + return; + } global $nginx_purger, $wp; @@ -775,5 +783,16 @@ public function purge_all() { public function display_notices() { echo '

' . esc_html__( 'Purge initiated', 'nginx-helper' ) . '

'; } + + /** + * Determines if the current request is for importing Posts/ WordPress content. + * + * @return bool + */ + public function is_import_request() { + $import_query_var = get_query_var( 'import' ); + $has_import_started = did_action( 'import_start' ); + return (defined( 'WP_IMPORTING' ) && true === WP_IMPORTING) || 0 === $has_import_started || ! empty( $import_query_var ); + } } From ac53b89fb51757160332f8685e54e4529bf7afb1 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 8 Aug 2024 14:36:56 +0530 Subject: [PATCH 02/13] refactor: remove extra spaces. --- admin/class-nginx-helper-admin.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 3fe0fa0..a158e5d 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -96,11 +96,6 @@ public function __construct( $plugin_name, $version ) { ); $this->options = $this->nginx_helper_settings(); - - if( $this->is_import_request() ) { - $this->options['enable_purge'] = false; - } - } /** @@ -706,7 +701,7 @@ public function purge_all() { if( $this->is_import_request() ) { return; } - + global $nginx_purger, $wp; $method = null; @@ -790,9 +785,10 @@ public function display_notices() { * @return bool */ public function is_import_request() { - $import_query_var = get_query_var( 'import' ); + $import_query_var = sanitize_text_field( $_GET['import'] ?? '' ); $has_import_started = did_action( 'import_start' ); - return (defined( 'WP_IMPORTING' ) && true === WP_IMPORTING) || 0 === $has_import_started || ! empty( $import_query_var ); + + return (defined( 'WP_IMPORTING' ) && true === WP_IMPORTING) || 0 !== $has_import_started || ! empty( $import_query_var ); } } From be1d0f78d57ffb7108d900cfbc39c8d6312f9da6 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 8 Aug 2024 14:38:36 +0530 Subject: [PATCH 03/13] feat: add contribution name. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fee3ca7..70de764 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Nginx Helper # [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) -**Contributors:** rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks +**Contributors:** rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123, ravanh, michaelbeil, samedwards, niwreg, entr, nuvoPoint, iam404, rittesh.patel, vishalkakadiya, BhargavBhandari90, vincent-lu, murrayjbrown, bryant1410, 1gor, matt-h, pySilver, johan-chassaing, dotsam, sanketio, petenelson, nathanielks, rigagoogoo, dslatten, jinschoi, kelin1003, vaishuagola27, rahulsprajapati, Joel-James, utkarshpatel, gsayed786, shashwatmittal, sudhiryadav, thrijith, stayallive, jaredwsmith, abhijitrakas, umeshnevase, sid177, souptik, arafatkn, subscriptiongroup, akrocks, Vedant-Gandhi **Tags:** nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks From e56078b38496b24fb99c767bfbc83528a02ae66f Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Fri, 9 Aug 2024 19:19:35 +0530 Subject: [PATCH 04/13] fix: phpcs errors. --- admin/class-nginx-helper-admin.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index a158e5d..9dbce60 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -698,10 +698,10 @@ public function update_new_blog_options( $blog_id ) { */ public function purge_all() { - if( $this->is_import_request() ) { + if ( $this->is_import_request() ) { return; } - + global $nginx_purger, $wp; $method = null; @@ -782,13 +782,16 @@ public function display_notices() { /** * Determines if the current request is for importing Posts/ WordPress content. * - * @return bool + * @return bool True if the request is for importing, false otherwise. */ public function is_import_request() { - $import_query_var = sanitize_text_field( $_GET['import'] ?? '' ); + $import_query_var = sanitize_text_field( wp_unslash($_GET['import'] ?? '') ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is already in the admin dashboard. $has_import_started = did_action( 'import_start' ); - - return (defined( 'WP_IMPORTING' ) && true === WP_IMPORTING) || 0 !== $has_import_started || ! empty( $import_query_var ); + + return ( defined( 'WP_IMPORTING' ) && true === WP_IMPORTING ) + || 0 !== $has_import_started + || ! empty( $import_query_var ); } - + + } From a166c1f923dfd99a4e9b99f066fc4e2025b1c249 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Fri, 9 Aug 2024 19:21:41 +0530 Subject: [PATCH 05/13] feat: add disable purge. --- admin/class-nginx-helper-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 9dbce60..109aaf7 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -604,7 +604,7 @@ public function set_future_post_option_on_future_status( $new_status, $old_statu return; } - if ( ! $this->options['enable_purge'] ) { + if ( ! $this->options['enable_purge'] || $this->is_import_request() ) { return; } From 7483a8d18d395ce9eade45839742fab0c7b3745a Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Fri, 9 Aug 2024 19:22:43 +0530 Subject: [PATCH 06/13] refactor: add proper spacing. --- admin/class-nginx-helper-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 109aaf7..ca48454 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -785,7 +785,7 @@ public function display_notices() { * @return bool True if the request is for importing, false otherwise. */ public function is_import_request() { - $import_query_var = sanitize_text_field( wp_unslash($_GET['import'] ?? '') ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is already in the admin dashboard. + $import_query_var = sanitize_text_field( wp_unslash( $_GET['import'] ?? '' ) ); //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is already in the admin dashboard. $has_import_started = did_action( 'import_start' ); return ( defined( 'WP_IMPORTING' ) && true === WP_IMPORTING ) From 8befd1846e99ad56a3b181f96a393a0d5ae07a3c Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Wed, 25 Sep 2024 19:42:53 +0530 Subject: [PATCH 07/13] feat: add general options. --- admin/class-nginx-helper-admin.php | 77 +++++++++++++++++++ .../partials/nginx-helper-general-options.php | 7 ++ 2 files changed, 84 insertions(+) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index f91289a..675753d 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -96,6 +96,12 @@ public function __construct( $plugin_name, $version ) { ); $this->options = $this->nginx_helper_settings(); + + $is_cache_preloaded = get_option( 'is_cache_preloaded' ); + $preload_cache_enabled = get_option( 'preload_cache' ); + if ( $preload_cache_enabled && false === $is_cache_preloaded ) { + $this->preload_cache_from_sitemap(); + } } @@ -278,6 +284,8 @@ public function nginx_helper_default_settings() { 'redis_prefix' => 'nginx-cache:', 'purge_url' => '', 'redis_enabled_by_constant' => 0, + 'preload_cache' => 0, + 'is_cache_preloaded' => 0 ); } @@ -775,5 +783,74 @@ public function purge_all() { public function display_notices() { echo '

' . esc_html__( 'Purge initiated', 'nginx-helper' ) . '

'; } + + /** + * This function preloads the cache from sitemap url. + * + * @return void + */ + public function preload_cache_from_sitemap() { + global $nginx_purger; + $sitemap_url = get_sitemap_url( 'index' ); + + if ( false === $sitemap_url || empty( $sitemap_url ) ) { + return; + } + + $sitemap_page = get_page_by_path( $sitemap_url ); + + if ( ! $sitemap_page instanceof WP_Post ) { + return; + } + + $sitemap_content = $sitemap_page->post_content; + $urls = $this->extract_sitemap_urls( $sitemap_content ); + + if ( $urls instanceof WP_Error ) { + $nginx_purger->log( ' Error while extracting URL\'s from the sitemap while preloading cache. Error - ', $urls->get_error_message() ); + return; + } + + $args = array( + 'timeout' => 0.01, + 'blocking' => false, + 'sslverify' => false, + ); + + foreach ( $urls as $url ) { + wp_remote_get( esc_url_raw( $url ), $args ); + } + + add_option( 'is_cache_preloaded', true ); + } + + /** + * Parse sitemap content and extract all URLs. + * + * @param string $sitemap_content The XML content of the sitemap. + * @return array|WP_Error An array of URLs or WP_Error on failure. + */ + private function extract_sitemap_urls( $sitemap_content ) { + libxml_use_internal_errors( true ); + $xml = simplexml_load_string( $sitemap_content ); + + if ( false === $xml ) { + return new WP_Error( 'sitemap_parse_error', esc_html__( 'Failed to parse the sitemap XML', 'nginx-helper' ) ); + } + + $urls = array(); + + if ( 'sitemapindex' === $xml->getName() ) { + foreach ( $xml->sitemap as $sitemap ) { + $urls[] = (string) $sitemap->loc; + } + } else { + foreach ( $xml->url as $url ) { + $urls[] = (string) $url->loc; + } + } + + return $urls; + } } diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php index a91eb53..705fcb2 100644 --- a/admin/partials/nginx-helper-general-options.php +++ b/admin/partials/nginx-helper-general-options.php @@ -40,6 +40,7 @@ 'purge_page_on_deleted_comment', 'purge_feeds', 'smart_http_expire_form_nonce', + 'preload_cache', ); $all_inputs = array(); @@ -126,6 +127,12 @@ + + + /> + + + From c1198f0629bec92248e9d8ab4589faf5498679c0 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 26 Sep 2024 13:19:28 +0530 Subject: [PATCH 08/13] feat: add cache preload. --- admin/class-nginx-helper-admin.php | 94 +++++++++++++++++------------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 675753d..cde6ce4 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -96,12 +96,19 @@ public function __construct( $plugin_name, $version ) { ); $this->options = $this->nginx_helper_settings(); - - $is_cache_preloaded = get_option( 'is_cache_preloaded' ); - $preload_cache_enabled = get_option( 'preload_cache' ); - if ( $preload_cache_enabled && false === $is_cache_preloaded ) { - $this->preload_cache_from_sitemap(); - } + + add_action( 'init', function() { + $is_cache_preloaded = $this->options['is_cache_preloaded']; + $preload_cache_enabled = $this->options['preload_cache']; + + if ( $preload_cache_enabled && false === boolval( $is_cache_preloaded ) ) { + $this->options['is_cache_preloaded'] = true; + + update_site_option( 'rt_wp_nginx_helper_options', $this->options ); + $this->preload_cache_from_sitemap(); + + } + } ); } @@ -790,47 +797,58 @@ public function display_notices() { * @return void */ public function preload_cache_from_sitemap() { - global $nginx_purger; - $sitemap_url = get_sitemap_url( 'index' ); - - if ( false === $sitemap_url || empty( $sitemap_url ) ) { - return; - } - - $sitemap_page = get_page_by_path( $sitemap_url ); - - if ( ! $sitemap_page instanceof WP_Post ) { - return; - } - - $sitemap_content = $sitemap_page->post_content; - $urls = $this->extract_sitemap_urls( $sitemap_content ); - - if ( $urls instanceof WP_Error ) { - $nginx_purger->log( ' Error while extracting URL\'s from the sitemap while preloading cache. Error - ', $urls->get_error_message() ); - return; - } + $sitemap_urls = $this->get_index_sitemap_urls(); + $all_urls = array(); + + foreach ( $sitemap_urls as $sitemap_url ) { + $urls = $this->extract_sitemap_urls( $sitemap_url ); + $all_urls = array_merge( $all_urls, $urls ); + } + $args = array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => false, ); - foreach ( $urls as $url ) { + foreach ( $all_urls as $url ) { wp_remote_get( esc_url_raw( $url ), $args ); } - - add_option( 'is_cache_preloaded', true ); + + } + + /** + * Fetches all the sitemap urls for the site. + * + * @return array + */ + private function get_index_sitemap_urls() { + $sitemaps = wp_sitemaps_get_server()->index->get_sitemap_list(); + $urls = array(); + foreach ( $sitemaps as $sitemap ) { + $urls[] = $sitemap['loc']; + } + return $urls; } /** * Parse sitemap content and extract all URLs. * - * @param string $sitemap_content The XML content of the sitemap. + * @param string $sitemap_url The URL of the sitemap. * @return array|WP_Error An array of URLs or WP_Error on failure. */ - private function extract_sitemap_urls( $sitemap_content ) { + private function extract_sitemap_urls( $sitemap_url ) { + $response = wp_remote_get( $sitemap_url ); + + $urls = array(); + + if ( is_wp_error( $response ) ) { + return $urls; + } + + $sitemap_content = wp_remote_retrieve_body( $response ); + libxml_use_internal_errors( true ); $xml = simplexml_load_string( $sitemap_content ); @@ -840,14 +858,12 @@ private function extract_sitemap_urls( $sitemap_content ) { $urls = array(); - if ( 'sitemapindex' === $xml->getName() ) { - foreach ( $xml->sitemap as $sitemap ) { - $urls[] = (string) $sitemap->loc; - } - } else { - foreach ( $xml->url as $url ) { - $urls[] = (string) $url->loc; - } + if ( $xml === false ) { + return $urls; + } + + foreach ( $xml->url as $url ) { + $urls[] = (string) $url->loc; } return $urls; From 9d6d1170789da486647a14201f3bdc9648a8c3af Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 26 Sep 2024 13:26:12 +0530 Subject: [PATCH 09/13] feat: tag the preload cache on admin_init action. --- admin/class-nginx-helper-admin.php | 32 +++++++++++++++++------------- includes/class-nginx-helper.php | 3 +++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index cde6ce4..436c9dc 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -96,19 +96,6 @@ public function __construct( $plugin_name, $version ) { ); $this->options = $this->nginx_helper_settings(); - - add_action( 'init', function() { - $is_cache_preloaded = $this->options['is_cache_preloaded']; - $preload_cache_enabled = $this->options['preload_cache']; - - if ( $preload_cache_enabled && false === boolval( $is_cache_preloaded ) ) { - $this->options['is_cache_preloaded'] = true; - - update_site_option( 'rt_wp_nginx_helper_options', $this->options ); - $this->preload_cache_from_sitemap(); - - } - } ); } @@ -791,12 +778,29 @@ public function display_notices() { echo '

' . esc_html__( 'Purge initiated', 'nginx-helper' ) . '

'; } + /** + * Preloads the cache for the website. + * + * @return void + */ + public function preload_cache() { + $is_cache_preloaded = $this->options['is_cache_preloaded']; + $preload_cache_enabled = $this->options['preload_cache']; + + if ( $preload_cache_enabled && false === boolval( $is_cache_preloaded ) ) { + $this->options['is_cache_preloaded'] = true; + + update_site_option( 'rt_wp_nginx_helper_options', $this->options ); + $this->preload_cache_from_sitemap(); + } + } + /** * This function preloads the cache from sitemap url. * * @return void */ - public function preload_cache_from_sitemap() { + private function preload_cache_from_sitemap() { $sitemap_urls = $this->get_index_sitemap_urls(); $all_urls = array(); diff --git a/includes/class-nginx-helper.php b/includes/class-nginx-helper.php index f96e6d0..71cb137 100644 --- a/includes/class-nginx-helper.php +++ b/includes/class-nginx-helper.php @@ -227,6 +227,9 @@ private function define_admin_hooks() { // expose action to allow other plugins to purge the cache. $this->loader->add_action( 'rt_nginx_helper_purge_all', $nginx_purger, 'purge_all' ); + + // add action to preload the cache + $this->loader->add_action( 'admin_init', $nginx_helper_admin, 'preload_cache' ); } /** From 204fb8d99a908ee176c7eb6e99d8dab8547478df Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Thu, 26 Sep 2024 13:46:42 +0530 Subject: [PATCH 10/13] feat: change the timeout for sitemap fetch. --- admin/class-nginx-helper-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 436c9dc..1040495 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -811,7 +811,7 @@ private function preload_cache_from_sitemap() { } $args = array( - 'timeout' => 0.01, + 'timeout' => 1, 'blocking' => false, 'sslverify' => false, ); From 57a1f4fd8ce3b692c15b278143a4aec1ca8945f7 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Mon, 21 Oct 2024 17:59:42 +0530 Subject: [PATCH 11/13] refactor: change all indentation to tabs. --- admin/class-nginx-helper-admin.php | 22 +++++++++---------- .../partials/nginx-helper-general-options.php | 14 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index bc94fdc..038a170 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -319,7 +319,7 @@ public function nginx_helper_settings() { $data['cache_method'] = 'enable_redis'; $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; - $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; + $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; return $data; @@ -421,7 +421,7 @@ public function nginx_helper_get_feeds() { } ?> -
    +
      ' . esc_html_e( 'No items', 'nginx-helper' ) . '.'; @@ -430,7 +430,7 @@ public function nginx_helper_get_feeds() { // Loop through each feed item and display each item as a hyperlink. foreach ( $rss_items as $item ) { ?> -
    • +
    • %s', @@ -439,12 +439,12 @@ public function nginx_helper_get_feeds() { esc_html( $item->get_title() ) ); ?> -
    • + -
    +
- - - /> - - - + + + /> + + + From 911e8c5f44d469604b2ae15a90b0ba24c315a3e6 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Mon, 21 Oct 2024 18:04:50 +0530 Subject: [PATCH 12/13] refactor: add alignment to equal signs. --- admin/class-nginx-helper-admin.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index 038a170..e6d52dc 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -260,7 +260,7 @@ public function nginx_helper_default_settings() { 'enable_map' => 0, 'enable_log' => 0, 'log_level' => 'INFO', - 'log_filesize' => '5', + 'log_filesize' => '5', 'enable_stamp' => 0, 'purge_homepage_on_edit' => 1, 'purge_homepage_on_del' => 1, @@ -274,7 +274,7 @@ public function nginx_helper_default_settings() { 'purge_feeds' => 1, 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', - 'redis_prefix' => 'nginx-cache:', + 'redis_prefix' => 'nginx-cache:', 'purge_url' => '', 'redis_enabled_by_constant' => 0, 'preload_cache' => 0, @@ -295,7 +295,7 @@ public function nginx_helper_settings() { array( 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', - 'redis_prefix' => 'nginx-cache:', + 'redis_prefix' => 'nginx-cache:', ) ); @@ -809,7 +809,7 @@ private function preload_cache_from_sitemap() { $all_urls = array(); foreach ( $sitemap_urls as $sitemap_url ) { - $urls = $this->extract_sitemap_urls( $sitemap_url ); + $urls = $this->extract_sitemap_urls( $sitemap_url ); $all_urls = array_merge( $all_urls, $urls ); } @@ -865,7 +865,7 @@ private function extract_sitemap_urls( $sitemap_url ) { $urls = array(); - if ( $xml === false ) { + if ( false === $xml ) { return $urls; } From 989d1a01730137896d2731241eed4f5bb281cf29 Mon Sep 17 00:00:00 2001 From: Vedant Gandhi Date: Mon, 21 Oct 2024 19:09:37 +0530 Subject: [PATCH 13/13] refactor: fix arrow indentation in get_site_option while fetching settings. --- admin/class-nginx-helper-admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index e6d52dc..a6ff9ce 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -260,7 +260,7 @@ public function nginx_helper_default_settings() { 'enable_map' => 0, 'enable_log' => 0, 'log_level' => 'INFO', - 'log_filesize' => '5', + 'log_filesize' => '5', 'enable_stamp' => 0, 'purge_homepage_on_edit' => 1, 'purge_homepage_on_del' => 1, @@ -274,7 +274,7 @@ public function nginx_helper_default_settings() { 'purge_feeds' => 1, 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', - 'redis_prefix' => 'nginx-cache:', + 'redis_prefix' => 'nginx-cache:', 'purge_url' => '', 'redis_enabled_by_constant' => 0, 'preload_cache' => 0, @@ -295,7 +295,7 @@ public function nginx_helper_settings() { array( 'redis_hostname' => '127.0.0.1', 'redis_port' => '6379', - 'redis_prefix' => 'nginx-cache:', + 'redis_prefix' => 'nginx-cache:', ) ); @@ -319,7 +319,7 @@ public function nginx_helper_settings() { $data['cache_method'] = 'enable_redis'; $data['redis_hostname'] = RT_WP_NGINX_HELPER_REDIS_HOSTNAME; $data['redis_port'] = RT_WP_NGINX_HELPER_REDIS_PORT; - $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; + $data['redis_prefix'] = RT_WP_NGINX_HELPER_REDIS_PREFIX; return $data;