@@ -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_Install' ) ) { |
|
| 18 | +if ( ! class_exists('Auto_Load_Next_Post_Install')) { |
|
| 19 | 19 | |
| 20 | 20 | class Auto_Load_Next_Post_Install { |
| 21 | 21 | |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct() { |
| 39 | 39 | // Resets Auto Load Next Post settings when requested. |
| 40 | - add_action( 'init', array( __CLASS__, 'reset_alnp' ), 0 ); |
|
| 40 | + add_action('init', array(__CLASS__, 'reset_alnp'), 0); |
|
| 41 | 41 | |
| 42 | 42 | // Checks version of Auto Load Next Post and install/update if needed. |
| 43 | - add_action( 'init', array( __CLASS__, 'check_version' ), 5 ); |
|
| 43 | + add_action('init', array(__CLASS__, 'check_version'), 5); |
|
| 44 | 44 | |
| 45 | 45 | // Adds rewrite endpoint. |
| 46 | - add_action( 'init', array( __CLASS__, 'add_rewrite_endpoint' ), 10 ); |
|
| 46 | + add_action('init', array(__CLASS__, 'add_rewrite_endpoint'), 10); |
|
| 47 | 47 | |
| 48 | 48 | // Get plugin version. |
| 49 | - self::$current_version = get_option( 'auto_load_next_post_version' ); |
|
| 49 | + self::$current_version = get_option('auto_load_next_post_version'); |
|
| 50 | 50 | } // END __construct() |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * @version 1.5.11 |
| 61 | 61 | */ |
| 62 | 62 | public static function check_version() { |
| 63 | - if ( ! defined( 'IFRAME_REQUEST' ) && version_compare( self::$current_version, AUTO_LOAD_NEXT_POST_VERSION, '<' ) && current_user_can( 'install_plugins' ) ) { |
|
| 63 | + if ( ! defined('IFRAME_REQUEST') && version_compare(self::$current_version, AUTO_LOAD_NEXT_POST_VERSION, '<') && current_user_can('install_plugins')) { |
|
| 64 | 64 | self::install(); |
| 65 | - do_action( 'auto_load_next_post_updated' ); |
|
| 65 | + do_action('auto_load_next_post_updated'); |
|
| 66 | 66 | } |
| 67 | 67 | } // END check_version() |
| 68 | 68 | |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | * @version 1.5.0 |
| 76 | 76 | */ |
| 77 | 77 | public static function install() { |
| 78 | - if ( ! is_blog_installed() ) { |
|
| 78 | + if ( ! is_blog_installed()) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Check if we are not already running this routine. |
| 83 | - if ( 'yes' === get_transient( 'alnp_installing' ) ) { |
|
| 83 | + if ('yes' === get_transient('alnp_installing')) { |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // If we made it till here nothing is running yet, lets set the transient now for five minutes. |
| 88 | - set_transient( 'alnp_installing', 'yes', MINUTE_IN_SECONDS * 5 ); |
|
| 89 | - if ( ! defined( 'AUTO_LOAD_NEXT_POST_INSTALLING' ) ) { |
|
| 90 | - define( 'AUTO_LOAD_NEXT_POST_INSTALLING', true ); |
|
| 88 | + set_transient('alnp_installing', 'yes', MINUTE_IN_SECONDS * 5); |
|
| 89 | + if ( ! defined('AUTO_LOAD_NEXT_POST_INSTALLING')) { |
|
| 90 | + define('AUTO_LOAD_NEXT_POST_INSTALLING', true); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Add default options. |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | // Refresh rewrite rules. |
| 109 | 109 | self::flush_rewrite_rules(); |
| 110 | 110 | |
| 111 | - delete_transient( 'alnp_installing' ); |
|
| 111 | + delete_transient('alnp_installing'); |
|
| 112 | 112 | |
| 113 | - do_action( 'alnp_installed' ); |
|
| 113 | + do_action('alnp_installed'); |
|
| 114 | 114 | } // END install() |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @since 1.5.0 |
| 123 | 123 | */ |
| 124 | 124 | private static function set_theme_selectors() { |
| 125 | - if ( is_alnp_supported() ) { |
|
| 126 | - $content_container = alnp_get_theme_support( 'content_container' ); |
|
| 127 | - $title_selector = alnp_get_theme_support( 'title_selector' ); |
|
| 128 | - $navigation_container = alnp_get_theme_support( 'navigation_container' ); |
|
| 129 | - $comments_container = alnp_get_theme_support( 'comments_container' ); |
|
| 130 | - |
|
| 131 | - if ( ! empty( $content_container ) ) update_option( 'auto_load_next_post_content_container', $content_container ); |
|
| 132 | - if ( ! empty( $title_selector ) ) update_option( 'auto_load_next_post_title_selector', $title_selector ); |
|
| 133 | - if ( ! empty( $navigation_container ) ) update_option( 'auto_load_next_post_navigation_container', $navigation_container ); |
|
| 134 | - if ( ! empty( $comments_container ) ) update_option( 'auto_load_next_post_comments_container', $comments_container ); |
|
| 125 | + if (is_alnp_supported()) { |
|
| 126 | + $content_container = alnp_get_theme_support('content_container'); |
|
| 127 | + $title_selector = alnp_get_theme_support('title_selector'); |
|
| 128 | + $navigation_container = alnp_get_theme_support('navigation_container'); |
|
| 129 | + $comments_container = alnp_get_theme_support('comments_container'); |
|
| 130 | + |
|
| 131 | + if ( ! empty($content_container)) update_option('auto_load_next_post_content_container', $content_container); |
|
| 132 | + if ( ! empty($title_selector)) update_option('auto_load_next_post_title_selector', $title_selector); |
|
| 133 | + if ( ! empty($navigation_container)) update_option('auto_load_next_post_navigation_container', $navigation_container); |
|
| 134 | + if ( ! empty($comments_container)) update_option('auto_load_next_post_comments_container', $comments_container); |
|
| 135 | 135 | } |
| 136 | 136 | } // END set_theme_selectors() |
| 137 | 137 | |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | * @version 1.5.3 |
| 147 | 147 | */ |
| 148 | 148 | private static function set_js_in_footer() { |
| 149 | - if ( is_alnp_supported() ) { |
|
| 150 | - $load_js_in_footer = alnp_get_theme_support( 'load_js_in_footer' ); |
|
| 151 | - $lock_js_in_footer = alnp_get_theme_support( 'lock_js_in_footer' ); |
|
| 149 | + if (is_alnp_supported()) { |
|
| 150 | + $load_js_in_footer = alnp_get_theme_support('load_js_in_footer'); |
|
| 151 | + $lock_js_in_footer = alnp_get_theme_support('lock_js_in_footer'); |
|
| 152 | 152 | |
| 153 | - if ( ! empty( $load_js_in_footer ) && $load_js_in_footer == 'yes' ) update_option( 'auto_load_next_post_load_js_in_footer', $load_js_in_footer ); |
|
| 154 | - if ( ! empty( $lock_js_in_footer ) && $lock_js_in_footer == 'yes' ) update_option( 'auto_load_next_post_lock_js_in_footer', $lock_js_in_footer ); |
|
| 153 | + if ( ! empty($load_js_in_footer) && $load_js_in_footer == 'yes') update_option('auto_load_next_post_load_js_in_footer', $load_js_in_footer); |
|
| 154 | + if ( ! empty($lock_js_in_footer) && $lock_js_in_footer == 'yes') update_option('auto_load_next_post_lock_js_in_footer', $lock_js_in_footer); |
|
| 155 | 155 | } |
| 156 | 156 | } // END set_js_in_footer() |
| 157 | 157 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @static |
| 163 | 163 | */ |
| 164 | 164 | private static function update_version() { |
| 165 | - update_option( 'auto_load_next_post_version', AUTO_LOAD_NEXT_POST_VERSION ); |
|
| 165 | + update_option('auto_load_next_post_version', AUTO_LOAD_NEXT_POST_VERSION); |
|
| 166 | 166 | } // END update_version() |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | * @version 1.5.0 |
| 175 | 175 | */ |
| 176 | 176 | public static function set_install_date() { |
| 177 | - $install_date = get_site_option( 'auto_load_next_post_install_date' ); |
|
| 177 | + $install_date = get_site_option('auto_load_next_post_install_date'); |
|
| 178 | 178 | |
| 179 | 179 | // If ALNP was installed before but the install date was not converted to time then convert it. |
| 180 | - if ( ! empty( $install_date ) && !intval( $install_date ) ) { |
|
| 181 | - update_site_option( 'auto_load_next_post_install_date', strtotime( $install_date ) ); |
|
| 180 | + if ( ! empty($install_date) && ! intval($install_date)) { |
|
| 181 | + update_site_option('auto_load_next_post_install_date', strtotime($install_date)); |
|
| 182 | 182 | } else { |
| 183 | - add_site_option( 'auto_load_next_post_install_date', time() ); |
|
| 183 | + add_site_option('auto_load_next_post_install_date', time()); |
|
| 184 | 184 | } |
| 185 | 185 | } // END set_install_date() |
| 186 | 186 | |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public static function create_options() { |
| 198 | 198 | // Include settings so that we can run through defaults |
| 199 | - include_once( dirname( __FILE__ ) . '/admin/class-alnp-admin-settings.php' ); |
|
| 199 | + include_once(dirname(__FILE__).'/admin/class-alnp-admin-settings.php'); |
|
| 200 | 200 | |
| 201 | 201 | $settings = Auto_Load_Next_Post_Admin_Settings::get_settings_pages(); |
| 202 | 202 | |
| 203 | - foreach ( $settings as $section ) { |
|
| 204 | - foreach ( $section->get_settings() as $value ) { |
|
| 205 | - if ( isset( $value['default'] ) && isset( $value['id'] ) ) { |
|
| 206 | - $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true; |
|
| 207 | - add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) ); |
|
| 203 | + foreach ($settings as $section) { |
|
| 204 | + foreach ($section->get_settings() as $value) { |
|
| 205 | + if (isset($value['default']) && isset($value['id'])) { |
|
| 206 | + $autoload = isset($value['autoload']) ? (bool) $value['autoload'] : true; |
|
| 207 | + add_option($value['id'], $value['default'], '', ($autoload ? 'yes' : 'no')); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * @version 1.5.0 |
| 220 | 220 | */ |
| 221 | 221 | public static function add_rewrite_endpoint() { |
| 222 | - add_rewrite_endpoint( 'alnp', EP_PERMALINK | EP_PAGES | EP_ATTACHMENT ); |
|
| 222 | + add_rewrite_endpoint('alnp', EP_PERMALINK | EP_PAGES | EP_ATTACHMENT); |
|
| 223 | 223 | } // END add_rewrite_endpoint() |
| 224 | 224 | |
| 225 | 225 | /** |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | * @global object $wpdb |
| 243 | 243 | */ |
| 244 | 244 | public static function reset_alnp() { |
| 245 | - if ( current_user_can( 'install_plugins' ) && isset( $_GET['reset-alnp'] ) && $_GET['reset-alnp'] == 'yes' ) { |
|
| 245 | + if (current_user_can('install_plugins') && isset($_GET['reset-alnp']) && $_GET['reset-alnp'] == 'yes') { |
|
| 246 | 246 | global $wpdb; |
| 247 | 247 | |
| 248 | 248 | // Make sure it is only a single site we are resetting. |
| 249 | - if ( ! is_multisite() ) { |
|
| 249 | + if ( ! is_multisite()) { |
|
| 250 | 250 | // Delete options |
| 251 | 251 | $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'auto_load_next_post_%'"); |
| 252 | 252 | |
@@ -254,26 +254,26 @@ discard block |
||
| 254 | 254 | $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'auto_load_next_post_%'"); |
| 255 | 255 | |
| 256 | 256 | // Delete Uninstall Data - Just to double check it has been removed. |
| 257 | - delete_option( 'auto_load_next_post_uninstall_data' ); |
|
| 257 | + delete_option('auto_load_next_post_uninstall_data'); |
|
| 258 | 258 | |
| 259 | 259 | // Delete Install Date |
| 260 | - delete_option( 'auto_load_next_post_install_date' ); |
|
| 260 | + delete_option('auto_load_next_post_install_date'); |
|
| 261 | 261 | } |
| 262 | 262 | else { |
| 263 | 263 | // Delete Uninstall Data |
| 264 | - delete_site_option( 'auto_load_next_post_uninstall_data' ); |
|
| 264 | + delete_site_option('auto_load_next_post_uninstall_data'); |
|
| 265 | 265 | |
| 266 | 266 | // Delete Install Date |
| 267 | - delete_site_option( 'auto_load_next_post_install_date' ); |
|
| 267 | + delete_site_option('auto_load_next_post_install_date'); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // Re-install Auto Load Next Post |
| 271 | 271 | self::install(); |
| 272 | 272 | |
| 273 | - wp_safe_redirect( add_query_arg( array( |
|
| 273 | + wp_safe_redirect(add_query_arg(array( |
|
| 274 | 274 | 'page' => 'auto-load-next-post-settings', |
| 275 | 275 | 'reset' => 'done' |
| 276 | - ), admin_url( 'options-general.php' ) ) ); |
|
| 276 | + ), admin_url('options-general.php'))); |
|
| 277 | 277 | exit; |
| 278 | 278 | } |
| 279 | 279 | } // END reset_alnp() |
@@ -128,10 +128,18 @@ discard block |
||
| 128 | 128 | $navigation_container = alnp_get_theme_support( 'navigation_container' ); |
| 129 | 129 | $comments_container = alnp_get_theme_support( 'comments_container' ); |
| 130 | 130 | |
| 131 | - if ( ! empty( $content_container ) ) update_option( 'auto_load_next_post_content_container', $content_container ); |
|
| 132 | - if ( ! empty( $title_selector ) ) update_option( 'auto_load_next_post_title_selector', $title_selector ); |
|
| 133 | - if ( ! empty( $navigation_container ) ) update_option( 'auto_load_next_post_navigation_container', $navigation_container ); |
|
| 134 | - if ( ! empty( $comments_container ) ) update_option( 'auto_load_next_post_comments_container', $comments_container ); |
|
| 131 | + if ( ! empty( $content_container ) ) { |
|
| 132 | + update_option( 'auto_load_next_post_content_container', $content_container ); |
|
| 133 | + } |
|
| 134 | + if ( ! empty( $title_selector ) ) { |
|
| 135 | + update_option( 'auto_load_next_post_title_selector', $title_selector ); |
|
| 136 | + } |
|
| 137 | + if ( ! empty( $navigation_container ) ) { |
|
| 138 | + update_option( 'auto_load_next_post_navigation_container', $navigation_container ); |
|
| 139 | + } |
|
| 140 | + if ( ! empty( $comments_container ) ) { |
|
| 141 | + update_option( 'auto_load_next_post_comments_container', $comments_container ); |
|
| 142 | + } |
|
| 135 | 143 | } |
| 136 | 144 | } // END set_theme_selectors() |
| 137 | 145 | |
@@ -150,8 +158,12 @@ discard block |
||
| 150 | 158 | $load_js_in_footer = alnp_get_theme_support( 'load_js_in_footer' ); |
| 151 | 159 | $lock_js_in_footer = alnp_get_theme_support( 'lock_js_in_footer' ); |
| 152 | 160 | |
| 153 | - if ( ! empty( $load_js_in_footer ) && $load_js_in_footer == 'yes' ) update_option( 'auto_load_next_post_load_js_in_footer', $load_js_in_footer ); |
|
| 154 | - if ( ! empty( $lock_js_in_footer ) && $lock_js_in_footer == 'yes' ) update_option( 'auto_load_next_post_lock_js_in_footer', $lock_js_in_footer ); |
|
| 161 | + if ( ! empty( $load_js_in_footer ) && $load_js_in_footer == 'yes' ) { |
|
| 162 | + update_option( 'auto_load_next_post_load_js_in_footer', $load_js_in_footer ); |
|
| 163 | + } |
|
| 164 | + if ( ! empty( $lock_js_in_footer ) && $lock_js_in_footer == 'yes' ) { |
|
| 165 | + update_option( 'auto_load_next_post_lock_js_in_footer', $lock_js_in_footer ); |
|
| 166 | + } |
|
| 155 | 167 | } |
| 156 | 168 | } // END set_js_in_footer() |
| 157 | 169 | |
@@ -258,8 +270,7 @@ discard block |
||
| 258 | 270 | |
| 259 | 271 | // Delete Install Date |
| 260 | 272 | delete_option( 'auto_load_next_post_install_date' ); |
| 261 | - } |
|
| 262 | - else { |
|
| 273 | + } else { |
|
| 263 | 274 | // Delete Uninstall Data |
| 264 | 275 | delete_site_option( 'auto_load_next_post_uninstall_data' ); |
| 265 | 276 | |