@@ -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' ) ) { |
|
| 18 | +if ( ! class_exists('Auto_Load_Next_Post_Admin')) { |
|
| 19 | 19 | |
| 20 | 20 | class Auto_Load_Next_Post_Admin { |
| 21 | 21 | |
@@ -31,20 +31,20 @@ discard block |
||
| 31 | 31 | self::includes(); |
| 32 | 32 | |
| 33 | 33 | // Register scripts and styles for settings page. |
| 34 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ), 10 ); |
|
| 35 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 10 ); |
|
| 34 | + add_action('admin_enqueue_scripts', array($this, 'admin_styles'), 10); |
|
| 35 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 10); |
|
| 36 | 36 | |
| 37 | 37 | // Add a message in the WP Privacy Policy Guide page. |
| 38 | - add_action( 'admin_init', array( $this, 'add_privacy_policy_guide_content' ) ); |
|
| 38 | + add_action('admin_init', array($this, 'add_privacy_policy_guide_content')); |
|
| 39 | 39 | |
| 40 | 40 | // Add settings page. |
| 41 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); |
|
| 41 | + add_action('admin_menu', array($this, 'admin_menu'), 9); |
|
| 42 | 42 | |
| 43 | 43 | // Filters plugin row and admin footer. |
| 44 | - add_filter( 'plugin_action_links_' . plugin_basename( AUTO_LOAD_NEXT_POST_FILE ), array( $this, 'plugin_action_links' ) ); |
|
| 45 | - add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta'), 10, 3 ); |
|
| 46 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 15, 1 ); |
|
| 47 | - add_filter( 'update_footer', array( $this, 'update_footer'), 15 ); |
|
| 44 | + add_filter('plugin_action_links_'.plugin_basename(AUTO_LOAD_NEXT_POST_FILE), array($this, 'plugin_action_links')); |
|
| 45 | + add_filter('plugin_row_meta', array($this, 'plugin_row_meta'), 10, 3); |
|
| 46 | + add_filter('admin_footer_text', array($this, 'admin_footer_text'), 15, 1); |
|
| 47 | + add_filter('update_footer', array($this, 'update_footer'), 15); |
|
| 48 | 48 | } // END __construct() |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * @version 1.5.11 |
| 56 | 56 | */ |
| 57 | 57 | public function includes() { |
| 58 | - include( dirname( __FILE__ ) . '/class-alnp-admin-notices.php' ); // Plugin Notices |
|
| 58 | + include(dirname(__FILE__).'/class-alnp-admin-notices.php'); // Plugin Notices |
|
| 59 | 59 | |
| 60 | 60 | // Classes we only need if the ajax is not-ajax |
| 61 | - if ( apply_filters( 'auto_load_next_post_enable_admin_help_tab', true ) ) { |
|
| 62 | - include( dirname( __FILE__ ) . '/class-alnp-admin-help.php' ); // Plugin Help Tab |
|
| 61 | + if (apply_filters('auto_load_next_post_enable_admin_help_tab', true)) { |
|
| 62 | + include(dirname(__FILE__).'/class-alnp-admin-help.php'); // Plugin Help Tab |
|
| 63 | 63 | } |
| 64 | 64 | } // END includes() |
| 65 | 65 | |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | $screen = get_current_screen(); |
| 74 | 74 | $screen_id = $screen ? $screen->id : ''; |
| 75 | 75 | |
| 76 | - Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_admin', '/assets/css/admin/auto-load-next-post' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.css' ); |
|
| 76 | + Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin', '/assets/css/admin/auto-load-next-post'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css'); |
|
| 77 | 77 | |
| 78 | - if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) { |
|
| 78 | + if ($screen_id == 'settings_page_auto-load-next-post-settings') { |
|
| 79 | 79 | // Select2 - Make sure that we remove other registered Select2 to prevent styling issues. |
| 80 | - if ( wp_script_is( 'select2', 'registered' ) ) { |
|
| 81 | - wp_dequeue_style( 'select2' ); |
|
| 82 | - wp_deregister_style( 'select2' ); |
|
| 80 | + if (wp_script_is('select2', 'registered')) { |
|
| 81 | + wp_dequeue_style('select2'); |
|
| 82 | + wp_deregister_style('select2'); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - Auto_Load_Next_Post::load_file( 'select2', '/assets/css/libs/select2' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.css' ); |
|
| 85 | + Auto_Load_Next_Post::load_file('select2', '/assets/css/libs/select2'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.css'); |
|
| 86 | 86 | } |
| 87 | 87 | } // END admin_styles() |
| 88 | 88 | |
@@ -97,25 +97,25 @@ discard block |
||
| 97 | 97 | $screen = get_current_screen(); |
| 98 | 98 | $screen_id = $screen ? $screen->id : ''; |
| 99 | 99 | |
| 100 | - if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) { |
|
| 100 | + if ($screen_id == 'settings_page_auto-load-next-post-settings') { |
|
| 101 | 101 | // Select2 - Make sure that we remove other registered Select2 to prevent plugin conflict issues. |
| 102 | - if ( wp_script_is( 'select2', 'registered' ) ) { |
|
| 103 | - wp_dequeue_script( 'select2' ); |
|
| 104 | - wp_deregister_script( 'select2' ); |
|
| 102 | + if (wp_script_is('select2', 'registered')) { |
|
| 103 | + wp_dequeue_script('select2'); |
|
| 104 | + wp_deregister_script('select2'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Load Select2 |
| 108 | - Auto_Load_Next_Post::load_file( 'select2', '/assets/js/libs/select2' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery' ), '4.0.5', true ); |
|
| 108 | + Auto_Load_Next_Post::load_file('select2', '/assets/js/libs/select2'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), '4.0.5', true); |
|
| 109 | 109 | |
| 110 | 110 | // Load plugin settings. |
| 111 | - Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_admin', '/assets/js/admin/settings' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery' ), AUTO_LOAD_NEXT_POST_VERSION, true ); |
|
| 111 | + Auto_Load_Next_Post::load_file(AUTO_LOAD_NEXT_POST_SLUG.'_admin', '/assets/js/admin/settings'.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, true); |
|
| 112 | 112 | |
| 113 | 113 | // Variables for Admin JavaScript. |
| 114 | - wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_admin', 'alnp_settings_params', array( |
|
| 114 | + wp_localize_script(AUTO_LOAD_NEXT_POST_SLUG.'_admin', 'alnp_settings_params', array( |
|
| 115 | 115 | 'is_rtl' => is_rtl() ? 'rtl' : 'ltr', |
| 116 | - 'i18n_nav_warning' => esc_html__( 'The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post' ), |
|
| 117 | - 'i18n_reset_warning' => sprintf( esc_html__( 'This will reset all settings back to default and re-initialize %s. Are you sure?', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
|
| 118 | - ) ); |
|
| 116 | + 'i18n_nav_warning' => esc_html__('The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post'), |
|
| 117 | + 'i18n_reset_warning' => sprintf(esc_html__('This will reset all settings back to default and re-initialize %s. Are you sure?', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')), |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | } // END admin_scripts() |
| 121 | 121 | |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | * @static |
| 128 | 128 | */ |
| 129 | 129 | public static function add_privacy_policy_guide_content() { |
| 130 | - if ( function_exists( 'wp_add_privacy_policy_content' ) ) { |
|
| 131 | - wp_add_privacy_policy_content( esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), self::get_privacy_policy_guide_message() ); |
|
| 130 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
| 131 | + wp_add_privacy_policy_content(esc_html__('Auto Load Next Post', 'auto-load-next-post'), self::get_privacy_policy_guide_message()); |
|
| 132 | 132 | } |
| 133 | 133 | } // END add_privacy_policy_guide_content() |
| 134 | 134 | |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | protected static function get_privacy_policy_guide_message() { |
| 144 | 144 | $content = ' |
| 145 | 145 | <div contenteditable="false">' . |
| 146 | - '<p class="wp-policy-help">' . |
|
| 147 | - sprintf( __( '%s does not collect, store or share any personal data.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . |
|
| 148 | - '</p>' . |
|
| 146 | + '<p class="wp-policy-help">'. |
|
| 147 | + sprintf(__('%s does not collect, store or share any personal data.', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')). |
|
| 148 | + '</p>'. |
|
| 149 | 149 | '</div>'; |
| 150 | 150 | |
| 151 | 151 | return $content; |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function admin_menu() { |
| 162 | 162 | $settings_page = add_options_page( |
| 163 | - sprintf( __( '%s Settings', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
|
| 164 | - esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), |
|
| 163 | + sprintf(__('%s Settings', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')), |
|
| 164 | + esc_html__('Auto Load Next Post', 'auto-load-next-post'), |
|
| 165 | 165 | 'manage_options', |
| 166 | 166 | 'auto-load-next-post-settings', |
| 167 | - array( $this, 'settings_page' ) |
|
| 167 | + array($this, 'settings_page') |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) ); |
|
| 170 | + add_action('load-'.$settings_page, array($this, 'settings_page_init')); |
|
| 171 | 171 | } // END admin_menu() |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -182,29 +182,29 @@ discard block |
||
| 182 | 182 | global $current_tab, $current_section; |
| 183 | 183 | |
| 184 | 184 | // Include settings pages. |
| 185 | - include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' ); |
|
| 185 | + include_once(dirname(__FILE__).'/class-alnp-admin-settings.php'); |
|
| 186 | 186 | |
| 187 | 187 | Auto_Load_Next_Post_Admin_Settings::get_settings_pages(); |
| 188 | 188 | |
| 189 | 189 | // Get current tab/section. |
| 190 | - $current_tab = empty( $_GET['tab'] ) ? 'theme-selectors' : sanitize_title( wp_unslash( $_GET['tab'] ) ); |
|
| 191 | - $current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); |
|
| 190 | + $current_tab = empty($_GET['tab']) ? 'theme-selectors' : sanitize_title(wp_unslash($_GET['tab'])); |
|
| 191 | + $current_section = empty($_REQUEST['section']) ? '' : sanitize_title(wp_unslash($_REQUEST['section'])); |
|
| 192 | 192 | |
| 193 | 193 | // Save settings if data has been posted. |
| 194 | - if ( apply_filters( '' !== $current_section ? "auto_load_next_post_save_settings_{$current_tab}_{$current_section}" : "auto_load_next_post_save_settings_{$current_tab}", ! empty( $_POST ) ) ) { |
|
| 194 | + if (apply_filters('' !== $current_section ? "auto_load_next_post_save_settings_{$current_tab}_{$current_section}" : "auto_load_next_post_save_settings_{$current_tab}", ! empty($_POST))) { |
|
| 195 | 195 | Auto_Load_Next_Post_Admin_Settings::save(); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Add any posted messages. |
| 199 | - if ( ! empty( $_GET['auto_load_next_post_error'] ) ) { |
|
| 200 | - Auto_Load_Next_Post_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_error'] ) ) ); |
|
| 199 | + if ( ! empty($_GET['auto_load_next_post_error'])) { |
|
| 200 | + Auto_Load_Next_Post_Admin_Settings::add_error(wp_kses_post(wp_unslash($_GET['auto_load_next_post_error']))); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( ! empty( $_GET['auto_load_next_post_message'] ) ) { |
|
| 204 | - Auto_Load_Next_Post_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_message'] ) ) ); |
|
| 203 | + if ( ! empty($_GET['auto_load_next_post_message'])) { |
|
| 204 | + Auto_Load_Next_Post_Admin_Settings::add_message(wp_kses_post(wp_unslash($_GET['auto_load_next_post_message']))); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - do_action( 'auto_load_next_post_settings_page_init' ); |
|
| 207 | + do_action('auto_load_next_post_settings_page_init'); |
|
| 208 | 208 | } // END settings_page_init() |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @since 1.0.0 |
| 215 | 215 | */ |
| 216 | 216 | public function settings_page() { |
| 217 | - include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' ); |
|
| 217 | + include_once(dirname(__FILE__).'/class-alnp-admin-settings.php'); |
|
| 218 | 218 | |
| 219 | 219 | Auto_Load_Next_Post_Admin_Settings::output(); |
| 220 | 220 | } // END settings_page() |
@@ -228,18 +228,18 @@ discard block |
||
| 228 | 228 | * @param array $links |
| 229 | 229 | * @return array $links |
| 230 | 230 | */ |
| 231 | - public function plugin_action_links( $links ) { |
|
| 231 | + public function plugin_action_links($links) { |
|
| 232 | 232 | $plugin_action_links = array(); |
| 233 | 233 | |
| 234 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 234 | + if (current_user_can('manage_options')) { |
|
| 235 | 235 | // Checks if Auto Load Next Post Pro has been installed. |
| 236 | - if ( ! is_alnp_pro_version_installed() ) { |
|
| 237 | - $plugin_action_links['go-pro'] = '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'pro/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" aria-label="' . esc_attr__( 'Sign up for Auto Load Next Post Pro', 'auto-load-next-post' ) . '" target="_blank" style="color:green; font-weight:bold;">' . __( 'Sign up for Pro', 'auto-load-next-post' ) . '</a>'; |
|
| 236 | + if ( ! is_alnp_pro_version_installed()) { |
|
| 237 | + $plugin_action_links['go-pro'] = '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'pro/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" aria-label="'.esc_attr__('Sign up for Auto Load Next Post Pro', 'auto-load-next-post').'" target="_blank" style="color:green; font-weight:bold;">'.__('Sign up for Pro', 'auto-load-next-post').'</a>'; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $plugin_action_links['settings'] = '<a href="' . admin_url( 'options-general.php?page=auto-load-next-post-settings' ) . '" aria-label="' . esc_attr__( 'View Auto Load Next Post settings', 'auto-load-next-post' ) . '">' . __( 'Settings', 'auto-load-next-post' ) . '</a>'; |
|
| 240 | + $plugin_action_links['settings'] = '<a href="'.admin_url('options-general.php?page=auto-load-next-post-settings').'" aria-label="'.esc_attr__('View Auto Load Next Post settings', 'auto-load-next-post').'">'.__('Settings', 'auto-load-next-post').'</a>'; |
|
| 241 | 241 | |
| 242 | - return array_merge( $plugin_action_links, $links ); |
|
| 242 | + return array_merge($plugin_action_links, $links); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return $links; |
@@ -256,18 +256,18 @@ discard block |
||
| 256 | 256 | * @param array $data Plugin Information |
| 257 | 257 | * @return array $links |
| 258 | 258 | */ |
| 259 | - public function plugin_row_meta( $links, $file, $data ) { |
|
| 260 | - if ( $file == plugin_basename( AUTO_LOAD_NEXT_POST_FILE ) ) { |
|
| 261 | - $links[ 1 ] = sprintf( __( 'Developed By %s', 'auto-load-next-post' ), '<a href="' . $data[ 'AuthorURI' ] . '" aria-label="' . esc_attr__( 'View the developers site', 'auto-load-next-post' ) . '">' . $data[ 'Author' ] . '</a>' ); |
|
| 259 | + public function plugin_row_meta($links, $file, $data) { |
|
| 260 | + if ($file == plugin_basename(AUTO_LOAD_NEXT_POST_FILE)) { |
|
| 261 | + $links[1] = sprintf(__('Developed By %s', 'auto-load-next-post'), '<a href="'.$data['AuthorURI'].'" aria-label="'.esc_attr__('View the developers site', 'auto-load-next-post').'">'.$data['Author'].'</a>'); |
|
| 262 | 262 | |
| 263 | 263 | $row_meta = array( |
| 264 | - 'docs' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'documentation/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" aria-label="' . esc_attr__( 'View Auto Load Next Post documentation', 'auto-load-next-post' ) . '" target="_blank">' . esc_attr__( 'Documentation', 'auto-load-next-post' ) . '</a>', |
|
| 265 | - 'community' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/auto-load-next-post' ) . '" aria-label="' . esc_attr__( 'Get support from the community', 'auto-load-next-post' ). '" target="_blank">' . esc_attr__( 'Community Support', 'auto-load-next-post' ) . '</a>', |
|
| 266 | - 'theme-support' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'product/theme-support/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page' ) . '" attr-label="' . esc_attr__( 'Get theme support', 'auto-load-next-post' ) . '" target="_blank">' . esc_attr__( 'Theme Support', 'auto-load-next-post' ) . '</a>', |
|
| 267 | - 'review' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_REVIEW_URL ) . '" aria-label="' . esc_attr( __( 'Review Auto Load Next Post on WordPress.org', 'auto-load-next-post' ) ) . '" target="_blank">' . __( 'Leave a Review', 'auto-load-next-post' ) . '</a>', |
|
| 264 | + 'docs' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'documentation/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" aria-label="'.esc_attr__('View Auto Load Next Post documentation', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Documentation', 'auto-load-next-post').'</a>', |
|
| 265 | + 'community' => '<a href="'.esc_url('https://wordpress.org/support/plugin/auto-load-next-post').'" aria-label="'.esc_attr__('Get support from the community', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Community Support', 'auto-load-next-post').'</a>', |
|
| 266 | + 'theme-support' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'product/theme-support/?utm_source=plugin&utm_medium=link&utm_campaign=plugins-page').'" attr-label="'.esc_attr__('Get theme support', 'auto-load-next-post').'" target="_blank">'.esc_attr__('Theme Support', 'auto-load-next-post').'</a>', |
|
| 267 | + 'review' => '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_REVIEW_URL).'" aria-label="'.esc_attr(__('Review Auto Load Next Post on WordPress.org', 'auto-load-next-post')).'" target="_blank">'.__('Leave a Review', 'auto-load-next-post').'</a>', |
|
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | - $links = array_merge( $links, $row_meta ); |
|
| 270 | + $links = array_merge($links, $row_meta); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | return $links; |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | * @param string $text text to be rendered in the footer. |
| 284 | 284 | * @return string $text |
| 285 | 285 | */ |
| 286 | - public function admin_footer_text( $text ) { |
|
| 286 | + public function admin_footer_text($text) { |
|
| 287 | 287 | $screen = get_current_screen(); |
| 288 | 288 | $screen_id = $screen ? $screen->id : ''; |
| 289 | 289 | |
| 290 | - if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) { |
|
| 290 | + if ($screen_id == 'settings_page_auto-load-next-post-settings') { |
|
| 291 | 291 | // Rating and Review |
| 292 | 292 | $text = sprintf( |
| 293 | 293 | /* translators: 1: Auto Load Next Post 2:: five stars */ |
| 294 | - __( 'If you like %1$s, please leave a %2$s rating. A huge thank you in advance!', 'auto-load-next-post' ), |
|
| 295 | - sprintf( '<strong>%1$s</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
|
| 296 | - '<a href="' . AUTO_LOAD_NEXT_POST_REVIEW_URL . '?rate=5#new-post" target="_blank" aria-label="' . esc_attr__( 'five star', 'auto-load-next-post' ) . '" data-rated="' . esc_attr__( 'Thanks :)', 'auto-load-next-post' ) . '">★★★★★</a>' |
|
| 294 | + __('If you like %1$s, please leave a %2$s rating. A huge thank you in advance!', 'auto-load-next-post'), |
|
| 295 | + sprintf('<strong>%1$s</strong>', esc_html__('Auto Load Next Post', 'auto-load-next-post')), |
|
| 296 | + '<a href="'.AUTO_LOAD_NEXT_POST_REVIEW_URL.'?rate=5#new-post" target="_blank" aria-label="'.esc_attr__('five star', 'auto-load-next-post').'" data-rated="'.esc_attr__('Thanks :)', 'auto-load-next-post').'">★★★★★</a>' |
|
| 297 | 297 | ); |
| 298 | 298 | } |
| 299 | 299 | |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | * @param string $text |
| 311 | 311 | * @return string $text |
| 312 | 312 | */ |
| 313 | - public function update_footer( $text ) { |
|
| 313 | + public function update_footer($text) { |
|
| 314 | 314 | $screen = get_current_screen(); |
| 315 | 315 | $screen_id = $screen ? $screen->id : ''; |
| 316 | 316 | |
| 317 | - if ( $screen_id == 'settings_page_auto-load-next-post-settings' ) { |
|
| 318 | - return sprintf( __( '%s Version', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . ' ' . esc_attr( AUTO_LOAD_NEXT_POST_VERSION ); |
|
| 317 | + if ($screen_id == 'settings_page_auto-load-next-post-settings') { |
|
| 318 | + return sprintf(__('%s Version', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')).' '.esc_attr(AUTO_LOAD_NEXT_POST_VERSION); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | return $text; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * The main instance of the plugin. |
| 27 | 27 | */ |
| 28 | -if ( ! class_exists( 'Auto_Load_Next_Post' ) ) { |
|
| 28 | +if ( ! class_exists('Auto_Load_Next_Post')) { |
|
| 29 | 29 | |
| 30 | 30 | class Auto_Load_Next_Post { |
| 31 | 31 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @return Auto_Load_Next_Post Single instance. |
| 60 | 60 | */ |
| 61 | 61 | public static function instance() { |
| 62 | - if ( is_null( self::$_instance ) ) { |
|
| 62 | + if (is_null(self::$_instance)) { |
|
| 63 | 63 | self::$_instance = new self(); |
| 64 | 64 | } |
| 65 | 65 | return self::$_instance; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function __clone() { |
| 76 | 76 | // Cloning instances of the class is forbidden |
| 77 | - _doing_it_wrong( __FUNCTION__, __( 'Cloning this object is forbidden.', 'auto-load-next-post' ), self::$version ); |
|
| 77 | + _doing_it_wrong(__FUNCTION__, __('Cloning this object is forbidden.', 'auto-load-next-post'), self::$version); |
|
| 78 | 78 | } // END __clone() |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | 87 | public function __wakeup() { |
| 88 | - _doing_it_wrong( __FUNCTION__, __( 'Unserializing instances of this class is forbidden.', 'auto-load-next-post' ), self::$version ); |
|
| 88 | + _doing_it_wrong(__FUNCTION__, __('Unserializing instances of this class is forbidden.', 'auto-load-next-post'), self::$version); |
|
| 89 | 89 | } // END __wakeup() |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $this->init_hooks(); |
| 102 | 102 | |
| 103 | 103 | // Auto Load Next Post is fully loaded. |
| 104 | - do_action( 'auto_load_next_post_loaded' ); |
|
| 104 | + do_action('auto_load_next_post_loaded'); |
|
| 105 | 105 | } // END __construct() |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function init_hooks() { |
| 114 | 114 | // Load translation files. |
| 115 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 115 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 116 | 116 | |
| 117 | 117 | // Load Auto Load Next Post scripts on the frontend. |
| 118 | - add_action( 'wp_enqueue_scripts', array( $this, 'alnp_enqueue_scripts' ) ); |
|
| 118 | + add_action('wp_enqueue_scripts', array($this, 'alnp_enqueue_scripts')); |
|
| 119 | 119 | } // END init_hooks() |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | $this->define('AUTO_LOAD_NEXT_POST_FILE', __FILE__); |
| 131 | 131 | $this->define('AUTO_LOAD_NEXT_POST_SLUG', 'auto-load-next-post'); |
| 132 | 132 | |
| 133 | - $this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit( plugins_url( '/', __FILE__ ) ) ); |
|
| 134 | - $this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
| 133 | + $this->define('AUTO_LOAD_NEXT_POST_URL_PATH', untrailingslashit(plugins_url('/', __FILE__))); |
|
| 134 | + $this->define('AUTO_LOAD_NEXT_POST_FILE_PATH', untrailingslashit(plugin_dir_path(__FILE__))); |
|
| 135 | 135 | $this->define('AUTO_LOAD_NEXT_POST_TEMPLATE_PATH', 'auto-load-next-post/'); |
| 136 | - $this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH . '/includes/3rd-party/'); |
|
| 136 | + $this->define('AUTO_LOAD_NEXT_POST_3RD_PARTY', AUTO_LOAD_NEXT_POST_FILE_PATH.'/includes/3rd-party/'); |
|
| 137 | 137 | |
| 138 | 138 | $this->define('AUTO_LOAD_NEXT_POST_WP_VERSION_REQUIRE', '4.4'); |
| 139 | 139 | |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | * @access private |
| 157 | 157 | * @since 1.4.3 |
| 158 | 158 | */ |
| 159 | - private function define( $name, $value ) { |
|
| 160 | - if ( ! defined( $name ) ) { |
|
| 161 | - define( $name, $value ); |
|
| 159 | + private function define($name, $value) { |
|
| 160 | + if ( ! defined($name)) { |
|
| 161 | + define($name, $value); |
|
| 162 | 162 | } |
| 163 | 163 | } // END define() |
| 164 | 164 | |
@@ -171,29 +171,29 @@ discard block |
||
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | 173 | public function includes() { |
| 174 | - include_once( dirname( __FILE__ ) . '/includes/class-alnp-autoloader.php' ); // Autoloader. |
|
| 175 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-conditional-functions.php' ); // Conditional functions. |
|
| 176 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-formatting-functions.php' ); // Formatting functions. |
|
| 177 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-themes-supported.php' ); // Handles all supported themes out of the box. |
|
| 178 | - include_once( dirname( __FILE__ ) . '/includes/auto-load-next-post-core-functions.php' ); // Contains core functions for the front/back end. |
|
| 174 | + include_once(dirname(__FILE__).'/includes/class-alnp-autoloader.php'); // Autoloader. |
|
| 175 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-conditional-functions.php'); // Conditional functions. |
|
| 176 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-formatting-functions.php'); // Formatting functions. |
|
| 177 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-themes-supported.php'); // Handles all supported themes out of the box. |
|
| 178 | + include_once(dirname(__FILE__).'/includes/auto-load-next-post-core-functions.php'); // Contains core functions for the front/back end. |
|
| 179 | 179 | |
| 180 | 180 | // Include theme support. |
| 181 | 181 | alnp_include_theme_support(); |
| 182 | 182 | |
| 183 | 183 | // 3rd Party support. |
| 184 | - include_once( dirname( __FILE__ ) . '/includes/3rd-party/3rd-party.php' ); |
|
| 184 | + include_once(dirname(__FILE__).'/includes/3rd-party/3rd-party.php'); |
|
| 185 | 185 | |
| 186 | 186 | // Customizer. |
| 187 | - include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer.php' ); |
|
| 188 | - include_once( dirname( __FILE__ ) . '/includes/customizer/class-alnp-customizer-scripts.php' ); |
|
| 187 | + include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer.php'); |
|
| 188 | + include_once(dirname(__FILE__).'/includes/customizer/class-alnp-customizer-scripts.php'); |
|
| 189 | 189 | |
| 190 | 190 | // Include admin class to handle all back-end functions. |
| 191 | - if ( is_admin() ) { |
|
| 192 | - include_once( dirname( __FILE__ ) . '/includes/admin/class-alnp-admin.php' ); // Admin section. |
|
| 191 | + if (is_admin()) { |
|
| 192 | + include_once(dirname(__FILE__).'/includes/admin/class-alnp-admin.php'); // Admin section. |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Install. |
| 196 | - require_once( dirname( __FILE__ ) . '/includes/class-alnp-install.php' ); |
|
| 196 | + require_once(dirname(__FILE__).'/includes/class-alnp-install.php'); |
|
| 197 | 197 | } // END includes() |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | 210 | public function load_plugin_textdomain() { |
| 211 | - load_plugin_textdomain( 'auto-load-next-post', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
|
| 211 | + load_plugin_textdomain('auto-load-next-post', false, dirname(plugin_basename(__FILE__)).'/languages/'); |
|
| 212 | 212 | } // END load_plugin_textdomain() |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -220,33 +220,33 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function alnp_enqueue_scripts() { |
| 222 | 222 | // Load the Javascript if found as a singluar post and the user is not a bot. |
| 223 | - if ( !alnp_is_bot() && is_singular() && get_post_type() == 'post' ) { |
|
| 223 | + if ( ! alnp_is_bot() && is_singular() && get_post_type() == 'post') { |
|
| 224 | 224 | // This checks to see if the JavaScript should load in the footer or not. |
| 225 | 225 | $load_in_footer = alnp_load_js_in_footer(); |
| 226 | 226 | |
| 227 | - $this->load_file( 'auto-load-next-post-scrollspy', '/assets/js/libs/scrollspy.min.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
| 227 | + $this->load_file('auto-load-next-post-scrollspy', '/assets/js/libs/scrollspy.min.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
| 228 | 228 | |
| 229 | 229 | // Only load History.js when not in the customizer. |
| 230 | - if ( ! is_customize_preview() ) { |
|
| 231 | - $this->load_file( 'auto-load-next-post-history', '/assets/js/libs/jquery.history.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
| 230 | + if ( ! is_customize_preview()) { |
|
| 231 | + $this->load_file('auto-load-next-post-history', '/assets/js/libs/jquery.history.js', true, array('jquery'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $this->load_file( 'auto-load-next-post-script', '/assets/js/frontend/auto-load-next-post' . AUTO_LOAD_NEXT_POST_DEBUG_MODE.AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array('auto-load-next-post-scrollspy'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer ); |
|
| 234 | + $this->load_file('auto-load-next-post-script', '/assets/js/frontend/auto-load-next-post'.AUTO_LOAD_NEXT_POST_DEBUG_MODE.AUTO_LOAD_NEXT_POST_SCRIPT_MODE.'.js', true, array('auto-load-next-post-scrollspy'), AUTO_LOAD_NEXT_POST_VERSION, $load_in_footer); |
|
| 235 | 235 | |
| 236 | 236 | // Variables for the JavaScript |
| 237 | - wp_localize_script( 'auto-load-next-post-script', 'auto_load_next_post_params', array( |
|
| 237 | + wp_localize_script('auto-load-next-post-script', 'auto_load_next_post_params', array( |
|
| 238 | 238 | 'alnp_version' => AUTO_LOAD_NEXT_POST_VERSION, |
| 239 | - 'alnp_content_container' => get_option( 'auto_load_next_post_content_container' ), |
|
| 240 | - 'alnp_title_selector' => get_option( 'auto_load_next_post_title_selector' ), |
|
| 241 | - 'alnp_navigation_container' => get_option( 'auto_load_next_post_navigation_container' ), |
|
| 242 | - 'alnp_comments_container' => get_option( 'auto_load_next_post_comments_container' ), |
|
| 243 | - 'alnp_remove_comments' => get_option( 'auto_load_next_post_remove_comments' ), |
|
| 244 | - 'alnp_google_analytics' => get_option( 'auto_load_next_post_google_analytics' ), |
|
| 245 | - 'alnp_event_on_load' => get_option( 'auto_load_next_post_on_load_event' ), |
|
| 246 | - 'alnp_event_on_entering' => get_option( 'auto_load_next_post_on_entering_event' ), |
|
| 239 | + 'alnp_content_container' => get_option('auto_load_next_post_content_container'), |
|
| 240 | + 'alnp_title_selector' => get_option('auto_load_next_post_title_selector'), |
|
| 241 | + 'alnp_navigation_container' => get_option('auto_load_next_post_navigation_container'), |
|
| 242 | + 'alnp_comments_container' => get_option('auto_load_next_post_comments_container'), |
|
| 243 | + 'alnp_remove_comments' => get_option('auto_load_next_post_remove_comments'), |
|
| 244 | + 'alnp_google_analytics' => get_option('auto_load_next_post_google_analytics'), |
|
| 245 | + 'alnp_event_on_load' => get_option('auto_load_next_post_on_load_event'), |
|
| 246 | + 'alnp_event_on_entering' => get_option('auto_load_next_post_on_entering_event'), |
|
| 247 | 247 | 'alnp_is_customizer' => $this->is_alnp_using_customizer(), |
| 248 | 248 | 'alnp_load_in_footer' => $load_in_footer |
| 249 | - ) ); |
|
| 249 | + )); |
|
| 250 | 250 | } // END if is_singular() && get_post_type() |
| 251 | 251 | } // END alnp_enqueue_scripts() |
| 252 | 252 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @return string|false |
| 260 | 260 | */ |
| 261 | 261 | public static function is_alnp_using_customizer() { |
| 262 | - if ( is_customize_preview() ) { |
|
| 262 | + if (is_customize_preview()) { |
|
| 263 | 263 | return "yes"; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -280,19 +280,19 @@ discard block |
||
| 280 | 280 | * @param string $version Optional, can match the version of the plugin or version of the source file. |
| 281 | 281 | * @param bool $footer Optional, can set the JavaScript to load in the footer instead. |
| 282 | 282 | */ |
| 283 | - public static function load_file( $name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false ) { |
|
| 284 | - $url = AUTO_LOAD_NEXT_POST_URL_PATH . $file_path; // URL to the file. |
|
| 285 | - |
|
| 286 | - if ( file_exists( AUTO_LOAD_NEXT_POST_FILE_PATH . $file_path ) ) { |
|
| 287 | - if ( $is_script ) { |
|
| 288 | - if ( !wp_script_is( $name, 'registered' ) ) { |
|
| 289 | - wp_register_script( $name, $url, $support, $version, $footer ); |
|
| 290 | - wp_enqueue_script( $name ); |
|
| 283 | + public static function load_file($name, $file_path, $is_script = false, $support = array(), $version = '', $footer = false) { |
|
| 284 | + $url = AUTO_LOAD_NEXT_POST_URL_PATH.$file_path; // URL to the file. |
|
| 285 | + |
|
| 286 | + if (file_exists(AUTO_LOAD_NEXT_POST_FILE_PATH.$file_path)) { |
|
| 287 | + if ($is_script) { |
|
| 288 | + if ( ! wp_script_is($name, 'registered')) { |
|
| 289 | + wp_register_script($name, $url, $support, $version, $footer); |
|
| 290 | + wp_enqueue_script($name); |
|
| 291 | 291 | } |
| 292 | 292 | } else { |
| 293 | - if ( !wp_style_is( $name, 'registered' ) ) { |
|
| 294 | - wp_register_style( $name, $url ); |
|
| 295 | - wp_enqueue_style( $name ); |
|
| 293 | + if ( ! wp_style_is($name, 'registered')) { |
|
| 294 | + wp_register_style($name, $url); |
|
| 295 | + wp_enqueue_style($name); |
|
| 296 | 296 | } |
| 297 | 297 | } // end if |
| 298 | 298 | } // end if |
@@ -8,40 +8,40 @@ |
||
| 8 | 8 | * @version 1.5.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -if ( have_posts() ) : |
|
| 11 | +if (have_posts()) : |
|
| 12 | 12 | |
| 13 | 13 | // Load content before the loop. |
| 14 | - do_action( 'alnp_load_before_loop' ); |
|
| 14 | + do_action('alnp_load_before_loop'); |
|
| 15 | 15 | |
| 16 | 16 | // Check that there are more posts to load. |
| 17 | - while ( have_posts() ) : the_post(); |
|
| 17 | + while (have_posts()) : the_post(); |
|
| 18 | 18 | |
| 19 | 19 | $post_type = alnp_get_post_type(); // Post Type e.g. single |
| 20 | 20 | |
| 21 | 21 | // Load content before the post content. |
| 22 | - do_action( 'alnp_load_before_content' ); |
|
| 22 | + do_action('alnp_load_before_content'); |
|
| 23 | 23 | |
| 24 | 24 | // Load content before the post content for a specific post type. |
| 25 | - do_action( 'alnp_load_before_content_post_type_' . $post_type ); |
|
| 25 | + do_action('alnp_load_before_content_post_type_'.$post_type); |
|
| 26 | 26 | |
| 27 | 27 | // Load Make partial template for the correct post type. |
| 28 | - get_template_part( 'partials/content', $post_type ); |
|
| 28 | + get_template_part('partials/content', $post_type); |
|
| 29 | 29 | |
| 30 | 30 | // Load content after the post content for a specific post type. |
| 31 | - do_action( 'alnp_load_after_content_post_type_' . $post_type ); |
|
| 31 | + do_action('alnp_load_after_content_post_type_'.$post_type); |
|
| 32 | 32 | |
| 33 | 33 | // Load content before the post content. |
| 34 | - do_action( 'alnp_load_after_content' ); |
|
| 34 | + do_action('alnp_load_after_content'); |
|
| 35 | 35 | |
| 36 | 36 | // End the loop. |
| 37 | 37 | endwhile; |
| 38 | 38 | |
| 39 | 39 | // Load content after the loop. |
| 40 | - do_action( 'alnp_load_after_loop' ); |
|
| 40 | + do_action('alnp_load_after_loop'); |
|
| 41 | 41 | |
| 42 | 42 | else : |
| 43 | 43 | |
| 44 | 44 | // Load content if there are no more posts. |
| 45 | - do_action( 'alnp_no_more_posts' ); |
|
| 45 | + do_action('alnp_no_more_posts'); |
|
| 46 | 46 | |
| 47 | 47 | endif; // END if have_posts() |
@@ -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 | |
@@ -87,25 +87,25 @@ discard block |
||
| 87 | 87 | $user_hidden_notice = false; |
| 88 | 88 | |
| 89 | 89 | // If the user is allowed to install plugins and requested to hide the review notice then hide it for that user. |
| 90 | - if ( ! empty( $_GET['hide_auto_load_next_post_review_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 91 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true ); |
|
| 90 | + if ( ! empty($_GET['hide_auto_load_next_post_review_notice']) && current_user_can('install_plugins')) { |
|
| 91 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', '1', true); |
|
| 92 | 92 | $user_hidden_notice = true; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // If the user is allowed to install plugins and requested to hide the welcome notice then hide it for that user. |
| 96 | - if ( ! empty( $_GET['hide_auto_load_next_post_welcome_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 97 | - add_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true ); |
|
| 96 | + if ( ! empty($_GET['hide_auto_load_next_post_welcome_notice']) && current_user_can('install_plugins')) { |
|
| 97 | + add_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', '1', true); |
|
| 98 | 98 | $user_hidden_notice = true; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if ( ! empty( $_GET['hide_auto_load_next_post_beta_notice'] ) && current_user_can( 'install_plugins' ) ) { |
|
| 102 | - set_transient( 'alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS ); |
|
| 101 | + if ( ! empty($_GET['hide_auto_load_next_post_beta_notice']) && current_user_can('install_plugins')) { |
|
| 102 | + set_transient('alnp_beta_notice_hidden', 'hidden', WEEK_IN_SECONDS); |
|
| 103 | 103 | $user_hidden_notice = true; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( $user_hidden_notice ) { |
|
| 106 | + if ($user_hidden_notice) { |
|
| 107 | 107 | // Redirect to the plugins page. |
| 108 | - wp_safe_redirect( admin_url( 'plugins.php' ) ); |
|
| 108 | + wp_safe_redirect(admin_url('plugins.php')); |
|
| 109 | 109 | exit; |
| 110 | 110 | } |
| 111 | 111 | } // END dont_bug_me() |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | global $current_user; |
| 125 | 125 | |
| 126 | 126 | // If the current user can not install plugins then return nothing! |
| 127 | - if ( ! current_user_can( 'install_plugins' ) ) { |
|
| 127 | + if ( ! current_user_can('install_plugins')) { |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -132,57 +132,57 @@ discard block |
||
| 132 | 132 | $screen_id = $screen ? $screen->id : ''; |
| 133 | 133 | |
| 134 | 134 | // Notices should only show on the main dashboard and on the plugins screen. |
| 135 | - if ( ! in_array( $screen_id, alnp_get_admin_screens() ) ) { |
|
| 135 | + if ( ! in_array($screen_id, alnp_get_admin_screens())) { |
|
| 136 | 136 | return false; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Is admin welcome notice hidden? |
| 140 | - $hide_welcome_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', true ); |
|
| 140 | + $hide_welcome_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_welcome_notice', true); |
|
| 141 | 141 | |
| 142 | 142 | // Check if we need to display the welcome notice. |
| 143 | - if ( empty( $hide_welcome_notice ) ) { |
|
| 143 | + if (empty($hide_welcome_notice)) { |
|
| 144 | 144 | // If the user has just installed the plugin for the first time then welcome the user. |
| 145 | - if ( ( intval( time() - self::$install_date ) / WEEK_IN_SECONDS ) % 52 <= 2 ) { |
|
| 146 | - add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); |
|
| 145 | + if ((intval(time() - self::$install_date) / WEEK_IN_SECONDS) % 52 <= 2) { |
|
| 146 | + add_action('admin_notices', array($this, 'welcome_notice')); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Is admin review notice hidden? |
| 151 | - $hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true ); |
|
| 151 | + $hide_review_notice = get_user_meta($current_user->ID, 'auto_load_next_post_hide_review_notice', true); |
|
| 152 | 152 | |
| 153 | 153 | // Check if we need to display the review plugin notice. |
| 154 | - if ( empty( $hide_review_notice ) ) { |
|
| 154 | + if (empty($hide_review_notice)) { |
|
| 155 | 155 | // If it has been a week or more since activating the plugin then display the review notice. |
| 156 | - if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) { |
|
| 157 | - add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) ); |
|
| 156 | + if ((intval(time() - self::$install_date)) > WEEK_IN_SECONDS) { |
|
| 157 | + add_action('admin_notices', array($this, 'plugin_review_notice')); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Is this version of Auto Load Next Post a beta release? |
| 162 | - if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) { |
|
| 163 | - add_action( 'admin_notices', array( $this, 'beta_notice' ) ); |
|
| 162 | + if (is_alnp_beta() && empty(get_transient('alnp_beta_notice_hidden'))) { |
|
| 163 | + add_action('admin_notices', array($this, 'beta_notice')); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $template = get_option( 'template' ); |
|
| 166 | + $template = get_option('template'); |
|
| 167 | 167 | |
| 168 | 168 | // Checks if the theme supports Auto Load Next Post and not provided via a plugin. |
| 169 | - if ( is_alnp_supported() ) { |
|
| 170 | - $plugin_supported = alnp_get_theme_support( 'plugin_support' ); |
|
| 169 | + if (is_alnp_supported()) { |
|
| 170 | + $plugin_supported = alnp_get_theme_support('plugin_support'); |
|
| 171 | 171 | |
| 172 | 172 | // Return if theme is supported via plugin. |
| 173 | - if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) { |
|
| 174 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
| 173 | + if ( ! empty($plugin_supported) && $plugin_supported == 'yes') { |
|
| 174 | + update_option('auto_load_next_post_theme_supported', $template); |
|
| 175 | 175 | return false; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // If supported theme does not match active theme then show notice. |
| 179 | - if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) { |
|
| 180 | - add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) ); |
|
| 181 | - update_option( 'auto_load_next_post_theme_supported', $template ); |
|
| 179 | + if (get_option('auto_load_next_post_theme_supported') !== $template) { |
|
| 180 | + add_action('admin_notices', array($this, 'theme_ready_notice')); |
|
| 181 | + update_option('auto_load_next_post_theme_supported', $template); |
|
| 182 | 182 | } |
| 183 | 183 | } else { |
| 184 | 184 | // If theme not supported then delete option. |
| 185 | - delete_option( 'auto_load_next_post_theme_supported' ); |
|
| 185 | + delete_option('auto_load_next_post_theme_supported'); |
|
| 186 | 186 | } |
| 187 | 187 | } // END add_notices() |
| 188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @since 1.4.3 |
| 194 | 194 | */ |
| 195 | 195 | public function requirement_wp_notice() { |
| 196 | - include( dirname( __FILE__ ) . '/views/html-notice-requirement-wp.php' ); |
|
| 196 | + include(dirname(__FILE__).'/views/html-notice-requirement-wp.php'); |
|
| 197 | 197 | } // END requirement_wp_notice() |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @since 1.5.0 |
| 204 | 204 | */ |
| 205 | 205 | public function theme_ready_notice() { |
| 206 | - include( dirname( __FILE__ ) . '/views/html-notice-theme-ready.php' ); |
|
| 206 | + include(dirname(__FILE__).'/views/html-notice-theme-ready.php'); |
|
| 207 | 207 | } // END theme_ready_notice() |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @since 1.5.0 |
| 214 | 214 | */ |
| 215 | 215 | public function welcome_notice() { |
| 216 | - include( dirname( __FILE__ ) . '/views/html-notice-welcome.php' ); |
|
| 216 | + include(dirname(__FILE__).'/views/html-notice-welcome.php'); |
|
| 217 | 217 | } // END welcome_notice() |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @since 1.5.0 |
| 224 | 224 | */ |
| 225 | 225 | public function beta_notice() { |
| 226 | - include( dirname( __FILE__ ) . '/views/html-notice-trying-beta.php' ); |
|
| 226 | + include(dirname(__FILE__).'/views/html-notice-trying-beta.php'); |
|
| 227 | 227 | } // END beta_notice() |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | public function plugin_review_notice() { |
| 237 | 237 | $install_date = self::$install_date; |
| 238 | 238 | |
| 239 | - include( dirname( __FILE__ ) . '/views/html-notice-please-review.php' ); |
|
| 239 | + include(dirname(__FILE__).'/views/html-notice-please-review.php'); |
|
| 240 | 240 | } // END plugin_review_notice() |
| 241 | 241 | |
| 242 | 242 | } // END class. |
@@ -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_Settings' ) ) { |
|
| 18 | +if ( ! class_exists('Auto_Load_Next_Post_Admin_Settings')) { |
|
| 19 | 19 | |
| 20 | 20 | class Auto_Load_Next_Post_Admin_Settings { |
| 21 | 21 | |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | * @return $settings |
| 57 | 57 | */ |
| 58 | 58 | public static function get_settings_pages() { |
| 59 | - if ( empty( self::$settings ) ) { |
|
| 59 | + if (empty(self::$settings)) { |
|
| 60 | 60 | $settings = array(); |
| 61 | 61 | |
| 62 | - include_once( dirname( __FILE__ ) . '/settings/class-alnp-settings-page.php' ); |
|
| 62 | + include_once(dirname(__FILE__).'/settings/class-alnp-settings-page.php'); |
|
| 63 | 63 | |
| 64 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-theme-selectors.php'); |
|
| 65 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-misc.php'); |
|
| 66 | - $settings[] = include( dirname( __FILE__ ) . '/settings/class-alnp-settings-events.php'); |
|
| 64 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-theme-selectors.php'); |
|
| 65 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-misc.php'); |
|
| 66 | + $settings[] = include(dirname(__FILE__).'/settings/class-alnp-settings-events.php'); |
|
| 67 | 67 | |
| 68 | - self::$settings = apply_filters( 'auto_load_next_post_get_settings_pages', $settings ); |
|
| 68 | + self::$settings = apply_filters('auto_load_next_post_get_settings_pages', $settings); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return self::$settings; |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | public static function save() { |
| 84 | 84 | global $current_tab; |
| 85 | 85 | |
| 86 | - check_admin_referer( 'auto-load-next-post-settings' ); |
|
| 86 | + check_admin_referer('auto-load-next-post-settings'); |
|
| 87 | 87 | |
| 88 | 88 | // Trigger actions |
| 89 | - do_action( 'auto_load_next_post_settings_save_' . $current_tab ); |
|
| 90 | - do_action( 'auto_load_next_post_update_options_' . $current_tab ); |
|
| 91 | - do_action( 'auto_load_next_post_update_options' ); |
|
| 89 | + do_action('auto_load_next_post_settings_save_'.$current_tab); |
|
| 90 | + do_action('auto_load_next_post_update_options_'.$current_tab); |
|
| 91 | + do_action('auto_load_next_post_update_options'); |
|
| 92 | 92 | |
| 93 | - self::add_message( __( 'Your settings have been saved.', 'auto-load-next-post' ) ); |
|
| 93 | + self::add_message(__('Your settings have been saved.', 'auto-load-next-post')); |
|
| 94 | 94 | |
| 95 | - do_action( 'auto_load_next_post_settings_saved' ); |
|
| 95 | + do_action('auto_load_next_post_settings_saved'); |
|
| 96 | 96 | } // END save() |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @since 1.0.0 |
| 104 | 104 | * @param string $text Message |
| 105 | 105 | */ |
| 106 | - public static function add_message( $text ) { |
|
| 106 | + public static function add_message($text) { |
|
| 107 | 107 | self::$messages[] = $text; |
| 108 | 108 | } // END add_message() |
| 109 | 109 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @since 1.0.0 |
| 116 | 116 | * @param string $text Error |
| 117 | 117 | */ |
| 118 | - public static function add_error( $text ) { |
|
| 118 | + public static function add_error($text) { |
|
| 119 | 119 | self::$errors[] = $text; |
| 120 | 120 | } // END add_error() |
| 121 | 121 | |
@@ -128,13 +128,13 @@ discard block |
||
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | 130 | public static function show_messages() { |
| 131 | - if ( count( self::$errors ) > 0 ) { |
|
| 132 | - foreach ( self::$errors as $error ) { |
|
| 133 | - echo '<div id="message" class="error inline"><p><strong>' . esc_html( $error ) . '</strong></p></div>'; |
|
| 131 | + if (count(self::$errors) > 0) { |
|
| 132 | + foreach (self::$errors as $error) { |
|
| 133 | + echo '<div id="message" class="error inline"><p><strong>'.esc_html($error).'</strong></p></div>'; |
|
| 134 | 134 | } |
| 135 | - } elseif ( count( self::$messages ) > 0 ) { |
|
| 136 | - foreach ( self::$messages as $message ) { |
|
| 137 | - echo '<div id="message" class="updated inline"><p><strong>' . esc_html( $message ) . '</strong></p></div>'; |
|
| 135 | + } elseif (count(self::$messages) > 0) { |
|
| 136 | + foreach (self::$messages as $message) { |
|
| 137 | + echo '<div id="message" class="updated inline"><p><strong>'.esc_html($message).'</strong></p></div>'; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } // END show_messages() |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | public static function output() { |
| 155 | - do_action( 'auto_load_next_post_settings_start' ); |
|
| 155 | + do_action('auto_load_next_post_settings_start'); |
|
| 156 | 156 | |
| 157 | - include( dirname( __FILE__ ) . '/views/html-admin-settings.php' ); |
|
| 157 | + include(dirname(__FILE__).'/views/html-admin-settings.php'); |
|
| 158 | 158 | } // END output() |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -166,33 +166,33 @@ discard block |
||
| 166 | 166 | * @param mixed $option_name |
| 167 | 167 | * @return string |
| 168 | 168 | */ |
| 169 | - public static function get_option( $option_name, $default = '' ) { |
|
| 169 | + public static function get_option($option_name, $default = '') { |
|
| 170 | 170 | // Array value |
| 171 | - if ( strstr( $option_name, '[' ) ) { |
|
| 172 | - parse_str( $option_name, $option_array ); |
|
| 171 | + if (strstr($option_name, '[')) { |
|
| 172 | + parse_str($option_name, $option_array); |
|
| 173 | 173 | |
| 174 | 174 | // Option name is first key |
| 175 | - $option_name = current( array_keys( $option_array ) ); |
|
| 175 | + $option_name = current(array_keys($option_array)); |
|
| 176 | 176 | |
| 177 | 177 | // Get value |
| 178 | - $option_values = get_option( $option_name, '' ); |
|
| 178 | + $option_values = get_option($option_name, ''); |
|
| 179 | 179 | |
| 180 | - $key = key( $option_array[$option_name] ); |
|
| 180 | + $key = key($option_array[$option_name]); |
|
| 181 | 181 | |
| 182 | - if ( isset( $option_values[$key] ) ) { |
|
| 182 | + if (isset($option_values[$key])) { |
|
| 183 | 183 | $option_value = $option_values[$key]; |
| 184 | 184 | } else { |
| 185 | 185 | $option_value = null; |
| 186 | 186 | } |
| 187 | 187 | } else { |
| 188 | 188 | // Single value |
| 189 | - $option_value = get_option( $option_name, null ); |
|
| 189 | + $option_value = get_option($option_name, null); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( is_array( $option_value ) ) { |
|
| 193 | - $option_value = array_map( 'stripslashes', $option_value ); |
|
| 194 | - } elseif ( ! is_null( $option_value ) ) { |
|
| 195 | - $option_value = stripslashes( $option_value ); |
|
| 192 | + if (is_array($option_value)) { |
|
| 193 | + $option_value = array_map('stripslashes', $option_value); |
|
| 194 | + } elseif ( ! is_null($option_value)) { |
|
| 195 | + $option_value = stripslashes($option_value); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | return $option_value === null ? $default : $option_value; |
@@ -209,86 +209,86 @@ discard block |
||
| 209 | 209 | * @version 1.5.0 |
| 210 | 210 | * @param array $options Opens array to output |
| 211 | 211 | */ |
| 212 | - public static function output_fields( $options ) { |
|
| 213 | - foreach ( $options as $key => $value ) { |
|
| 212 | + public static function output_fields($options) { |
|
| 213 | + foreach ($options as $key => $value) { |
|
| 214 | 214 | |
| 215 | - if ( ! isset( $value['type'] ) ) { |
|
| 215 | + if ( ! isset($value['type'])) { |
|
| 216 | 216 | continue; |
| 217 | 217 | } |
| 218 | - if ( ! isset( $value['id'] ) ) { |
|
| 218 | + if ( ! isset($value['id'])) { |
|
| 219 | 219 | $value['id'] = ''; |
| 220 | 220 | } |
| 221 | - if ( ! isset( $value['title'] ) ) { |
|
| 222 | - $value['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
| 221 | + if ( ! isset($value['title'])) { |
|
| 222 | + $value['title'] = isset($value['name']) ? $value['name'] : ''; |
|
| 223 | 223 | } |
| 224 | - if ( ! isset( $value['class'] ) ) { |
|
| 224 | + if ( ! isset($value['class'])) { |
|
| 225 | 225 | $value['class'] = ''; |
| 226 | 226 | } |
| 227 | - if ( ! isset( $value['css'] ) ) { |
|
| 227 | + if ( ! isset($value['css'])) { |
|
| 228 | 228 | $value['css'] = ''; |
| 229 | 229 | } |
| 230 | - if ( ! isset( $value['default'] ) ) { |
|
| 230 | + if ( ! isset($value['default'])) { |
|
| 231 | 231 | $value['default'] = ''; |
| 232 | 232 | } |
| 233 | - if ( ! isset( $value['desc'] ) ) { |
|
| 233 | + if ( ! isset($value['desc'])) { |
|
| 234 | 234 | $value['desc'] = ''; |
| 235 | 235 | } |
| 236 | - if ( ! isset( $value['placeholder'] ) ) { |
|
| 236 | + if ( ! isset($value['placeholder'])) { |
|
| 237 | 237 | $value['placeholder'] = ''; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Custom attribute handling |
| 241 | 241 | $custom_attributes = array(); |
| 242 | 242 | |
| 243 | - if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) { |
|
| 244 | - foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) { |
|
| 245 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
| 243 | + if ( ! empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { |
|
| 244 | + foreach ($value['custom_attributes'] as $attribute => $attribute_value) { |
|
| 245 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // Description handling |
| 250 | 250 | $description = ''; |
| 251 | 251 | |
| 252 | - if ( ! empty( $value['desc'] ) ) { |
|
| 252 | + if ( ! empty($value['desc'])) { |
|
| 253 | 253 | $description = $value['desc']; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( $description && in_array( $value['type'], array( 'textarea', 'radio' ), true ) ) { |
|
| 257 | - $description = '<p style="margin-top:0">' . wp_kses_post( $description ) . '</p>'; |
|
| 258 | - } elseif ( $description && in_array( $value['type'], array( 'checkbox' ), true ) ) { |
|
| 259 | - $description = wp_kses_post( $description ); |
|
| 260 | - } elseif ( $description ) { |
|
| 261 | - $description = '<p class="description">' . wp_kses_post( $description ) . '</p>'; |
|
| 256 | + if ($description && in_array($value['type'], array('textarea', 'radio'), true)) { |
|
| 257 | + $description = '<p style="margin-top:0">'.wp_kses_post($description).'</p>'; |
|
| 258 | + } elseif ($description && in_array($value['type'], array('checkbox'), true)) { |
|
| 259 | + $description = wp_kses_post($description); |
|
| 260 | + } elseif ($description) { |
|
| 261 | + $description = '<p class="description">'.wp_kses_post($description).'</p>'; |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Switch based on type |
| 265 | - switch( $value['type'] ) { |
|
| 265 | + switch ($value['type']) { |
|
| 266 | 266 | |
| 267 | 267 | // Section Titles |
| 268 | 268 | case 'title': |
| 269 | - if ( ! empty( $value['title'] ) ) { |
|
| 270 | - echo '<h2>' . esc_html( $value['title'] ) . '</h2>'; |
|
| 269 | + if ( ! empty($value['title'])) { |
|
| 270 | + echo '<h2>'.esc_html($value['title']).'</h2>'; |
|
| 271 | 271 | } |
| 272 | - if ( ! empty( $value['desc'] ) ) { |
|
| 273 | - echo '<div id="' . esc_attr( sanitize_title( $value['id'] ) ) . '-description">'; |
|
| 274 | - echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) ); |
|
| 272 | + if ( ! empty($value['desc'])) { |
|
| 273 | + echo '<div id="'.esc_attr(sanitize_title($value['id'])).'-description">'; |
|
| 274 | + echo wp_kses_post(wpautop(wptexturize($value['desc']))); |
|
| 275 | 275 | echo '</div>'; |
| 276 | 276 | } |
| 277 | 277 | echo '<table class="form-table">'."\n\n"; |
| 278 | - if ( ! empty( $value['id'] ) ) { |
|
| 279 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) ); |
|
| 278 | + if ( ! empty($value['id'])) { |
|
| 279 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id'])); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | break; |
| 283 | 283 | |
| 284 | 284 | // Section Ends |
| 285 | 285 | case 'sectionend': |
| 286 | - if ( ! empty( $value['id'] ) ) { |
|
| 287 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
| 286 | + if ( ! empty($value['id'])) { |
|
| 287 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_end'); |
|
| 288 | 288 | } |
| 289 | 289 | echo '</table>'; |
| 290 | - if ( ! empty( $value['id'] ) ) { |
|
| 291 | - do_action( 'auto_load_next_post_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
| 290 | + if ( ! empty($value['id'])) { |
|
| 291 | + do_action('auto_load_next_post_settings_'.sanitize_title($value['id']).'_after'); |
|
| 292 | 292 | } |
| 293 | 293 | break; |
| 294 | 294 | |
@@ -301,22 +301,22 @@ discard block |
||
| 301 | 301 | case 'time': |
| 302 | 302 | case 'week': |
| 303 | 303 | case 'email': |
| 304 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
| 304 | + $option_value = self::get_option($value['id'], $value['default']); |
|
| 305 | 305 | |
| 306 | 306 | ?><tr valign="top"> |
| 307 | 307 | <th scope="row" class="titledesc"> |
| 308 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
| 308 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
| 309 | 309 | </th> |
| 310 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
| 310 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
| 311 | 311 | <input |
| 312 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 313 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 314 | - type="<?php echo esc_attr( $value['type'] ); ?>" |
|
| 315 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 316 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
| 317 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 318 | - placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
| 319 | - <?php echo implode(' ', $custom_attributes ); ?> |
|
| 312 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 313 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 314 | + type="<?php echo esc_attr($value['type']); ?>" |
|
| 315 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 316 | + value="<?php echo esc_attr($option_value); ?>" |
|
| 317 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 318 | + placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
| 319 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 320 | 320 | /><?php echo $description; ?> |
| 321 | 321 | </td> |
| 322 | 322 | </tr><?php |
@@ -324,23 +324,23 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | // Textarea. |
| 326 | 326 | case 'textarea': |
| 327 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
| 327 | + $option_value = self::get_option($value['id'], $value['default']); |
|
| 328 | 328 | ?> |
| 329 | 329 | <tr valign="top"> |
| 330 | 330 | <th scope="row" class="titledesc"> |
| 331 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
| 331 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
| 332 | 332 | </th> |
| 333 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
| 333 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
| 334 | 334 | <?php echo $description; ?> |
| 335 | 335 | |
| 336 | 336 | <textarea |
| 337 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 338 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 339 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 340 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 341 | - placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
| 342 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 343 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
| 337 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 338 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 339 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 340 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 341 | + placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
| 342 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 343 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
| 344 | 344 | </td> |
| 345 | 345 | </tr> |
| 346 | 346 | <?php |
@@ -349,35 +349,35 @@ discard block |
||
| 349 | 349 | // Select boxes. |
| 350 | 350 | case 'select': |
| 351 | 351 | case 'multiselect': |
| 352 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
| 352 | + $option_value = self::get_option($value['id'], $value['default']); |
|
| 353 | 353 | ?> |
| 354 | 354 | <tr valign="top"> |
| 355 | 355 | <th scope="row" class="titledesc"> |
| 356 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
| 356 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
| 357 | 357 | </th> |
| 358 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
| 358 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
| 359 | 359 | <select |
| 360 | - name="<?php echo esc_attr( $value['id'] ); ?><?php echo ( 'multiselect' === $value['type'] ) ? '[]' : ''; ?>" |
|
| 361 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 362 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 363 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 364 | - data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" |
|
| 365 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 360 | + name="<?php echo esc_attr($value['id']); ?><?php echo ('multiselect' === $value['type']) ? '[]' : ''; ?>" |
|
| 361 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 362 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 363 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 364 | + data-placeholder="<?php echo esc_attr($value['placeholder']); ?>" |
|
| 365 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 366 | 366 | <?php echo 'multiselect' === $value['type'] ? 'multiple="multiple"' : ''; ?> |
| 367 | 367 | > |
| 368 | 368 | <?php |
| 369 | - foreach ( $value['options'] as $key => $val ) { |
|
| 369 | + foreach ($value['options'] as $key => $val) { |
|
| 370 | 370 | ?> |
| 371 | - <option value="<?php echo esc_attr( $key ); ?>" |
|
| 371 | + <option value="<?php echo esc_attr($key); ?>" |
|
| 372 | 372 | <?php |
| 373 | - if ( is_array( $option_value ) ) { |
|
| 374 | - selected( in_array( (string) $key, $option_value, true ), true ); |
|
| 373 | + if (is_array($option_value)) { |
|
| 374 | + selected(in_array((string) $key, $option_value, true), true); |
|
| 375 | 375 | } else { |
| 376 | - selected( $option_value, (string) $key ); |
|
| 376 | + selected($option_value, (string) $key); |
|
| 377 | 377 | } |
| 378 | 378 | ?> |
| 379 | 379 | > |
| 380 | - <?php echo esc_html( $val ); ?></option> |
|
| 380 | + <?php echo esc_html($val); ?></option> |
|
| 381 | 381 | <?php |
| 382 | 382 | } |
| 383 | 383 | ?> |
@@ -389,29 +389,29 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | // Radio inputs. |
| 391 | 391 | case 'radio': |
| 392 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
| 392 | + $option_value = self::get_option($value['id'], $value['default']); |
|
| 393 | 393 | ?> |
| 394 | 394 | <tr valign="top"> |
| 395 | 395 | <th scope="row" class="titledesc"> |
| 396 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label> |
|
| 396 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label> |
|
| 397 | 397 | </th> |
| 398 | - <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>"> |
|
| 398 | + <td class="forminp forminp-<?php echo esc_attr(sanitize_title($value['type'])); ?>"> |
|
| 399 | 399 | <fieldset> |
| 400 | 400 | <?php echo $description; ?> |
| 401 | 401 | <ul> |
| 402 | 402 | <?php |
| 403 | - foreach ( $value['options'] as $key => $val ) { |
|
| 403 | + foreach ($value['options'] as $key => $val) { |
|
| 404 | 404 | ?> |
| 405 | 405 | <li> |
| 406 | 406 | <label><input |
| 407 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 408 | - value="<?php echo esc_attr( $key ); ?>" |
|
| 407 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 408 | + value="<?php echo esc_attr($key); ?>" |
|
| 409 | 409 | type="radio" |
| 410 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
| 411 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
| 412 | - <?php echo implode( ' ', $custom_attributes ); // WPCS: XSS ok. ?> |
|
| 413 | - <?php checked( $key, $option_value ); ?> |
|
| 414 | - /> <?php echo esc_html( $val ); ?></label> |
|
| 410 | + style="<?php echo esc_attr($value['css']); ?>" |
|
| 411 | + class="<?php echo esc_attr($value['class']); ?>" |
|
| 412 | + <?php echo implode(' ', $custom_attributes); // WPCS: XSS ok. ?> |
|
| 413 | + <?php checked($key, $option_value); ?> |
|
| 414 | + /> <?php echo esc_html($val); ?></label> |
|
| 415 | 415 | </li> |
| 416 | 416 | <?php |
| 417 | 417 | } |
@@ -425,58 +425,58 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | // Checkbox input. |
| 427 | 427 | case 'checkbox': |
| 428 | - $option_value = self::get_option( $value['id'], $value['default'] ); |
|
| 428 | + $option_value = self::get_option($value['id'], $value['default']); |
|
| 429 | 429 | $visibility_class = array(); |
| 430 | 430 | |
| 431 | - if ( ! isset( $value['hide_if_checked'] ) ) { |
|
| 431 | + if ( ! isset($value['hide_if_checked'])) { |
|
| 432 | 432 | $value['hide_if_checked'] = false; |
| 433 | 433 | } |
| 434 | - if ( ! isset( $value['show_if_checked'] ) ) { |
|
| 434 | + if ( ! isset($value['show_if_checked'])) { |
|
| 435 | 435 | $value['show_if_checked'] = false; |
| 436 | 436 | } |
| 437 | - if ( 'yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked'] ) { |
|
| 437 | + if ('yes' === $value['hide_if_checked'] || 'yes' === $value['show_if_checked']) { |
|
| 438 | 438 | $visibility_class[] = 'hidden_option'; |
| 439 | 439 | } |
| 440 | - if ( 'option' === $value['hide_if_checked'] ) { |
|
| 440 | + if ('option' === $value['hide_if_checked']) { |
|
| 441 | 441 | $visibility_class[] = 'hide_options_if_checked'; |
| 442 | 442 | } |
| 443 | - if ( 'option' === $value['show_if_checked'] ) { |
|
| 443 | + if ('option' === $value['show_if_checked']) { |
|
| 444 | 444 | $visibility_class[] = 'show_options_if_checked'; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - if ( ! isset( $value['checkboxgroup'] ) || 'start' === $value['checkboxgroup'] ) { |
|
| 447 | + if ( ! isset($value['checkboxgroup']) || 'start' === $value['checkboxgroup']) { |
|
| 448 | 448 | ?> |
| 449 | - <tr valign="top" class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>"> |
|
| 450 | - <th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ); ?></th> |
|
| 449 | + <tr valign="top" class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>"> |
|
| 450 | + <th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?></th> |
|
| 451 | 451 | <td class="forminp forminp-checkbox"> |
| 452 | 452 | <fieldset> |
| 453 | 453 | <?php |
| 454 | 454 | } else { |
| 455 | 455 | ?> |
| 456 | - <fieldset class="<?php echo esc_attr( implode( ' ', $visibility_class ) ); ?>"> |
|
| 456 | + <fieldset class="<?php echo esc_attr(implode(' ', $visibility_class)); ?>"> |
|
| 457 | 457 | <?php |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( ! empty( $value['title'] ) ) { |
|
| 460 | + if ( ! empty($value['title'])) { |
|
| 461 | 461 | ?> |
| 462 | - <legend class="screen-reader-text"><span><?php echo esc_html( $value['title'] ); ?></span></legend> |
|
| 462 | + <legend class="screen-reader-text"><span><?php echo esc_html($value['title']); ?></span></legend> |
|
| 463 | 463 | <?php |
| 464 | 464 | } |
| 465 | 465 | ?> |
| 466 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"> |
|
| 466 | + <label for="<?php echo esc_attr($value['id']); ?>"> |
|
| 467 | 467 | <input |
| 468 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 469 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
| 468 | + name="<?php echo esc_attr($value['id']); ?>" |
|
| 469 | + id="<?php echo esc_attr($value['id']); ?>" |
|
| 470 | 470 | type="checkbox" |
| 471 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
| 471 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
| 472 | 472 | value="1" |
| 473 | - <?php checked( $option_value, 'yes' ); ?> |
|
| 474 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
| 473 | + <?php checked($option_value, 'yes'); ?> |
|
| 474 | + <?php echo implode(' ', $custom_attributes); ?> |
|
| 475 | 475 | /> <?php echo $description; ?> |
| 476 | 476 | </label> |
| 477 | 477 | <?php |
| 478 | 478 | |
| 479 | - if ( ! isset( $value['checkboxgroup'] ) || 'end' === $value['checkboxgroup'] ) { |
|
| 479 | + if ( ! isset($value['checkboxgroup']) || 'end' === $value['checkboxgroup']) { |
|
| 480 | 480 | ?> |
| 481 | 481 | </fieldset> |
| 482 | 482 | </td> |
@@ -490,12 +490,12 @@ discard block |
||
| 490 | 490 | break; |
| 491 | 491 | |
| 492 | 492 | case 'button': |
| 493 | - if ( isset( $value['url'] ) && ! empty( $value['url'] ) ) { |
|
| 493 | + if (isset($value['url']) && ! empty($value['url'])) { |
|
| 494 | 494 | ?> |
| 495 | 495 | <tr valign="top"> |
| 496 | - <th scope="row" class="titledesc"><?php echo $value['title'];?></th> |
|
| 497 | - <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
| 498 | - <a href="<?php echo $value['url']; ?>" class="button-secondary <?php echo esc_attr( $value['class'] ); ?>"> |
|
| 496 | + <th scope="row" class="titledesc"><?php echo $value['title']; ?></th> |
|
| 497 | + <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
| 498 | + <a href="<?php echo $value['url']; ?>" class="button-secondary <?php echo esc_attr($value['class']); ?>"> |
|
| 499 | 499 | <?php echo $value['value']; ?> |
| 500 | 500 | </a> |
| 501 | 501 | <?php echo $description; ?> |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | // Default: run an action |
| 509 | 509 | default: |
| 510 | - do_action( 'auto_load_next_post_admin_field_' . $value['type'], $value ); |
|
| 510 | + do_action('auto_load_next_post_admin_field_'.$value['type'], $value); |
|
| 511 | 511 | |
| 512 | 512 | break; |
| 513 | 513 | } // end switch() |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | * @param array $options Opens array to output |
| 527 | 527 | * @return bool |
| 528 | 528 | */ |
| 529 | - public static function save_fields( $options ) { |
|
| 530 | - if ( empty( $_POST ) ) { |
|
| 529 | + public static function save_fields($options) { |
|
| 530 | + if (empty($_POST)) { |
|
| 531 | 531 | return false; |
| 532 | 532 | } |
| 533 | 533 | |
@@ -536,48 +536,48 @@ discard block |
||
| 536 | 536 | $autoload_options = array(); |
| 537 | 537 | |
| 538 | 538 | // Loop options and get values to save |
| 539 | - foreach ( $options as $option ) { |
|
| 540 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
| 539 | + foreach ($options as $option) { |
|
| 540 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
| 541 | 541 | continue; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | // Get posted value. |
| 545 | - if ( strstr( $option['id'], '[' ) ) { |
|
| 546 | - parse_str( $option['id'], $option_name_array ); |
|
| 547 | - $option_name = current( array_keys( $option_name_array ) ); |
|
| 548 | - $setting_name = key( $option_name_array[ $option_name ] ); |
|
| 549 | - $raw_value = isset( $_POST[ $option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $option_name ][ $setting_name ] ) : null; |
|
| 545 | + if (strstr($option['id'], '[')) { |
|
| 546 | + parse_str($option['id'], $option_name_array); |
|
| 547 | + $option_name = current(array_keys($option_name_array)); |
|
| 548 | + $setting_name = key($option_name_array[$option_name]); |
|
| 549 | + $raw_value = isset($_POST[$option_name][$setting_name]) ? wp_unslash($_POST[$option_name][$setting_name]) : null; |
|
| 550 | 550 | } else { |
| 551 | 551 | $option_name = $option['id']; |
| 552 | 552 | $setting_name = ''; |
| 553 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
| 553 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - switch ( $option['type'] ) { |
|
| 556 | + switch ($option['type']) { |
|
| 557 | 557 | case "checkbox" : |
| 558 | 558 | $value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no'; |
| 559 | 559 | break; |
| 560 | 560 | |
| 561 | 561 | case "textarea" : |
| 562 | - $value = wp_kses_post( trim( stripslashes( $_POST[$option['id']] ) ) ); |
|
| 562 | + $value = wp_kses_post(trim(stripslashes($_POST[$option['id']]))); |
|
| 563 | 563 | break; |
| 564 | 564 | |
| 565 | 565 | case "multiselect" : |
| 566 | - $value = array_filter( array_map( 'auto_load_next_post_clean', (array) $raw_value ) ); |
|
| 566 | + $value = array_filter(array_map('auto_load_next_post_clean', (array) $raw_value)); |
|
| 567 | 567 | break; |
| 568 | 568 | |
| 569 | 569 | case 'select' : |
| 570 | - $allowed_values = empty( $option['options'] ) ? array() : array_map( 'strval', array_keys( $option['options'] ) ); |
|
| 571 | - if ( empty( $option['default'] ) && empty( $allowed_values ) ) { |
|
| 570 | + $allowed_values = empty($option['options']) ? array() : array_map('strval', array_keys($option['options'])); |
|
| 571 | + if (empty($option['default']) && empty($allowed_values)) { |
|
| 572 | 572 | $value = null; |
| 573 | 573 | break; |
| 574 | 574 | } |
| 575 | - $default = ( empty( $option['default'] ) ? $allowed_values[0] : $option['default'] ); |
|
| 576 | - $value = in_array( $raw_value, $allowed_values, true ) ? $raw_value : $default; |
|
| 575 | + $default = (empty($option['default']) ? $allowed_values[0] : $option['default']); |
|
| 576 | + $value = in_array($raw_value, $allowed_values, true) ? $raw_value : $default; |
|
| 577 | 577 | break; |
| 578 | 578 | |
| 579 | 579 | default : |
| 580 | - $value = auto_load_next_post_clean( $raw_value ); |
|
| 580 | + $value = auto_load_next_post_clean($raw_value); |
|
| 581 | 581 | break; |
| 582 | 582 | } // END switch() |
| 583 | 583 | |
@@ -586,59 +586,59 @@ discard block |
||
| 586 | 586 | * |
| 587 | 587 | * @deprecated 1.5.0 - doesn't allow manipulation of values! |
| 588 | 588 | */ |
| 589 | - if ( has_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) ) ) { |
|
| 590 | - if ( is_ajax() ) { |
|
| 591 | - error_log( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ) . ' is deprecated since version 1.5.0' ); |
|
| 589 | + if (has_action('auto_load_next_post_update_option_'.sanitize_title($option['type']))) { |
|
| 590 | + if (is_ajax()) { |
|
| 591 | + error_log('auto_load_next_post_update_option_'.sanitize_title($option['type']).' is deprecated since version 1.5.0'); |
|
| 592 | 592 | } else { |
| 593 | - _deprecated_hook( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), '1.5.0' ); |
|
| 593 | + _deprecated_hook('auto_load_next_post_update_option_'.sanitize_title($option['type']), '1.5.0'); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - do_action( 'auto_load_next_post_update_option_' . sanitize_title( $option['type'] ), $option ); |
|
| 596 | + do_action('auto_load_next_post_update_option_'.sanitize_title($option['type']), $option); |
|
| 597 | 597 | continue; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if ( is_null( $value ) ) { |
|
| 600 | + if (is_null($value)) { |
|
| 601 | 601 | continue; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | // Check if option is an array and handle that differently to single values. |
| 605 | - if ( $option_name && $setting_name ) { |
|
| 606 | - if ( ! isset( $update_options[ $option_name ] ) ) { |
|
| 607 | - $update_options[ $option_name ] = get_option( $option_name, array() ); |
|
| 605 | + if ($option_name && $setting_name) { |
|
| 606 | + if ( ! isset($update_options[$option_name])) { |
|
| 607 | + $update_options[$option_name] = get_option($option_name, array()); |
|
| 608 | 608 | } |
| 609 | - if ( ! is_array( $update_options[ $option_name ] ) ) { |
|
| 610 | - $update_options[ $option_name ] = array(); |
|
| 609 | + if ( ! is_array($update_options[$option_name])) { |
|
| 610 | + $update_options[$option_name] = array(); |
|
| 611 | 611 | } |
| 612 | - $update_options[ $option_name ][ $setting_name ] = $value; |
|
| 612 | + $update_options[$option_name][$setting_name] = $value; |
|
| 613 | 613 | } else { |
| 614 | - $update_options[ $option_name ] = $value; |
|
| 614 | + $update_options[$option_name] = $value; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - $autoload_options[ $option_name ] = isset( $option['autoload'] ) ? (bool) $option['autoload'] : true; |
|
| 617 | + $autoload_options[$option_name] = isset($option['autoload']) ? (bool) $option['autoload'] : true; |
|
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | 620 | * Fire an action before saved. |
| 621 | 621 | * |
| 622 | 622 | * @deprecated 1.5.0 - doesn't allow manipulation of values! |
| 623 | 623 | */ |
| 624 | - if ( has_action( 'auto_load_next_post_update_option' ) ) { |
|
| 625 | - if ( is_ajax() ) { |
|
| 626 | - error_log( 'auto_load_next_post_update_option is deprecated since version 1.5.0' ); |
|
| 624 | + if (has_action('auto_load_next_post_update_option')) { |
|
| 625 | + if (is_ajax()) { |
|
| 626 | + error_log('auto_load_next_post_update_option is deprecated since version 1.5.0'); |
|
| 627 | 627 | } else { |
| 628 | - _deprecated_hook( 'auto_load_next_post_update_option', '1.5.0' ); |
|
| 628 | + _deprecated_hook('auto_load_next_post_update_option', '1.5.0'); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - do_action( 'auto_load_next_post_update_option', $option ); |
|
| 631 | + do_action('auto_load_next_post_update_option', $option); |
|
| 632 | 632 | } |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | // Now save the options |
| 636 | - foreach ( $update_options as $name => $value ) { |
|
| 637 | - update_option( $name, $value, $autoload_options[ $name ] ? 'yes' : 'no' ); |
|
| 636 | + foreach ($update_options as $name => $value) { |
|
| 637 | + update_option($name, $value, $autoload_options[$name] ? 'yes' : 'no'); |
|
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | // Save all options as an array. Ready for export. |
| 641 | - update_option( 'auto_load_next_post_options', $update_options ); |
|
| 641 | + update_option('auto_load_next_post_options', $update_options); |
|
| 642 | 642 | |
| 643 | 643 | return true; |
| 644 | 644 | } // END save_fields() |
@@ -13,20 +13,20 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Exit if accessed directly. |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | global $current_section, $current_tab; |
| 21 | 21 | |
| 22 | 22 | // Get tabs for the settings page |
| 23 | -$tabs = apply_filters( 'auto_load_next_post_settings_tabs_array', array() ); |
|
| 23 | +$tabs = apply_filters('auto_load_next_post_settings_tabs_array', array()); |
|
| 24 | 24 | |
| 25 | -$tab_exists = isset( $tabs[ $current_tab ] ) || has_action( 'auto_load_next_post_sections_' . $current_tab ) || has_action( 'auto_load_next_post_settings_' . $current_tab ) || has_action( 'auto_load_next_post_settings_tabs_' . $current_tab ); |
|
| 26 | -$current_tab_label = isset( $tabs[ $current_tab ] ) ? $tabs[ $current_tab ] : ''; |
|
| 25 | +$tab_exists = isset($tabs[$current_tab]) || has_action('auto_load_next_post_sections_'.$current_tab) || has_action('auto_load_next_post_settings_'.$current_tab) || has_action('auto_load_next_post_settings_tabs_'.$current_tab); |
|
| 26 | +$current_tab_label = isset($tabs[$current_tab]) ? $tabs[$current_tab] : ''; |
|
| 27 | 27 | |
| 28 | -if ( ! $tab_exists ) { |
|
| 29 | - wp_safe_redirect( admin_url( 'options-general.php?page=auto-load-next-post-settings' ) ); |
|
| 28 | +if ( ! $tab_exists) { |
|
| 29 | + wp_safe_redirect(admin_url('options-general.php?page=auto-load-next-post-settings')); |
|
| 30 | 30 | exit; |
| 31 | 31 | } |
| 32 | 32 | ?> |
@@ -34,43 +34,43 @@ discard block |
||
| 34 | 34 | <form method="post" id="mainform" action="" enctype="multipart/form-data"> |
| 35 | 35 | <nav class="nav-tab-wrapper"> |
| 36 | 36 | <?php |
| 37 | - foreach ( $tabs as $slug => $label ) { |
|
| 38 | - $url = add_query_arg( array( |
|
| 37 | + foreach ($tabs as $slug => $label) { |
|
| 38 | + $url = add_query_arg(array( |
|
| 39 | 39 | 'page' => 'auto-load-next-post-settings', |
| 40 | - 'tab' => esc_attr( $slug ), |
|
| 41 | - ), admin_url( 'options-general.php' ) ); |
|
| 40 | + 'tab' => esc_attr($slug), |
|
| 41 | + ), admin_url('options-general.php')); |
|
| 42 | 42 | |
| 43 | - echo '<a href="' . esc_html( $url ) . '" class="nav-tab ' . ( $current_tab === $slug ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
| 43 | + echo '<a href="'.esc_html($url).'" class="nav-tab '.($current_tab === $slug ? 'nav-tab-active' : '').'">'.esc_html($label).'</a>'; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - do_action( 'auto_load_next_post_settings_tabs' ); |
|
| 46 | + do_action('auto_load_next_post_settings_tabs'); |
|
| 47 | 47 | ?> |
| 48 | 48 | </nav> |
| 49 | - <h1 class="screen-reader-text"><?php echo esc_html( $current_tab_label ); ?></h1> |
|
| 49 | + <h1 class="screen-reader-text"><?php echo esc_html($current_tab_label); ?></h1> |
|
| 50 | 50 | <?php |
| 51 | - do_action( 'auto_load_next_post_sections_' . $current_tab ); |
|
| 51 | + do_action('auto_load_next_post_sections_'.$current_tab); |
|
| 52 | 52 | |
| 53 | 53 | self::show_messages(); |
| 54 | 54 | |
| 55 | - do_action( 'auto_load_next_post_settings_' . $current_tab ); |
|
| 55 | + do_action('auto_load_next_post_settings_'.$current_tab); |
|
| 56 | 56 | ?> |
| 57 | 57 | <p class="submit"> |
| 58 | - <?php submit_button( esc_attr__( 'Save Changes', 'auto-load-next-post' ), 'button-primary', esc_attr__( 'Save Changes', 'auto-load-next-post' ), false, array( 'id' => 'save' ) ); ?> |
|
| 59 | - <?php wp_nonce_field( 'auto-load-next-post-settings' ); ?> |
|
| 58 | + <?php submit_button(esc_attr__('Save Changes', 'auto-load-next-post'), 'button-primary', esc_attr__('Save Changes', 'auto-load-next-post'), false, array('id' => 'save')); ?> |
|
| 59 | + <?php wp_nonce_field('auto-load-next-post-settings'); ?> |
|
| 60 | 60 | </p> |
| 61 | 61 | </form> |
| 62 | 62 | |
| 63 | 63 | <?php |
| 64 | 64 | // Checks if Auto Load Next Post Pro is installed before displaying sidebar. |
| 65 | - if ( ! is_alnp_pro_version_installed() ) { |
|
| 66 | - include_once( dirname( __FILE__ ) . '/html-admin-sidebar.php' ); |
|
| 65 | + if ( ! is_alnp_pro_version_installed()) { |
|
| 66 | + include_once(dirname(__FILE__).'/html-admin-sidebar.php'); |
|
| 67 | 67 | } else { |
| 68 | 68 | echo '<div class="alnp-sidebar">'; |
| 69 | 69 | |
| 70 | - do_action( 'auto_load_next_post_after_settings' ); |
|
| 70 | + do_action('auto_load_next_post_after_settings'); |
|
| 71 | 71 | |
| 72 | 72 | // Use this hook to display after settings for a specific tab. |
| 73 | - do_action( 'auto_load_next_post_after_settings_' . $current_tab ); |
|
| 73 | + do_action('auto_load_next_post_after_settings_'.$current_tab); |
|
| 74 | 74 | |
| 75 | 75 | echo '</div>'; |
| 76 | 76 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if ( !class_exists( 'Auto_Load_Next_Post_Customizer' ) ) { |
|
| 17 | +if ( ! class_exists('Auto_Load_Next_Post_Customizer')) { |
|
| 18 | 18 | |
| 19 | 19 | class Auto_Load_Next_Post_Customizer { |
| 20 | 20 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @access public |
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | - add_action( 'customize_register', array( $this, 'alnp_init_customizer' ), 50 ); |
|
| 29 | - add_filter( 'customize_loaded_components', array( $this, 'alnp_remove_widgets_panel' ) ); |
|
| 28 | + add_action('customize_register', array($this, 'alnp_init_customizer'), 50); |
|
| 29 | + add_filter('customize_loaded_components', array($this, 'alnp_remove_widgets_panel')); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -36,21 +36,21 @@ discard block |
||
| 36 | 36 | * @since 1.5.0 |
| 37 | 37 | * @param WP_Customize_Manager $wp_customize The Customizer object. |
| 38 | 38 | */ |
| 39 | - public function alnp_init_customizer( $wp_customize ) { |
|
| 39 | + public function alnp_init_customizer($wp_customize) { |
|
| 40 | 40 | /** |
| 41 | 41 | * Dont add settings to the customizer if the user does |
| 42 | 42 | * not have permission to make changes to the theme. |
| 43 | 43 | */ |
| 44 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
| 44 | + if ( ! current_user_can('edit_theme_options')) { |
|
| 45 | 45 | return; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Load custom controllers. |
| 49 | - require_once( dirname( __FILE__ ) . '/class-alnp-arbitrary-controller.php' ); |
|
| 49 | + require_once(dirname(__FILE__).'/class-alnp-arbitrary-controller.php'); |
|
| 50 | 50 | //require_once( dirname( __FILE__ ) . '/class-alnp-display-video-controller.php' ); |
| 51 | 51 | |
| 52 | 52 | // Auto Load Next Post Panel. |
| 53 | - $panel = array( 'panel' => 'alnp' ); |
|
| 53 | + $panel = array('panel' => 'alnp'); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Add the main panel and sections. |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | $wp_customize->add_panel( |
| 61 | 61 | 'alnp', array( |
| 62 | - 'title' => esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), |
|
| 62 | + 'title' => esc_html__('Auto Load Next Post', 'auto-load-next-post'), |
|
| 63 | 63 | 'capability' => 'edit_theme_options', |
| 64 | - 'description' => esc_html__( 'Auto Load Next Post increases your pageviews by engaging the site viewers to keep reading your content rather than increasing your bounce rate.', 'auto-load-next-post' ), |
|
| 64 | + 'description' => esc_html__('Auto Load Next Post increases your pageviews by engaging the site viewers to keep reading your content rather than increasing your bounce rate.', 'auto-load-next-post'), |
|
| 65 | 65 | 'priority' => 160, |
| 66 | - 'active_callback' => array( $this, 'is_page_alnp_ready' ) |
|
| 66 | + 'active_callback' => array($this, 'is_page_alnp_ready') |
|
| 67 | 67 | ) |
| 68 | 68 | ); |
| 69 | 69 | |
@@ -71,24 +71,24 @@ discard block |
||
| 71 | 71 | $sections = $this->alnp_get_customizer_sections(); |
| 72 | 72 | |
| 73 | 73 | // Add each section. |
| 74 | - foreach ( $sections as $section => $args ) { |
|
| 74 | + foreach ($sections as $section => $args) { |
|
| 75 | 75 | /** |
| 76 | 76 | * If we are not only viewing Auto Load Next Post customizer sections |
| 77 | 77 | * then move them under our own panel. |
| 78 | 78 | */ |
| 79 | - if ( ! $this->alnp_is_customizer() ) { |
|
| 80 | - $args = array_merge( $args, $panel ); |
|
| 79 | + if ( ! $this->alnp_is_customizer()) { |
|
| 80 | + $args = array_merge($args, $panel); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $wp_customize->add_section( $section, $args ); |
|
| 83 | + $wp_customize->add_section($section, $args); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Get plugin settings. |
| 87 | 87 | $settings = $this->alnp_get_customizer_settings(); |
| 88 | 88 | |
| 89 | 89 | // Add each setting. |
| 90 | - foreach ( $settings as $setting => $args ) { |
|
| 91 | - $wp_customize->add_setting( $setting, $args ); |
|
| 90 | + foreach ($settings as $setting => $args) { |
|
| 91 | + $wp_customize->add_setting($setting, $args); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -97,16 +97,16 @@ discard block |
||
| 97 | 97 | * @since 1.5.0 |
| 98 | 98 | * @param WP_Customize_Manager $wp_customize The Customizer object. |
| 99 | 99 | */ |
| 100 | - do_action( 'alnp_customizer_register', $wp_customize ); |
|
| 100 | + do_action('alnp_customizer_register', $wp_customize); |
|
| 101 | 101 | |
| 102 | 102 | $controls = $this->alnp_get_customizer_controls(); |
| 103 | 103 | |
| 104 | - foreach ( $controls as $control => $args ) { |
|
| 105 | - $wp_customize->add_control( new $args['class']( $wp_customize, $control, $args ) ); |
|
| 104 | + foreach ($controls as $control => $args) { |
|
| 105 | + $wp_customize->add_control(new $args['class']($wp_customize, $control, $args)); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( $this->alnp_is_customizer() ) { |
|
| 109 | - $this->alnp_remove_default_customizer_panels( $wp_customize ); // Remove controls from the customizer. |
|
| 108 | + if ($this->alnp_is_customizer()) { |
|
| 109 | + $this->alnp_remove_default_customizer_panels($wp_customize); // Remove controls from the customizer. |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Video Help - Coming Soon |
@@ -128,30 +128,30 @@ discard block |
||
| 128 | 128 | * to tell users about the pro version, what comes with it |
| 129 | 129 | * and link to product page. |
| 130 | 130 | */ |
| 131 | - if ( ! is_alnp_pro_version_installed() ) { |
|
| 132 | - include_once( dirname( __FILE__ ) . '/class-alnp-pro-preview-controller.php' ); |
|
| 131 | + if ( ! is_alnp_pro_version_installed()) { |
|
| 132 | + include_once(dirname(__FILE__).'/class-alnp-pro-preview-controller.php'); |
|
| 133 | 133 | |
| 134 | 134 | $preview_args = array( |
| 135 | - 'title' => esc_html__( 'More?', 'auto-load-next-post' ), |
|
| 135 | + 'title' => esc_html__('More?', 'auto-load-next-post'), |
|
| 136 | 136 | 'priority' => 999, |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - if ( ! $this->alnp_is_customizer() ) { |
|
| 140 | - $preview_args = array_merge( $preview_args, $panel ); |
|
| 139 | + if ( ! $this->alnp_is_customizer()) { |
|
| 140 | + $preview_args = array_merge($preview_args, $panel); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $wp_customize->add_section( 'alnp_pro_preview', $preview_args ); |
|
| 143 | + $wp_customize->add_section('alnp_pro_preview', $preview_args); |
|
| 144 | 144 | |
| 145 | - $wp_customize->add_setting( 'alnp_pro_preview', array( |
|
| 145 | + $wp_customize->add_setting('alnp_pro_preview', array( |
|
| 146 | 146 | 'default' => null, |
| 147 | - ) ); |
|
| 147 | + )); |
|
| 148 | 148 | |
| 149 | - $wp_customize->add_control( new Auto_Load_Next_Post_Pro_Preview_Controller( $wp_customize, 'alnp_pro_preview', array( |
|
| 150 | - 'label' => __( 'Looking for more options?', 'auto-load-next-post' ), |
|
| 149 | + $wp_customize->add_control(new Auto_Load_Next_Post_Pro_Preview_Controller($wp_customize, 'alnp_pro_preview', array( |
|
| 150 | + 'label' => __('Looking for more options?', 'auto-load-next-post'), |
|
| 151 | 151 | 'section' => 'alnp_pro_preview', |
| 152 | 152 | 'settings' => 'alnp_pro_preview', |
| 153 | 153 | 'priority' => 1, |
| 154 | - ) ) ); |
|
| 154 | + ))); |
|
| 155 | 155 | } |
| 156 | 156 | } // END alnp_init_customizer() |
| 157 | 157 | |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | * @param array $components Core Customizer components list. |
| 163 | 163 | * @return array (Maybe) modified components list. |
| 164 | 164 | */ |
| 165 | - public function alnp_remove_widgets_panel( $components ) { |
|
| 166 | - if ( $this->alnp_is_customizer() ) { |
|
| 167 | - foreach( $components as $key => $component ) { |
|
| 168 | - if ( $component == 'widgets' ) { |
|
| 169 | - unset( $components[ 'widgets' ] ); |
|
| 165 | + public function alnp_remove_widgets_panel($components) { |
|
| 166 | + if ($this->alnp_is_customizer()) { |
|
| 167 | + foreach ($components as $key => $component) { |
|
| 168 | + if ($component == 'widgets') { |
|
| 169 | + unset($components['widgets']); |
|
| 170 | 170 | } |
| 171 | - if ( $component == 'nav_menus' ) { |
|
| 172 | - unset( $components[ 'nav_menus' ] ); |
|
| 171 | + if ($component == 'nav_menus') { |
|
| 172 | + unset($components['nav_menus']); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param object $wp_customize |
| 186 | 186 | * @return boolean |
| 187 | 187 | */ |
| 188 | - public function alnp_remove_default_customizer_panels( $wp_customize ) { |
|
| 188 | + public function alnp_remove_default_customizer_panels($wp_customize) { |
|
| 189 | 189 | global $wp_customize; |
| 190 | 190 | |
| 191 | 191 | $wp_customize->remove_section("themes"); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @return boolean |
| 209 | 209 | */ |
| 210 | 210 | public function alnp_is_customizer() { |
| 211 | - return isset( $_GET['alnp-customizer'] ) && $_GET['alnp-customizer'] === 'yes'; |
|
| 211 | + return isset($_GET['alnp-customizer']) && $_GET['alnp-customizer'] === 'yes'; |
|
| 212 | 212 | } // END alnp_is_customizer() |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -223,23 +223,23 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @param array $sections Customizer sections to add. |
| 225 | 225 | */ |
| 226 | - return apply_filters( 'auto_load_next_post_get_customizer_sections', array( |
|
| 226 | + return apply_filters('auto_load_next_post_get_customizer_sections', array( |
|
| 227 | 227 | 'auto_load_next_post_theme_selectors' => array( |
| 228 | 228 | 'capability' => 'edit_theme_options', |
| 229 | - 'title' => esc_html__( 'Theme Selectors', 'auto-load-next-post' ), |
|
| 230 | - 'description' => sprintf( __( 'Set the theme selectors below according to the theme. %1$sHow to find my theme selectors?%2$s', 'auto-load-next-post' ), '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_STORE_URL . 'documentation/find-theme-selectors/?utm_source=wpcustomizer&utm_campaign=plugin-settings-theme-selectors' ) . '" target="_blank">', '</a>' ), |
|
| 229 | + 'title' => esc_html__('Theme Selectors', 'auto-load-next-post'), |
|
| 230 | + 'description' => sprintf(__('Set the theme selectors below according to the theme. %1$sHow to find my theme selectors?%2$s', 'auto-load-next-post'), '<a href="'.esc_url(AUTO_LOAD_NEXT_POST_STORE_URL.'documentation/find-theme-selectors/?utm_source=wpcustomizer&utm_campaign=plugin-settings-theme-selectors').'" target="_blank">', '</a>'), |
|
| 231 | 231 | ), |
| 232 | 232 | 'auto_load_next_post_misc' => array( |
| 233 | 233 | 'capability' => 'edit_theme_options', |
| 234 | - 'title' => esc_html__( 'Misc Settings', 'auto-load-next-post' ), |
|
| 235 | - 'description' => sprintf( __( 'Here you can set if you want to track pageviews, remove comments and load %s javascript in the footer.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
|
| 234 | + 'title' => esc_html__('Misc Settings', 'auto-load-next-post'), |
|
| 235 | + 'description' => sprintf(__('Here you can set if you want to track pageviews, remove comments and load %s javascript in the footer.', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post')), |
|
| 236 | 236 | ), |
| 237 | 237 | 'auto_load_next_post_events' => array( |
| 238 | 238 | 'capability' => 'edit_theme_options', |
| 239 | - 'title' => esc_html__( 'Events', 'auto-load-next-post' ), |
|
| 240 | - 'description' => sprintf( __( 'Below you can enter external JavaScript events to be triggered alongside %1$s native events. Separate each event like so: %2$s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), '<code>event1, event2,</code>' ), |
|
| 239 | + 'title' => esc_html__('Events', 'auto-load-next-post'), |
|
| 240 | + 'description' => sprintf(__('Below you can enter external JavaScript events to be triggered alongside %1$s native events. Separate each event like so: %2$s', 'auto-load-next-post'), esc_html__('Auto Load Next Post', 'auto-load-next-post'), '<code>event1, event2,</code>'), |
|
| 241 | 241 | ), |
| 242 | - ) ); |
|
| 242 | + )); |
|
| 243 | 243 | } // END alnp_get_customizer_sections() |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | * |
| 257 | 257 | * @param array $settings Customizer settings to add. |
| 258 | 258 | */ |
| 259 | - return apply_filters( 'auto_load_next_post_get_customizer_settings', array( |
|
| 259 | + return apply_filters('auto_load_next_post_get_customizer_settings', array( |
|
| 260 | 260 | 'auto_load_next_post_content_container' => array( |
| 261 | 261 | 'capability' => 'edit_theme_options', |
| 262 | 262 | 'default' => $settings['alnp_content_container'], |
| 263 | 263 | 'sanitize_callback' => 'wp_filter_post_kses', |
| 264 | - 'validate_callback' => array( $this, 'alnp_validate_content_container_selector' ), |
|
| 264 | + 'validate_callback' => array($this, 'alnp_validate_content_container_selector'), |
|
| 265 | 265 | 'transport' => 'postMessage', |
| 266 | 266 | 'type' => 'option', |
| 267 | 267 | ), |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | 'capability' => 'edit_theme_options', |
| 270 | 270 | 'default' => $settings['alnp_title_selector'], |
| 271 | 271 | 'sanitize_callback' => 'wp_filter_post_kses', |
| 272 | - 'validate_callback' => array( $this, 'alnp_validate_post_title_selector' ), |
|
| 272 | + 'validate_callback' => array($this, 'alnp_validate_post_title_selector'), |
|
| 273 | 273 | 'transport' => 'postMessage', |
| 274 | 274 | 'type' => 'option', |
| 275 | 275 | ), |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | 'capability' => 'edit_theme_options', |
| 278 | 278 | 'default' => $settings['alnp_navigation_container'], |
| 279 | 279 | 'sanitize_callback' => 'wp_filter_post_kses', |
| 280 | - 'validate_callback' => array( $this, 'alnp_validate_post_navigation_selector' ), |
|
| 280 | + 'validate_callback' => array($this, 'alnp_validate_post_navigation_selector'), |
|
| 281 | 281 | 'transport' => 'postMessage', |
| 282 | 282 | 'type' => 'option', |
| 283 | 283 | ), |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | 'transport' => 'postMessage', |
| 326 | 326 | 'type' => 'option', |
| 327 | 327 | ), |
| 328 | - ) ); |
|
| 328 | + )); |
|
| 329 | 329 | } // END alnp_get_customizer_settings() |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -340,80 +340,80 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @param array $controls Customizer controls to add. |
| 342 | 342 | */ |
| 343 | - return apply_filters( 'auto_load_next_post_get_customizer_controls', array( |
|
| 343 | + return apply_filters('auto_load_next_post_get_customizer_controls', array( |
|
| 344 | 344 | 'alnp_content_container' => array( |
| 345 | 345 | 'class' => 'WP_Customize_Control', |
| 346 | - 'label' => esc_html__( 'Content Container', 'auto-load-next-post' ), |
|
| 347 | - 'description' => sprintf( __( 'The primary container where the post content is loaded in. Default: %s', 'auto-load-next-post' ), '<code>main.site-main</code>' ), |
|
| 346 | + 'label' => esc_html__('Content Container', 'auto-load-next-post'), |
|
| 347 | + 'description' => sprintf(__('The primary container where the post content is loaded in. Default: %s', 'auto-load-next-post'), '<code>main.site-main</code>'), |
|
| 348 | 348 | 'section' => 'auto_load_next_post_theme_selectors', |
| 349 | 349 | 'settings' => 'auto_load_next_post_content_container', |
| 350 | 350 | 'type' => 'text', |
| 351 | 351 | ), |
| 352 | 352 | 'alnp_title_selector' => array( |
| 353 | 353 | 'class' => 'WP_Customize_Control', |
| 354 | - 'label' => esc_html__( 'Post Title Selector', 'auto-load-next-post' ), |
|
| 355 | - 'description' => sprintf( __( 'Used to identify which article the user is reading and track should Google Analytics or other analytics be enabled. Default: %s', 'auto-load-next-post' ), '<code>h1.entry-title</code>' ), |
|
| 354 | + 'label' => esc_html__('Post Title Selector', 'auto-load-next-post'), |
|
| 355 | + 'description' => sprintf(__('Used to identify which article the user is reading and track should Google Analytics or other analytics be enabled. Default: %s', 'auto-load-next-post'), '<code>h1.entry-title</code>'), |
|
| 356 | 356 | 'section' => 'auto_load_next_post_theme_selectors', |
| 357 | 357 | 'settings' => 'auto_load_next_post_title_selector', |
| 358 | 358 | 'type' => 'text', |
| 359 | 359 | ), |
| 360 | 360 | 'alnp_navigation_container' => array( |
| 361 | 361 | 'class' => 'WP_Customize_Control', |
| 362 | - 'label' => esc_html__( 'Post Navigation Container', 'auto-load-next-post' ), |
|
| 363 | - 'description' => sprintf( __( 'Used to identify which post to load next if any. Default: %s', 'auto-load-next-post' ), '<code>nav.post-navigation</code>' ), |
|
| 362 | + 'label' => esc_html__('Post Navigation Container', 'auto-load-next-post'), |
|
| 363 | + 'description' => sprintf(__('Used to identify which post to load next if any. Default: %s', 'auto-load-next-post'), '<code>nav.post-navigation</code>'), |
|
| 364 | 364 | 'section' => 'auto_load_next_post_theme_selectors', |
| 365 | 365 | 'settings' => 'auto_load_next_post_navigation_container', |
| 366 | 366 | 'type' => 'text', |
| 367 | 367 | ), |
| 368 | 368 | 'alnp_comments_container' => array( |
| 369 | 369 | 'class' => 'WP_Customize_Control', |
| 370 | - 'label' => esc_html__( 'Comments Container', 'auto-load-next-post' ), |
|
| 371 | - 'description' => sprintf( __( 'Used to remove comments if enabled under <strong>%1$sMisc%2$s</strong> settings. Default: %3$s', 'auto-load-next-post' ), '<a href="javascript:wp.customize.section( \'auto_load_next_post_misc\' ).focus();">', '</a>', '<code>div#comments</code>' ), |
|
| 370 | + 'label' => esc_html__('Comments Container', 'auto-load-next-post'), |
|
| 371 | + 'description' => sprintf(__('Used to remove comments if enabled under <strong>%1$sMisc%2$s</strong> settings. Default: %3$s', 'auto-load-next-post'), '<a href="javascript:wp.customize.section( \'auto_load_next_post_misc\' ).focus();">', '</a>', '<code>div#comments</code>'), |
|
| 372 | 372 | 'section' => 'auto_load_next_post_theme_selectors', |
| 373 | 373 | 'settings' => 'auto_load_next_post_comments_container', |
| 374 | 374 | 'type' => 'text', |
| 375 | 375 | ), |
| 376 | 376 | 'alnp_remove_comments' => array( |
| 377 | 377 | 'class' => 'WP_Customize_Control', |
| 378 | - 'label' => esc_html__( 'Remove Comments', 'auto-load-next-post' ), |
|
| 379 | - 'description' => esc_html__( 'Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post' ), |
|
| 378 | + 'label' => esc_html__('Remove Comments', 'auto-load-next-post'), |
|
| 379 | + 'description' => esc_html__('Enable to remove comments when each post loads including the initial post.', 'auto-load-next-post'), |
|
| 380 | 380 | 'section' => 'auto_load_next_post_misc', |
| 381 | 381 | 'settings' => 'auto_load_next_post_remove_comments', |
| 382 | 382 | 'type' => 'checkbox', |
| 383 | 383 | ), |
| 384 | 384 | 'alnp_google_analytics' => array( |
| 385 | 385 | 'class' => 'WP_Customize_Control', |
| 386 | - 'label' => esc_html__( 'Update Google Analytics', 'auto-load-next-post' ), |
|
| 387 | - 'description' => esc_html__( 'Enable to track each post the visitor is reading. This will count as a pageview. You must already have Google Analytics setup.', 'auto-load-next-post' ), |
|
| 386 | + 'label' => esc_html__('Update Google Analytics', 'auto-load-next-post'), |
|
| 387 | + 'description' => esc_html__('Enable to track each post the visitor is reading. This will count as a pageview. You must already have Google Analytics setup.', 'auto-load-next-post'), |
|
| 388 | 388 | 'section' => 'auto_load_next_post_misc', |
| 389 | 389 | 'settings' => 'auto_load_next_post_google_analytics', |
| 390 | 390 | 'type' => 'checkbox', |
| 391 | 391 | ), |
| 392 | 392 | 'alnp_js_footer' => array( |
| 393 | 393 | 'class' => 'WP_Customize_Control', |
| 394 | - 'label' => esc_html__( 'JavaScript in Footer?', 'auto-load-next-post' ), |
|
| 395 | - 'description' => esc_html__( 'Enable to load Auto Load Next Post in the footer instead of the header. Can be useful to optimize your site.', 'auto-load-next-post' ), |
|
| 394 | + 'label' => esc_html__('JavaScript in Footer?', 'auto-load-next-post'), |
|
| 395 | + 'description' => esc_html__('Enable to load Auto Load Next Post in the footer instead of the header. Can be useful to optimize your site.', 'auto-load-next-post'), |
|
| 396 | 396 | 'section' => 'auto_load_next_post_misc', |
| 397 | 397 | 'settings' => 'auto_load_next_post_load_js_in_footer', |
| 398 | 398 | 'type' => 'checkbox', |
| 399 | 399 | ), |
| 400 | 400 | 'alnp_on_load_event' => array( |
| 401 | 401 | 'class' => 'WP_Customize_Control', |
| 402 | - 'label' => esc_html__( 'Post loaded', 'auto-load-next-post' ), |
|
| 403 | - 'description' => esc_html__( 'Events listed here will be triggered after a new post has loaded.', 'auto-load-next-post' ), |
|
| 402 | + 'label' => esc_html__('Post loaded', 'auto-load-next-post'), |
|
| 403 | + 'description' => esc_html__('Events listed here will be triggered after a new post has loaded.', 'auto-load-next-post'), |
|
| 404 | 404 | 'section' => 'auto_load_next_post_events', |
| 405 | 405 | 'settings' => 'auto_load_next_post_on_load_event', |
| 406 | 406 | 'type' => 'textarea', |
| 407 | 407 | ), |
| 408 | 408 | 'alnp_on_entering_event' => array( |
| 409 | 409 | 'class' => 'WP_Customize_Control', |
| 410 | - 'label' => esc_html__( 'Entering a Post', 'auto-load-next-post' ), |
|
| 411 | - 'description' => esc_html__( 'Events listed here will be triggered when entering a post.', 'auto-load-next-post' ), |
|
| 410 | + 'label' => esc_html__('Entering a Post', 'auto-load-next-post'), |
|
| 411 | + 'description' => esc_html__('Events listed here will be triggered when entering a post.', 'auto-load-next-post'), |
|
| 412 | 412 | 'section' => 'auto_load_next_post_events', |
| 413 | 413 | 'settings' => 'auto_load_next_post_on_entering_event', |
| 414 | 414 | 'type' => 'textarea', |
| 415 | 415 | ), |
| 416 | - ) ); |
|
| 416 | + )); |
|
| 417 | 417 | } // END alnp_get_customizer_controls() |
| 418 | 418 | |
| 419 | 419 | /** |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | * @param string $value Value, normally pre-sanitized. |
| 425 | 425 | * @return WP_Error $validity |
| 426 | 426 | */ |
| 427 | - public function alnp_validate_content_container_selector( $validity, $value ) { |
|
| 428 | - if ( empty( $value ) ) { |
|
| 429 | - $validity->add( 'required', esc_html__( 'The content container selector is empty. Will not know where to load posts without it.', 'auto-load-next-post' ) ); |
|
| 427 | + public function alnp_validate_content_container_selector($validity, $value) { |
|
| 428 | + if (empty($value)) { |
|
| 429 | + $validity->add('required', esc_html__('The content container selector is empty. Will not know where to load posts without it.', 'auto-load-next-post')); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | return $validity; |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | * @param string $value Value, normally pre-sanitized. |
| 441 | 441 | * @return WP_Error $validity |
| 442 | 442 | */ |
| 443 | - public function alnp_validate_post_title_selector( $validity, $value ) { |
|
| 444 | - if ( empty( $value ) ) { |
|
| 445 | - $validity->add( 'required', esc_html__( 'The post title selector is empty. Will not be able to identify which article the user is reading.', 'auto-load-next-post' ) ); |
|
| 443 | + public function alnp_validate_post_title_selector($validity, $value) { |
|
| 444 | + if (empty($value)) { |
|
| 445 | + $validity->add('required', esc_html__('The post title selector is empty. Will not be able to identify which article the user is reading.', 'auto-load-next-post')); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | return $validity; |
@@ -456,9 +456,9 @@ discard block |
||
| 456 | 456 | * @param string $value Value, normally pre-sanitized. |
| 457 | 457 | * @return WP_Error $validity |
| 458 | 458 | */ |
| 459 | - public function alnp_validate_post_navigation_selector( $validity, $value ) { |
|
| 460 | - if ( empty( $value ) ) { |
|
| 461 | - $validity->add( 'required', esc_html__( 'The post navigation container selector is empty. Required so ALNP can look up the next post to load.', 'auto-load-next-post' ) ); |
|
| 459 | + public function alnp_validate_post_navigation_selector($validity, $value) { |
|
| 460 | + if (empty($value)) { |
|
| 461 | + $validity->add('required', esc_html__('The post navigation container selector is empty. Required so ALNP can look up the next post to load.', 'auto-load-next-post')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | return $validity; |
@@ -472,16 +472,16 @@ discard block |
||
| 472 | 472 | */ |
| 473 | 473 | public function alnp_get_settings() { |
| 474 | 474 | $args = array( |
| 475 | - 'alnp_content_container' => get_option( 'auto_load_next_post_content_container' ), |
|
| 476 | - 'alnp_title_selector' => get_option( 'auto_load_next_post_title_selector' ), |
|
| 477 | - 'alnp_navigation_container' => get_option( 'auto_load_next_post_navigation_container' ), |
|
| 478 | - 'alnp_previous_post_selector' => get_option( 'auto_load_next_post_previous_post_selector' ), |
|
| 479 | - 'alnp_comments_container' => get_option( 'auto_load_next_post_comments_container' ), |
|
| 480 | - 'alnp_remove_comments' => get_option( 'auto_load_next_post_remove_comments' ), |
|
| 481 | - 'alnp_google_analytics' => get_option( 'auto_load_next_post_google_analytics' ), |
|
| 482 | - 'alnp_js_footer' => get_option( 'auto_load_next_post_load_js_in_footer' ), |
|
| 483 | - 'alnp_on_load_event' => get_option( 'auto_load_next_post_on_load_event' ), |
|
| 484 | - 'alnp_on_entering_event' => get_option( 'auto_load_next_post_on_entering_event' ), |
|
| 475 | + 'alnp_content_container' => get_option('auto_load_next_post_content_container'), |
|
| 476 | + 'alnp_title_selector' => get_option('auto_load_next_post_title_selector'), |
|
| 477 | + 'alnp_navigation_container' => get_option('auto_load_next_post_navigation_container'), |
|
| 478 | + 'alnp_previous_post_selector' => get_option('auto_load_next_post_previous_post_selector'), |
|
| 479 | + 'alnp_comments_container' => get_option('auto_load_next_post_comments_container'), |
|
| 480 | + 'alnp_remove_comments' => get_option('auto_load_next_post_remove_comments'), |
|
| 481 | + 'alnp_google_analytics' => get_option('auto_load_next_post_google_analytics'), |
|
| 482 | + 'alnp_js_footer' => get_option('auto_load_next_post_load_js_in_footer'), |
|
| 483 | + 'alnp_on_load_event' => get_option('auto_load_next_post_on_load_event'), |
|
| 484 | + 'alnp_on_entering_event' => get_option('auto_load_next_post_on_entering_event'), |
|
| 485 | 485 | ); |
| 486 | 486 | |
| 487 | 487 | return $args; |
@@ -495,13 +495,13 @@ discard block |
||
| 495 | 495 | * @return boolean |
| 496 | 496 | */ |
| 497 | 497 | public function is_page_alnp_ready() { |
| 498 | - if ( is_front_page() && is_home() ) { |
|
| 498 | + if (is_front_page() && is_home()) { |
|
| 499 | 499 | return false; |
| 500 | - } elseif ( is_front_page() ) { |
|
| 500 | + } elseif (is_front_page()) { |
|
| 501 | 501 | return false; |
| 502 | - } elseif ( is_home() ) { |
|
| 502 | + } elseif (is_home()) { |
|
| 503 | 503 | return true; |
| 504 | - } elseif ( is_singular( apply_filters( 'alnp_customizer_posts_ready', array( 'post' ) ) ) ) { |
|
| 504 | + } elseif (is_singular(apply_filters('alnp_customizer_posts_ready', array('post')))) { |
|
| 505 | 505 | return true; |
| 506 | 506 | } |
| 507 | 507 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly. |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function __construct() { |
| 30 | 30 | // Update theme selectors if the theme was switched and it has theme support. |
| 31 | - add_action( 'after_switch_theme', array( $this, 'update_alnp_theme_selectors' ), 15, 2 ); |
|
| 31 | + add_action('after_switch_theme', array($this, 'update_alnp_theme_selectors'), 15, 2); |
|
| 32 | 32 | } // END __construct() |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -37,17 +37,17 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @access public |
| 39 | 39 | */ |
| 40 | - public function update_alnp_theme_selectors( $stylesheet = '', $old_theme = false ) { |
|
| 40 | + public function update_alnp_theme_selectors($stylesheet = '', $old_theme = false) { |
|
| 41 | 41 | // Check if Auto Load Next Post is supported before updating the theme selectors. |
| 42 | - if ( is_alnp_supported() ) { |
|
| 43 | - $theme_support = get_theme_support( 'auto-load-next-post' ); |
|
| 42 | + if (is_alnp_supported()) { |
|
| 43 | + $theme_support = get_theme_support('auto-load-next-post'); |
|
| 44 | 44 | |
| 45 | - if ( is_array( $theme_support ) ) { |
|
| 45 | + if (is_array($theme_support)) { |
|
| 46 | 46 | // Preferred implementation, where theme provides an array of options |
| 47 | - if ( isset( $theme_support[0] ) && is_array( $theme_support[0] ) ) { |
|
| 48 | - foreach( $theme_support[0] as $key => $value ) { |
|
| 49 | - if ( ! empty( $value ) ) { |
|
| 50 | - update_option( 'auto_load_next_post_' . $key, $value ); |
|
| 47 | + if (isset($theme_support[0]) && is_array($theme_support[0])) { |
|
| 48 | + foreach ($theme_support[0] as $key => $value) { |
|
| 49 | + if ( ! empty($value)) { |
|
| 50 | + update_option('auto_load_next_post_'.$key, $value); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Exit if accessed directly. |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | * @version 1.5.4 |
| 27 | 27 | * @global WP_Query $wp_query - The object information defining the current request and determines what type of query it's dealing with. See https://codex.wordpress.org/Class_Reference/WP_Query |
| 28 | 28 | */ |
| 29 | -if ( ! function_exists( 'auto_load_next_post_template_redirect' ) ) { |
|
| 29 | +if ( ! function_exists('auto_load_next_post_template_redirect')) { |
|
| 30 | 30 | function auto_load_next_post_template_redirect() { |
| 31 | 31 | global $wp_query; |
| 32 | 32 | |
| 33 | 33 | // If this is not a request for alnp or a singular object then bail |
| 34 | - if ( ! isset( $wp_query->query_vars['alnp'] ) || ! is_singular() ) { |
|
| 34 | + if ( ! isset($wp_query->query_vars['alnp']) || ! is_singular()) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | * If theme does not have a template file for Auto Load Next Post, |
| 41 | 41 | * the plugin will load a default template. |
| 42 | 42 | */ |
| 43 | - $child_path = get_stylesheet_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH; |
|
| 44 | - $template_path = get_template_directory() . '/' . AUTO_LOAD_NEXT_POST_TEMPLATE_PATH; |
|
| 43 | + $child_path = get_stylesheet_directory().'/'.AUTO_LOAD_NEXT_POST_TEMPLATE_PATH; |
|
| 44 | + $template_path = get_template_directory().'/'.AUTO_LOAD_NEXT_POST_TEMPLATE_PATH; |
|
| 45 | 45 | $default_path = AUTO_LOAD_NEXT_POST_FILE_PATH; |
| 46 | 46 | $template_redirect = ''; |
| 47 | 47 | |
| 48 | - if ( file_exists( $child_path . 'content-alnp.php' ) ) { |
|
| 49 | - $template_redirect = $child_path . 'content-alnp.php'; |
|
| 50 | - } else if ( file_exists( $template_path . 'content-alnp.php' ) ) { |
|
| 51 | - $template_redirect = $template_path . 'content-alnp.php'; |
|
| 52 | - } else if ( file_exists( $default_path . '/template/content-alnp.php' ) ) { |
|
| 53 | - $template_redirect = $default_path . '/template/content-alnp.php'; |
|
| 48 | + if (file_exists($child_path.'content-alnp.php')) { |
|
| 49 | + $template_redirect = $child_path.'content-alnp.php'; |
|
| 50 | + } else if (file_exists($template_path.'content-alnp.php')) { |
|
| 51 | + $template_redirect = $template_path.'content-alnp.php'; |
|
| 52 | + } else if (file_exists($default_path.'/template/content-alnp.php')) { |
|
| 53 | + $template_redirect = $default_path.'/template/content-alnp.php'; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $template_redirect = apply_filters( 'alnp_template_redirect', $template_redirect ); |
|
| 56 | + $template_redirect = apply_filters('alnp_template_redirect', $template_redirect); |
|
| 57 | 57 | |
| 58 | - include( $template_redirect ); |
|
| 58 | + include($template_redirect); |
|
| 59 | 59 | |
| 60 | 60 | exit; |
| 61 | 61 | } // END auto_load_next_post_template_redirect() |
| 62 | 62 | } |
| 63 | -add_action( 'template_redirect', 'auto_load_next_post_template_redirect' ); |
|
| 63 | +add_action('template_redirect', 'auto_load_next_post_template_redirect'); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Adds the comments template after the post content. |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | * @since 1.4.8 |
| 70 | 70 | * @version 1.5.4 |
| 71 | 71 | */ |
| 72 | -if ( ! function_exists( 'auto_load_next_post_comments' ) ) { |
|
| 72 | +if ( ! function_exists('auto_load_next_post_comments')) { |
|
| 73 | 73 | function auto_load_next_post_comments() { |
| 74 | 74 | // If comments are open or we have at least one comment, load up the comment template. |
| 75 | - if ( comments_open() || get_comments_number() ) : |
|
| 75 | + if (comments_open() || get_comments_number()) : |
|
| 76 | 76 | comments_template(); |
| 77 | 77 | endif; |
| 78 | 78 | } // END auto_load_next_post_comments() |
| 79 | 79 | } |
| 80 | -add_action( 'alnp_load_after_content', 'auto_load_next_post_comments', 1, 5 ); |
|
| 80 | +add_action('alnp_load_after_content', 'auto_load_next_post_comments', 1, 5); |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Adds the post navigation for the previous link only after the post content. |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | * @since 1.4.8 |
| 87 | 87 | * @version 1.5.4 |
| 88 | 88 | */ |
| 89 | -if ( ! function_exists( 'auto_load_next_post_navigation' ) ) { |
|
| 89 | +if ( ! function_exists('auto_load_next_post_navigation')) { |
|
| 90 | 90 | function auto_load_next_post_navigation() { |
| 91 | 91 | ?> |
| 92 | 92 | <nav class="navigation post-navigation" role="navigation"> |
| 93 | - <span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'auto-load-next-post' ) . '</span> %title' ); ?></span> |
|
| 93 | + <span class="nav-previous"><?php previous_post_link('%link', '<span class="meta-nav">'._x('←', 'Previous post link', 'auto-load-next-post').'</span> %title'); ?></span> |
|
| 94 | 94 | </nav> |
| 95 | 95 | <?php |
| 96 | 96 | } // END auto_load_next_post_navigation() |
| 97 | 97 | } |
| 98 | -add_action( 'alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10 ); |
|
| 98 | +add_action('alnp_load_after_content', 'auto_load_next_post_navigation', 1, 10); |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Returns the permalink of a random page |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $post_type - Default is post. |
| 105 | 105 | * @return int|boolean |
| 106 | 106 | */ |
| 107 | -if ( ! function_exists( 'alnp_get_random_page_permalink' ) ) { |
|
| 108 | - function alnp_get_random_page_permalink( $post_type = 'post' ) { |
|
| 107 | +if ( ! function_exists('alnp_get_random_page_permalink')) { |
|
| 108 | + function alnp_get_random_page_permalink($post_type = 'post') { |
|
| 109 | 109 | $args = array( |
| 110 | 110 | 'post_type' => $post_type, |
| 111 | 111 | 'post_status' => 'publish', |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | 'posts_per_page' => 1 |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - $query = new WP_Query( $args ); |
|
| 116 | + $query = new WP_Query($args); |
|
| 117 | 117 | |
| 118 | - if ( $query->have_posts() ) { |
|
| 119 | - while ( $query->have_posts() ) : $query->the_post(); |
|
| 118 | + if ($query->have_posts()) { |
|
| 119 | + while ($query->have_posts()) : $query->the_post(); |
|
| 120 | 120 | $id = get_the_ID(); |
| 121 | 121 | |
| 122 | - return get_permalink( $id ); |
|
| 122 | + return get_permalink($id); |
|
| 123 | 123 | endwhile; |
| 124 | 124 | } else { |
| 125 | 125 | return false; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | * @since 1.5.7 |
| 134 | 134 | * @return boolean |
| 135 | 135 | */ |
| 136 | -if ( ! function_exists( 'alnp_load_js_in_footer' ) ) { |
|
| 136 | +if ( ! function_exists('alnp_load_js_in_footer')) { |
|
| 137 | 137 | function alnp_load_js_in_footer() { |
| 138 | - $load_in_footer = get_option( 'auto_load_next_post_load_js_in_footer', false ); |
|
| 138 | + $load_in_footer = get_option('auto_load_next_post_load_js_in_footer', false); |
|
| 139 | 139 | |
| 140 | - if ( isset( $load_in_footer ) && $load_in_footer == 'yes' ) { |
|
| 140 | + if (isset($load_in_footer) && $load_in_footer == 'yes') { |
|
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @since 1.5.11 |
| 153 | 153 | * @return array |
| 154 | 154 | */ |
| 155 | -if ( ! function_exists( 'alnp_get_admin_screens' ) ) { |
|
| 155 | +if ( ! function_exists('alnp_get_admin_screens')) { |
|
| 156 | 156 | function alnp_get_admin_screens() { |
| 157 | 157 | return array( |
| 158 | 158 | 'dashboard', |