Completed
Push — master ( 471c26...e80620 )
by frank
01:49
created
classes/autoptimizeCacheChecker.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Checks if cachesize is > 0.5GB (size is filterable), if so, an option is set which controls showing an admin notice.
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
     exit;
11 11
 }
12 12
 
@@ -25,51 +25,51 @@  discard block
 block discarded – undo
25 25
 
26 26
     public function add_hooks()
27 27
     {
28
-        if ( is_admin() ) {
29
-            add_action( 'plugins_loaded', array( $this, 'setup' ) );
28
+        if (is_admin()) {
29
+            add_action('plugins_loaded', array($this, 'setup'));
30 30
         }
31
-        add_action( self::SCHEDULE_HOOK, array( $this, 'cronjob' ) );
32
-        add_action( 'admin_notices', array( $this, 'show_admin_notice' ) );
31
+        add_action(self::SCHEDULE_HOOK, array($this, 'cronjob'));
32
+        add_action('admin_notices', array($this, 'show_admin_notice'));
33 33
     }
34 34
 
35 35
     public function setup()
36 36
     {
37
-        $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
38
-        $schedule       = wp_get_schedule( self::SCHEDULE_HOOK );
39
-        $frequency      = apply_filters( 'autoptimize_filter_cachecheck_frequency', 'twicedaily' );
40
-        if ( ! in_array( $frequency, array( 'hourly', 'twicedaily', 'daily', 'weekly', 'monthly' ) ) ) {
37
+        $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true);
38
+        $schedule       = wp_get_schedule(self::SCHEDULE_HOOK);
39
+        $frequency      = apply_filters('autoptimize_filter_cachecheck_frequency', 'twicedaily');
40
+        if (!in_array($frequency, array('hourly', 'twicedaily', 'daily', 'weekly', 'monthly'))) {
41 41
             $frequency = 'twicedaily';
42 42
         }
43
-        if ( $do_cache_check && ( ! $schedule || $schedule !== $frequency ) ) {
44
-            if ( $schedule ) {
45
-                wp_clear_scheduled_hook( self::SCHEDULE_HOOK );
43
+        if ($do_cache_check && (!$schedule || $schedule !== $frequency)) {
44
+            if ($schedule) {
45
+                wp_clear_scheduled_hook(self::SCHEDULE_HOOK);
46 46
             }
47
-            wp_schedule_event( time(), $frequency, self::SCHEDULE_HOOK );
48
-        } elseif ( $schedule && ! $do_cache_check ) {
49
-            wp_clear_scheduled_hook( self::SCHEDULE_HOOK );
47
+            wp_schedule_event(time(), $frequency, self::SCHEDULE_HOOK);
48
+        } elseif ($schedule && !$do_cache_check) {
49
+            wp_clear_scheduled_hook(self::SCHEDULE_HOOK);
50 50
         }
51 51
     }
52 52
 
53 53
     public function cronjob()
54 54
     {
55 55
         // Check cachesize and act accordingly.
56
-        $max_size       = (int) apply_filters( 'autoptimize_filter_cachecheck_maxsize', 536870912 );
57
-        $do_cache_check = (bool) apply_filters( 'autoptimize_filter_cachecheck_do', true );
56
+        $max_size       = (int) apply_filters('autoptimize_filter_cachecheck_maxsize', 536870912);
57
+        $do_cache_check = (bool) apply_filters('autoptimize_filter_cachecheck_do', true);
58 58
         $stat_array     = autoptimizeCache::stats();
59
-        $cache_size     = round( $stat_array[1] );
60
-        if ( ( $cache_size > $max_size ) && ( $do_cache_check ) ) {
61
-            autoptimizeOptionWrapper::update_option( 'autoptimize_cachesize_notice', true );
62
-            if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) {
63
-                $home_url  = esc_url( home_url() );
64
-                $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', autoptimizeOptionWrapper::get_option( 'admin_email', '' ) );
65
-
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 . ')';
68
-
69
-                if ( ! empty( $ao_mailto ) ) {
70
-                    $ao_mailresult = wp_mail( $ao_mailto, $ao_mailsubject, $ao_mailbody );
71
-                    if ( ! $ao_mailresult ) {
72
-                        error_log( 'Autoptimize could not send cache size warning mail.' );
59
+        $cache_size     = round($stat_array[1]);
60
+        if (($cache_size > $max_size) && ($do_cache_check)) {
61
+            autoptimizeOptionWrapper::update_option('autoptimize_cachesize_notice', true);
62
+            if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) {
63
+                $home_url  = esc_url(home_url());
64
+                $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', autoptimizeOptionWrapper::get_option('admin_email', ''));
65
+
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.')';
68
+
69
+                if (!empty($ao_mailto)) {
70
+                    $ao_mailresult = wp_mail($ao_mailto, $ao_mailsubject, $ao_mailbody);
71
+                    if (!$ao_mailresult) {
72
+                        error_log('Autoptimize could not send cache size warning mail.');
73 73
                     }
74 74
                 }
75 75
             }
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
 
88 88
     public function show_admin_notice()
89 89
     {
90
-        if ( (bool) autoptimizeOptionWrapper::get_option( 'autoptimize_cachesize_notice', false ) && current_user_can( 'manage_options' ) ) {
90
+        if ((bool) autoptimizeOptionWrapper::get_option('autoptimize_cachesize_notice', false) && current_user_can('manage_options')) {
91 91
             echo '<div class="notice notice-warning"><p>';
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' );
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');
93 93
             echo '</p></div>';
94
-            autoptimizeOptionWrapper::update_option( 'autoptimize_cachesize_notice', false );
94
+            autoptimizeOptionWrapper::update_option('autoptimize_cachesize_notice', false);
95 95
         }
96 96
 
97 97
         // Notice for image proxy usage.
98 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 ) ) ) {
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))) {
100 100
             $_dismissible = 'ao-img-opt-notice-';
101 101
             $_hide_notice = '7';
102 102
 
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
                 $_hide_notice = '1';
105 105
             }
106 106
 
107
-            $_imgopt_notice_dismissible = apply_filters( 'autoptimize_filter_imgopt_notice_dismissable', $_dismissible . $_hide_notice );
107
+            $_imgopt_notice_dismissible = apply_filters('autoptimize_filter_imgopt_notice_dismissable', $_dismissible.$_hide_notice);
108 108
 
109
-            if ( $_imgopt_notice && PAnD::is_admin_notice_active( $_imgopt_notice_dismissible ) ) {
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
+            if ($_imgopt_notice && PAnD::is_admin_notice_active($_imgopt_notice_dismissible)) {
110
+                echo '<div class="notice notice-warning is-dismissible" data-dismissible="'.$_imgopt_notice_dismissible.'"><p><strong>'.__('Autoptimize', 'autoptimize').'</strong>: '.$_imgopt_notice['notice'].'</p></div>';
111 111
             }
112 112
         }
113 113
     }
Please login to merge, or discard this patch.
classes/autoptimizePartners.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * addons and/or affiliate services.
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
     exit;
9 9
 }
10 10
 
@@ -17,68 +17,68 @@  discard block
 block discarded – undo
17 17
 
18 18
     public function run()
19 19
     {
20
-        if ( $this->enabled() ) {
21
-            add_filter( 'autoptimize_filter_settingsscreen_tabs', array( $this, 'add_partner_tabs' ), 10, 1 );
20
+        if ($this->enabled()) {
21
+            add_filter('autoptimize_filter_settingsscreen_tabs', array($this, 'add_partner_tabs'), 10, 1);
22 22
         }
23
-        if ( is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network() ) {
24
-            add_action( 'network_admin_menu', array( $this, 'add_admin_menu' ) );
23
+        if (is_multisite() && is_network_admin() && autoptimizeOptionWrapper::is_ao_active_for_network()) {
24
+            add_action('network_admin_menu', array($this, 'add_admin_menu'));
25 25
         } else {
26
-            add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
26
+            add_action('admin_menu', array($this, 'add_admin_menu'));
27 27
         }
28 28
     }
29 29
 
30 30
     protected function enabled()
31 31
     {
32
-        return apply_filters( 'autoptimize_filter_show_partner_tabs', true );
32
+        return apply_filters('autoptimize_filter_show_partner_tabs', true);
33 33
     }
34 34
 
35
-    public function add_partner_tabs( $in )
35
+    public function add_partner_tabs($in)
36 36
     {
37
-        $in = array_merge( $in, array(
38
-            'ao_partners' => __( 'Optimize More!', 'autoptimize' ),
39
-        ) );
37
+        $in = array_merge($in, array(
38
+            'ao_partners' => __('Optimize More!', 'autoptimize'),
39
+        ));
40 40
 
41 41
         return $in;
42 42
     }
43 43
 
44 44
     public function add_admin_menu()
45 45
     {
46
-        if ( $this->enabled() ) {
47
-            add_submenu_page( null, 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array( $this, 'ao_partners_page' ) );
46
+        if ($this->enabled()) {
47
+            add_submenu_page(null, 'AO partner', 'AO partner', 'manage_options', 'ao_partners', array($this, 'ao_partners_page'));
48 48
         }
49 49
     }
50 50
 
51 51
     protected function get_ao_partner_feed_markup()
52 52
     {
53
-        $no_feed_text = __( 'Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize' );
53
+        $no_feed_text = __('Have a look at <a href="http://optimizingmatters.com/">optimizingmatters.com</a> for Autoptimize power-ups!', 'autoptimize');
54 54
         $output       = '';
55
-        if ( apply_filters( 'autoptimize_settingsscreen_remotehttp', true ) ) {
56
-            $rss      = fetch_feed( 'http://feeds.feedburner.com/OptimizingMattersDownloads' );
55
+        if (apply_filters('autoptimize_settingsscreen_remotehttp', true)) {
56
+            $rss      = fetch_feed('http://feeds.feedburner.com/OptimizingMattersDownloads');
57 57
             $maxitems = 0;
58 58
 
59
-            if ( ! is_wp_error( $rss ) ) {
60
-                $maxitems  = $rss->get_item_quantity( 20 );
61
-                $rss_items = $rss->get_items( 0, $maxitems );
59
+            if (!is_wp_error($rss)) {
60
+                $maxitems  = $rss->get_item_quantity(20);
61
+                $rss_items = $rss->get_items(0, $maxitems);
62 62
             }
63 63
 
64
-            if ( 0 == $maxitems ) {
64
+            if (0 == $maxitems) {
65 65
                 $output .= $no_feed_text;
66 66
             } else {
67 67
                 $output .= '<ul>';
68
-                foreach ( $rss_items as $item ) {
69
-                    $item_url  = esc_url( $item->get_permalink() );
68
+                foreach ($rss_items as $item) {
69
+                    $item_url  = esc_url($item->get_permalink());
70 70
                     $enclosure = $item->get_enclosure();
71 71
 
72 72
                     $output .= '<li class="itemDetail">';
73
-                    $output .= '<h3 class="itemTitle"><a href="' . $item_url . '" target="_blank">' . esc_html( $item->get_title() ) . '</a></h3>';
73
+                    $output .= '<h3 class="itemTitle"><a href="'.$item_url.'" target="_blank">'.esc_html($item->get_title()).'</a></h3>';
74 74
 
75
-                    if ( $enclosure && ( false !== strpos( $enclosure->get_type(), 'image' ) ) ) {
76
-                        $img_url = esc_url( $enclosure->get_link() );
77
-                        $output .= '<div class="itemImage"><a href="' . $item_url . '" target="_blank"><img src="' . $img_url . '"></a></div>';
75
+                    if ($enclosure && (false !== strpos($enclosure->get_type(), 'image'))) {
76
+                        $img_url = esc_url($enclosure->get_link());
77
+                        $output .= '<div class="itemImage"><a href="'.$item_url.'" target="_blank"><img src="'.$img_url.'"></a></div>';
78 78
                     }
79 79
 
80
-                    $output .= '<div class="itemDescription">' . wp_kses_post( $item->get_description() ) . '</div>';
81
-                    $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="' . $item_url . '" target="_blank">' . __( 'More info', 'autoptimize' ) . '</a></div></div>';
80
+                    $output .= '<div class="itemDescription">'.wp_kses_post($item->get_description()).'</div>';
81
+                    $output .= '<div class="itemButtonRow"><div class="itemButton button-secondary"><a href="'.$item_url.'" target="_blank">'.__('More info', 'autoptimize').'</a></div></div>';
82 82
                     $output .= '</li>';
83 83
                 }
84 84
                 $output .= '</ul>';
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
         color: #23282d;
137 137
     }
138 138
     </style>
139
-    <script>document.title = "Autoptimize: <?php _e( 'Optimize More!', 'autoptimize' ); ?> " + document.title;</script>
139
+    <script>document.title = "Autoptimize: <?php _e('Optimize More!', 'autoptimize'); ?> " + document.title;</script>
140 140
     <div class="wrap">
141
-        <h1><?php _e( 'Autoptimize Settings', 'autoptimize' ); ?></h1>
141
+        <h1><?php _e('Autoptimize Settings', 'autoptimize'); ?></h1>
142 142
         <?php echo autoptimizeConfig::ao_admin_tabs(); ?>
143
-        <?php echo '<h2>' . __( "These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize' ) . '</h2>'; ?>
143
+        <?php echo '<h2>'.__("These Autoptimize power-ups and related services will improve your site's performance even more!", 'autoptimize').'</h2>'; ?>
144 144
         <div>
145 145
             <?php echo $this->get_ao_partner_feed_markup(); ?>
146 146
         </div>
Please login to merge, or discard this patch.
classes/autoptimizeOptionWrapper.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Autoptimize options handler.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
      * Ensure that is_plugin_active_for_network function is declared.
22 22
      */
23 23
     public static function maybe_include_plugin_functions() {
24
-        if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
25
-            include_once ABSPATH . 'wp-admin/includes/plugin.php';
24
+        if (!function_exists('is_plugin_active_for_network')) {
25
+            include_once ABSPATH.'wp-admin/includes/plugin.php';
26 26
         }
27 27
     }
28 28
 
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
      * @param mixed  $default Optional. Default value to return if the option does not exist.
34 34
      * @return mixed Value set for the option.
35 35
      */
36
-    public static function get_option( $option, $default = false ) {
36
+    public static function get_option($option, $default = false) {
37 37
         // This is always a network setting, it is on by default to ensure settings are available at site level unless explicitly turned off.
38
-        if ( 'autoptimize_enable_site_config' === $option ) {
39
-            return get_network_option( get_main_network_id(), $option, 'on' );
38
+        if ('autoptimize_enable_site_config' === $option) {
39
+            return get_network_option(get_main_network_id(), $option, 'on');
40 40
         }
41 41
 
42 42
         // If the plugin is network activated and our per site setting is not on, use the network configuration.
43
-        $configuration_per_site = get_network_option( get_main_network_id(), 'autoptimize_enable_site_config', 'on' );
44
-        if ( self::is_ao_active_for_network() && ( 'on' !== $configuration_per_site || is_network_admin() ) ) {
45
-            return get_network_option( get_main_network_id(), $option, $default );
43
+        $configuration_per_site = get_network_option(get_main_network_id(), 'autoptimize_enable_site_config', 'on');
44
+        if (self::is_ao_active_for_network() && ('on' !== $configuration_per_site || is_network_admin())) {
45
+            return get_network_option(get_main_network_id(), $option, $default);
46 46
         }
47 47
 
48
-        return get_option( $option, $default );
48
+        return get_option($option, $default);
49 49
     }
50 50
 
51 51
     /**
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
      *                              the default value is 'yes'. Default null.
60 60
      * @return bool False if value was not updated and true if value was updated.
61 61
      */
62
-    public static function update_option( $option, $value, $autoload = null ) {
63
-        if ( self::is_ao_active_for_network() && is_network_admin() ) {
64
-            return update_network_option( get_main_network_id(), $option, $value );
65
-        } elseif ( 'autoptimize_enable_site_config' !== $option ) {
66
-            return update_option( $option, $value, $autoload );
62
+    public static function update_option($option, $value, $autoload = null) {
63
+        if (self::is_ao_active_for_network() && is_network_admin()) {
64
+            return update_network_option(get_main_network_id(), $option, $value);
65
+        } elseif ('autoptimize_enable_site_config' !== $option) {
66
+            return update_option($option, $value, $autoload);
67 67
         }
68 68
     }
69 69
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
      * in that case, take care of multisite case.
73 73
      */
74 74
     public static function check_multisite_on_saving_options() {
75
-        if ( self::is_ao_active_for_network() ) {
76
-            add_filter( 'pre_update_option', 'autoptimizeOptionWrapper::update_autoptimize_option_on_network', 10, 3 );
75
+        if (self::is_ao_active_for_network()) {
76
+            add_filter('pre_update_option', 'autoptimizeOptionWrapper::update_autoptimize_option_on_network', 10, 3);
77 77
         }
78 78
     }
79 79
 
@@ -84,16 +84,16 @@  discard block
 block discarded – undo
84 84
      * @param string $option    Option name.
85 85
      * @param string $old_value Old value.
86 86
      */
87
-    public static function update_autoptimize_option_on_network( $value, $option, $old_value ) {
88
-        if ( strpos( $option, 'autoptimize_' ) === 0 && self::is_options_from_network_admin() ) {
89
-            if ( self::is_ao_active_for_network() ) {
90
-                update_network_option( get_main_network_id(), $option, $value );
87
+    public static function update_autoptimize_option_on_network($value, $option, $old_value) {
88
+        if (strpos($option, 'autoptimize_') === 0 && self::is_options_from_network_admin()) {
89
+            if (self::is_ao_active_for_network()) {
90
+                update_network_option(get_main_network_id(), $option, $value);
91 91
                 // Return old value, to stop update_option logic.
92 92
                 return $old_value;
93 93
             }
94
-            if ( apply_filters( 'autoptimize_filter_optionwrapper_wp_cache_delete', false ) ) {
94
+            if (apply_filters('autoptimize_filter_optionwrapper_wp_cache_delete', false)) {
95 95
                 // in some (rare) cases options seem to get stuck in WP's Object cache, this should clear it there.
96
-                wp_cache_delete( $option );
96
+                wp_cache_delete($option);
97 97
             }
98 98
         }
99 99
         return $value;
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
     public static function is_options_from_network_admin() {
108 108
         static $_really_is_network_admin = null;
109 109
 
110
-        if ( null === $_really_is_network_admin ) {
111
-            if ( array_key_exists( '_wp_http_referer', $_POST ) && strpos( network_admin_url( 'settings.php' ), strtok( $_POST['_wp_http_referer'], '?' ) ) !== false ) {
110
+        if (null === $_really_is_network_admin) {
111
+            if (array_key_exists('_wp_http_referer', $_POST) && strpos(network_admin_url('settings.php'), strtok($_POST['_wp_http_referer'], '?')) !== false) {
112 112
                 $_really_is_network_admin = true;
113 113
             } else {
114 114
                 $_really_is_network_admin = false;
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function is_ao_active_for_network() {
125 125
         static $_is_ao_active_for_network = null;
126
-        if ( null === $_is_ao_active_for_network || defined( 'TEST_MULTISITE_FORCE_AO_ON_NETWORK' ) ) {
126
+        if (null === $_is_ao_active_for_network || defined('TEST_MULTISITE_FORCE_AO_ON_NETWORK')) {
127 127
             self::maybe_include_plugin_functions();
128
-            if ( is_plugin_active_for_network( 'autoptimize/autoptimize.php' ) || is_plugin_active_for_network( 'autoptimize-beta/autoptimize.php' ) || defined( 'TEST_MULTISITE_FORCE_AO_ON_NETWORK' ) ) {
128
+            if (is_plugin_active_for_network('autoptimize/autoptimize.php') || is_plugin_active_for_network('autoptimize-beta/autoptimize.php') || defined('TEST_MULTISITE_FORCE_AO_ON_NETWORK')) {
129 129
                 $_is_ao_active_for_network = true;
130 130
             } else {
131 131
                 $_is_ao_active_for_network = false;
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_impexp.js.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
     console.log('Exporting...');
10 10
     var data = {
11 11
         'action': 'ao_ccss_export',
12
-        'ao_ccss_export_nonce': '<?php echo wp_create_nonce( 'ao_ccss_export_nonce' ); ?>',
12
+        'ao_ccss_export_nonce': '<?php echo wp_create_nonce('ao_ccss_export_nonce'); ?>',
13 13
     };
14 14
 
15 15
     jQuery.post(ajaxurl, data, function(response) {
16 16
         response_array=JSON.parse(response);
17 17
         if (response_array['code'] == 200) {
18 18
             <?php
19
-            if ( is_multisite() ) {
20
-                $blog_id = '/' . get_current_blog_id() . '/';
19
+            if (is_multisite()) {
20
+                $blog_id = '/'.get_current_blog_id().'/';
21 21
             } else {
22 22
                 $blog_id = '/';
23 23
             }
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             autoOpen: true,
33 33
             height: 210,
34 34
             width: 700,
35
-            title: "<?php _e( 'Export settings result', 'autoptimize' ); ?>",
35
+            title: "<?php _e('Export settings result', 'autoptimize'); ?>",
36 36
             modal: true,
37 37
             buttons: {
38 38
                 OK: function() {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     var settings_file = file[0].files[0];
51 51
     fd.append('file', settings_file);
52 52
     fd.append('action', 'ao_ccss_import');
53
-    fd.append('ao_ccss_import_nonce', '<?php echo wp_create_nonce( 'ao_ccss_import_nonce' ); ?>');
53
+    fd.append('ao_ccss_import_nonce', '<?php echo wp_create_nonce('ao_ccss_import_nonce'); ?>');
54 54
 
55 55
     jQuery.ajax({
56 56
         url: ajaxurl,
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_debug.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $ao_options = $wpdb->get_results('
11 11
   SELECT option_name  AS name,
12 12
          option_value AS value
13
-  FROM ' . $wpdb->options . '
13
+  FROM ' . $wpdb->options.'
14 14
   WHERE option_name LIKE "autoptimize_%%"
15 15
   ORDER BY name
16 16
 ', ARRAY_A);
@@ -19,27 +19,27 @@  discard block
 block discarded – undo
19 19
 $ao_trans = $wpdb->get_results('
20 20
   SELECT option_name  AS name,
21 21
          option_value AS value
22
-  FROM ' . $wpdb->options . '
22
+  FROM ' . $wpdb->options.'
23 23
   WHERE option_name LIKE "_transient_autoptimize_%%"
24 24
      OR option_name LIKE "_transient_timeout_autoptimize_%%"
25 25
 ', ARRAY_A);
26 26
 
27 27
 // Render debug panel if there's something to show.
28
-if ( $ao_options || $ao_trans ) {
28
+if ($ao_options || $ao_trans) {
29 29
 ?>
30 30
 <!-- BEGIN: Settings Debug -->
31 31
 <ul>
32 32
     <li class="itemDetail">
33
-        <h2 class="itemTitle"><?php _e( 'Debug Information', 'autoptimize' ); ?></h2>
33
+        <h2 class="itemTitle"><?php _e('Debug Information', 'autoptimize'); ?></h2>
34 34
 
35 35
         <?php
36 36
         // Render options.
37
-        if ( $ao_options ) {
37
+        if ($ao_options) {
38 38
         ?>
39
-            <h4><?php _e( 'Options', 'autoptimize' ); ?>:</h4>
39
+            <h4><?php _e('Options', 'autoptimize'); ?>:</h4>
40 40
             <table class="form-table debug">
41 41
             <?php
42
-            foreach ( $ao_options as $option ) {
42
+            foreach ($ao_options as $option) {
43 43
             ?>
44 44
                 <tr>
45 45
                     <th scope="row">
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
                     </th>
48 48
                     <td>
49 49
                         <?php
50
-                        if ( 'autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name'] ) {
51
-                            $value = print_r( json_decode( $option['value'], true ), true );
52
-                            if ( $value ) {
53
-                                echo "Raw JSON:\n<pre>" . $option['value'] . "</pre>\n\nDecoded JSON:\n<pre>" . $value . '</pre>';
50
+                        if ('autoptimize_ccss_queue' == $option['name'] || 'autoptimize_ccss_rules' == $option['name']) {
51
+                            $value = print_r(json_decode($option['value'], true), true);
52
+                            if ($value) {
53
+                                echo "Raw JSON:\n<pre>".$option['value']."</pre>\n\nDecoded JSON:\n<pre>".$value.'</pre>';
54 54
                             } else {
55 55
                                 echo 'Empty';
56 56
                             }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
         }
70 70
         // Render WP-Cron intervals and scheduled events.
71 71
         ?>
72
-        <h4><?php _e( 'WP-Cron Intervals', 'autoptimize' ); ?>:</h4>
73
-        <pre><?php print_r( wp_get_schedules() ); ?></pre>
72
+        <h4><?php _e('WP-Cron Intervals', 'autoptimize'); ?>:</h4>
73
+        <pre><?php print_r(wp_get_schedules()); ?></pre>
74 74
         <hr />
75
-        <h4><?php _e( 'WP-Cron Scheduled Events', 'autoptimize' ); ?>:</h4>
76
-        <pre><?php print_r( _get_cron_array() ); ?></pre>
75
+        <h4><?php _e('WP-Cron Scheduled Events', 'autoptimize'); ?>:</h4>
76
+        <pre><?php print_r(_get_cron_array()); ?></pre>
77 77
     </li>
78 78
 </ul>
79 79
 <!-- END: Settings Debug -->
Please login to merge, or discard this patch.
classes/autoptimizeUtils.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * General helpers.
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
     exit;
8 8
 }
9 9
 
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return bool
18 18
      */
19
-    public static function mbstring_available( $override = null )
19
+    public static function mbstring_available($override = null)
20 20
     {
21 21
         static $available = null;
22 22
 
23
-        if ( null === $available ) {
24
-            $available = \extension_loaded( 'mbstring' );
23
+        if (null === $available) {
24
+            $available = \extension_loaded('mbstring');
25 25
         }
26 26
 
27
-        if ( null !== $override ) {
27
+        if (null !== $override) {
28 28
             $available = $override;
29 29
         }
30 30
 
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return int|false
44 44
      */
45
-    public static function strpos( $haystack, $needle, $offset = 0, $encoding = null )
45
+    public static function strpos($haystack, $needle, $offset = 0, $encoding = null)
46 46
     {
47
-        if ( self::mbstring_available() ) {
48
-            return ( null === $encoding ) ? \mb_strpos( $haystack, $needle, $offset ) : \mb_strpos( $haystack, $needle, $offset, $encoding );
47
+        if (self::mbstring_available()) {
48
+            return (null === $encoding) ? \mb_strpos($haystack, $needle, $offset) : \mb_strpos($haystack, $needle, $offset, $encoding);
49 49
         } else {
50
-            return \strpos( $haystack, $needle, $offset );
50
+            return \strpos($haystack, $needle, $offset);
51 51
         }
52 52
     }
53 53
 
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
      * @return int Number of characters or bytes in given $string
63 63
      *             (characters if/when supported, bytes otherwise).
64 64
      */
65
-    public static function strlen( $string, $encoding = null )
65
+    public static function strlen($string, $encoding = null)
66 66
     {
67
-        if ( self::mbstring_available() ) {
68
-            return ( null === $encoding ) ? \mb_strlen( $string ) : \mb_strlen( $string, $encoding );
67
+        if (self::mbstring_available()) {
68
+            return (null === $encoding) ? \mb_strlen($string) : \mb_strlen($string, $encoding);
69 69
         } else {
70
-            return \strlen( $string );
70
+            return \strlen($string);
71 71
         }
72 72
     }
73 73
 
@@ -85,44 +85,44 @@  discard block
 block discarded – undo
85 85
      *
86 86
      * @return string
87 87
      */
88
-    public static function substr_replace( $string, $replacement, $start, $length = null, $encoding = null )
88
+    public static function substr_replace($string, $replacement, $start, $length = null, $encoding = null)
89 89
     {
90
-        if ( self::mbstring_available() ) {
91
-            $strlen = self::strlen( $string, $encoding );
90
+        if (self::mbstring_available()) {
91
+            $strlen = self::strlen($string, $encoding);
92 92
 
93
-            if ( $start < 0 ) {
93
+            if ($start < 0) {
94 94
                 if ( -$start < $strlen ) {
95 95
                     $start = $strlen + $start;
96 96
                 } else {
97 97
                     $start = 0;
98 98
                 }
99
-            } elseif ( $start > $strlen ) {
99
+            } elseif ($start > $strlen) {
100 100
                 $start = $strlen;
101 101
             }
102 102
 
103
-            if ( null === $length || '' === $length ) {
103
+            if (null === $length || '' === $length) {
104 104
                 $start2 = $strlen;
105
-            } elseif ( $length < 0 ) {
105
+            } elseif ($length < 0) {
106 106
                 $start2 = $strlen + $length;
107
-                if ( $start2 < $start ) {
107
+                if ($start2 < $start) {
108 108
                     $start2 = $start;
109 109
                 }
110 110
             } else {
111 111
                 $start2 = $start + $length;
112 112
             }
113 113
 
114
-            if ( null === $encoding ) {
115
-                $leader  = $start ? \mb_substr( $string, 0, $start ) : '';
116
-                $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null ) : '';
114
+            if (null === $encoding) {
115
+                $leader  = $start ? \mb_substr($string, 0, $start) : '';
116
+                $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null) : '';
117 117
             } else {
118
-                $leader  = $start ? \mb_substr( $string, 0, $start, $encoding ) : '';
119
-                $trailer = ( $start2 < $strlen ) ? \mb_substr( $string, $start2, null, $encoding ) : '';
118
+                $leader  = $start ? \mb_substr($string, 0, $start, $encoding) : '';
119
+                $trailer = ($start2 < $strlen) ? \mb_substr($string, $start2, null, $encoding) : '';
120 120
             }
121 121
 
122 122
             return "{$leader}{$replacement}{$trailer}";
123 123
         }
124 124
 
125
-        return ( null === $length ) ? \substr_replace( $string, $replacement, $start ) : \substr_replace( $string, $replacement, $start, $length );
125
+        return (null === $length) ? \substr_replace($string, $replacement, $start) : \substr_replace($string, $replacement, $start, $length);
126 126
     }
127 127
 
128 128
     /**
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
      *
133 133
      * @return bool
134 134
      */
135
-    public static function siteurl_not_root( $override = null )
135
+    public static function siteurl_not_root($override = null)
136 136
     {
137 137
         static $subdir = null;
138 138
 
139
-        if ( null === $subdir ) {
139
+        if (null === $subdir) {
140 140
             $parts  = self::get_ao_wp_site_url_parts();
141
-            $subdir = ( isset( $parts['path'] ) && ( '/' !== $parts['path'] ) );
141
+            $subdir = (isset($parts['path']) && ('/' !== $parts['path']));
142 142
         }
143 143
 
144
-        if ( null !== $override ) {
144
+        if (null !== $override) {
145 145
             $subdir = $override;
146 146
         }
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     {
159 159
         static $parts = array();
160 160
 
161
-        if ( empty( $parts ) ) {
162
-            $parts = \parse_url( AUTOPTIMIZE_WP_SITE_URL );
161
+        if (empty($parts)) {
162
+            $parts = \parse_url(AUTOPTIMIZE_WP_SITE_URL);
163 163
         }
164 164
 
165 165
         return $parts;
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @return string
176 176
      */
177
-    public static function tweak_cdn_url_if_needed( $cdn_url, $force_cache_miss = false )
177
+    public static function tweak_cdn_url_if_needed($cdn_url, $force_cache_miss = false)
178 178
     {
179 179
         static $results = array();
180 180
 
181
-        if ( ! isset( $results[ $cdn_url ] ) || $force_cache_miss ) {
181
+        if (!isset($results[$cdn_url]) || $force_cache_miss) {
182 182
 
183 183
             // In order to return unmodified input when there's no need to tweak.
184
-            $results[ $cdn_url ] = $cdn_url;
184
+            $results[$cdn_url] = $cdn_url;
185 185
 
186 186
             // Behind a default true filter for backcompat, and only for sites
187 187
             // in a subfolder/subdirectory, but still easily turned off if
188 188
             // not wanted/needed...
189
-            if ( autoptimizeUtils::siteurl_not_root() ) {
190
-                $check = apply_filters( 'autoptimize_filter_cdn_magic_path_check', true, $cdn_url );
191
-                if ( $check ) {
189
+            if (autoptimizeUtils::siteurl_not_root()) {
190
+                $check = apply_filters('autoptimize_filter_cdn_magic_path_check', true, $cdn_url);
191
+                if ($check) {
192 192
                     $site_url_parts = autoptimizeUtils::get_ao_wp_site_url_parts();
193
-                    $cdn_url_parts  = \parse_url( $cdn_url );
194
-                    $schemeless     = self::is_protocol_relative( $cdn_url );
195
-                    $cdn_url_parts  = self::maybe_replace_cdn_path( $site_url_parts, $cdn_url_parts );
196
-                    if ( false !== $cdn_url_parts ) {
197
-                        $results[ $cdn_url ] = self::assemble_parsed_url( $cdn_url_parts, $schemeless );
193
+                    $cdn_url_parts  = \parse_url($cdn_url);
194
+                    $schemeless     = self::is_protocol_relative($cdn_url);
195
+                    $cdn_url_parts  = self::maybe_replace_cdn_path($site_url_parts, $cdn_url_parts);
196
+                    if (false !== $cdn_url_parts) {
197
+                        $results[$cdn_url] = self::assemble_parsed_url($cdn_url_parts, $schemeless);
198 198
                     }
199 199
                 }
200 200
             }
201 201
         }
202 202
 
203
-        return $results[ $cdn_url ];
203
+        return $results[$cdn_url];
204 204
     }
205 205
 
206 206
     /**
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @return array|false
216 216
      */
217
-    public static function maybe_replace_cdn_path( array $site_url_parts, array $cdn_url_parts )
217
+    public static function maybe_replace_cdn_path(array $site_url_parts, array $cdn_url_parts)
218 218
     {
219
-        if ( isset( $site_url_parts['path'] ) && '/' !== $site_url_parts['path'] ) {
220
-            if ( ! isset( $cdn_url_parts['path'] ) || '/' === $cdn_url_parts['path'] ) {
219
+        if (isset($site_url_parts['path']) && '/' !== $site_url_parts['path']) {
220
+            if (!isset($cdn_url_parts['path']) || '/' === $cdn_url_parts['path']) {
221 221
                 $cdn_url_parts['path'] = $site_url_parts['path'];
222 222
                 return $cdn_url_parts;
223 223
             }
@@ -237,20 +237,20 @@  discard block
 block discarded – undo
237 237
      *
238 238
      * @return string
239 239
      */
240
-    public static function assemble_parsed_url( array $parsed_url, $schemeless = false )
240
+    public static function assemble_parsed_url(array $parsed_url, $schemeless = false)
241 241
     {
242
-        $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
243
-        if ( $schemeless ) {
242
+        $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
243
+        if ($schemeless) {
244 244
             $scheme = '//';
245 245
         }
246
-        $host     = isset( $parsed_url['host'] ) ? $parsed_url['host'] : '';
247
-        $port     = isset( $parsed_url['port'] ) ? ':' . $parsed_url['port'] : '';
248
-        $user     = isset( $parsed_url['user'] ) ? $parsed_url['user'] : '';
249
-        $pass     = isset( $parsed_url['pass'] ) ? ':' . $parsed_url['pass'] : '';
250
-        $pass     = ( $user || $pass ) ? "$pass@" : '';
251
-        $path     = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
252
-        $query    = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
253
-        $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
246
+        $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
247
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
248
+        $user     = isset($parsed_url['user']) ? $parsed_url['user'] : '';
249
+        $pass     = isset($parsed_url['pass']) ? ':'.$parsed_url['pass'] : '';
250
+        $pass     = ($user || $pass) ? "$pass@" : '';
251
+        $path     = isset($parsed_url['path']) ? $parsed_url['path'] : '';
252
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
253
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
254 254
 
255 255
         return "$scheme$user$pass$host$port$path$query$fragment";
256 256
     }
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
      *
263 263
      * @return bool
264 264
      */
265
-    public static function is_protocol_relative( $url )
265
+    public static function is_protocol_relative($url)
266 266
     {
267 267
         $result = false;
268 268
 
269
-        if ( ! empty( $url ) ) {
270
-            $result = ( 0 === strpos( $url, '//' ) );
269
+        if (!empty($url)) {
270
+            $result = (0 === strpos($url, '//'));
271 271
         }
272 272
 
273 273
         return $result;
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @return string
282 282
      */
283
-    public static function path_canonicalize( $path )
283
+    public static function path_canonicalize($path)
284 284
     {
285
-        $patterns     = array(
285
+        $patterns = array(
286 286
             '~/{2,}~',
287 287
             '~/(\./)+~',
288 288
             '~([^/\.]+/(?R)*\.{2,}/)~',
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             '',
296 296
         );
297 297
 
298
-        return preg_replace( $patterns, $replacements, $path );
298
+        return preg_replace($patterns, $replacements, $path);
299 299
     }
300 300
 
301 301
     /**
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
      *
308 308
      * @return null|array Service status or null.
309 309
      */
310
-    public static function check_service_availability( $return_result = false )
310
+    public static function check_service_availability($return_result = false)
311 311
     {
312
-        $service_availability_resp = wp_remote_get( 'https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver=' . AUTOPTIMIZE_PLUGIN_VERSION );
313
-        if ( ! is_wp_error( $service_availability_resp ) ) {
314
-            if ( '200' == wp_remote_retrieve_response_code( $service_availability_resp ) ) {
315
-                $availabilities = json_decode( wp_remote_retrieve_body( $service_availability_resp ), true );
316
-                if ( is_array( $availabilities ) ) {
317
-                    autoptimizeOptionWrapper::update_option( 'autoptimize_service_availablity', $availabilities );
318
-                    if ( $return_result ) {
312
+        $service_availability_resp = wp_remote_get('https://misc.optimizingmatters.com/api/autoptimize_service_availablity.json?from=aomain&ver='.AUTOPTIMIZE_PLUGIN_VERSION);
313
+        if (!is_wp_error($service_availability_resp)) {
314
+            if ('200' == wp_remote_retrieve_response_code($service_availability_resp)) {
315
+                $availabilities = json_decode(wp_remote_retrieve_body($service_availability_resp), true);
316
+                if (is_array($availabilities)) {
317
+                    autoptimizeOptionWrapper::update_option('autoptimize_service_availablity', $availabilities);
318
+                    if ($return_result) {
319 319
                         return $availabilities;
320 320
                     }
321 321
                 }
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
      *
332 332
      * @return bool
333 333
      */
334
-    public static function str_is_valid_regex( $string )
334
+    public static function str_is_valid_regex($string)
335 335
     {
336
-        set_error_handler( function() {}, E_WARNING );
337
-        $is_regex = ( false !== preg_match( $string, '' ) );
336
+        set_error_handler(function() {}, E_WARNING);
337
+        $is_regex = (false !== preg_match($string, ''));
338 338
         restore_error_handler();
339 339
 
340 340
         return $is_regex;
@@ -347,17 +347,17 @@  discard block
 block discarded – undo
347 347
      *
348 348
      * @return bool
349 349
      */
350
-    public static function is_plugin_active( $plugin_file )
350
+    public static function is_plugin_active($plugin_file)
351 351
     {
352 352
         static $ipa_exists = null;
353
-        if ( null === $ipa_exists ) {
354
-            if ( ! function_exists( '\is_plugin_active' ) ) {
355
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
353
+        if (null === $ipa_exists) {
354
+            if (!function_exists('\is_plugin_active')) {
355
+                require_once ABSPATH.'wp-admin/includes/plugin.php';
356 356
             }
357
-            $ipa_exists = function_exists( '\is_plugin_active' );
357
+            $ipa_exists = function_exists('\is_plugin_active');
358 358
         }
359 359
 
360
-        return $ipa_exists && \is_plugin_active( $plugin_file );
360
+        return $ipa_exists && \is_plugin_active($plugin_file);
361 361
     }
362 362
 
363 363
     /**
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
      *
368 368
      * @return string
369 369
      */
370
-    public static function remove_id_from_node( $node ) {
371
-        if ( strpos( $node, 'id=' ) === false || apply_filters( 'autoptimize_filter_utils_keep_ids', false ) ) {
370
+    public static function remove_id_from_node($node) {
371
+        if (strpos($node, 'id=') === false || apply_filters('autoptimize_filter_utils_keep_ids', false)) {
372 372
             return $node;
373 373
         } else {
374
-            return preg_replace( '#(.*) id=[\'|"].*[\'|"] (.*)#Um', '$1 $2', $node );
374
+            return preg_replace('#(.*) id=[\'|"].*[\'|"] (.*)#Um', '$1 $2', $node);
375 375
         }
376 376
     }
377 377
 
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
      *
384 384
      * @return bool
385 385
      */
386
-    public static function str_ends_in( $str, $test )
386
+    public static function str_ends_in($str, $test)
387 387
     {
388 388
         // @codingStandardsIgnoreStart
389 389
         // substr_compare() is bugged on 5.5.11: https://3v4l.org/qGYBH
390 390
         // return ( 0 === substr_compare( $str, $test, -strlen( $test ) ) );
391 391
         // @codingStandardsIgnoreEnd
392 392
 
393
-        $length = strlen( $test );
393
+        $length = strlen($test);
394 394
 
395
-        return ( substr( $str, -$length, $length ) === $test );
395
+        return (substr($str, -$length, $length) === $test);
396 396
     }
397 397
 }
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_queue.js.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
                                 "empty" :
21 21
                                 aoCssQueue;
22 22
         <?php
23
-        if ( $ao_ccss_debug ) {
23
+        if ($ao_ccss_debug) {
24 24
             echo "console.log( 'Queue Object:', aoCssQueueLog );\n";
25 25
         }
26 26
         ?>
@@ -62,34 +62,34 @@  discard block
 block discarded – undo
62 62
             // Status: NEW (N, sort order 1)
63 63
             status      = '<span class="hidden">1</span>N';
64 64
             statusClass = 'new';
65
-            title       = '<?php _e( 'New', 'autoptimize' ); ?> (' + ljid + ')';
66
-            buttons     = '<?php _e( 'None', 'autoptimize' ); ?>';
65
+            title       = '<?php _e('New', 'autoptimize'); ?> (' + ljid + ')';
66
+            buttons     = '<?php _e('None', 'autoptimize'); ?>';
67 67
         } else if (keys.jqstat === 'JOB_QUEUED' || keys.jqstat === 'JOB_ONGOING') {
68 68
             // Status: PENDING (P, sort order 2)
69 69
             status      = '<span class="hidden">2</span>P';
70 70
             statusClass = 'pending';
71
-            title       = '<?php _e( 'PENDING', 'autoptimize' ); ?> (' + ljid + ')';
72
-            buttons     = '<?php _e( 'None', 'autoptimize' ); ?>';
71
+            title       = '<?php _e('PENDING', 'autoptimize'); ?> (' + ljid + ')';
72
+            buttons     = '<?php _e('None', 'autoptimize'); ?>';
73 73
         } else if (keys.jqstat === 'JOB_DONE' && keys.jrstat === 'GOOD' && (keys.jvstat === 'WARN' || keys.jvstat === 'BAD')) {
74 74
             // Status: REVIEW (R, sort order 5)
75 75
             status      = '<span class="hidden">5</span>R';
76 76
             statusClass = 'review';
77
-            title       = "<?php _e( 'REVIEW', 'autoptimize' ); ?> (" + ljid + ")\n<?php _e( 'Info from criticalcss.com:', 'autoptimize' ); ?>\n<?php _e( '- Job ID: ', 'autoptimize' ); ?>" + keys.jid + "\n<?php _e( '- Status: ', 'autoptimize' ); ?>" + keys.jqstat + "\n<?php _e( '- Result: ', 'autoptimize' ); ?>" + keys.jrstat + "\n<?php _e( '- Validation: ', 'autoptimize' ); ?>" + keys.jvstat;
78
-            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>"><span class="dashicons dashicons-trash"></span></span>';
77
+            title       = "<?php _e('REVIEW', 'autoptimize'); ?> (" + ljid + ")\n<?php _e('Info from criticalcss.com:', 'autoptimize'); ?>\n<?php _e('- Job ID: ', 'autoptimize'); ?>" + keys.jid + "\n<?php _e('- Status: ', 'autoptimize'); ?>" + keys.jqstat + "\n<?php _e('- Result: ', 'autoptimize'); ?>" + keys.jrstat + "\n<?php _e('- Validation: ', 'autoptimize'); ?>" + keys.jvstat;
78
+            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e('Delete Job', 'autoptimize'); ?>"><span class="dashicons dashicons-trash"></span></span>';
79 79
             dbtn        = true;
80 80
         } else if (keys.jqstat === 'JOB_DONE') {
81 81
             // Status: DONE (D, sort order 6)
82 82
             status      = '<span class="hidden">6</span>D';
83 83
             statusClass = 'done';
84
-            title       = '<?php _e( 'DONE', 'autoptimize' ); ?> (' + ljid + ')';
85
-            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>"><span class="dashicons dashicons-trash"></span></span>';
84
+            title       = '<?php _e('DONE', 'autoptimize'); ?> (' + ljid + ')';
85
+            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e('Delete Job', 'autoptimize'); ?>"><span class="dashicons dashicons-trash"></span></span>';
86 86
             dbtn        = true;
87 87
         } else if (keys.jqstat === 'JOB_FAILED' || keys.jqstat === 'STATUS_JOB_BAD' || keys.jqstat === 'INVALID_JWT_TOKEN' || keys.jqstat === 'NO_CSS' || keys.jqstat === 'NO_RESPONSE') {
88 88
         // Status: ERROR (E, sort order 4)
89 89
             status      = '<span class="hidden">4</span>E';
90 90
             statusClass = 'error';
91
-            title       = "<?php _e( 'ERROR', 'autoptimize' ); ?> (" + ljid + ")\n<?php _e( 'Info from criticalcss.com:', 'autoptimize' ); ?>\n<?php _e( '- Job ID: ', 'autoptimize' ); ?>" + keys.jid + "\n<?php _e( '- Status: ', 'autoptimize' ); ?>" + keys.jqstat + "\n<?php _e( '- Result: ', 'autoptimize' ); ?>" + keys.jrstat + "\n<?php _e( '- Validation: ', 'autoptimize' ); ?>" + keys.jvstat;
92
-            buttons     = '<span class="button-secondary" id="' + ljid + '_retry" title="<?php _e( 'Retry Job', 'autoptimize' ); ?>"><span class="dashicons dashicons-update"></span></span><span class="button-secondary to-right" id="' + ljid + '_remove" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>"><span class="dashicons dashicons-trash"></span></span><span class="button-secondary to-right" id="' + ljid + '_help" title="<?php _e( 'Get Help', 'autoptimize' ); ?>"><span class="dashicons dashicons-sos"></span></span>';
91
+            title       = "<?php _e('ERROR', 'autoptimize'); ?> (" + ljid + ")\n<?php _e('Info from criticalcss.com:', 'autoptimize'); ?>\n<?php _e('- Job ID: ', 'autoptimize'); ?>" + keys.jid + "\n<?php _e('- Status: ', 'autoptimize'); ?>" + keys.jqstat + "\n<?php _e('- Result: ', 'autoptimize'); ?>" + keys.jrstat + "\n<?php _e('- Validation: ', 'autoptimize'); ?>" + keys.jvstat;
92
+            buttons     = '<span class="button-secondary" id="' + ljid + '_retry" title="<?php _e('Retry Job', 'autoptimize'); ?>"><span class="dashicons dashicons-update"></span></span><span class="button-secondary to-right" id="' + ljid + '_remove" title="<?php _e('Delete Job', 'autoptimize'); ?>"><span class="dashicons dashicons-trash"></span></span><span class="button-secondary to-right" id="' + ljid + '_help" title="<?php _e('Get Help', 'autoptimize'); ?>"><span class="dashicons dashicons-sos"></span></span>';
93 93
             rbtn        = true;
94 94
             dbtn        = true;
95 95
             hbtn        = true;
@@ -97,21 +97,21 @@  discard block
 block discarded – undo
97 97
             // Status: UNKNOWN (U, sort order 5)
98 98
             status      = '<span class="hidden">5</span>U';
99 99
             statusClass = 'unknown';
100
-            title       = "<?php _e( 'UNKNOWN', 'autoptimize' ); ?> (" + ljid + ")\n<?php _e( 'Info from criticalcss.com:', 'autoptimize' ); ?>\n<?php _e( '- Job ID: ', 'autoptimize' ); ?>" + keys.jid + "\n<?php _e( '- Status: ', 'autoptimize' ); ?>" + keys.jqstat + "\n<?php _e( '- Result: ', 'autoptimize' ); ?>" + keys.jrstat + "\n<?php _e( '- Validation: ', 'autoptimize' ); ?>" + keys.jvstat;
101
-            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>"><span class="dashicons dashicons-trash"></span></span><span class="button-secondary to-right" id="' + ljid + '_help" title="<?php _e( 'Get Help', 'autoptimize' ); ?>"><span class="dashicons dashicons-sos"></span></span>';
100
+            title       = "<?php _e('UNKNOWN', 'autoptimize'); ?> (" + ljid + ")\n<?php _e('Info from criticalcss.com:', 'autoptimize'); ?>\n<?php _e('- Job ID: ', 'autoptimize'); ?>" + keys.jid + "\n<?php _e('- Status: ', 'autoptimize'); ?>" + keys.jqstat + "\n<?php _e('- Result: ', 'autoptimize'); ?>" + keys.jrstat + "\n<?php _e('- Validation: ', 'autoptimize'); ?>" + keys.jvstat;
101
+            buttons     = '<span class="button-secondary" id="' + ljid + '_remove" title="<?php _e('Delete Job', 'autoptimize'); ?>"><span class="dashicons dashicons-trash"></span></span><span class="button-secondary to-right" id="' + ljid + '_help" title="<?php _e('Get Help', 'autoptimize'); ?>"><span class="dashicons dashicons-sos"></span></span>';
102 102
             dbtn        = true;
103 103
             hbtn        = true;
104 104
         }
105 105
 
106 106
         // Prepare job finish time
107 107
         if (keys.jftime === null) {
108
-            ftime = '<?php _e( 'N/A', 'autoptimize' ); ?>';
108
+            ftime = '<?php _e('N/A', 'autoptimize'); ?>';
109 109
         } else {
110 110
             ftime = EpochToDate(keys.jftime);
111 111
         }
112 112
 
113 113
         // Append job entry
114
-        jQuery("#queue").append("<tr id='" + ljid + "' class='job " + statusClass + "'><td class='status'><span class='badge " + statusClass + "' title='<?php _e( 'Job status is ', 'autoptimize' ); ?>" + title + "'>" + status + "</span></td><td>" + target.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,'') + "</td><td>" + path + "</td><td>" + type.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,'') + "</td><td>" + ctime + "</td><td>" + ftime + "</td><td class='btn'>" + buttons + "</td></tr>");
114
+        jQuery("#queue").append("<tr id='" + ljid + "' class='job " + statusClass + "'><td class='status'><span class='badge " + statusClass + "' title='<?php _e('Job status is ', 'autoptimize'); ?>" + title + "'>" + status + "</span></td><td>" + target.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,'') + "</td><td>" + path + "</td><td>" + type.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,'') + "</td><td>" + ctime + "</td><td>" + ftime + "</td><td class='btn'>" + buttons + "</td></tr>");
115 115
 
116 116
         // Attach button actions
117 117
         if (rbtn) {
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
         height: 180,
135 135
         modal: true,
136 136
         buttons: {
137
-            "<?php _e( 'Delete', 'autoptimize' ); ?>": function() {
137
+            "<?php _e('Delete', 'autoptimize'); ?>": function() {
138 138
                 delete queue[jpath];
139 139
                 updateQueue(queue);
140 140
                 jQuery(this).dialog('close' );
141 141
             },
142
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
142
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
143 143
                 jQuery(this).dialog('close' );
144 144
             }
145 145
         }
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
         height:235,
153 153
         modal: true,
154 154
         buttons: {
155
-            "<?php _e( 'Delete all jobs?', 'autoptimize' ); ?>": function() {
155
+            "<?php _e('Delete all jobs?', 'autoptimize'); ?>": function() {
156 156
                 queue=[];
157 157
                 updateQueue(queue);
158 158
                 jQuery( this ).dialog( "close" );
159 159
             },
160
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
160
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
161 161
                 jQuery( this ).dialog( "close" );
162 162
             }
163 163
         }
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
         height: 180,
173 173
         modal: true,
174 174
         buttons: {
175
-            "<?php _e( 'Retry', 'autoptimize' ); ?>": function() {
175
+            "<?php _e('Retry', 'autoptimize'); ?>": function() {
176 176
                 <?php
177
-                if ( $ao_ccss_debug ) {
177
+                if ($ao_ccss_debug) {
178 178
                     echo "console.log( 'SHOULD retry job:', jid[0], jpath );\n";
179 179
                 }
180 180
                 ?>
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 updateQueue(queue);
188 188
                 jQuery(this).dialog('close' );
189 189
             },
190
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
190
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
191 191
                 jQuery(this).dialog('close' );
192 192
             }
193 193
         }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     jQuery('#unSavedWarning').show();
202 202
     document.getElementById('ao_title_and_button').scrollIntoView();  
203 203
     <?php
204
-    if ( $ao_ccss_debug ) {
204
+    if ($ao_ccss_debug) {
205 205
         echo "console.log('Updated Queue Object:', queue);\n";
206 206
     }
207 207
     ?>
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_rules.js.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Outputs JS code for the rules panel.
4 4
  */
5 5
 
6
-if ( $ao_ccss_debug ) {
6
+if ($ao_ccss_debug) {
7 7
     echo "console.log('[WARN] Autoptimize CriticalCSS Power-Up is in DEBUG MODE!');\n";
8 8
     echo "console.log('[WARN] Avoid using debug mode on production/live environments unless for ad-hoc troubleshooting purposes and make sure to disable it after!');\n";
9 9
 }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     jQuery(document).ready(function() {
24 24
         critCssArray=JSON.parse(document.getElementById("critCssOrigin").value);
25 25
         <?php
26
-        if ( $ao_ccss_debug ) {
26
+        if ($ao_ccss_debug) {
27 27
             echo "console.log('Rules Object:', critCssArray);\n";
28 28
         }
29 29
         ?>
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
     jQuery("#rules-list").empty();
40 40
     jQuery.each(critCssArray,function(k,v) {
41 41
         if (k=="paths") {
42
-            kstring="<?php _e( 'Path Based Rules', 'autoptimize' ); ?>";
42
+            kstring="<?php _e('Path Based Rules', 'autoptimize'); ?>";
43 43
         } else {
44
-            kstring="<?php _e( 'Conditional Tags, Custom Post Types and Page Templates Rules', 'autoptimize' ); ?>";
44
+            kstring="<?php _e('Conditional Tags, Custom Post Types and Page Templates Rules', 'autoptimize'); ?>";
45 45
         }
46 46
         if (!(jQuery.isEmptyObject(v))) {
47 47
             jQuery("#rules-list").append("<tr><td colspan='5'><h4>" + kstring + "</h4></td></tr>");
48
-            jQuery("#rules-list").append("<tr class='header "+k+"Rule'><th><?php _e( 'Type', 'autoptimize' ); ?></th><th><?php _e( 'Target', 'autoptimize' ); ?></th><th><?php _e( 'Critical CSS File', 'autoptimize' ); ?></th><th colspan='2'><?php _e( 'Actions', 'autoptimize' ); ?></th></tr>");
48
+            jQuery("#rules-list").append("<tr class='header "+k+"Rule'><th><?php _e('Type', 'autoptimize'); ?></th><th><?php _e('Target', 'autoptimize'); ?></th><th><?php _e('Critical CSS File', 'autoptimize'); ?></th><th colspan='2'><?php _e('Actions', 'autoptimize'); ?></th></tr>");
49 49
         }
50 50
         nodeNumber=0;
51 51
         jQuery.each(v,function(i,nv){
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
             file=nv.file;
56 56
             filest=nv.file;
57 57
             if (file == 0) {
58
-                file='<?php _e( 'To be fetched from criticalcss.com in the next queue run...', 'autoptimize' ); ?>';
58
+                file='<?php _e('To be fetched from criticalcss.com in the next queue run...', 'autoptimize'); ?>';
59 59
             }
60 60
             if (nv.hash === 0 && filest != 0) {
61
-                type='<?php _e( 'MANUAL', 'autoptimize' ); ?>';
61
+                type='<?php _e('MANUAL', 'autoptimize'); ?>';
62 62
                 typeClass = 'manual';
63 63
             } else {
64
-                type='<?php _e( 'AUTO', 'autoptimize' ); ?>';
64
+                type='<?php _e('AUTO', 'autoptimize'); ?>';
65 65
                 typeClass = 'auto';
66 66
             }
67 67
             if (file && typeof file == 'string') {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             } else {
78 78
                 target = i.replace(/(woo_|template_|custom_post_|edd_|bp_|bbp_)/,'');
79 79
             }
80
-            jQuery("#rules-list").append("<tr class='rule "+k+"Rule'><td class='type'><span class='badge " + typeClass + "'>" + type + "</span>" + rmark + "</td><td class='target'>" + target + "</td><td class='file'>" + file + "</td><td class='btn edit'><span class=\"button-secondary\" id=\"" + nodeId + "_edit\"><?php _e( 'Edit', 'autoptimize' ); ?></span></td><td class='btn delete'><span class=\"button-secondary\" id=\"" + nodeId + "_remove\"><?php _e( 'Remove', 'autoptimize' ); ?></span></td></tr>");
80
+            jQuery("#rules-list").append("<tr class='rule "+k+"Rule'><td class='type'><span class='badge " + typeClass + "'>" + type + "</span>" + rmark + "</td><td class='target'>" + target + "</td><td class='file'>" + file + "</td><td class='btn edit'><span class=\"button-secondary\" id=\"" + nodeId + "_edit\"><?php _e('Edit', 'autoptimize'); ?></span></td><td class='btn delete'><span class=\"button-secondary\" id=\"" + nodeId + "_remove\"><?php _e('Remove', 'autoptimize'); ?></span></td></tr>");
81 81
             jQuery("#" + nodeId + "_edit").click(function(){addEditRow(this.id);});
82 82
             jQuery("#" + nodeId + "_remove").click(function(){confirmRemove(this.id);});
83 83
         })
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
         height:235,
91 91
         modal: true,
92 92
         buttons: {
93
-            "<?php _e( 'Delete', 'autoptimize' ); ?>": function() {
93
+            "<?php _e('Delete', 'autoptimize'); ?>": function() {
94 94
                 removeRow(idToRemove);
95 95
                 updateAfterChange();
96 96
                 jQuery( this ).dialog( "close" );
97 97
             },
98
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
98
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
99 99
                 jQuery( this ).dialog( "close" );
100 100
             }
101 101
         }
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
         height:235,
109 109
         modal: true,
110 110
         buttons: {
111
-            "<?php _e( 'Delete All', 'autoptimize' ); ?>": function() {
111
+            "<?php _e('Delete All', 'autoptimize'); ?>": function() {
112 112
                 critCssArray={'paths':[],'types':[]};
113 113
                 drawTable(critCssArray);
114 114
                 updateAfterChange();
115 115
                 removeAllCcssFilesOnServer();
116 116
                 jQuery( this ).dialog( "close" );
117 117
             },
118
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
118
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
119 119
                 jQuery( this ).dialog( "close" );
120 120
             }
121 121
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
     var data = {
134 134
         'action': 'rm_critcss',
135
-        'critcss_rm_nonce': '<?php echo wp_create_nonce( 'rm_critcss_nonce' ); ?>',
135
+        'critcss_rm_nonce': '<?php echo wp_create_nonce('rm_critcss_nonce'); ?>',
136 136
         'cachebustingtimestamp': new Date().getTime(),
137 137
         'critcssfile': crit_file
138 138
     };
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 function removeAllCcssFilesOnServer() {
154 154
     var data = {
155 155
         'action': 'rm_critcss_all',
156
-        'critcss_rm_all_nonce': '<?php echo wp_create_nonce( 'rm_critcss_all_nonce' ); ?>',
156
+        'critcss_rm_all_nonce': '<?php echo wp_create_nonce('rm_critcss_all_nonce'); ?>',
157 157
         'cachebustingtimestamp': new Date().getTime()
158 158
     };
159 159
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 function addEditRow(idToEdit) {
174 174
     resetForm();
175 175
     if (idToEdit) {
176
-        dialogTitle="<?php _e( 'Edit Critical CSS Rule', 'autoptimize' ); ?>";
176
+        dialogTitle="<?php _e('Edit Critical CSS Rule', 'autoptimize'); ?>";
177 177
 
178 178
         splits=idToEdit.split(/_/);
179 179
         crit_type=splits[0];
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         jQuery("#critcss_addedit_id").val(idToEdit);
185 185
         jQuery("#critcss_addedit_type").val(crit_type);
186 186
         jQuery("#critcss_addedit_file").val(crit_file);
187
-        jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'Loading critical CSS...', 'autoptimize' ); ?>");
187
+        jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('Loading critical CSS...', 'autoptimize'); ?>");
188 188
         jQuery("#critcss_addedit_type").attr("disabled",true);
189 189
 
190 190
         if (crit_type==="paths") {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
         var data = {
201 201
             'action': 'fetch_critcss',
202
-            'critcss_fetch_nonce': '<?php echo wp_create_nonce( 'fetch_critcss_nonce' ); ?>',
202
+            'critcss_fetch_nonce': '<?php echo wp_create_nonce('fetch_critcss_nonce'); ?>',
203 203
             'cachebustingtimestamp': new Date().getTime(),
204 204
             'critcssfile': crit_file
205 205
         };
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             }
214 214
         });
215 215
     } else {
216
-        dialogTitle="<?php _e( 'Add Critical CSS Rule', 'autotimize' ); ?>";
216
+        dialogTitle="<?php _e('Add Critical CSS Rule', 'autotimize'); ?>";
217 217
 
218 218
         // default: paths, hide content type field
219 219
         jQuery("#critcss_addedit_type").val("paths");
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
             if(this.value==="types") {
225 225
                 jQuery("#critcss_addedit_pagetype_wrapper").show();
226 226
                 jQuery("#critcss_addedit_path_wrapper").hide();
227
-                jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For type based rules, paste your specific and minified critical CSS here and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\".', 'autoptimize' ); ?>");
227
+                jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For type based rules, paste your specific and minified critical CSS here and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\".', 'autoptimize'); ?>");
228 228
             } else {
229 229
                 jQuery("#critcss_addedit_path_wrapper").show();
230 230
                 jQuery("#critcss_addedit_pagetype_wrapper").hide();
231
-                jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize' ); ?>");
231
+                jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize'); ?>");
232 232
             }
233 233
         });
234 234
     }
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
         title: dialogTitle,
241 241
         modal: true,
242 242
         buttons: {
243
-            "<?php _e( 'Submit', 'autoptimize' ); ?>": function() {
243
+            "<?php _e('Submit', 'autoptimize'); ?>": function() {
244 244
                 rpath = jQuery("#critcss_addedit_path").val();
245 245
                 rtype = jQuery("#critcss_addedit_pagetype option:selected").val();
246 246
                 rccss = jQuery("#critcss_addedit_css").val();
247 247
                 console.log('rpath: ' + rpath, 'rtype: ' + rtype, 'rccss: ' + rccss);
248 248
                 if (rpath === '' && rtype === '') {
249
-                    alert('<?php _e( "RULE VALIDATION ERROR!\\n\\nBased on your rule type, you SHOULD set a path or conditional tag.", 'autoptimize' ); ?>');
249
+                    alert('<?php _e("RULE VALIDATION ERROR!\\n\\nBased on your rule type, you SHOULD set a path or conditional tag.", 'autoptimize'); ?>');
250 250
                 } else if (rtype !== '' && rccss == '') {
251
-                    alert('<?php _e( "RULE VALIDATION ERROR!\\n\\nType based rules REQUIRES a minified critical CSS.", 'autoptimize' ); ?>');
251
+                    alert('<?php _e("RULE VALIDATION ERROR!\\n\\nType based rules REQUIRES a minified critical CSS.", 'autoptimize'); ?>');
252 252
                 } else {
253 253
                     saveEditCritCss();
254 254
                     jQuery(this).dialog('close');
255 255
                 }
256 256
             },
257
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
257
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
258 258
                 resetForm();
259 259
                 jQuery(this).dialog("close");
260 260
             }
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
         autoOpen: true,
269 269
         height: 505,
270 270
         width: 700,
271
-        title: "<?php _e( 'Default Critical CSS', 'autoptimize' ); ?>",
271
+        title: "<?php _e('Default Critical CSS', 'autoptimize'); ?>",
272 272
         modal: true,
273 273
         buttons: {
274
-            "<?php _e( 'Submit', 'autoptimize' ); ?>": function() {
274
+            "<?php _e('Submit', 'autoptimize'); ?>": function() {
275 275
                 document.getElementById("autoptimize_css_defer_inline").value=document.getElementById("dummyDefault").value;
276 276
                 jQuery("#unSavedWarning").show();
277 277
                 jQuery("#default_critcss_wrapper").dialog( "close" );
278 278
             },
279
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
279
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
280 280
                 jQuery("#default_critcss_wrapper").dialog( "close" );
281 281
             }
282 282
         }
@@ -289,15 +289,15 @@  discard block
 block discarded – undo
289 289
         autoOpen: true,
290 290
         height: 505,
291 291
         width: 700,
292
-        title: "<?php _e( 'Additional Critical CSS', 'autoptimize' ); ?>",
292
+        title: "<?php _e('Additional Critical CSS', 'autoptimize'); ?>",
293 293
         modal: true,
294 294
         buttons: {
295
-            "<?php _e( 'Submit', 'autoptimize' ); ?>": function() {
295
+            "<?php _e('Submit', 'autoptimize'); ?>": function() {
296 296
                 document.getElementById("autoptimize_ccss_additional").value=document.getElementById("dummyAdditional").value;
297 297
                 jQuery("#unSavedWarning").show();
298 298
                 jQuery("#additional_critcss_wrapper").dialog( "close" );
299 299
             },
300
-            "<?php _e( 'Cancel', 'autoptimize' ); ?>": function() {
300
+            "<?php _e('Cancel', 'autoptimize'); ?>": function() {
301 301
                 jQuery("#additional_critcss_wrapper").dialog( "close" );
302 302
             }
303 303
         }
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     critCssArray[critcsstype][critcsstarget].file=critcssfile;
334 334
 
335 335
     <?php
336
-    if ( $ao_ccss_debug ) {
336
+    if ($ao_ccss_debug) {
337 337
         echo "console.log('[RULE PROPERTIES] Type:', critcsstype, ', Target:', critcsstarget, ', Hash:', 0, ', File:',  critcssfile);";
338 338
     }
339 339
     ?>
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
     var data = {
344 344
         'action': 'save_critcss',
345
-        'critcss_save_nonce': '<?php echo wp_create_nonce( 'save_critcss_nonce' ); ?>',
345
+        'critcss_save_nonce': '<?php echo wp_create_nonce('save_critcss_nonce'); ?>',
346 346
         'critcssfile': critcssfile,
347 347
         'critcsscontents': critcsscontents
348 348
     };
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 }
368 368
 
369 369
 function resetForm() {
370
-    jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e( 'For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize' ); ?>");
370
+    jQuery("#critcss_addedit_css").attr("placeholder", "<?php _e('For path based rules, paste your specific and minified critical CSS here or leave this empty to fetch it from criticalcss.com and hit submit to save. If you want to create a rule to exclude from critical CSS injection, enter \"none\"', 'autoptimize'); ?>");
371 371
     jQuery("#critcss_addedit_type").attr("disabled",false);
372 372
     jQuery("#critcss_addedit_path_wrapper").show();
373 373
     jQuery("#critcss_addedit_id").val("");
Please login to merge, or discard this patch.
classes/critcss-inc/admin_settings_queue.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@  discard block
 block discarded – undo
11 11
     global $ao_ccss_queue;
12 12
 
13 13
     // Prepare the queue object.
14
-    if ( empty( $ao_ccss_queue ) ) {
14
+    if (empty($ao_ccss_queue)) {
15 15
         $ao_ccss_queue = '';
16 16
     } else {
17
-        $ao_ccss_queue = json_encode( $ao_ccss_queue );
17
+        $ao_ccss_queue = json_encode($ao_ccss_queue);
18 18
     }
19 19
 ?>
20 20
 
21 21
     <ul id="queue-panel">
22 22
         <li class="itemDetail">
23
-            <h2 class="itemTitle fleft"><?php _e( 'Job Queue', 'autoptimize' ); ?></h2>
23
+            <h2 class="itemTitle fleft"><?php _e('Job Queue', 'autoptimize'); ?></h2>
24 24
             <button type="button" class="toggle-btn">
25 25
                 <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
26 26
             </button>
27 27
             <?php
28
-            if ( autoptimizeCriticalCSSSettings::ao_ccss_has_autorules() ) {
28
+            if (autoptimizeCriticalCSSSettings::ao_ccss_has_autorules()) {
29 29
                 $_queue_visibility = 'hidden';
30 30
             } else {
31 31
                 $_queue_visibility = 'visible';
@@ -34,54 +34,54 @@  discard block
 block discarded – undo
34 34
             <div class="collapsible <?php echo $_queue_visibility; ?>">
35 35
                 <!-- BEGIN Queue dialogs -->
36 36
                 <!-- Retry dialog -->
37
-                <div id="queue-confirm-retry" title="<?php _e( 'Retry Job', 'autoptimize' ); ?>" class="hidden">
38
-                    <p><?php _e( 'Are you sure you want to retry this job?', 'autoptimize' ); ?></p>
37
+                <div id="queue-confirm-retry" title="<?php _e('Retry Job', 'autoptimize'); ?>" class="hidden">
38
+                    <p><?php _e('Are you sure you want to retry this job?', 'autoptimize'); ?></p>
39 39
                 </div>
40 40
 
41 41
                 <!-- Remove dialog -->
42
-                <div id="queue-confirm-rm" title="<?php _e( 'Delete Job', 'autoptimize' ); ?>" class="hidden">
43
-                    <p><?php _e( 'Are you sure you want to delete this job?', 'autoptimize' ); ?></p>
42
+                <div id="queue-confirm-rm" title="<?php _e('Delete Job', 'autoptimize'); ?>" class="hidden">
43
+                    <p><?php _e('Are you sure you want to delete this job?', 'autoptimize'); ?></p>
44 44
                 </div>
45 45
 
46 46
                 <!-- Remove all dialog -->
47
-                <div id="queue-confirm-rm-all" title="<?php _e( 'Delete all jobs', 'autoptimize' ); ?>" class="hidden">
48
-                    <p><?php _e( 'This will delete all jobs, are you sure?', 'autoptimize' ); ?></p>
47
+                <div id="queue-confirm-rm-all" title="<?php _e('Delete all jobs', 'autoptimize'); ?>" class="hidden">
48
+                    <p><?php _e('This will delete all jobs, are you sure?', 'autoptimize'); ?></p>
49 49
                 </div>
50 50
                 <!-- END Queue dialogs -->
51 51
 
52 52
                 <!-- BEGIN Queue UI -->
53 53
                 <div class="howto">
54 54
                     <div class="title-wrap">
55
-                        <h4 class="title"><?php _e( 'How To Use Autoptimize CriticalCSS Power-Up Queue', 'autoptimize' ); ?></h4>
56
-                        <p class="subtitle"><?php _e( 'Click the side arrow to toggle instructions', 'autoptimize' ); ?></p>
55
+                        <h4 class="title"><?php _e('How To Use Autoptimize CriticalCSS Power-Up Queue', 'autoptimize'); ?></h4>
56
+                        <p class="subtitle"><?php _e('Click the side arrow to toggle instructions', 'autoptimize'); ?></p>
57 57
                     </div>
58 58
                     <button type="button" class="toggle-btn">
59 59
                         <span class="toggle-indicator dashicons dashicons-arrow-up dashicons-arrow-down"></span>
60 60
                     </button>
61 61
                     <div class="howto-wrap hidden">
62
-                        <p><?php _e( 'TL;DR:<br /><strong>Queue runs every 10 minutes.</strong> Job statuses are <span class="badge new">N</span> for NEW, <span class="badge pending">P</span> for PENDING, <span class="badge error">E</span> for ERROR and <span class="badge unknown">U</span> for UNKOWN.', 'autoptimize' ); ?></p>
62
+                        <p><?php _e('TL;DR:<br /><strong>Queue runs every 10 minutes.</strong> Job statuses are <span class="badge new">N</span> for NEW, <span class="badge pending">P</span> for PENDING, <span class="badge error">E</span> for ERROR and <span class="badge unknown">U</span> for UNKOWN.', 'autoptimize'); ?></p>
63 63
                         <ol>
64
-                            <li><?php _e( 'The queue operates <strong>automatically, asynchronously and on regular intervals of 10 minutes.</strong> To view updated queue status, refresh this page.', 'autoptimize' ); ?></li>
65
-                            <li><?php _e( 'When the conditions to create a job are met (i.e. user not logged in, no matching <span class="badge manual">MANUAL</span> rule or CSS files has changed for an <span class="badge auto">AUTO</span> rule), a <span class="badge new">N</span> job is created in the queue.', 'autoptimize' ); ?></li>
66
-                            <li><?php _e( "Autoptimize CriticalCSS Power-Up constantly query the queue for <span class='badge new'>N</span> jobs. When it finds one, gears spins and jobs becomes <span class='badge pending'>P</span> while they are running and <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> doesn't return a result.", 'autoptimize' ); ?></li>
67
-                            <li><?php _e( 'As soon as <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> returns a valid critical CSS file, the job is then finished and removed from the queue.', 'autoptimize' ); ?></li>
68
-                            <li><?php _e( 'When things go wrong, a job is marked as <span class="badge error">E</span>. You can retry faulty jobs, delete them or get in touch with <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li>
69
-                            <li><?php _e( 'Sometimes an unknown condition can happen. In this case, the job status becomes <span class="badge unknown">U</span> and you may want to ask <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for help or just delete it.', 'autoptimize' ); ?></li>
70
-                            <li><?php _e( 'To get more information about jobs statuses, specially the ones with <span class="badge error">E</span> and <span class="badge unknown">U</span> status, hover your mouse in the status badge of that job. This information might be crucial when contacting <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize' ); ?></li>
71
-                            <li><?php _e( '<strong>A word about WordPress cron:</strong> Autoptimize CriticalCSS Power-Up watch the queue by using WordPress Cron (or WP-Cron for short.) It <a href="https://www.smashingmagazine.com/2013/10/schedule-events-using-wordpress-cron/#limitations-of-wordpress-cron-and-solutions-to-fix-em" target="_blank">could be faulty</a> on very light or very heavy loads. If your site receives just a few or thousands visits a day, it might be a good idea to <a href="https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/" target="_blank">turn WP-Cron off and use your system task scheduler</a> to fire it instead.', 'autoptimize' ); ?></li>
64
+                            <li><?php _e('The queue operates <strong>automatically, asynchronously and on regular intervals of 10 minutes.</strong> To view updated queue status, refresh this page.', 'autoptimize'); ?></li>
65
+                            <li><?php _e('When the conditions to create a job are met (i.e. user not logged in, no matching <span class="badge manual">MANUAL</span> rule or CSS files has changed for an <span class="badge auto">AUTO</span> rule), a <span class="badge new">N</span> job is created in the queue.', 'autoptimize'); ?></li>
66
+                            <li><?php _e("Autoptimize CriticalCSS Power-Up constantly query the queue for <span class='badge new'>N</span> jobs. When it finds one, gears spins and jobs becomes <span class='badge pending'>P</span> while they are running and <a href='https://criticalcss.com/?aff=1' target='_blank'>criticalcss.com</a> doesn't return a result.", 'autoptimize'); ?></li>
67
+                            <li><?php _e('As soon as <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> returns a valid critical CSS file, the job is then finished and removed from the queue.', 'autoptimize'); ?></li>
68
+                            <li><?php _e('When things go wrong, a job is marked as <span class="badge error">E</span>. You can retry faulty jobs, delete them or get in touch with <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize'); ?></li>
69
+                            <li><?php _e('Sometimes an unknown condition can happen. In this case, the job status becomes <span class="badge unknown">U</span> and you may want to ask <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for help or just delete it.', 'autoptimize'); ?></li>
70
+                            <li><?php _e('To get more information about jobs statuses, specially the ones with <span class="badge error">E</span> and <span class="badge unknown">U</span> status, hover your mouse in the status badge of that job. This information might be crucial when contacting <a href="https://criticalcss.com/?aff=1" target="_blank">criticalcss.com</a> for assistance.', 'autoptimize'); ?></li>
71
+                            <li><?php _e('<strong>A word about WordPress cron:</strong> Autoptimize CriticalCSS Power-Up watch the queue by using WordPress Cron (or WP-Cron for short.) It <a href="https://www.smashingmagazine.com/2013/10/schedule-events-using-wordpress-cron/#limitations-of-wordpress-cron-and-solutions-to-fix-em" target="_blank">could be faulty</a> on very light or very heavy loads. If your site receives just a few or thousands visits a day, it might be a good idea to <a href="https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/" target="_blank">turn WP-Cron off and use your system task scheduler</a> to fire it instead.', 'autoptimize'); ?></li>
72 72
                         </ol>
73 73
                     </div>
74 74
                 </div>
75 75
                 <table id="queue-tbl" class="queue tablesorter" cellspacing="0">
76 76
                     <thead>
77
-                        <tr><th class="status"><?php _e( 'Status', 'autoptimize' ); ?></th><th><?php _e( 'Target Rule', 'autoptimize' ); ?></th><th><?php _e( 'Page Path', 'autoptimize' ); ?></th><th><?php _e( 'Page Type', 'autoptimize' ); ?></th><th><?php _e( 'Creation Date', 'autoptimize' ); ?></th><th><?php _e( 'Finish Date', 'autoptimize' ); ?></th><th class="btn"><?php _e( 'Actions', 'autoptimize' ); ?></th></tr>
77
+                        <tr><th class="status"><?php _e('Status', 'autoptimize'); ?></th><th><?php _e('Target Rule', 'autoptimize'); ?></th><th><?php _e('Page Path', 'autoptimize'); ?></th><th><?php _e('Page Type', 'autoptimize'); ?></th><th><?php _e('Creation Date', 'autoptimize'); ?></th><th><?php _e('Finish Date', 'autoptimize'); ?></th><th class="btn"><?php _e('Actions', 'autoptimize'); ?></th></tr>
78 78
                     </thead>
79 79
                     <tbody id="queue"></tbody>
80 80
                 </table>
81
-                <input class="hidden" type="text" id="ao-ccss-queue" name="autoptimize_ccss_queue" value='<?php echo( $ao_ccss_queue ); ?>'>
81
+                <input class="hidden" type="text" id="ao-ccss-queue" name="autoptimize_ccss_queue" value='<?php echo($ao_ccss_queue); ?>'>
82 82
                 <div class="submit jobs-btn">
83 83
                     <div class="alignright">
84
-                        <span id="removeAllJobs" class="button-secondary" style="color:red;"><?php _e( 'Remove all jobs', 'autoptimize' ); ?></span>
84
+                        <span id="removeAllJobs" class="button-secondary" style="color:red;"><?php _e('Remove all jobs', 'autoptimize'); ?></span>
85 85
                     </div>
86 86
                 </div>
87 87
             </div>
Please login to merge, or discard this patch.