PluginProbe
Autoptimize / 3.0.3
Autoptimize v3.0.3
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 2.7.8 All 107 releases
← All changes | classes/autoptimizeCacheChecker.php +20 -18 2.4.13.0.3 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 = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $home_url . ')';
67 + $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: ' . $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,31 @@
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 92 _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' );
91 93 echo '</p></div>';
92 - update_option( 'autoptimize_cachesize_notice', false );
94 + autoptimizeOptionWrapper::update_option( 'autoptimize_cachesize_notice', false );
93 95 }
94 96
95 97 // 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 ) ) ) {
98 + $_imgopt_notice = autoptimizeImages::instance()->get_imgopt_status_notice_wrapper();
99 + 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 100 $_dismissible = 'ao-img-opt-notice-';
99 101 $_hide_notice = '7';
100 102
101 - if ( -1 == $_imgopt_notice['status'] ) {
103 + if ( -1 == $_imgopt_notice['status'] || -2 == $_imgopt_notice['status'] || -3 == $_imgopt_notice['status'] ) {
102 104 $_hide_notice = '1';
103 105 }
104 106
105 107 $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
@@ -104,9 +106,9 @@
104 106
105 107 $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
106 108
107 109 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>';
110 + echo '<div class="notice notice-warning is-dismissible" data-dismissible="' . $_imgopt_notice_dismissible . '"><p><strong>' . __( 'Autoptimize', 'autoptimize' ) . '</strong>: ' . $_imgopt_notice['notice'] . '</p></div>';
109 111 }
110 112 }
111 113 }
112 114 }