PluginProbe
Autoptimize / 3.1.16
Autoptimize v3.1.16
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
← All changes | classes/autoptimizeCacheChecker.php +22 -19 2.4.0 → 3.1.16 View file →
@@ -35,13 +35,16 @@
35 35 public function setup()
36 36 {
37 37 $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
38 38 $schedule = wp_get_schedule( self::SCHEDULE_HOOK );
39 - $frequency = apply_filters( 'autoptimize_filter_cachecheck_frequency', 'daily' );
40 - if ( ! in_array( $frequency, array( 'hourly', 'daily', 'weekly', 'monthly' ) ) ) {
41 - $frequency = 'daily';
39 + $frequency = apply_filters( 'autoptimize_filter_cachecheck_frequency', 'twicedaily' );
40 + if ( ! in_array( $frequency, array( 'hourly', 'twicedaily', 'daily', 'weekly', 'monthly' ) ) ) {
41 + $frequency = 'twicedaily';
42 42 }
43 43 if ( $do_cache_check && ( ! $schedule || $schedule !== $frequency ) ) {
44 + if ( $schedule ) {
45 + wp_clear_scheduled_hook( self::SCHEDULE_HOOK );
46 + }
44 47 wp_schedule_event( time(), $frequency, self::SCHEDULE_HOOK );
45 48 } elseif ( $schedule && ! $do_cache_check ) {
46 49 wp_clear_scheduled_hook( self::SCHEDULE_HOOK );
47 50 }
@@ -54,15 +57,15 @@
54 57 $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
55 58 $stat_array = autoptimizeCache::stats();
56 59 $cache_size = round( $stat_array[1] );
57 60 if ( ( $cache_size > $max_size ) && ( $do_cache_check ) ) {
58 - update_option( 'autoptimize_cachesize_notice', true );
61 + autoptimizeOptionWrapper::update_option( 'autoptimize_cachesize_notice', true );
59 62 if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) {
60 - $site_url = esc_url( site_url() );
61 - $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', get_option( 'admin_email', '' ) );
63 + $home_url = esc_url( home_url() );
64 + $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', autoptimizeOptionWrapper::get_option( 'admin_email', '' ) );
62 65
63 - $ao_mailsubject = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $site_url . ')';
64 - $ao_mailbody = __( 'Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize' ) . ' (site: ' . $site_url . ')';
66 + $ao_mailsubject = esc_html__( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $home_url . ')';
67 + $ao_mailbody = esc_html__( 'Autoptimize\'s cache size is getting big, consider purging the cache. Have a look at https://wordpress.org/plugins/autoptimize/faq/ to see how you can keep the cache size under control.', 'autoptimize' ) . ' (site: ' . $home_url . ')';
65 68
66 69 if ( ! empty( $ao_mailto ) ) {
67 70 $ao_mailresult = wp_mail( $ao_mailto, $ao_mailsubject, $ao_mailbody );
68 71 if ( ! $ao_mailresult ) {
@@ -74,32 +77,32 @@
74 77
75 78 // Check if 3rd party services (e.g. image proxy) are up.
76 79 autoptimizeUtils::check_service_availability();
77 80
78 - // Check image optimization stats.
79 - autoptimizeExtra::get_img_provider_stats();
80 -
81 81 // Nukes advanced cache clearing artifacts if they exists...
82 82 autoptimizeCache::delete_advanced_cache_clear_artifacts();
83 +
84 + // Check image optimization stats.
85 + autoptimizeImages::instance()->query_img_provider_stats();
83 86 }
84 87
85 88 public function show_admin_notice()
86 89 {
87 - // fixme: make notices dismissable.
88 - if ( (bool) get_option( 'autoptimize_cachesize_notice', false ) ) {
90 + if ( (bool) autoptimizeOptionWrapper::get_option( 'autoptimize_cachesize_notice', false ) && current_user_can( 'manage_options' ) ) {
89 91 echo '<div class="notice notice-warning"><p>';
90 - _e( '<strong>Autoptimize\'s cache size is getting big</strong>, consider purging the cache. Have a look at <a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank" rel="noopener noreferrer">the Autoptimize FAQ</a> to see how you can keep the cache size under control.', 'autoptimize' );
92 + // Translators: first two variables are strong tags, 3rd is link to the AO FAQ and the 4th closes that tag.
93 + printf( esc_html__( '%1$sAutoptimize\'s cache size is getting big%2$s, consider purging the cache. Have a look at %3$sthe Autoptimize FAQ%4$s to see how you can keep the cache size under control.', 'autoptimize' ), '<strong>', '</strong>', '<a href="https://wordpress.org/plugins/autoptimize/faq/" target="_blank" rel="noopener noreferrer">', '</a>' );
91 94 echo '</p></div>';
92 - update_option( 'autoptimize_cachesize_notice', false );
95 + autoptimizeOptionWrapper::update_option( 'autoptimize_cachesize_notice', false );
93 96 }
94 97
95 98 // Notice for image proxy usage.
96 - $_imgopt_notice = autoptimizeExtra::get_imgopt_status_notice_wrapper();
97 - if ( is_array( $_imgopt_notice ) && array_key_exists( 'status', $_imgopt_notice ) && in_array( $_imgopt_notice['status'], array( 1, -1 ) ) ) {
99 + $_imgopt_notice = autoptimizeImages::instance()->get_imgopt_status_notice_wrapper();
100 + if ( current_user_can( 'manage_options' ) && is_array( $_imgopt_notice ) && array_key_exists( 'status', $_imgopt_notice ) && in_array( $_imgopt_notice['status'], array( 1, -1, -2, -3 ) ) ) {
98 101 $_dismissible = 'ao-img-opt-notice-';
99 102 $_hide_notice = '7';
100 103
101 - if ( -1 == $_imgopt_notice['status'] ) {
104 + if ( -1 == $_imgopt_notice['status'] || -2 == $_imgopt_notice['status'] || -3 == $_imgopt_notice['status'] ) {
102 105 $_hide_notice = '1';
103 106 }
104 107
105 108 $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
@@ -104,9 +107,9 @@
104 107
105 108 $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
106 109
107 110 if ( $_imgopt_notice && PAnD::is_admin_notice_active( $_imgopt_notice_dismissible ) ) {
108 - echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p>' . $_imgopt_notice['notice'] . '</p></div>';
111 + echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p><strong>' . esc_html__( 'Autoptimize', 'autoptimize' ) . '</strong>: ' . $_imgopt_notice['notice'] . '</p></div>';
109 112 }
110 113 }
111 114 }
112 115 }