From 7655741ccc0317973546bafb146666dc991e3f4b Mon Sep 17 00:00:00 2001
From: Jacob Dunn <88040916+jacobd91@users.noreply.github.com>
Date: Mon, 2 Dec 2024 11:20:14 -0500
Subject: [PATCH] Cron Flush Descriptions (#999)

* Updated descriptions and added descriptions for time and interval.
---
 Extension_AlwaysCached_Page_View_BoxCron.php |  2 +-
 inc/options/dbcache.php                      | 24 +++++++++++++++++++-
 inc/options/general.php                      | 20 +++++++++++++++-
 inc/options/minify.php                       | 24 +++++++++++++++++++-
 inc/options/objectcache.php                  | 24 +++++++++++++++++++-
 inc/options/pgcache.php                      | 24 +++++++++++++++++++-
 6 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/Extension_AlwaysCached_Page_View_BoxCron.php b/Extension_AlwaysCached_Page_View_BoxCron.php
index 07bba9eeb..8559c5d57 100644
--- a/Extension_AlwaysCached_Page_View_BoxCron.php
+++ b/Extension_AlwaysCached_Page_View_BoxCron.php
@@ -58,7 +58,7 @@
 				'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 				'control'          => 'selectbox',
 				'selectbox_values' => $time_options,
-				'description'      => esc_html__( 'This setting controls the initial start time of the cron job based on the configured WordPress timezone. It will automatically adjust the timestamp to accommodate differences between the configured WordPress and server timezones. If the selected time has already passed, it will add a day so that it begins the next day.', 'w3-total-cache' ),
+				'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 				'disabled'         => $pgcache_disabled || $wp_cron_disabled,
 			)
 		);
diff --git a/inc/options/dbcache.php b/inc/options/dbcache.php
index f813d01b5..3e8e34059 100644
--- a/inc/options/dbcache.php
+++ b/inc/options/dbcache.php
@@ -134,6 +134,27 @@
 
 		<?php Util_Ui::postbox_header( esc_html__( 'Purge via WP Cron', 'w3-total-cache' ), '', 'dbcache_wp_cron' ); ?>
 		<table class="form-table">
+			<p>
+				<?php
+				echo wp_kses(
+					sprintf(
+						// Translators: 1 opening HTML a tag, 2 closing HTML a tag.
+						__(
+							'Enabling this will schedule a WP-Cron event that will flush the Database Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush db". Visit %1$shere%2$s for more information.',
+							'w3-total-cache'
+						),
+						'<a href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/schedule-cache-purges/' ) . '" target="_blank">',
+						'</a>'
+					),
+					array(
+						'a' => array(
+							'href'   => array(),
+							'target' => array(),
+						),
+					)
+				);
+				?>
+			</p>
 			<?php
 			$c           = Dispatcher::config();
 			$disabled    = ! $c->get_boolean( 'dbcache.enabled' );
@@ -168,7 +189,6 @@
 					'label'          => esc_html__( 'Enable WP-Cron Event', 'w3-total-cache' ),
 					'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
 					'control'        => 'checkbox',
-					'description'    => esc_html__( 'Enabling this will schedule a WP-Cron event that will flush the Database Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush db".', 'w3-total-cache' ),
 					'disabled'       => $disabled,
 				)
 			);
@@ -189,6 +209,7 @@
 					'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 					'control'          => 'selectbox',
 					'selectbox_values' => $time_options,
+					'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
@@ -204,6 +225,7 @@
 						'daily'      => esc_html__( 'Daily', 'w3-total-cache' ),
 						'weekly'     => esc_html__( 'Weekly', 'w3-total-cache' ),
 					),
+					'description'      => esc_html__( 'This setting controls the interval that the cron job should occur.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
diff --git a/inc/options/general.php b/inc/options/general.php
index 48065ed60..939db3a4f 100644
--- a/inc/options/general.php
+++ b/inc/options/general.php
@@ -494,7 +494,23 @@
 		<?php
 		Util_Ui::postbox_header_tabs(
 			esc_html__( 'Purge via WP Cron', 'w3-total-cache' ),
-			esc_html__( 'Enabling this will schedule a WP-Cron event that will flush all enabled Caches. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush all". If the Always Cached extension is active and enabled, page cache entries will instead be added to the queue instead of being purged from the cache.', 'w3-total-cache' ),
+			wp_kses(
+				sprintf(
+					// Translators: 1 opening HTML a tag, 2 closing HTML a tag.
+					__(
+						'Enabling this will schedule a WP-Cron event that will flush all enabled Caches via a single cron job. Each cache\'s advanced settings page features similar settings to this if you wish to schedule purges for specific caches only. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush all". If the Always Cached extension is active and enabled, page cache entries will instead be added to the queue instead of being purged from the cache. Visit %1$shere%2$s for more information.',
+						'w3-total-cache'
+					),
+					'<a href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/schedule-cache-purges/' ) . '" target="_blank">',
+					'</a>'
+				),
+				array(
+					'a' => array(
+						'href'   => array(),
+						'target' => array(),
+					),
+				)
+			),
 			'',
 			'allcache_wp_cron'
 		);
@@ -529,6 +545,7 @@
 					'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 					'control'          => 'selectbox',
 					'selectbox_values' => $time_options,
+					'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 					'disabled'         => $wp_disabled,
 				)
 			);
@@ -544,6 +561,7 @@
 						'daily'      => esc_html__( 'Daily', 'w3-total-cache' ),
 						'weekly'     => esc_html__( 'Weekly', 'w3-total-cache' ),
 					),
+					'description'      => esc_html__( 'This setting controls the interval that the cron job should occur.', 'w3-total-cache' ),
 					'disabled'         => $wp_disabled,
 				)
 			);
diff --git a/inc/options/minify.php b/inc/options/minify.php
index b443e0576..e899a9949 100644
--- a/inc/options/minify.php
+++ b/inc/options/minify.php
@@ -998,6 +998,27 @@
 
 		<?php Util_Ui::postbox_header( esc_html__( 'Purge via WP Cron', 'w3-total-cache' ), '', 'minify_wp_cron' ); ?>
 		<table class="form-table">
+			<p>
+				<?php
+				echo wp_kses(
+					sprintf(
+						// Translators: 1 opening HTML a tag, 2 closing HTML a tag.
+						__(
+							'Enabling this will schedule a WP-Cron event that will flush the Minify Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush minify". Visit %1$shere%2$s for more information.',
+							'w3-total-cache'
+						),
+						'<a href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/schedule-cache-purges/' ) . '" target="_blank">',
+						'</a>'
+					),
+					array(
+						'a' => array(
+							'href'   => array(),
+							'target' => array(),
+						),
+					)
+				);
+				?>
+			</p>
 			<?php
 			$c           = Dispatcher::config();
 			$disabled    = ! $c->get_boolean( 'minify.enabled' );
@@ -1032,7 +1053,6 @@
 					'label'          => esc_html__( 'Enable WP-Cron Event', 'w3-total-cache' ),
 					'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
 					'control'        => 'checkbox',
-					'description'    => esc_html__( 'Enabling this will schedule a WP-Cron event that will flush the Minify Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush minify".', 'w3-total-cache' ),
 					'disabled'       => $disabled,
 				)
 			);
@@ -1053,6 +1073,7 @@
 					'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 					'control'          => 'selectbox',
 					'selectbox_values' => $time_options,
+					'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
@@ -1068,6 +1089,7 @@
 						'daily'      => esc_html__( 'Daily', 'w3-total-cache' ),
 						'weekly'     => esc_html__( 'Weekly', 'w3-total-cache' ),
 					),
+					'description'      => esc_html__( 'This setting controls the interval that the cron job should occur.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
diff --git a/inc/options/objectcache.php b/inc/options/objectcache.php
index ba28e87d9..035965265 100644
--- a/inc/options/objectcache.php
+++ b/inc/options/objectcache.php
@@ -119,6 +119,27 @@
 
 		<?php Util_Ui::postbox_header( esc_html__( 'Purge via WP Cron', 'w3-total-cache' ), '', 'objectcache_wp_cron' ); ?>
 		<table class="form-table">
+			<p>
+				<?php
+				echo wp_kses(
+					sprintf(
+						// Translators: 1 opening HTML a tag, 2 closing HTML a tag.
+						__(
+							'Enabling this will schedule a WP-Cron event that will flush the Object Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush object". Visit %1$shere%2$s for more information.',
+							'w3-total-cache'
+						),
+						'<a href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/schedule-cache-purges/' ) . '" target="_blank">',
+						'</a>'
+					),
+					array(
+						'a' => array(
+							'href'   => array(),
+							'target' => array(),
+						),
+					)
+				);
+				?>
+			</p>
 			<?php
 			$c           = Dispatcher::config();
 			$disabled    = ! $c->get_boolean( 'objectcache.enabled' );
@@ -153,7 +174,6 @@
 					'label'          => esc_html__( 'Enable WP-Cron Event', 'w3-total-cache' ),
 					'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
 					'control'        => 'checkbox',
-					'description'    => esc_html__( 'Enabling this will schedule a WP-Cron event that will flush the Object Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush object".', 'w3-total-cache' ),
 					'disabled'       => $disabled,
 				)
 			);
@@ -174,6 +194,7 @@
 					'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 					'control'          => 'selectbox',
 					'selectbox_values' => $time_options,
+					'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
@@ -189,6 +210,7 @@
 						'daily'      => esc_html__( 'Daily', 'w3-total-cache' ),
 						'weekly'     => esc_html__( 'Weekly', 'w3-total-cache' ),
 					),
+					'description'      => esc_html__( 'This setting controls the interval that the cron job should occur.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
diff --git a/inc/options/pgcache.php b/inc/options/pgcache.php
index d96130fd6..3d9c128c2 100644
--- a/inc/options/pgcache.php
+++ b/inc/options/pgcache.php
@@ -843,6 +843,27 @@
 
 		<?php Util_Ui::postbox_header( esc_html__( 'Purge via WP Cron', 'w3-total-cache' ), '', 'pgcache_wp_cron' ); ?>
 		<table class="form-table">
+			<p>
+				<?php
+				echo wp_kses(
+					sprintf(
+						// Translators: 1 opening HTML a tag, 2 closing HTML a tag.
+						__(
+							'Enabling this will schedule a WP-Cron event that will flush the Page Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush posts". If the Always Cached extension is active and enabled, page cache entries will instead be added to the queue instead of being purged from the cache. Visit %1$shere%2$s for more information.',
+							'w3-total-cache'
+						),
+						'<a href="' . esc_url( 'https://www.boldgrid.com/support/w3-total-cache/schedule-cache-purges/' ) . '" target="_blank">',
+						'</a>'
+					),
+					array(
+						'a' => array(
+							'href'   => array(),
+							'target' => array(),
+						),
+					)
+				);
+				?>
+			</p>
 			<?php
 			$c           = Dispatcher::config();
 			$disabled    = ! $c->get_boolean( 'pgcache.enabled' );
@@ -877,7 +898,6 @@
 					'label'          => esc_html__( 'Enable WP-Cron Event', 'w3-total-cache' ),
 					'checkbox_label' => esc_html__( 'Enable', 'w3-total-cache' ),
 					'control'        => 'checkbox',
-					'description'    => esc_html__( 'Enabling this will schedule a WP-Cron event that will flush the Page Cache. If you prefer to use a system cron job instead of WP-Cron, you can schedule the following command to run at your desired interval: "wp w3tc flush posts". If the Always Cached extension is active and enabled, page cache entries will instead be added to the queue instead of being purged from the cache.', 'w3-total-cache' ),
 					'disabled'       => $disabled,
 				)
 			);
@@ -898,6 +918,7 @@
 					'label'            => esc_html__( 'Start Time', 'w3-total-cache' ),
 					'control'          => 'selectbox',
 					'selectbox_values' => $time_options,
+					'description'      => esc_html__( 'This setting controls the initial start time of the cron job. If the selected time has already passed, it will schedule the job for the following day at the selected time.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);
@@ -913,6 +934,7 @@
 						'daily'      => esc_html__( 'Daily', 'w3-total-cache' ),
 						'weekly'     => esc_html__( 'Weekly', 'w3-total-cache' ),
 					),
+					'description'      => esc_html__( 'This setting controls the interval that the cron job should occur.', 'w3-total-cache' ),
 					'disabled'         => $disabled || $wp_disabled,
 				)
 			);