@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( 'Auto_Load_Next_Post_Admin_Notices' ) ) { |
|
| 18 | +if ( ! class_exists('Auto_Load_Next_Post_Admin_Notices')) { |
|
| 19 | 19 | |
| 20 | 20 | class Auto_Load_Next_Post_Admin_Notices { |
| 21 | 21 | |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | * @version 1.5.11 |
| 38 | 38 | */ |
| 39 | 39 | public function __construct() { |
| 40 | - self::$install_date = get_site_option( 'auto_load_next_post_install_date', time() ); |
|
| 40 | + self::$install_date = get_site_option('auto_load_next_post_install_date', time()); |
|
| 41 | 41 | |
| 42 | 42 | // Check WordPress enviroment. |
| 43 | - add_action( 'admin_init', array( $this, 'check_wp' ), 12 ); |
|
| 43 | + add_action('admin_init', array($this, 'check_wp'), 12); |
|
| 44 | 44 | |
| 45 | 45 | // Don't bug the user if they don't want to see any notices. |
| 46 | - add_action( 'admin_init', array( $this, 'dont_bug_me' ), 15 ); |
|
| 46 | + add_action('admin_init', array($this, 'dont_bug_me'), 15); |
|
| 47 | 47 | |
| 48 | 48 | // Display other admin notices when required. All are dismissable. |
| 49 | - add_action( 'admin_print_styles', array( $this, 'add_notices' ), 0 ); |
|
| 49 | + add_action('admin_print_styles', array($this, 'add_notices'), 0); |
|
| 50 | 50 | } // END __construct() |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -62,12 +62,12 @@ discard block |
||
| 62 | 62 | global $wp_version; |
| 63 | 63 | |
| 64 | 64 | // If the current user can not install plugins then return nothing! |
| 65 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
| 65 | + if ( ! current_user_can('install_plugins')) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if ( ! version_compare( $wp_version, AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE, '>=' ) ) { |
|
| 70 | - add_action( 'admin_notices', array( $this, 'requirement_wp_notice' ) ); |
|
| 69 | + if ( ! version_compare($wp_version, AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE, '>=')) { |
|
| 70 | + add_action('admin_notices', array($this, 'requirement_wp_notice')); |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -88,31 +88,31 @@ discard block |
||
| 88 | 88 | $user_hidden_notice = false; |
| 89 | 89 | |
| 90 | 90 | // If the user is allowed to install plugins and requested to hide the review notice then hide it for that user. |
| 91 | - if ( ! empty( $_GET['hide_auto_load_next_post_review_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 92 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true ); |
|
| 91 | + if ( ! empty($_GET['hide_auto_load_next_post_review_notice']) && current_user_can('install_plugins')) { |
|
| 92 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true); |
|
| 93 | 93 | $user_hidden_notice = true; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // If the user is allowed to install plugins and requested to hide the upgrade notice then hide it for that user. |
| 97 | - if ( ! empty( $_GET['hide_auto_load_next_post_upgrade_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 98 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_upgrade_notice', '1', true ); |
|
| 97 | + if ( ! empty($_GET['hide_auto_load_next_post_upgrade_notice']) && current_user_can('install_plugins')) { |
|
| 98 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_upgrade_notice', '1', true); |
|
| 99 | 99 | $user_hidden_notice = true; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | // If the user is allowed to install plugins and requested to hide the welcome notice then hide it for that user. |
| 103 | - if ( ! empty( $_GET['hide_auto_load_next_post_welcome_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 104 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true ); |
|
| 103 | + if ( ! empty($_GET['hide_auto_load_next_post_welcome_notice']) && current_user_can('install_plugins')) { |
|
| 104 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true); |
|
| 105 | 105 | $user_hidden_notice = true; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( ! empty( $_GET['hide_auto_load_next_post_beta_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 109 | - set_transient( 'alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS ); |
|
| 108 | + if ( ! empty($_GET['hide_auto_load_next_post_beta_notice']) && current_user_can('install_plugins')) { |
|
| 109 | + set_transient('alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS); |
|
| 110 | 110 | $user_hidden_notice = true; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( $user_hidden_notice ) { |
|
| 113 | + if ($user_hidden_notice) { |
|
| 114 | 114 | // Redirect to the plugins page. |
| 115 | - wp_safe_redirect( admin_url( 'plugins.php' ) ); |
|
| 115 | + wp_safe_redirect(admin_url('plugins.php')); |
|
| 116 | 116 | exit; |
| 117 | 117 | } |
| 118 | 118 | } // END dont_bug_me() |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | global $current_user; |
| 132 | 132 | |
| 133 | 133 | // If the current user can not install plugins then return nothing! |
| 134 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
| 134 | + if ( ! current_user_can('install_plugins')) { |
|
| 135 | 135 | return false; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -139,66 +139,66 @@ discard block |
||
| 139 | 139 | $screen_id = $screen ? $screen->id : ''; |
| 140 | 140 | |
| 141 | 141 | // Notices should only show on the main dashboard and on the plugins screen. |
| 142 | - if ( ! in_array( $screen_id, alnp_get_admin_screens() ) ) { |
|
| 142 | + if ( ! in_array($screen_id, alnp_get_admin_screens())) { |
|
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Is admin welcome notice hidden? |
| 147 | - $hide_welcome_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', true ); |
|
| 147 | + $hide_welcome_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', true); |
|
| 148 | 148 | |
| 149 | 149 | // Check if we need to display the welcome notice. |
| 150 | - if ( empty( $hide_welcome_notice ) ) { |
|
| 150 | + if (empty($hide_welcome_notice)) { |
|
| 151 | 151 | // If the user has just installed the plugin for the first time then welcome the user. |
| 152 | - if ( ( intval( time() - self::$install_date ) / WEEK_IN_SECONDS ) % 52 <= 2 ) { |
|
| 153 | - add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); |
|
| 152 | + if ((intval(time() - self::$install_date) / WEEK_IN_SECONDS) % 52 <= 2) { |
|
| 153 | + add_action('admin_notices', array($this, 'welcome_notice')); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Is admin review notice hidden? |
| 158 | - $hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true ); |
|
| 158 | + $hide_review_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', true); |
|
| 159 | 159 | |
| 160 | 160 | // Check if we need to display the review plugin notice. |
| 161 | - if ( empty( $hide_review_notice ) ) { |
|
| 161 | + if (empty($hide_review_notice)) { |
|
| 162 | 162 | // If it has been a week or more since activating the plugin then display the review notice. |
| 163 | - if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) { |
|
| 164 | - add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) ); |
|
| 163 | + if ((intval(time() - self::$install_date)) > WEEK_IN_SECONDS) { |
|
| 164 | + add_action('admin_notices', array($this, 'plugin_review_notice')); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Is this version of Auto Load Next Post a beta release? |
| 169 | - if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) { |
|
| 170 | - add_action( 'admin_notices', array( $this, 'beta_notice' ) ); |
|
| 169 | + if (is_alnp_beta() && empty(get_transient('alnp_beta_notice_hidden'))) { |
|
| 170 | + add_action('admin_notices', array($this, 'beta_notice')); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - $template = get_option( 'template' ); |
|
| 173 | + $template = get_option('template'); |
|
| 174 | 174 | |
| 175 | 175 | // Checks if the theme supports Auto Load Next Post and not provided via a plugin. |
| 176 | - if ( is_alnp_supported() ) { |
|
| 177 | - $plugin_supported = alnp_get_theme_support( 'plugin_support' ); |
|
| 176 | + if (is_alnp_supported()) { |
|
| 177 | + $plugin_supported = alnp_get_theme_support('plugin_support'); |
|
| 178 | 178 | |
| 179 | 179 | // Return if theme is supported via plugin. |
| 180 | - if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) { |
|
| 181 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
| 180 | + if ( ! empty($plugin_supported) && $plugin_supported == 'yes') { |
|
| 181 | + update_option('auto_load_next_post_theme_supported', $template); |
|
| 182 | 182 | return false; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // If supported theme does not match active theme then show notice. |
| 186 | - if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) { |
|
| 187 | - add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) ); |
|
| 188 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
| 186 | + if (get_option('auto_load_next_post_theme_supported') !== $template) { |
|
| 187 | + add_action('admin_notices', array($this, 'theme_ready_notice')); |
|
| 188 | + update_option('auto_load_next_post_theme_supported', $template); |
|
| 189 | 189 | } |
| 190 | 190 | } else { |
| 191 | 191 | // If theme not supported then delete option. |
| 192 | - delete_option( 'auto_load_next_post_theme_supported' ); |
|
| 192 | + delete_option('auto_load_next_post_theme_supported'); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Upgrade warning notice that will disappear once the new release is installed. |
| 196 | 196 | $upgrade_version = '1.6.0'; |
| 197 | 197 | |
| 198 | - $user_hidden_upgrade = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_upgrade_notice', '1' ); |
|
| 198 | + $user_hidden_upgrade = get_user_meta($current_user->ID, 'auto_load_next_post_hide_upgrade_notice', '1'); |
|
| 199 | 199 | |
| 200 | - if ( version_compare( AUTO_LOAD_NEXT_POST_VERSION, $upgrade_version, '<' ) && empty( $user_hidden_upgrade ) ) { |
|
| 201 | - add_action( 'admin_notices', array( $this, 'upgrade_warning' ) ); |
|
| 200 | + if (version_compare(AUTO_LOAD_NEXT_POST_VERSION, $upgrade_version, '<') && empty($user_hidden_upgrade)) { |
|
| 201 | + add_action('admin_notices', array($this, 'upgrade_warning')); |
|
| 202 | 202 | } |
| 203 | 203 | } // END add_notices() |
| 204 | 204 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @version 1.5.13 |
| 212 | 212 | */ |
| 213 | 213 | public function upgrade_warning() { |
| 214 | - include_once( dirname( __FILE__ ) . '/views/html-notice-upgrade-warning.php' ); |
|
| 214 | + include_once(dirname(__FILE__).'/views/html-notice-upgrade-warning.php'); |
|
| 215 | 215 | } // END upgrade_warning() |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @since 1.4.3 |
| 222 | 222 | */ |
| 223 | 223 | public function requirement_wp_notice() { |
| 224 | - include( dirname( __FILE__ ) . '/views/html-notice-requirement-wp.php' ); |
|
| 224 | + include(dirname(__FILE__).'/views/html-notice-requirement-wp.php'); |
|
| 225 | 225 | } // END requirement_wp_notice() |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @since 1.5.0 |
| 232 | 232 | */ |
| 233 | 233 | public function theme_ready_notice() { |
| 234 | - include( dirname( __FILE__ ) . '/views/html-notice-theme-ready.php' ); |
|
| 234 | + include(dirname(__FILE__).'/views/html-notice-theme-ready.php'); |
|
| 235 | 235 | } // END theme_ready_notice() |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @since 1.5.0 |
| 242 | 242 | */ |
| 243 | 243 | public function welcome_notice() { |
| 244 | - include( dirname( __FILE__ ) . '/views/html-notice-welcome.php' ); |
|
| 244 | + include(dirname(__FILE__).'/views/html-notice-welcome.php'); |
|
| 245 | 245 | } // END welcome_notice() |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @since 1.5.0 |
| 252 | 252 | */ |
| 253 | 253 | public function beta_notice() { |
| 254 | - include( dirname( __FILE__ ) . '/views/html-notice-trying-beta.php' ); |
|
| 254 | + include(dirname(__FILE__).'/views/html-notice-trying-beta.php'); |
|
| 255 | 255 | } // END beta_notice() |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | public function plugin_review_notice() { |
| 265 | 265 | $install_date = self::$install_date; |
| 266 | 266 | |
| 267 | - include( dirname( __FILE__ ) . '/views/html-notice-please-review.php' ); |
|
| 267 | + include(dirname(__FILE__).'/views/html-notice-please-review.php'); |
|
| 268 | 268 | } // END plugin_review_notice() |
| 269 | 269 | |
| 270 | 270 | } // END class. |