Skip to content

Commit

Permalink
WP Super Cache: Add preload number of posts to the dropdown if it's n…
Browse files Browse the repository at this point in the history
…ot listed (#36249)

* If preload posts amount is not listed, added it to the list

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8198140983
  • Loading branch information
thingalon authored and matticbot committed Mar 8, 2024
1 parent 03a2071 commit ad2fd1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This is an alpha version! The changes listed here are not final.
- WP Super Cache: don't create an output buffer if there's already one active
- WP Super Cache: fixed serving a cached page on POST with late init enabled.
- WP Super Cache: fix the output buffer check, and make debug logs pre-formatted.
- WP Super Cache: if the preload number of posts is not in the list, then add it

## [1.11.0] - 2023-11-08
### Added
Expand Down
13 changes: 12 additions & 1 deletion partials/preload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="wpsc-settings-inner">
<?php
global $wp_cache_preload_posts;

echo '<a name="preload"></a>';
if ( ! $cache_enabled || ! $super_cache_enabled || true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
Expand Down Expand Up @@ -37,12 +39,21 @@
}
$select .= "{$checked}>" . __( 'all', 'wp-super-cache' ) . "</option>";

$options = array();
for( $c = $step; $c < $count; $c += $step ) {
$checked = ' ';
if ( $best == $c )
$checked = 'selected=1 ';
$select .= "<option value='$c'{$checked}>$c</option>";

$options[ $c ] = "<option value='$c'{$checked}>$c</option>";
}

if ( ! isset( $options[ $wp_cache_preload_posts ] ) ) {
$options[ $wp_cache_preload_posts ] = "<option value='$wp_cache_preload_posts' selected=1>$wp_cache_preload_posts</option>";
}
ksort( $options );
$select .= implode( "\n", $options );

$checked = ' ';
if ( $best == $count )
$checked = 'selected=1 ';
Expand Down

0 comments on commit ad2fd1f

Please sign in to comment.