@@ -29,131 +29,131 @@ |
||
| 29 | 29 | * Exit if called directly. |
| 30 | 30 | */ |
| 31 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 32 | - die; |
|
| 32 | + die; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | if ( ! class_exists( 'PAnD' ) ) { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Class PAnD |
|
| 39 | - */ |
|
| 40 | - class PAnD { |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Init hooks. |
|
| 44 | - */ |
|
| 45 | - public static function init() { |
|
| 46 | - add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) ); |
|
| 47 | - add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Enqueue javascript and variables. |
|
| 52 | - */ |
|
| 53 | - public static function load_script() { |
|
| 54 | - |
|
| 55 | - if ( is_customize_preview() ) { |
|
| 56 | - return; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - wp_enqueue_script( |
|
| 60 | - 'dismissible-notices', |
|
| 61 | - plugins_url( 'dismiss-notice.js', __FILE__ ), |
|
| 62 | - array( 'jquery', 'common' ), |
|
| 63 | - false, |
|
| 64 | - true |
|
| 65 | - ); |
|
| 66 | - |
|
| 67 | - wp_localize_script( |
|
| 68 | - 'dismissible-notices', |
|
| 69 | - 'dismissible_notice', |
|
| 70 | - array( |
|
| 71 | - 'nonce' => wp_create_nonce( 'dismissible-notice' ), |
|
| 72 | - ) |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Handles Ajax request to persist notices dismissal. |
|
| 78 | - * Uses check_ajax_referer to verify nonce. |
|
| 79 | - */ |
|
| 80 | - public static function dismiss_admin_notice() { |
|
| 81 | - $option_name = sanitize_text_field( $_POST['option_name'] ); |
|
| 82 | - $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] ); |
|
| 83 | - |
|
| 84 | - if ( 'forever' != $dismissible_length ) { |
|
| 85 | - // If $dismissible_length is not an integer default to 1 |
|
| 86 | - $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length; |
|
| 87 | - $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' ); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - check_ajax_referer( 'dismissible-notice', 'nonce' ); |
|
| 91 | - self::set_admin_notice_cache( $option_name, $dismissible_length ); |
|
| 92 | - wp_die(); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Is admin notice active? |
|
| 97 | - * |
|
| 98 | - * @param string $arg data-dismissible content of notice. |
|
| 99 | - * |
|
| 100 | - * @return bool |
|
| 101 | - */ |
|
| 102 | - public static function is_admin_notice_active( $arg ) { |
|
| 103 | - $array = explode( '-', $arg ); |
|
| 104 | - $length = array_pop( $array ); |
|
| 105 | - $option_name = implode( '-', $array ); |
|
| 106 | - $db_record = self::get_admin_notice_cache( $option_name ); |
|
| 107 | - if ( 'forever' == $db_record ) { |
|
| 108 | - return false; |
|
| 109 | - } elseif ( absint( $db_record ) >= time() ) { |
|
| 110 | - return false; |
|
| 111 | - } else { |
|
| 112 | - return true; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Returns admin notice cached timeout. |
|
| 118 | - * |
|
| 119 | - * @access public |
|
| 120 | - * |
|
| 121 | - * @param string|bool $id admin notice name or false. |
|
| 122 | - * |
|
| 123 | - * @return array|bool The timeout. False if expired. |
|
| 124 | - */ |
|
| 125 | - public static function get_admin_notice_cache( $id = false ) { |
|
| 126 | - if ( ! $id ) { |
|
| 127 | - return false; |
|
| 128 | - } |
|
| 129 | - $cache_key = 'pand-' . md5( $id ); |
|
| 130 | - $timeout = get_site_option( $cache_key ); |
|
| 131 | - $timeout = 'forever' === $timeout ? time() + 60 : $timeout; |
|
| 132 | - |
|
| 133 | - if ( empty( $timeout ) || time() > $timeout ) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - return $timeout; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Sets admin notice timeout in site option. |
|
| 142 | - * |
|
| 143 | - * @access public |
|
| 144 | - * |
|
| 145 | - * @param string $id Data Identifier. |
|
| 146 | - * @param string|bool $timeout Timeout for admin notice. |
|
| 147 | - * |
|
| 148 | - * @return bool |
|
| 149 | - */ |
|
| 150 | - public static function set_admin_notice_cache( $id, $timeout ) { |
|
| 151 | - $cache_key = 'pand-' . md5( $id ); |
|
| 152 | - update_site_option( $cache_key, $timeout ); |
|
| 153 | - |
|
| 154 | - return true; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - } |
|
| 37 | + /** |
|
| 38 | + * Class PAnD |
|
| 39 | + */ |
|
| 40 | + class PAnD { |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Init hooks. |
|
| 44 | + */ |
|
| 45 | + public static function init() { |
|
| 46 | + add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) ); |
|
| 47 | + add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Enqueue javascript and variables. |
|
| 52 | + */ |
|
| 53 | + public static function load_script() { |
|
| 54 | + |
|
| 55 | + if ( is_customize_preview() ) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + wp_enqueue_script( |
|
| 60 | + 'dismissible-notices', |
|
| 61 | + plugins_url( 'dismiss-notice.js', __FILE__ ), |
|
| 62 | + array( 'jquery', 'common' ), |
|
| 63 | + false, |
|
| 64 | + true |
|
| 65 | + ); |
|
| 66 | + |
|
| 67 | + wp_localize_script( |
|
| 68 | + 'dismissible-notices', |
|
| 69 | + 'dismissible_notice', |
|
| 70 | + array( |
|
| 71 | + 'nonce' => wp_create_nonce( 'dismissible-notice' ), |
|
| 72 | + ) |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Handles Ajax request to persist notices dismissal. |
|
| 78 | + * Uses check_ajax_referer to verify nonce. |
|
| 79 | + */ |
|
| 80 | + public static function dismiss_admin_notice() { |
|
| 81 | + $option_name = sanitize_text_field( $_POST['option_name'] ); |
|
| 82 | + $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] ); |
|
| 83 | + |
|
| 84 | + if ( 'forever' != $dismissible_length ) { |
|
| 85 | + // If $dismissible_length is not an integer default to 1 |
|
| 86 | + $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length; |
|
| 87 | + $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' ); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + check_ajax_referer( 'dismissible-notice', 'nonce' ); |
|
| 91 | + self::set_admin_notice_cache( $option_name, $dismissible_length ); |
|
| 92 | + wp_die(); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Is admin notice active? |
|
| 97 | + * |
|
| 98 | + * @param string $arg data-dismissible content of notice. |
|
| 99 | + * |
|
| 100 | + * @return bool |
|
| 101 | + */ |
|
| 102 | + public static function is_admin_notice_active( $arg ) { |
|
| 103 | + $array = explode( '-', $arg ); |
|
| 104 | + $length = array_pop( $array ); |
|
| 105 | + $option_name = implode( '-', $array ); |
|
| 106 | + $db_record = self::get_admin_notice_cache( $option_name ); |
|
| 107 | + if ( 'forever' == $db_record ) { |
|
| 108 | + return false; |
|
| 109 | + } elseif ( absint( $db_record ) >= time() ) { |
|
| 110 | + return false; |
|
| 111 | + } else { |
|
| 112 | + return true; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Returns admin notice cached timeout. |
|
| 118 | + * |
|
| 119 | + * @access public |
|
| 120 | + * |
|
| 121 | + * @param string|bool $id admin notice name or false. |
|
| 122 | + * |
|
| 123 | + * @return array|bool The timeout. False if expired. |
|
| 124 | + */ |
|
| 125 | + public static function get_admin_notice_cache( $id = false ) { |
|
| 126 | + if ( ! $id ) { |
|
| 127 | + return false; |
|
| 128 | + } |
|
| 129 | + $cache_key = 'pand-' . md5( $id ); |
|
| 130 | + $timeout = get_site_option( $cache_key ); |
|
| 131 | + $timeout = 'forever' === $timeout ? time() + 60 : $timeout; |
|
| 132 | + |
|
| 133 | + if ( empty( $timeout ) || time() > $timeout ) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + return $timeout; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Sets admin notice timeout in site option. |
|
| 142 | + * |
|
| 143 | + * @access public |
|
| 144 | + * |
|
| 145 | + * @param string $id Data Identifier. |
|
| 146 | + * @param string|bool $timeout Timeout for admin notice. |
|
| 147 | + * |
|
| 148 | + * @return bool |
|
| 149 | + */ |
|
| 150 | + public static function set_admin_notice_cache( $id, $timeout ) { |
|
| 151 | + $cache_key = 'pand-' . md5( $id ); |
|
| 152 | + update_site_option( $cache_key, $timeout ); |
|
| 153 | + |
|
| 154 | + return true; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | 159 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Exit if called directly. |
| 30 | 30 | */ |
| 31 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 31 | +if (!defined('ABSPATH')) { |
|
| 32 | 32 | die; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -if ( ! class_exists( 'PAnD' ) ) { |
|
| 35 | +if (!class_exists('PAnD')) { |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Class PAnD |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | * Init hooks. |
| 44 | 44 | */ |
| 45 | 45 | public static function init() { |
| 46 | - add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) ); |
|
| 47 | - add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) ); |
|
| 46 | + add_action('admin_enqueue_scripts', array(__CLASS__, 'load_script')); |
|
| 47 | + add_action('wp_ajax_dismiss_admin_notice', array(__CLASS__, 'dismiss_admin_notice')); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public static function load_script() { |
| 54 | 54 | |
| 55 | - if ( is_customize_preview() ) { |
|
| 55 | + if (is_customize_preview()) { |
|
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | wp_enqueue_script( |
| 60 | 60 | 'dismissible-notices', |
| 61 | - plugins_url( 'dismiss-notice.js', __FILE__ ), |
|
| 62 | - array( 'jquery', 'common' ), |
|
| 61 | + plugins_url('dismiss-notice.js', __FILE__), |
|
| 62 | + array('jquery', 'common'), |
|
| 63 | 63 | false, |
| 64 | 64 | true |
| 65 | 65 | ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | 'dismissible-notices', |
| 69 | 69 | 'dismissible_notice', |
| 70 | 70 | array( |
| 71 | - 'nonce' => wp_create_nonce( 'dismissible-notice' ), |
|
| 71 | + 'nonce' => wp_create_nonce('dismissible-notice'), |
|
| 72 | 72 | ) |
| 73 | 73 | ); |
| 74 | 74 | } |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | * Uses check_ajax_referer to verify nonce. |
| 79 | 79 | */ |
| 80 | 80 | public static function dismiss_admin_notice() { |
| 81 | - $option_name = sanitize_text_field( $_POST['option_name'] ); |
|
| 82 | - $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] ); |
|
| 81 | + $option_name = sanitize_text_field($_POST['option_name']); |
|
| 82 | + $dismissible_length = sanitize_text_field($_POST['dismissible_length']); |
|
| 83 | 83 | |
| 84 | - if ( 'forever' != $dismissible_length ) { |
|
| 84 | + if ('forever' != $dismissible_length) { |
|
| 85 | 85 | // If $dismissible_length is not an integer default to 1 |
| 86 | - $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length; |
|
| 87 | - $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' ); |
|
| 86 | + $dismissible_length = (0 == absint($dismissible_length)) ? 1 : $dismissible_length; |
|
| 87 | + $dismissible_length = strtotime(absint($dismissible_length).' days'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - check_ajax_referer( 'dismissible-notice', 'nonce' ); |
|
| 91 | - self::set_admin_notice_cache( $option_name, $dismissible_length ); |
|
| 90 | + check_ajax_referer('dismissible-notice', 'nonce'); |
|
| 91 | + self::set_admin_notice_cache($option_name, $dismissible_length); |
|
| 92 | 92 | wp_die(); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return bool |
| 101 | 101 | */ |
| 102 | - public static function is_admin_notice_active( $arg ) { |
|
| 103 | - $array = explode( '-', $arg ); |
|
| 104 | - $length = array_pop( $array ); |
|
| 105 | - $option_name = implode( '-', $array ); |
|
| 106 | - $db_record = self::get_admin_notice_cache( $option_name ); |
|
| 107 | - if ( 'forever' == $db_record ) { |
|
| 102 | + public static function is_admin_notice_active($arg) { |
|
| 103 | + $array = explode('-', $arg); |
|
| 104 | + $length = array_pop($array); |
|
| 105 | + $option_name = implode('-', $array); |
|
| 106 | + $db_record = self::get_admin_notice_cache($option_name); |
|
| 107 | + if ('forever' == $db_record) { |
|
| 108 | 108 | return false; |
| 109 | - } elseif ( absint( $db_record ) >= time() ) { |
|
| 109 | + } elseif (absint($db_record) >= time()) { |
|
| 110 | 110 | return false; |
| 111 | 111 | } else { |
| 112 | 112 | return true; |
@@ -122,15 +122,15 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return array|bool The timeout. False if expired. |
| 124 | 124 | */ |
| 125 | - public static function get_admin_notice_cache( $id = false ) { |
|
| 126 | - if ( ! $id ) { |
|
| 125 | + public static function get_admin_notice_cache($id = false) { |
|
| 126 | + if (!$id) { |
|
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | - $cache_key = 'pand-' . md5( $id ); |
|
| 130 | - $timeout = get_site_option( $cache_key ); |
|
| 129 | + $cache_key = 'pand-'.md5($id); |
|
| 130 | + $timeout = get_site_option($cache_key); |
|
| 131 | 131 | $timeout = 'forever' === $timeout ? time() + 60 : $timeout; |
| 132 | 132 | |
| 133 | - if ( empty( $timeout ) || time() > $timeout ) { |
|
| 133 | + if (empty($timeout) || time() > $timeout) { |
|
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return bool |
| 149 | 149 | */ |
| 150 | - public static function set_admin_notice_cache( $id, $timeout ) { |
|
| 151 | - $cache_key = 'pand-' . md5( $id ); |
|
| 152 | - update_site_option( $cache_key, $timeout ); |
|
| 150 | + public static function set_admin_notice_cache($id, $timeout) { |
|
| 151 | + $cache_key = 'pand-'.md5($id); |
|
| 152 | + update_site_option($cache_key, $timeout); |
|
| 153 | 153 | |
| 154 | 154 | return true; |
| 155 | 155 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | protected $inputLength = 0; |
| 71 | 71 | protected $lookAhead = null; |
| 72 | 72 | protected $output = ''; |
| 73 | - protected $lastByteOut = ''; |
|
| 73 | + protected $lastByteOut = ''; |
|
| 74 | 74 | protected $keptComment = ''; |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $mbIntEnc = null; |
| 109 | - if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) { |
|
| 109 | + if (function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload') & 2)) { |
|
| 110 | 110 | $mbIntEnc = mb_internal_encoding(); |
| 111 | 111 | mb_internal_encoding('8bit'); |
| 112 | 112 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | && ($this->b === $this->lastByteOut)) { |
| 129 | 129 | // Don't delete this space. If we do, the addition/subtraction |
| 130 | 130 | // could be parsed as a post-increment |
| 131 | - } elseif (! $this->isAlphaNum($this->b)) { |
|
| 131 | + } elseif (!$this->isAlphaNum($this->b)) { |
|
| 132 | 132 | $command = self::ACTION_DELETE_A; |
| 133 | 133 | } |
| 134 | 134 | } elseif ($this->a === "\n") { |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | // otherwise mb_strpos will give WARNING |
| 140 | 140 | } elseif ($this->b === null |
| 141 | 141 | || (false === strpos('{[(+-!~', $this->b) |
| 142 | - && ! $this->isAlphaNum($this->b))) { |
|
| 142 | + && !$this->isAlphaNum($this->b))) { |
|
| 143 | 143 | $command = self::ACTION_DELETE_A; |
| 144 | 144 | } |
| 145 | - } elseif (! $this->isAlphaNum($this->a)) { |
|
| 145 | + } elseif (!$this->isAlphaNum($this->a)) { |
|
| 146 | 146 | if ($this->b === ' ' |
| 147 | 147 | || ($this->b === "\n" |
| 148 | 148 | && (false === strpos('}])+-"\'', $this->a)))) { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | if ($this->a === "'" || $this->a === '"' || $this->a === '`') { // string/template literal |
| 200 | 200 | $delimiter = $this->a; |
| 201 | 201 | $str = $this->a; // in case needed for exception |
| 202 | - for(;;) { |
|
| 202 | + for (;;) { |
|
| 203 | 203 | $this->output .= $this->a; |
| 204 | 204 | $this->lastByteOut = $this->a; |
| 205 | 205 | |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | case self::ACTION_DELETE_A_B: // 3 |
| 230 | 230 | $this->b = $this->next(); |
| 231 | 231 | if ($this->b === '/' && $this->isRegexpLiteral()) { |
| 232 | - $this->output .= $this->a . $this->b; |
|
| 232 | + $this->output .= $this->a.$this->b; |
|
| 233 | 233 | $pattern = '/'; // keep entire pattern in case we need to report it in the exception |
| 234 | - for(;;) { |
|
| 234 | + for (;;) { |
|
| 235 | 235 | $this->a = $this->get(); |
| 236 | 236 | $pattern .= $this->a; |
| 237 | 237 | if ($this->a === '[') { |
| 238 | - for(;;) { |
|
| 238 | + for (;;) { |
|
| 239 | 239 | $this->output .= $this->a; |
| 240 | 240 | $this->a = $this->get(); |
| 241 | 241 | $pattern .= $this->a; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | if ($this->isEOF($this->a)) { |
| 251 | 251 | throw new JSMin_UnterminatedRegExpException( |
| 252 | 252 | "JSMin: Unterminated set in RegExp at byte " |
| 253 | - . $this->inputIndex .": {$pattern}"); |
|
| 253 | + . $this->inputIndex.": {$pattern}"); |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | // if the "/" follows a keyword, it must be a regexp, otherwise it's best to assume division |
| 297 | 297 | |
| 298 | - $subject = $this->output . trim($this->a); |
|
| 298 | + $subject = $this->output.trim($this->a); |
|
| 299 | 299 | if (!preg_match('/(?:case|else|in|return|typeof)$/', $subject, $m)) { |
| 300 | 300 | // not a keyword |
| 301 | 301 | return false; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | { |
| 407 | 407 | $this->get(); |
| 408 | 408 | $comment = ''; |
| 409 | - for(;;) { |
|
| 409 | + for (;;) { |
|
| 410 | 410 | $get = $this->get(); |
| 411 | 411 | if ($get === '*') { |
| 412 | 412 | if ($this->peek() === '/') { // end of comment reached |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | // don't prepend a newline if two comments right after one another |
| 418 | 418 | $this->keptComment = "\n"; |
| 419 | 419 | } |
| 420 | - $this->keptComment .= "/*!" . substr($comment, 1) . "*/\n"; |
|
| 420 | + $this->keptComment .= "/*!".substr($comment, 1)."*/\n"; |
|
| 421 | 421 | } else if (preg_match('/^@(?:cc_on|if|elif|else|end)\\b/', $comment)) { |
| 422 | 422 | // IE conditional |
| 423 | 423 | $this->keptComment .= "/*{$comment}*/"; |
@@ -6,7 +6,7 @@ discard block |
||
| 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 |
||
| 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 | - update_option( 'autoptimize_cachesize_notice', true ); |
|
| 62 | - if ( apply_filters( 'autoptimize_filter_cachecheck_sendmail', true ) ) { |
|
| 63 | - $site_url = esc_url( site_url() ); |
|
| 64 | - $ao_mailto = apply_filters( 'autoptimize_filter_cachecheck_mailto', get_option( 'admin_email', '' ) ); |
|
| 65 | - |
|
| 66 | - $ao_mailsubject = __( 'Autoptimize cache size warning', 'autoptimize' ) . ' (' . $site_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: ' . $site_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 | + update_option('autoptimize_cachesize_notice', true); |
|
| 62 | + if (apply_filters('autoptimize_filter_cachecheck_sendmail', true)) { |
|
| 63 | + $site_url = esc_url(site_url()); |
|
| 64 | + $ao_mailto = apply_filters('autoptimize_filter_cachecheck_mailto', get_option('admin_email', '')); |
|
| 65 | + |
|
| 66 | + $ao_mailsubject = __('Autoptimize cache size warning', 'autoptimize').' ('.$site_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: '.$site_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 |
||
| 87 | 87 | |
| 88 | 88 | public function show_admin_notice() |
| 89 | 89 | { |
| 90 | - if ( (bool) get_option( 'autoptimize_cachesize_notice', false ) && current_user_can( 'manage_options' ) ) { |
|
| 90 | + if ((bool) 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 | - update_option( 'autoptimize_cachesize_notice', false ); |
|
| 94 | + update_option('autoptimize_cachesize_notice', false); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Notice for image proxy usage. |
| 98 | 98 | $_imgopt_notice = autoptimizeExtra::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 ) ) ) { |
|
| 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))) { |
|
| 100 | 100 | $_dismissible = 'ao-img-opt-notice-'; |
| 101 | 101 | $_hide_notice = '7'; |
| 102 | 102 | |
@@ -104,10 +104,10 @@ discard block |
||
| 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>' . $_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>'.$_imgopt_notice['notice'].'</p></div>'; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Handles version updates and should only be instantiated in autoptimize.php if/when needed. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 6 | +if (!defined('ABSPATH')) { |
|
| 7 | 7 | exit; |
| 8 | 8 | } |
| 9 | 9 | |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected $current_major_version = null; |
| 18 | 18 | |
| 19 | - public function __construct( $current_version ) |
|
| 19 | + public function __construct($current_version) |
|
| 20 | 20 | { |
| 21 | - $this->current_major_version = substr( $current_version, 0, 3 ); |
|
| 21 | + $this->current_major_version = substr($current_version, 0, 3); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $major_update = false; |
| 31 | 31 | |
| 32 | - switch ( $this->current_major_version ) { |
|
| 32 | + switch ($this->current_major_version) { |
|
| 33 | 33 | case '1.6': |
| 34 | 34 | $this->upgrade_from_1_6(); |
| 35 | 35 | $major_update = true; |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | $major_update = true; |
| 48 | 48 | // No break, intentionally, so all upgrades are ran during a single request... |
| 49 | 49 | case '2.4': |
| 50 | - if ( get_option( 'autoptimize_version', 'none' ) == '2.4.2' ) { |
|
| 50 | + if (get_option('autoptimize_version', 'none') == '2.4.2') { |
|
| 51 | 51 | $this->upgrade_from_2_4_2(); |
| 52 | 52 | } |
| 53 | 53 | $major_update = false; |
| 54 | 54 | // No break, intentionally, so all upgrades are ran during a single request... |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ( true === $major_update ) { |
|
| 57 | + if (true === $major_update) { |
|
| 58 | 58 | $this->on_major_version_update(); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -66,19 +66,19 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param string $target Target version to check against (ie., the currently running one). |
| 68 | 68 | */ |
| 69 | - public static function check_installed_and_update( $target ) |
|
| 69 | + public static function check_installed_and_update($target) |
|
| 70 | 70 | { |
| 71 | - $db_version = get_option( 'autoptimize_version', 'none' ); |
|
| 72 | - if ( $db_version !== $target ) { |
|
| 73 | - if ( 'none' === $db_version ) { |
|
| 74 | - add_action( 'admin_notices', 'autoptimizeMain::notice_installed' ); |
|
| 71 | + $db_version = get_option('autoptimize_version', 'none'); |
|
| 72 | + if ($db_version !== $target) { |
|
| 73 | + if ('none' === $db_version) { |
|
| 74 | + add_action('admin_notices', 'autoptimizeMain::notice_installed'); |
|
| 75 | 75 | } else { |
| 76 | - $updater = new self( $db_version ); |
|
| 76 | + $updater = new self($db_version); |
|
| 77 | 77 | $updater->run_needed_major_upgrades(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Versions differed, upgrades happened if needed, store the new version. |
| 81 | - update_option( 'autoptimize_version', $target ); |
|
| 81 | + update_option('autoptimize_version', $target); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | protected function on_major_version_update() |
| 90 | 90 | { |
| 91 | 91 | // The transients guard here prevents stale object caches from busting the cache on every request. |
| 92 | - if ( false == get_transient( 'autoptimize_stale_option_buster' ) ) { |
|
| 93 | - set_transient( 'autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS ); |
|
| 92 | + if (false == get_transient('autoptimize_stale_option_buster')) { |
|
| 93 | + set_transient('autoptimize_stale_option_buster', 'Mamsie & Liessie zehhe: ZWIJH!', HOUR_IN_SECONDS); |
|
| 94 | 94 | autoptimizeCache::clearall(); |
| 95 | - add_action( 'admin_notices', 'autoptimizeMain::notice_updated' ); |
|
| 95 | + add_action('admin_notices', 'autoptimizeMain::notice_updated'); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | private function upgrade_from_1_6() |
| 103 | 103 | { |
| 104 | 104 | // If user was on version 1.6.x, force advanced options to be shown by default. |
| 105 | - update_option( 'autoptimize_show_adv', '1' ); |
|
| 105 | + update_option('autoptimize_show_adv', '1'); |
|
| 106 | 106 | |
| 107 | 107 | // And remove old options. |
| 108 | 108 | $to_delete_options = array( |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | 'autoptimize_cdn_img_url', |
| 115 | 115 | 'autoptimize_css_yui', |
| 116 | 116 | ); |
| 117 | - foreach ( $to_delete_options as $del_opt ) { |
|
| 118 | - delete_option( $del_opt ); |
|
| 117 | + foreach ($to_delete_options as $del_opt) { |
|
| 118 | + delete_option($del_opt); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
@@ -126,29 +126,29 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | private function upgrade_from_1_7() |
| 128 | 128 | { |
| 129 | - if ( ! is_multisite() ) { |
|
| 130 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
| 131 | - if ( empty( $css_exclude ) ) { |
|
| 129 | + if (!is_multisite()) { |
|
| 130 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
| 131 | + if (empty($css_exclude)) { |
|
| 132 | 132 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
| 133 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
| 133 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
| 134 | 134 | $css_exclude .= ', dashicons.min.css'; |
| 135 | 135 | } |
| 136 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
| 136 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
| 137 | 137 | } else { |
| 138 | 138 | global $wpdb; |
| 139 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 139 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
| 140 | 140 | $original_blog_id = get_current_blog_id(); |
| 141 | - foreach ( $blog_ids as $blog_id ) { |
|
| 142 | - switch_to_blog( $blog_id ); |
|
| 143 | - $css_exclude = get_option( 'autoptimize_css_exclude' ); |
|
| 144 | - if ( empty( $css_exclude ) ) { |
|
| 141 | + foreach ($blog_ids as $blog_id) { |
|
| 142 | + switch_to_blog($blog_id); |
|
| 143 | + $css_exclude = get_option('autoptimize_css_exclude'); |
|
| 144 | + if (empty($css_exclude)) { |
|
| 145 | 145 | $css_exclude = 'admin-bar.min.css, dashicons.min.css'; |
| 146 | - } elseif ( false === strpos( $css_exclude, 'dashicons.min.css' ) ) { |
|
| 146 | + } elseif (false === strpos($css_exclude, 'dashicons.min.css')) { |
|
| 147 | 147 | $css_exclude .= ', dashicons.min.css'; |
| 148 | 148 | } |
| 149 | - update_option( 'autoptimize_css_exclude', $css_exclude ); |
|
| 149 | + update_option('autoptimize_css_exclude', $css_exclude); |
|
| 150 | 150 | } |
| 151 | - switch_to_blog( $original_blog_id ); |
|
| 151 | + switch_to_blog($original_blog_id); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
@@ -160,19 +160,19 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | private function upgrade_from_1_9() |
| 162 | 162 | { |
| 163 | - if ( ! is_multisite() ) { |
|
| 164 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
| 165 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
| 163 | + if (!is_multisite()) { |
|
| 164 | + update_option('autoptimize_css_include_inline', 'on'); |
|
| 165 | + update_option('autoptimize_js_include_inline', 'on'); |
|
| 166 | 166 | } else { |
| 167 | 167 | global $wpdb; |
| 168 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 168 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
| 169 | 169 | $original_blog_id = get_current_blog_id(); |
| 170 | - foreach ( $blog_ids as $blog_id ) { |
|
| 171 | - switch_to_blog( $blog_id ); |
|
| 172 | - update_option( 'autoptimize_css_include_inline', 'on' ); |
|
| 173 | - update_option( 'autoptimize_js_include_inline', 'on' ); |
|
| 170 | + foreach ($blog_ids as $blog_id) { |
|
| 171 | + switch_to_blog($blog_id); |
|
| 172 | + update_option('autoptimize_css_include_inline', 'on'); |
|
| 173 | + update_option('autoptimize_js_include_inline', 'on'); |
|
| 174 | 174 | } |
| 175 | - switch_to_blog( $original_blog_id ); |
|
| 175 | + switch_to_blog($original_blog_id); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
@@ -183,17 +183,17 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | private function upgrade_from_2_2() |
| 185 | 185 | { |
| 186 | - if ( ! is_multisite() ) { |
|
| 186 | + if (!is_multisite()) { |
|
| 187 | 187 | $this->do_2_2_settings_update(); |
| 188 | 188 | } else { |
| 189 | 189 | global $wpdb; |
| 190 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
| 190 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
| 191 | 191 | $original_blog_id = get_current_blog_id(); |
| 192 | - foreach ( $blog_ids as $blog_id ) { |
|
| 193 | - switch_to_blog( $blog_id ); |
|
| 192 | + foreach ($blog_ids as $blog_id) { |
|
| 193 | + switch_to_blog($blog_id); |
|
| 194 | 194 | $this->do_2_2_settings_update(); |
| 195 | 195 | } |
| 196 | - switch_to_blog( $original_blog_id ); |
|
| 196 | + switch_to_blog($original_blog_id); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -202,12 +202,12 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | private function do_2_2_settings_update() |
| 204 | 204 | { |
| 205 | - $nogooglefont = get_option( 'autoptimize_css_nogooglefont', '' ); |
|
| 206 | - $ao_extrasetting = get_option( 'autoptimize_extra_settings', '' ); |
|
| 207 | - if ( ( $nogooglefont ) && ( empty( $ao_extrasetting ) ) ) { |
|
| 208 | - update_option( 'autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options() ); |
|
| 205 | + $nogooglefont = get_option('autoptimize_css_nogooglefont', ''); |
|
| 206 | + $ao_extrasetting = get_option('autoptimize_extra_settings', ''); |
|
| 207 | + if (($nogooglefont) && (empty($ao_extrasetting))) { |
|
| 208 | + update_option('autoptimize_extra_settings', autoptimizeConfig::get_ao_extra_default_options()); |
|
| 209 | 209 | } |
| 210 | - delete_option( 'autoptimize_css_nogooglefont' ); |
|
| 210 | + delete_option('autoptimize_css_nogooglefont'); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | $jobs = _get_cron_array(); |
| 220 | 220 | |
| 221 | 221 | // Remove all ao_cachechecker cron jobs (for now). |
| 222 | - foreach ( $jobs as $when => $job ) { |
|
| 223 | - $name = key( $job ); |
|
| 222 | + foreach ($jobs as $when => $job) { |
|
| 223 | + $name = key($job); |
|
| 224 | 224 | |
| 225 | - if ( false !== strpos( $name, 'ao_cachechecker' ) ) { |
|
| 226 | - unset( $jobs[ $when ] ); |
|
| 225 | + if (false !== strpos($name, 'ao_cachechecker')) { |
|
| 226 | + unset($jobs[$when]); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Save the data. |
| 231 | - _set_cron_array( $jobs ); |
|
| 231 | + _set_cron_array($jobs); |
|
| 232 | 232 | } |
| 233 | 233 | } |
@@ -16,66 +16,66 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if (!defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.4.4' ); |
|
| 23 | +define('AUTOPTIMIZE_PLUGIN_VERSION', '2.4.4'); |
|
| 24 | 24 | |
| 25 | 25 | // plugin_dir_path() returns the trailing slash! |
| 26 | -define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
|
| 27 | -define( 'AUTOPTIMIZE_PLUGIN_FILE', __FILE__ ); |
|
| 26 | +define('AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path(__FILE__)); |
|
| 27 | +define('AUTOPTIMIZE_PLUGIN_FILE', __FILE__); |
|
| 28 | 28 | |
| 29 | 29 | // Bail early if attempting to run on non-supported php versions. |
| 30 | -if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { |
|
| 30 | +if (version_compare(PHP_VERSION, '5.3', '<')) { |
|
| 31 | 31 | function autoptimize_incompatible_admin_notice() { |
| 32 | - echo '<div class="error"><p>' . __( 'Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize' ) . '</p></div>'; |
|
| 33 | - if ( isset( $_GET['activate'] ) ) { |
|
| 34 | - unset( $_GET['activate'] ); |
|
| 32 | + echo '<div class="error"><p>'.__('Autoptimize requires PHP 5.3 (or higher) to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'autoptimize').'</p></div>'; |
|
| 33 | + if (isset($_GET['activate'])) { |
|
| 34 | + unset($_GET['activate']); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | function autoptimize_deactivate_self() { |
| 38 | - deactivate_plugins( plugin_basename( AUTOPTIMIZE_PLUGIN_FILE ) ); |
|
| 38 | + deactivate_plugins(plugin_basename(AUTOPTIMIZE_PLUGIN_FILE)); |
|
| 39 | 39 | } |
| 40 | - add_action( 'admin_notices', 'autoptimize_incompatible_admin_notice' ); |
|
| 41 | - add_action( 'admin_init', 'autoptimize_deactivate_self' ); |
|
| 40 | + add_action('admin_notices', 'autoptimize_incompatible_admin_notice'); |
|
| 41 | + add_action('admin_init', 'autoptimize_deactivate_self'); |
|
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | -function autoptimize_autoload( $class_name ) { |
|
| 46 | - if ( in_array( $class_name, array( 'Minify_HTML', 'JSMin' ) ) ) { |
|
| 47 | - $file = strtolower( $class_name ); |
|
| 48 | - $file = str_replace( '_', '-', $file ); |
|
| 49 | - $path = dirname( __FILE__ ) . '/classes/external/php/'; |
|
| 50 | - $filepath = $path . $file . '.php'; |
|
| 51 | - } elseif ( false !== strpos( $class_name, 'Autoptimize\\tubalmartin\\CssMin' ) ) { |
|
| 52 | - $file = str_replace( 'Autoptimize\\tubalmartin\\CssMin\\', '', $class_name ); |
|
| 53 | - $path = dirname( __FILE__ ) . '/classes/external/php/yui-php-cssmin-bundled/'; |
|
| 54 | - $filepath = $path . $file . '.php'; |
|
| 55 | - } elseif ( 'autoptimize' === substr( $class_name, 0, 11 ) ) { |
|
| 45 | +function autoptimize_autoload($class_name) { |
|
| 46 | + if (in_array($class_name, array('Minify_HTML', 'JSMin'))) { |
|
| 47 | + $file = strtolower($class_name); |
|
| 48 | + $file = str_replace('_', '-', $file); |
|
| 49 | + $path = dirname(__FILE__).'/classes/external/php/'; |
|
| 50 | + $filepath = $path.$file.'.php'; |
|
| 51 | + } elseif (false !== strpos($class_name, 'Autoptimize\\tubalmartin\\CssMin')) { |
|
| 52 | + $file = str_replace('Autoptimize\\tubalmartin\\CssMin\\', '', $class_name); |
|
| 53 | + $path = dirname(__FILE__).'/classes/external/php/yui-php-cssmin-bundled/'; |
|
| 54 | + $filepath = $path.$file.'.php'; |
|
| 55 | + } elseif ('autoptimize' === substr($class_name, 0, 11)) { |
|
| 56 | 56 | // One of our "old" classes. |
| 57 | 57 | $file = $class_name; |
| 58 | - $path = dirname( __FILE__ ) . '/classes/'; |
|
| 59 | - $filepath = $path . $file . '.php'; |
|
| 60 | - } elseif ( 'PAnD' === $class_name ) { |
|
| 58 | + $path = dirname(__FILE__).'/classes/'; |
|
| 59 | + $filepath = $path.$file.'.php'; |
|
| 60 | + } elseif ('PAnD' === $class_name) { |
|
| 61 | 61 | $file = 'persist-admin-notices-dismissal'; |
| 62 | - $path = dirname( __FILE__ ) . '/classes/external/php/persist-admin-notices-dismissal/'; |
|
| 63 | - $filepath = $path . $file . '.php'; |
|
| 62 | + $path = dirname(__FILE__).'/classes/external/php/persist-admin-notices-dismissal/'; |
|
| 63 | + $filepath = $path.$file.'.php'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // If we didn't match one of our rules, bail! |
| 67 | - if ( ! isset( $filepath ) ) { |
|
| 67 | + if (!isset($filepath)) { |
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | require $filepath; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -spl_autoload_register( 'autoptimize_autoload' ); |
|
| 74 | +spl_autoload_register('autoptimize_autoload'); |
|
| 75 | 75 | |
| 76 | 76 | // Load WP CLI command(s) on demand. |
| 77 | -if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 78 | - require AUTOPTIMIZE_PLUGIN_DIR . 'classes/autoptimizeCLI.php'; |
|
| 77 | +if (defined('WP_CLI') && WP_CLI) { |
|
| 78 | + require AUTOPTIMIZE_PLUGIN_DIR.'classes/autoptimizeCLI.php'; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | function autoptimize() { |
| 87 | 87 | static $plugin = null; |
| 88 | 88 | |
| 89 | - if ( null === $plugin ) { |
|
| 90 | - $plugin = new autoptimizeMain( AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE ); |
|
| 89 | + if (null === $plugin) { |
|
| 90 | + $plugin = new autoptimizeMain(AUTOPTIMIZE_PLUGIN_VERSION, AUTOPTIMIZE_PLUGIN_FILE); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | return $plugin; |