Skip to content

Commit e838879

Browse files
committed
Update docs++
1 parent 0431830 commit e838879

29 files changed

+180
-39
lines changed

docs/admin_dashboard.php.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ <h1 class="page-title">Source: admin/dashboard.php</h1>
450450
$sanitized_options['preload_sitemap'] = sanitize_textarea_field( $options['preload_sitemap'] );
451451
$sanitized_options['prefetch_dns'] = sanitize_textarea_field( $options['prefetch_dns'] );
452452
$sanitized_options['preconnect_resource'] = sanitize_textarea_field( $options['preconnect_resource'] );
453+
$sanitized_options['enable_lcp_optimization'] = ! empty( $options['enable_lcp_optimization'] );
453454
$sanitized_options['prefetch_links'] = ! empty( $options['prefetch_links'] );
454455
$sanitized_options['db_cleanup_post_revisions'] = ! empty( $options['db_cleanup_post_revisions'] );
455456
$sanitized_options['db_cleanup_auto_drafts'] = ! empty( $options['db_cleanup_auto_drafts'] );

docs/admin_notices.php.html

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ <h1 class="page-title">Source: admin/notices.php</h1>
6767
add_action( 'activated_plugin', __NAMESPACE__ . '\\observe_plugin_changes', 10, 2 );
6868
add_action( 'deactivated_plugin', __NAMESPACE__ . '\\observe_plugin_changes', 10, 2 );
6969
add_action( 'admin_post_powered_cache_dismiss_notice', __NAMESPACE__ . '\\dismiss_notice' );
70+
add_action( 'wp_ajax_powered_cache_dismiss_notice_ajax', __NAMESPACE__ . '\\dismiss_notice_ajax' );
7071
}
7172

7273
/**
@@ -392,24 +393,70 @@ <h1 class="page-title">Source: admin/notices.php</h1>
392393
}
393394

394395
if ( $has_notice ) {
395-
$message = __( '&lt;strong>Powered Cache:&lt;/strong> One or more plugins have been activated or deactivated; consider clearing the cache if these changes impact your site\'s front end.', 'powered-cache' );
396+
$message = __( '&lt;strong>Powered Cache:&lt;/strong> One or more plugins have been activated or deactivated; consider clearing the cache if these changes impact your site\'s front end.', 'powered-cache' );
397+
$dismiss_nonce = wp_create_nonce( 'powered_cache_dismiss_notice_ajax' );
396398
?>
397-
&lt;div class="notice notice-warning is-dismissible">
399+
&lt;div class="notice notice-warning is-dismissible powered-cache-dismissible-notice" data-notice-id="&lt;?php echo esc_attr( PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT ); ?>" data-nonce="&lt;?php echo esc_attr( $dismiss_nonce ); ?>">
398400
&lt;p>
399401
&lt;?php echo wp_kses_post( $message ); ?>
400402
&lt;/p>
401403
&lt;p>
402404
&lt;a href="&lt;?php echo esc_url_raw( $purge_url ); ?>" class="button-primary">
403405
&lt;?php esc_html_e( 'Purge Cache', 'powered-cache' ); ?>
404406
&lt;/a>
405-
&lt;a href="&lt;?php echo esc_url_raw( wp_nonce_url( admin_url( 'admin-post.php?action=powered_cache_dismiss_notice&amp;notice=' . PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT ), 'powered_cache_dismiss_notice' ) ); ?>" class="button-secondary">
407+
&lt;a href="&lt;?php echo esc_url_raw( wp_nonce_url( admin_url( 'admin-post.php?action=powered_cache_dismiss_notice&amp;notice=' . PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT ), 'powered_cache_dismiss_notice' ) ); ?>" class="button-secondary powered-cache-dismiss-button">
406408
&lt;?php esc_html_e( 'Dismiss this notice', 'powered-cache' ); ?>
407409
&lt;/a>
408410
&lt;/p>
409-
&lt;a href="&lt;?php echo esc_url_raw( wp_nonce_url( admin_url( 'admin-post.php?action=powered_cache_dismiss_notice&amp;notice=' . PURGE_CACHE_PLUGIN_NOTICE_TRANSIENT ), 'powered_cache_dismiss_notice' ) ); ?>" type="button" class="notice-dismiss" style="text-decoration:none;">
410-
&lt;span class="screen-reader-text">&lt;?php esc_html_e( 'Dismiss this notice', 'powered-cache' ); ?>&lt;/span>
411-
&lt;/a>
412411
&lt;/div>
412+
&lt;script type="text/javascript">
413+
(function() {
414+
document.addEventListener('click', function(e) {
415+
var button = e.target.closest('.notice-dismiss, .powered-cache-dismiss-button');
416+
if (!button) {
417+
return;
418+
}
419+
420+
var notice = button.closest('.powered-cache-dismissible-notice');
421+
if (!notice) {
422+
return;
423+
}
424+
425+
e.preventDefault();
426+
427+
var noticeId = notice.getAttribute('data-notice-id');
428+
var nonce = notice.getAttribute('data-nonce');
429+
430+
if (button.classList.contains('powered-cache-dismiss-button')) {
431+
e.preventDefault();
432+
notice.style.opacity = '1';
433+
notice.style.transition = 'opacity 0.3s';
434+
notice.style.opacity = '0';
435+
436+
setTimeout(function() {
437+
if (notice &amp;&amp; notice.parentNode) {
438+
notice.parentNode.removeChild(notice);
439+
}
440+
}, 300);
441+
}
442+
443+
var xhr = new XMLHttpRequest();
444+
xhr.open('POST', '&lt;?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', true);
445+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
446+
xhr.onload = function () {
447+
if (xhr.status !== 200) {
448+
console.error('Dismiss failed');
449+
}
450+
};
451+
452+
xhr.send(
453+
'action=powered_cache_dismiss_notice_ajax'
454+
+ '&amp;notice=' + encodeURIComponent(noticeId)
455+
+ '&amp;nonce=' + encodeURIComponent(nonce)
456+
);
457+
});
458+
})();
459+
&lt;/script>
413460
&lt;?php
414461
}
415462
}
@@ -439,6 +486,34 @@ <h1 class="page-title">Source: admin/notices.php</h1>
439486
exit;
440487
}
441488

489+
/**
490+
* Dismiss notice via AJAX
491+
*
492+
* @return void
493+
* @since 3.7
494+
*/
495+
function dismiss_notice_ajax() {
496+
check_ajax_referer( 'powered_cache_dismiss_notice_ajax', 'nonce' );
497+
498+
if ( ! current_user_can( 'manage_options' ) ) {
499+
wp_send_json_error( array( 'message' => esc_html__( 'Permission denied', 'powered-cache' ) ) );
500+
}
501+
502+
if ( empty( $_POST['notice'] ) ) {
503+
wp_send_json_error( array( 'message' => esc_html__( 'Notice ID missing', 'powered-cache' ) ) );
504+
}
505+
506+
$notice = sanitize_text_field( wp_unslash( $_POST['notice'] ) );
507+
508+
if ( POWERED_CACHE_IS_NETWORK ) {
509+
delete_site_transient( $notice );
510+
} else {
511+
delete_transient( $notice );
512+
}
513+
514+
wp_send_json_success( array( 'message' => esc_html__( 'Notice dismissed', 'powered-cache' ) ) );
515+
}
516+
442517
/**
443518
* Display a notice when development mode is active
444519
*

docs/admin_partials_settings-page.php.html

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ <h1 class="page-title">Source: admin/partials/settings-page.php</h1>
759759
&lt;?php checked( 1, $settings['minify_css'] ); ?>
760760
>
761761
&lt;span class="sui-toggle-slider" aria-hidden="true">&lt;/span>
762-
&lt;span id="minify_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Minify CSS' ); ?>&lt;/span>
762+
&lt;span id="minify_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Minify CSS', 'powered-cache' ); ?>&lt;/span>
763763
&lt;span id="minify_css_description" class="sui-description">&lt;?php esc_html_e( 'Minify CSS files', 'powered-cache' ); ?>&lt;/span>
764764
&lt;/label>
765765
&lt;/div>
@@ -775,7 +775,7 @@ <h1 class="page-title">Source: admin/partials/settings-page.php</h1>
775775
&lt;?php checked( 1, $settings['combine_css'] ); ?>
776776
>
777777
&lt;span class="sui-toggle-slider" aria-hidden="true">&lt;/span>
778-
&lt;span id="combine_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Combine CSS files' ); ?>&lt;/span>
778+
&lt;span id="combine_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Combine CSS files', 'powered-cache' ); ?>&lt;/span>
779779
&lt;span id="combine_css_description" class="sui-description">&lt;?php esc_html_e( 'Combine CSS files to reduce HTTP requests', 'powered-cache' ); ?>&lt;/span>
780780
&lt;/label>
781781
&lt;/div>
@@ -827,7 +827,7 @@ <h1 class="page-title">Source: admin/partials/settings-page.php</h1>
827827
&lt;?php checked( 1, $settings['critical_css'] ); ?>
828828
>
829829
&lt;span class="sui-toggle-slider" aria-hidden="true">&lt;/span>
830-
&lt;span id="critical_css_label" class="sui-toggle-label">&lt;?php esc_html_e( ' Critical CSS' ); ?>&lt;/span>
830+
&lt;span id="critical_css_label" class="sui-toggle-label">&lt;?php esc_html_e( ' Critical CSS', 'powered-cache' ); ?>&lt;/span>
831831
&lt;span id="critical_css_description" class="sui-description">&lt;?php esc_html_e( 'Critical CSS is a technique that extracts the CSS above the fold to display the page as quickly as possible.', 'powered-cache' ); ?>&lt;/span>
832832
&lt;/label>
833833
&lt;/div>
@@ -932,7 +932,7 @@ <h1 class="page-title">Source: admin/partials/settings-page.php</h1>
932932
&lt;?php checked( 1, $settings['remove_unused_css'] ); ?>
933933
>
934934
&lt;span class="sui-toggle-slider" aria-hidden="true">&lt;/span>
935-
&lt;span id="remove_unused_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Remove Unused CSS' ); ?>&lt;/span>
935+
&lt;span id="remove_unused_css_label" class="sui-toggle-label">&lt;?php esc_html_e( 'Remove Unused CSS', 'powered-cache' ); ?>&lt;/span>
936936
&lt;span id="remove_unused_css_description" class="sui-description">&lt;?php esc_html_e( 'It reduces page size by removing all CSS and stylesheets that are not used while keeping only the used CSS.', 'powered-cache' ); ?>&lt;/span>
937937
&lt;/label>
938938
&lt;/div>
@@ -1975,6 +1975,45 @@ <h1 class="page-title">Source: admin/partials/settings-page.php</h1>
19751975

19761976
&lt;/div>
19771977

1978+
&lt;div class="sui-box-settings-row &lt;?php echo( ! is_premium() ? 'sui-disabled' : '' ); ?>">
1979+
&lt;div class="sui-box-settings-col-1">
1980+
&lt;span class="sui-settings-label">&lt;?php esc_html_e( 'LCP Optimization', 'powered-cache' ); ?>
1981+
&lt;?php if ( ! is_premium() ) : ?>
1982+
&lt;span class="sui-tag sui-tag-pro">&lt;?php esc_html_e( 'Premium', 'powered-cache' ); ?>&lt;/span>
1983+
&lt;?php endif; ?>
1984+
&lt;/span>
1985+
&lt;span class="sui-description">&lt;/span>
1986+
&lt;/div>
1987+
1988+
&lt;div class="sui-box-settings-col-2">
1989+
&lt;div class="sui-form-field">
1990+
&lt;label for="enable_lcp_optimization" class="sui-toggle">
1991+
&lt;input
1992+
type="checkbox"
1993+
id="enable_lcp_optimization"
1994+
name="enable_lcp_optimization"
1995+
value="1"
1996+
aria-labelledby="enable_lcp_optimization_label"
1997+
aria-describedby="enable_lcp_optimization_description"
1998+
&lt;?php checked( $settings['enable_lcp_optimization'], 1 ); ?>
1999+
>
2000+
&lt;span class="sui-toggle-slider" aria-hidden="true">&lt;/span>
2001+
&lt;span id="enable_lcp_optimization_label" class="sui-toggle-label">
2002+
&lt;?php esc_html_e( 'Enable Automatic LCP Optimization', 'powered-cache' ); ?>
2003+
&lt;/span>
2004+
&lt;span id="enable_lcp_optimization_description" class="sui-description">
2005+
&lt;?php esc_html_e( 'Automatically detect and preload the Largest Contentful Paint (LCP) image to improve page loading experience.', 'powered-cache' ); ?>
2006+
&lt;a href="&lt;?php echo esc_url( get_doc_url( '/lcp-optimization/' ) ); ?>" target="_blank" rel="noopener noreferrer">
2007+
&lt;?php esc_html_e( 'Learn more', 'powered-cache' ); ?>
2008+
&lt;/a>
2009+
&lt;/span>
2010+
&lt;/label>
2011+
&lt;/div>
2012+
&lt;/div>
2013+
2014+
&lt;/div>
2015+
2016+
19782017
&lt;div class="sui-box-settings-row &lt;?php echo( ! is_premium() ? 'sui-disabled' : '' ); ?>">
19792018
&lt;div class="sui-box-settings-col-1">
19802019
&lt;span class="sui-settings-label">&lt;?php esc_html_e( 'Prefetch links', 'powered-cache' ); ?>

docs/classes_FileOptimizer.php.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,30 @@ <h1 class="page-title">Source: classes/FileOptimizer.php</h1>
825825
$script_loader .= 'console.log("[Powered Cache] - Script(s) will be loaded with delay or interaction");' . PHP_EOL;
826826
$script_loader .= 'window.PCScriptLoaderTimeout=' . absint( $delay_timeout ) . ';' . PHP_EOL;
827827

828-
$script_loader .= 'Defer.all(\'script[type="pc-delayed-js"]\', 0, true);' . PHP_EOL;
828+
$script_loader .= 'Defer.all(\'script[type="pc-delayed-js"]\', window.PCScriptLoaderTimeout, true);' . PHP_EOL;
829+
830+
// Dispatch DOMContentLoaded event after delayed scripts are loaded
831+
// This ensures scripts that listen for DOMContentLoaded still execute
832+
$script_loader .= '(function(){' . PHP_EOL;
833+
$script_loader .= ' var pcDelayedScripts=document.querySelectorAll(\'script[type="pc-delayed-js"]\');' . PHP_EOL;
834+
$script_loader .= ' if(pcDelayedScripts.length===0)return;' . PHP_EOL;
835+
$script_loader .= ' var pcScriptCount=pcDelayedScripts.length;' . PHP_EOL;
836+
$script_loader .= ' var pcCheckInterval=setInterval(function(){' . PHP_EOL;
837+
$script_loader .= ' var remaining=document.querySelectorAll(\'script[type="pc-delayed-js"]\').length;' . PHP_EOL;
838+
$script_loader .= ' if(remaining===0){' . PHP_EOL;
839+
$script_loader .= ' clearInterval(pcCheckInterval);' . PHP_EOL;
840+
$script_loader .= ' setTimeout(function(){' . PHP_EOL;
841+
$script_loader .= ' if(document.readyState==="complete"||document.readyState==="interactive"){' . PHP_EOL;
842+
$script_loader .= ' var event=document.createEvent?document.createEvent("Event"):new Event("DOMContentLoaded");' . PHP_EOL;
843+
$script_loader .= ' if(document.createEvent){event.initEvent("DOMContentLoaded",true,true);}' . PHP_EOL;
844+
$script_loader .= ' document.dispatchEvent(event);' . PHP_EOL;
845+
$script_loader .= ' console.log("[Powered Cache] - DOMContentLoaded event dispatched for "+pcScriptCount+" delayed script(s)");' . PHP_EOL;
846+
$script_loader .= ' }' . PHP_EOL;
847+
$script_loader .= ' },10);' . PHP_EOL;
848+
$script_loader .= ' }' . PHP_EOL;
849+
$script_loader .= ' },50);' . PHP_EOL;
850+
$script_loader .= '})();' . PHP_EOL;
829851

830-
if ( absint( $delay_timeout ) > 0 ) {
831-
$script_loader .= 'Defer.all(\'script[type="pc-delayed-js"]\', window.PCScriptLoaderTimeout, false);' . PHP_EOL;
832-
}
833852
$script_loader .= '&lt;/script>' . PHP_EOL;
834853

835854
/**

docs/dropins_page-cache.php.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,15 @@ <h1 class="page-title">Source: dropins/page-cache.php</h1>
514514
}
515515

516516
// trailingslash check
517-
if ( isset( $powered_cache_slash_check ) &amp;&amp; $powered_cache_slash_check ) {
517+
if ( isset( $powered_cache_slash_check ) ) {
518518
$current_path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
519-
if ( ! empty( $current_path ) &amp;&amp; '/' !== substr( $current_path, - 1 ) ) {
519+
if ( $powered_cache_slash_check &amp;&amp; ! empty( $current_path ) &amp;&amp; '/' !== substr( $current_path, - 1 ) ) {
520+
header( 'X-Powered-Cache: Passing to WordPress' );
521+
522+
return;
523+
}
524+
525+
if ( ! $powered_cache_slash_check &amp;&amp; ! empty( $current_path ) &amp;&amp; '/' === substr( $current_path, - 1 ) ) {
520526
header( 'X-Powered-Cache: Passing to WordPress' );
521527

522528
return;

docs/powered_cache_cdn_addresses.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5>Parameters:</h5>
139139

140140
<dt class="tag-source">Source:</dt>
141141
<dd class="tag-source"><ul class="dummy"><li>
142-
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line982">line 982</a>
142+
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line983">line 983</a>
143143
</li></ul></dd>
144144

145145

docs/powered_cache_cdn_zones.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5>Parameters:</h5>
139139

140140
<dt class="tag-source">Source:</dt>
141141
<dd class="tag-source"><ul class="dummy"><li>
142-
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line412">line 412</a>
142+
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line413">line 413</a>
143143
</li></ul></dd>
144144

145145

docs/powered_cache_clean_site_cache_dir.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5>Parameters:</h5>
139139

140140
<dt class="tag-source">Source:</dt>
141141
<dd class="tag-source"><ul class="dummy"><li>
142-
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line654">line 654</a>
142+
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line655">line 655</a>
143143
</li></ul></dd>
144144

145145

docs/powered_cache_default_settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5>Parameters:</h5>
139139

140140
<dt class="tag-source">Source:</dt>
141141
<dd class="tag-source"><ul class="dummy"><li>
142-
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line166">line 166</a>
142+
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line167">line 167</a>
143143
</li></ul></dd>
144144

145145

docs/powered_cache_delayed_js_script_loader.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h5>Parameters:</h5>
185185

186186
<dt class="tag-source">Source:</dt>
187187
<dd class="tag-source"><ul class="dummy"><li>
188-
<a href="classes_FileOptimizer.php.html">classes/FileOptimizer.php</a>, <a href="classes_FileOptimizer.php.html#line807">line 807</a>
188+
<a href="classes_FileOptimizer.php.html">classes/FileOptimizer.php</a>, <a href="classes_FileOptimizer.php.html#line826">line 826</a>
189189
</li></ul></dd>
190190

191191

0 commit comments

Comments
 (0)