| @@ -27,8 +27,15 @@ | ||
| 27 | 27 | */ |
| 28 | 28 | protected $filepath = null; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | + * Critical CSS base object | |
| 32 | + * | |
| 33 | + * @var object | |
| 34 | + */ | |
| 35 | + protected $_criticalcss = null; | |
| 36 | + | |
| 37 | + /** | |
| 31 | 38 | * Constructor. |
| 32 | 39 | * |
| 33 | 40 | * @param string $version Version. |
| 34 | 41 | * @param string $filepath Filepath. Needed for activation/deactivation/uninstall hooks. |
| @@ -58,15 +65,15 @@ | ||
| 58 | 65 | add_action( AUTOPTIMIZE_SETUP_INITHOOK, array( $this, 'hook_page_cache_purge' ) ); |
| 59 | 66 | |
| 60 | 67 | add_action( 'autoptimize_setup_done', array( $this, 'version_upgrades_check' ) ); |
| 61 | 68 | add_action( 'autoptimize_setup_done', array( $this, 'check_cache_and_run' ) ); |
| 69 | + add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_ao_compat' ), 10 ); | |
| 62 | 70 | add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_ao_extra' ), 15 ); |
| 63 | - add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_partners_tab' ), 20 ); | |
| 71 | + add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_admin_only_trinkets' ), 20 ); | |
| 64 | 72 | add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_criticalcss' ), 11 ); |
| 65 | 73 | add_action( 'autoptimize_setup_done', array( $this, 'maybe_run_notfound_fallback' ), 10 ); |
| 66 | 74 | |
| 67 | 75 | add_action( 'init', array( $this, 'load_textdomain' ) ); |
| 68 | - add_action( 'admin_init', array( 'PAnD', 'init' ) ); | |
| 69 | 76 | |
| 70 | 77 | if ( is_multisite() && is_admin() ) { |
| 71 | 78 | // Only if multisite and if in admin we want to check if we need to save options on network level. |
| 72 | 79 | add_action( 'init', 'autoptimizeOptionWrapper::check_multisite_on_saving_options' ); |
| @@ -186,8 +193,12 @@ | ||
| 186 | 193 | // And disable Jetpack's site accelerator if JS or CSS opt. are active. |
| 187 | 194 | if ( class_exists( 'Jetpack' ) && apply_filters( 'autoptimize_filter_main_disable_jetpack_cdn', true ) && ( $conf->get( 'autoptimize_js' ) || $conf->get( 'autoptimize_css' ) ) ) { |
| 188 | 195 | add_filter( 'jetpack_force_disable_site_accelerator', '__return_true' ); |
| 189 | 196 | } |
| 197 | + | |
| 198 | + // Add "no cache found" notice. | |
| 199 | + add_action( 'admin_notices', 'autoptimizeMain::notice_nopagecache', 99 ); | |
| 200 | + add_action( 'admin_notices', 'autoptimizeMain::notice_potential_conflict', 99 ); | |
| 190 | 201 | } |
| 191 | 202 | } else { |
| 192 | 203 | add_action( 'admin_notices', 'autoptimizeMain::notice_cache_unavailable' ); |
| 193 | 204 | } |
| @@ -205,21 +216,33 @@ | ||
| 205 | 216 | add_action( 'admin_notices', 'autoptimizeMain::notice_plug_imgopt' ); |
| 206 | 217 | } |
| 207 | 218 | } |
| 208 | 219 | |
| 209 | - public function maybe_run_partners_tab() | |
| 220 | + public function maybe_run_admin_only_trinkets() | |
| 210 | 221 | { |
| 211 | - // Loads partners tab code if in admin (and not in admin-ajax.php)! | |
| 222 | + // Loads partners tab and exit survey code if in admin (and not in admin-ajax.php)! | |
| 212 | 223 | if ( autoptimizeConfig::is_admin_and_not_ajax() ) { |
| 213 | 224 | new autoptimizePartners(); |
| 225 | + new autoptimizeExitSurvey(); | |
| 214 | 226 | } |
| 215 | 227 | } |
| 216 | 228 | |
| 229 | + public function criticalcss() | |
| 230 | + { | |
| 231 | + if ( apply_filters( 'autoptimize_filter_criticalcss_active', true ) && ! autoptimizeUtils::is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) { | |
| 232 | + return $this->_criticalcss; | |
| 233 | + } else { | |
| 234 | + return false; | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 217 | 238 | public function maybe_run_criticalcss() |
| 218 | 239 | { |
| 219 | - // Loads criticalcss if the power-up is not active and if the filter returns true. | |
| 240 | + // Loads criticalcss if the filter returns true & old power-up is not active. | |
| 220 | 241 | if ( apply_filters( 'autoptimize_filter_criticalcss_active', true ) && ! autoptimizeUtils::is_plugin_active( 'autoptimize-criticalcss/ao_criticss_aas.php' ) ) { |
| 221 | - new autoptimizeCriticalCSSBase(); | |
| 242 | + $this->_criticalcss = new autoptimizeCriticalCSSBase(); | |
| 243 | + $this->_criticalcss->setup(); | |
| 244 | + $this->_criticalcss->load_requires(); | |
| 222 | 245 | } |
| 223 | 246 | } |
| 224 | 247 | |
| 225 | 248 | public function maybe_run_notfound_fallback() |
| @@ -228,8 +251,25 @@ | ||
| 228 | 251 | add_action( 'template_redirect', array( 'autoptimizeCache', 'wordpress_notfound_fallback' ) ); |
| 229 | 252 | } |
| 230 | 253 | } |
| 231 | 254 | |
| 255 | + public function maybe_run_ao_compat() | |
| 256 | + { | |
| 257 | + // Condtionally loads the compatibility-class to ensure more out-of-the-box compatibility with big players. | |
| 258 | + $_run_compat = true; | |
| 259 | + | |
| 260 | + if ( autoptimizeOptionWrapper::get_option( 'autoptimize_installed_before_compatibility', false ) ) { | |
| 261 | + // If AO was already running before Compatibility logic was added, don't run compat by default | |
| 262 | + // because it can be assumed everything works and we want to avoid (perf) regressions that | |
| 263 | + // could occur due to compatibility code. | |
| 264 | + $_run_compat = false; | |
| 265 | + } | |
| 266 | + | |
| 267 | + if ( apply_filters( 'autoptimize_filter_init_compatibility', $_run_compat ) ) { | |
| 268 | + new autoptimizeCompatibility(); | |
| 269 | + } | |
| 270 | + } | |
| 271 | + | |
| 232 | 272 | public function hook_page_cache_purge() |
| 233 | 273 | { |
| 234 | 274 | // hook into a collection of page cache purge actions if filter allows. |
| 235 | 275 | if ( apply_filters( 'autoptimize_filter_main_hookpagecachepurge', true ) ) { |
| @@ -349,13 +389,20 @@ | ||
| 349 | 389 | } |
| 350 | 390 | } |
| 351 | 391 | } |
| 352 | 392 | |
| 353 | - // And make sure pagebuilder previews don't get optimized HTML/ JS/ CSS/ ... | |
| 393 | + // Misc. querystring paramaters that will stop AO from doing optimizations (pagebuilders + | |
| 394 | + // 2 generic parameters that could/ should become standard between optimization plugins?). | |
| 354 | 395 | if ( false === $ao_noptimize ) { |
| 355 | - $_qs_pagebuilders = array( 'tve', 'elementor-preview', 'fl_builder', 'vc_action', 'et_fb', 'bt-beaverbuildertheme', 'ct_builder', 'fb-edit', 'siteorigin_panels_live_editor' ); | |
| 356 | - foreach ( $_qs_pagebuilders as $_pagebuilder ) { | |
| 357 | - if ( array_key_exists( $_pagebuilder, $_GET ) ) { | |
| 396 | + $_qs_showstoppers = array( 'no_cache', 'no_optimize', 'tve', 'elementor-preview', 'fl_builder', 'vc_action', 'et_fb', 'bt-beaverbuildertheme', 'ct_builder', 'fb-edit', 'siteorigin_panels_live_editor', 'preview', 'td_action' ); | |
| 397 | + | |
| 398 | + // doing Jonathan a quick favor to allow correct unused CSS generation ;-) . | |
| 399 | + if ( apply_filters( 'autoptimize_filter_main_showstoppers_do_wp_rocket_a_favor', true ) ) { | |
| 400 | + $_qs_showstoppers[] = 'nowprocket'; | |
| 401 | + } | |
| 402 | + | |
| 403 | + foreach ( $_qs_showstoppers as $_showstopper ) { | |
| 404 | + if ( array_key_exists( $_showstopper, $_GET ) ) { | |
| 358 | 405 | $ao_noptimize = true; |
| 359 | 406 | break; |
| 360 | 407 | } |
| 361 | 408 | } |
| @@ -366,8 +413,13 @@ | ||
| 366 | 413 | if ( false === $ao_noptimize && array_key_exists( 'PageSpeed', $_GET ) && 'off' === $_GET['PageSpeed'] ) { |
| 367 | 414 | $ao_noptimize = true; |
| 368 | 415 | } |
| 369 | 416 | |
| 417 | + // If page/ post check post_meta to see if optimize is off. | |
| 418 | + if ( false === autoptimizeConfig::get_post_meta_ao_settings( 'ao_post_optimize' ) ) { | |
| 419 | + $ao_noptimize = true; | |
| 420 | + } | |
| 421 | + | |
| 370 | 422 | // And finally allows blocking of autoptimization on your own terms regardless of above decisions. |
| 371 | 423 | $ao_noptimize = (bool) apply_filters( 'autoptimize_filter_noptimize', $ao_noptimize ); |
| 372 | 424 | |
| 373 | 425 | // Check for site being previewed in the Customizer (available since WP 4.0). |
| @@ -430,16 +482,31 @@ | ||
| 430 | 482 | * @return bool |
| 431 | 483 | */ |
| 432 | 484 | public static function is_amp_markup( $content ) |
| 433 | 485 | { |
| 434 | - // Short-circuit when a function is available to determine whether the response is (or will be) an AMP page. | |
| 435 | - if ( function_exists( 'is_amp_endpoint' ) ) { | |
| 436 | - return is_amp_endpoint(); | |
| 486 | + // Short-circuit if the page is already AMP from the start. | |
| 487 | + if ( | |
| 488 | + preg_match( | |
| 489 | + sprintf( | |
| 490 | + '#^(?:<!.*?>|\s+)*+<html(?=\s)[^>]*?\s(%1$s|%2$s|%3$s)(\s|=|>)#is', | |
| 491 | + 'amp', | |
| 492 | + "\xE2\x9A\xA1", // From \AmpProject\Attribute::AMP_EMOJI. | |
| 493 | + "\xE2\x9A\xA1\xEF\xB8\x8F" // From \AmpProject\Attribute::AMP_EMOJI_ALT, per https://github.com/ampproject/amphtml/issues/25990. | |
| 494 | + ), | |
| 495 | + $content | |
| 496 | + ) | |
| 497 | + ) { | |
| 498 | + return true; | |
| 437 | 499 | } |
| 438 | 500 | |
| 439 | - $is_amp_markup = preg_match( '/<html[^>]*(?:amp|âš¡)/i', $content ); | |
| 501 | + // Or else short-circuit if the AMP plugin will be processing the output to be an AMP page. | |
| 502 | + if ( function_exists( 'amp_is_request' ) ) { | |
| 503 | + return amp_is_request(); // For AMP plugin v2.0+. | |
| 504 | + } elseif ( function_exists( 'is_amp_endpoint' ) ) { | |
| 505 | + return is_amp_endpoint(); // For older/other AMP plugins (still supported in 2.0 as an alias). | |
| 506 | + } | |
| 440 | 507 | |
| 441 | - return (bool) $is_amp_markup; | |
| 508 | + return false; | |
| 442 | 509 | } |
| 443 | 510 | |
| 444 | 511 | /** |
| 445 | 512 | * Processes/optimizes the output-buffered content and returns it. |
| @@ -471,16 +538,18 @@ | ||
| 471 | 538 | } |
| 472 | 539 | |
| 473 | 540 | $classoptions = array( |
| 474 | 541 | 'autoptimizeScripts' => array( |
| 475 | - 'aggregate' => $conf->get( 'autoptimize_js_aggregate' ), | |
| 476 | - 'justhead' => $conf->get( 'autoptimize_js_justhead' ), | |
| 477 | - 'forcehead' => $conf->get( 'autoptimize_js_forcehead' ), | |
| 478 | - 'trycatch' => $conf->get( 'autoptimize_js_trycatch' ), | |
| 479 | - 'js_exclude' => $conf->get( 'autoptimize_js_exclude' ), | |
| 480 | - 'cdn_url' => $conf->get( 'autoptimize_cdn_url' ), | |
| 481 | - 'include_inline' => $conf->get( 'autoptimize_js_include_inline' ), | |
| 482 | - 'minify_excluded' => $conf->get( 'autoptimize_minify_excluded' ), | |
| 542 | + 'aggregate' => $conf->get( 'autoptimize_js_aggregate' ), | |
| 543 | + 'defer_not_aggregate' => $conf->get( 'autoptimize_js_defer_not_aggregate' ), | |
| 544 | + 'defer_inline' => $conf->get( 'autoptimize_js_defer_inline' ), | |
| 545 | + 'justhead' => $conf->get( 'autoptimize_js_justhead' ), | |
| 546 | + 'forcehead' => $conf->get( 'autoptimize_js_forcehead' ), | |
| 547 | + 'trycatch' => $conf->get( 'autoptimize_js_trycatch' ), | |
| 548 | + 'js_exclude' => $conf->get( 'autoptimize_js_exclude' ), | |
| 549 | + 'cdn_url' => $conf->get( 'autoptimize_cdn_url' ), | |
| 550 | + 'include_inline' => $conf->get( 'autoptimize_js_include_inline' ), | |
| 551 | + 'minify_excluded' => $conf->get( 'autoptimize_minify_excluded' ), | |
| 483 | 552 | ), |
| 484 | 553 | 'autoptimizeStyles' => array( |
| 485 | 554 | 'aggregate' => $conf->get( 'autoptimize_css_aggregate' ), |
| 486 | 555 | 'justhead' => $conf->get( 'autoptimize_css_justhead' ), |
| @@ -494,9 +563,10 @@ | ||
| 494 | 563 | 'nogooglefont' => $conf->get( 'autoptimize_css_nogooglefont' ), |
| 495 | 564 | 'minify_excluded' => $conf->get( 'autoptimize_minify_excluded' ), |
| 496 | 565 | ), |
| 497 | 566 | 'autoptimizeHTML' => array( |
| 498 | - 'keepcomments' => $conf->get( 'autoptimize_html_keepcomments' ), | |
| 567 | + 'keepcomments' => $conf->get( 'autoptimize_html_keepcomments' ), | |
| 568 | + 'minify_inline' => $conf->get( 'autoptimize_html_minify_inline' ), | |
| 499 | 569 | ), |
| 500 | 570 | ); |
| 501 | 571 | |
| 502 | 572 | $content = apply_filters( 'autoptimize_filter_html_before_minify', $content ); |
| @@ -532,10 +602,17 @@ | ||
| 532 | 602 | } |
| 533 | 603 | |
| 534 | 604 | public static function on_uninstall() |
| 535 | 605 | { |
| 606 | + // clear the cache. | |
| 536 | 607 | autoptimizeCache::clearall(); |
| 537 | 608 | |
| 609 | + // remove postmeta if active. | |
| 610 | + if ( autoptimizeConfig::is_ao_meta_settings_active() ) { | |
| 611 | + delete_post_meta_by_key( 'ao_post_optimize' ); | |
| 612 | + } | |
| 613 | + | |
| 614 | + // remove all options. | |
| 538 | 615 | $delete_options = array( |
| 539 | 616 | 'autoptimize_cache_clean', |
| 540 | 617 | 'autoptimize_cache_nogzip', |
| 541 | 618 | 'autoptimize_css', |
| @@ -547,11 +624,15 @@ | ||
| 547 | 624 | 'autoptimize_css_inline', |
| 548 | 625 | 'autoptimize_css_exclude', |
| 549 | 626 | 'autoptimize_html', |
| 550 | 627 | 'autoptimize_html_keepcomments', |
| 628 | + 'autoptimize_html_minify_inline', | |
| 551 | 629 | 'autoptimize_enable_site_config', |
| 630 | + 'autoptimize_enable_meta_ao_settings', | |
| 552 | 631 | 'autoptimize_js', |
| 553 | 632 | 'autoptimize_js_aggregate', |
| 633 | + 'autoptimize_js_defer_not_aggregate', | |
| 634 | + 'autoptimize_js_defer_inline', | |
| 554 | 635 | 'autoptimize_js_exclude', |
| 555 | 636 | 'autoptimize_js_forcehead', |
| 556 | 637 | 'autoptimize_js_justhead', |
| 557 | 638 | 'autoptimize_js_trycatch', |
| @@ -575,8 +656,9 @@ | ||
| 575 | 656 | 'autoptimize_ccss_queue', |
| 576 | 657 | 'autoptimize_ccss_viewport', |
| 577 | 658 | 'autoptimize_ccss_finclude', |
| 578 | 659 | 'autoptimize_ccss_rlimit', |
| 660 | + 'autoptimize_ccss_rtimelimit', | |
| 579 | 661 | 'autoptimize_ccss_noptimize', |
| 580 | 662 | 'autoptimize_ccss_debug', |
| 581 | 663 | 'autoptimize_ccss_key', |
| 582 | 664 | 'autoptimize_ccss_keyst', |
| @@ -584,8 +666,10 @@ | ||
| 584 | 666 | 'autoptimize_ccss_loggedin', |
| 585 | 667 | 'autoptimize_ccss_forcepath', |
| 586 | 668 | 'autoptimize_ccss_deferjquery', |
| 587 | 669 | 'autoptimize_ccss_domain', |
| 670 | + 'autoptimize_ccss_unloadccss', | |
| 671 | + 'autoptimize_installed_before_compatibility', | |
| 588 | 672 | ); |
| 589 | 673 | |
| 590 | 674 | if ( ! is_multisite() ) { |
| 591 | 675 | foreach ( $delete_options as $del_opt ) { |
| @@ -609,11 +693,17 @@ | ||
| 609 | 693 | // Remove AO CCSS cached files and directory. |
| 610 | 694 | $ao_ccss_dir = WP_CONTENT_DIR . '/uploads/ao_ccss/'; |
| 611 | 695 | if ( file_exists( $ao_ccss_dir ) && is_dir( $ao_ccss_dir ) ) { |
| 612 | 696 | // fixme: should check for subdirs when in multisite and remove contents of those as well. |
| 613 | - array_map( 'unlink', glob( AO_CCSS_DIR . '*.{css,html,json,log,zip,lock}', GLOB_BRACE ) ); | |
| 614 | - rmdir( AO_CCSS_DIR ); | |
| 697 | + array_map( 'unlink', glob( $ao_ccss_dir . '*.{css,html,json,log,zip,lock}', GLOB_BRACE ) ); | |
| 698 | + rmdir( $ao_ccss_dir ); | |
| 615 | 699 | } |
| 700 | + | |
| 701 | + // Remove 404-handler (although that should have been removed in clearall already). | |
| 702 | + $_fallback_php = trailingslashit( WP_CONTENT_DIR ) . 'autoptimize_404_handler.php'; | |
| 703 | + if ( file_exists( $_fallback_php ) ) { | |
| 704 | + unlink( $_fallback_php ); | |
| 705 | + } | |
| 616 | 706 | } |
| 617 | 707 | |
| 618 | 708 | public static function on_deactivation() |
| 619 | 709 | { |
| @@ -633,9 +723,9 @@ | ||
| 633 | 723 | } |
| 634 | 724 | |
| 635 | 725 | public static function remove_cronjobs() { |
| 636 | 726 | // Remove scheduled events. |
| 637 | - foreach ( array( 'ao_cachechecker', 'ao_ccss_queue', 'ao_ccss_maintenance' ) as $_event ) { | |
| 727 | + foreach ( array( 'ao_cachechecker', 'ao_ccss_queue', 'ao_ccss_maintenance', 'ao_ccss_keychecker' ) as $_event ) { | |
| 638 | 728 | if ( wp_get_schedule( $_event ) ) { |
| 639 | 729 | wp_clear_scheduled_hook( $_event ); |
| 640 | 730 | } |
| 641 | 731 | } |
| @@ -651,9 +741,9 @@ | ||
| 651 | 741 | |
| 652 | 742 | public static function notice_installed() |
| 653 | 743 | { |
| 654 | 744 | echo '<div class="updated"><p>'; |
| 655 | - _e( 'Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize' ); | |
| 745 | + printf( __( 'Thank you for installing and activating Autoptimize. Please configure it under %1$sSettings -> Autoptimize%2$s to start improving your site\'s performance.', 'autoptimize' ), '<a href="options-general.php?page=autoptimize">', '</a>' ); | |
| 656 | 746 | echo '</p></div>'; |
| 657 | 747 | } |
| 658 | 748 | |
| 659 | 749 | public static function notice_updated() |
| @@ -665,17 +755,61 @@ | ||
| 665 | 755 | |
| 666 | 756 | public static function notice_plug_imgopt() |
| 667 | 757 | { |
| 668 | 758 | // Translators: the URL added points to the Autopmize Extra settings. |
| 669 | - $_ao_imgopt_plug_notice = sprintf( __( 'Did you know Autoptimize includes on-the-fly image optimization (with support for WebP) and CDN via ShortPixel? Check out the %1$sAutoptimize Image settings%2$s to activate this option.', 'autoptimize' ), '<a href="options-general.php?page=autoptimize_imgopt">', '</a>' ); | |
| 759 | + $_ao_imgopt_plug_notice = sprintf( __( 'Did you know Autoptimize that Autoptimize offers on-the-fly image optimization (with support for WebP and AVIF) and CDN via ShortPixel? Check out the %1$sAutoptimize Image settings%2$s to enable this option.', 'autoptimize' ), '<a href="options-general.php?page=autoptimize_imgopt">', '</a>' ); | |
| 670 | 760 | $_ao_imgopt_plug_notice = apply_filters( 'autoptimize_filter_main_imgopt_plug_notice', $_ao_imgopt_plug_notice ); |
| 671 | 761 | $_ao_imgopt_launch_ok = autoptimizeImages::launch_ok_wrapper(); |
| 672 | 762 | $_ao_imgopt_plug_dismissible = 'ao-img-opt-plug-123'; |
| 673 | 763 | $_ao_imgopt_active = autoptimizeImages::imgopt_active(); |
| 764 | + $_is_ao_settings_page = autoptimizeUtils::is_ao_settings(); | |
| 674 | 765 | |
| 675 | - if ( current_user_can( 'manage_options' ) && '' !== $_ao_imgopt_plug_notice && ! $_ao_imgopt_active && $_ao_imgopt_launch_ok && PAnD::is_admin_notice_active( $_ao_imgopt_plug_dismissible ) ) { | |
| 766 | + if ( current_user_can( 'manage_options' ) && ! defined( 'AO_PRO_VERSION' ) && $_is_ao_settings_page && '' !== $_ao_imgopt_plug_notice && ! $_ao_imgopt_active && $_ao_imgopt_launch_ok && PAnD::is_admin_notice_active( $_ao_imgopt_plug_dismissible ) ) { | |
| 676 | 767 | echo '<div class="notice notice-info is-dismissible" data-dismissible="' . $_ao_imgopt_plug_dismissible . '"><p>'; |
| 677 | 768 | echo $_ao_imgopt_plug_notice; |
| 678 | 769 | echo '</p></div>'; |
| 770 | + } | |
| 771 | + } | |
| 772 | + | |
| 773 | + public static function notice_nopagecache() | |
| 774 | + { | |
| 775 | + /* | |
| 776 | + * Autoptimize does not do page caching (yet) but not everyone knows, so below logic tries to find out if page caching is available and if not show a notice on the AO Settings pages. | |
| 777 | + * | |
| 778 | + * uses helper function in autoptimizeUtils.php | |
| 779 | + */ | |
| 780 | + $_ao_nopagecache_notice = __( 'It looks like your site might not have <strong>page caching</strong> which is a <strong>must-have for performance</strong>. If you are sure you have a page cache, you can close this notice, but when in doubt check with your host if they offer this or install a page caching plugin like for example', 'autoptimize' ); | |
| 781 | + $_ao_pagecache_install_url = network_admin_url() . 'plugin-install.php?tab=search&type=term&s='; | |
| 782 | + $_ao_nopagecache_notice .= ' <a href="' . $_ao_pagecache_install_url . 'wp+super+cache' . '">WP Super Cache</a>, <a href="' . $_ao_pagecache_install_url . 'keycdn+cache+enabler' . '">KeyCDN Cache Enabler</a>, ...'; | |
| 783 | + $_ao_nopagecache_dismissible = 'ao-nopagecache-forever'; // the notice is only shown once and will not re-appear when dismissed. | |
| 784 | + $_is_ao_settings_page = autoptimizeUtils::is_ao_settings(); | |
| 785 | + | |
| 786 | + if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_nopagecache_dismissible ) && true === apply_filters( 'autoptimize_filter_main_show_pagecache_notice', true ) ) { | |
| 787 | + if ( false === autoptimizeUtils::find_pagecache() ) { | |
| 788 | + echo '<div class="notice notice-info is-dismissible" data-dismissible="' . $_ao_nopagecache_dismissible . '"><p>'; | |
| 789 | + echo $_ao_nopagecache_notice; | |
| 790 | + echo '</p></div>'; | |
| 791 | + } | |
| 792 | + } | |
| 793 | + } | |
| 794 | + | |
| 795 | + public static function notice_potential_conflict() | |
| 796 | + { | |
| 797 | + /* | |
| 798 | + * Using other plugins to do CSS/ JS optimization can cause unexpected and hard to troubleshoot issues, warn users who seem to be in that situation. | |
| 799 | + */ | |
| 800 | + // Translators: the sentence will be finished with the name of the offending plugin and a final stop. | |
| 801 | + $_ao_potential_conflict_notice = __( 'It looks like you have <strong>another plugin also doing CSS and/ or JS optimization</strong>, which can result in hard to troubleshoot <strong>conflicts</strong>. For this reason it is recommended to disable this functionality in', 'autoptimize' ) . ' '; | |
| 802 | + $_ao_potential_conflict_dismissible = 'ao-potential-conflict-forever'; // the notice is only shown once and will not re-appear when dismissed. | |
| 803 | + $_is_ao_settings_page = autoptimizeUtils::is_ao_settings(); | |
| 804 | + | |
| 805 | + if ( current_user_can( 'manage_options' ) && $_is_ao_settings_page && PAnD::is_admin_notice_active( $_ao_potential_conflict_dismissible ) && true === apply_filters( 'autoptimize_filter_main_show_potential_conclict_notice', true ) ) { | |
| 806 | + $_potential_conflicts = autoptimizeUtils::find_potential_conflicts(); | |
| 807 | + if ( false !== $_potential_conflicts ) { | |
| 808 | + $_ao_potential_conflict_notice .= '<strong>' . $_potential_conflicts . '</strong>.'; | |
| 809 | + echo '<div class="notice notice-info is-dismissible" data-dismissible="' . $_ao_potential_conflict_dismissible . '"><p>'; | |
| 810 | + echo $_ao_potential_conflict_notice; | |
| 811 | + echo '</p></div>'; | |
| 812 | + } | |
| 679 | 813 | } |
| 680 | 814 | } |
| 681 | 815 | } |