AutoLoadNextPost /
auto-load-next-post
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Auto Load Next Post - Admin Assets. |
||
| 4 | * |
||
| 5 | * @since 1.6.0 |
||
| 6 | * @author Sébastien Dumont |
||
| 7 | * @category Admin |
||
| 8 | * @package Auto Load Next Post/Admin |
||
| 9 | * @license GPL-2.0+ |
||
| 10 | */ |
||
| 11 | |||
| 12 | // Exit if accessed directly. |
||
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
||
| 14 | exit; |
||
| 15 | } |
||
| 16 | |||
| 17 | if ( ! class_exists( 'ALNP_Admin_Assets' ) ) { |
||
| 18 | |||
| 19 | class ALNP_Admin_Assets { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Constructor |
||
| 23 | * |
||
| 24 | * @access public |
||
| 25 | */ |
||
| 26 | public function __construct() { |
||
| 27 | // Register scripts and styles for settings page. |
||
| 28 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ), 10 ); |
||
| 29 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 10 ); |
||
| 30 | |||
| 31 | // Register Stylesheet for Dark Mode if active. |
||
| 32 | add_action( 'doing_dark_mode', array( $this, 'do_dark_mode' ), 99 ); |
||
| 33 | |||
| 34 | // Adds admin body classes. |
||
| 35 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
||
| 36 | } // END __construct() |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Registers and enqueues Stylesheets. |
||
| 40 | * |
||
| 41 | * @access public |
||
| 42 | */ |
||
| 43 | public function admin_styles() { |
||
| 44 | $screen = get_current_screen(); |
||
| 45 | $screen_id = $screen ? $screen->id : ''; |
||
| 46 | |||
| 47 | if ( in_array( $screen_id, alnp_get_admin_screens() ) ) { |
||
| 48 | 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' ); |
||
| 49 | |||
| 50 | $current_view = ! empty( $_GET['view'] ) ? sanitize_title( wp_unslash( $_GET['view'] ) ) : ''; |
||
| 51 | |||
| 52 | // Dont load stylesheet if viewing any of these pages. |
||
| 53 | $dont_style = array( 'getting-started', 'setup-wizard', 'extensions', 'videos' ); |
||
| 54 | if ( ! in_array( $current_view, $dont_style ) ) { |
||
| 55 | |||
| 56 | // Select2 - Make sure that we remove other registered Select2 to prevent styling issues. |
||
| 57 | if ( wp_script_is( 'select2', 'registered' ) ) { |
||
| 58 | wp_dequeue_style( 'select2' ); |
||
| 59 | wp_deregister_style( 'select2' ); |
||
| 60 | } |
||
| 61 | |||
| 62 | Auto_Load_Next_Post::load_file( 'select2', '/assets/css/libs/select2.min.css' ); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } // END admin_styles() |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Registers and enqueue JavaScripts. |
||
| 69 | * |
||
| 70 | * @access public |
||
| 71 | */ |
||
| 72 | public function admin_scripts() { |
||
| 73 | $screen = get_current_screen(); |
||
| 74 | $screen_id = $screen ? $screen->id : ''; |
||
| 75 | |||
| 76 | if ( $screen_id == 'settings_page_auto-load-next-post' ) { |
||
| 77 | |||
| 78 | // Load jQuery Confirm |
||
| 79 | Auto_Load_Next_Post::load_file( 'jquery-confirm', '/assets/css/libs/jquery-confirm.min.css' ); |
||
| 80 | Auto_Load_Next_Post::load_file( 'jquery-confirm', '/assets/js/libs/jquery-confirm.min.js', true, array( 'jquery' ), '3.3.4', true ); |
||
| 81 | |||
| 82 | $current_view = ! empty( $_GET['view'] ) ? sanitize_title( wp_unslash( $_GET['view'] ) ) : ''; |
||
| 83 | |||
| 84 | switch( $current_view ) { |
||
| 85 | case 'setup-wizard': |
||
| 86 | // Scanner. |
||
| 87 | Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_scanner', '/assets/js/admin/scanner' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery' ), AUTO_LOAD_NEXT_POST_VERSION, true ); |
||
| 88 | |||
| 89 | // Variables for Scanner JavaScript. |
||
| 90 | wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_scanner', 'alnp_scanner_params', array( |
||
| 91 | 'is_rtl' => is_rtl() ? true : false, |
||
| 92 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
||
| 93 | 'random_page' => alnp_get_random_page_permalink(), |
||
| 94 | 'i18n_searching' => esc_html__( 'Searching...', 'auto-load-next-post' ), |
||
| 95 | 'i18n_scanning_theme' => esc_html__( 'Scanning Theme', 'auto-load-next-post' ), |
||
| 96 | 'i18n_scanning_theme_content' => esc_html__( 'Currently scanning a post on your site for your theme selectors. Please wait...', 'auto-load-next-post' ), |
||
| 97 | 'i18n_please_wait' => esc_html__( 'Please Wait', 'auto-load-next-post' ), |
||
| 98 | 'i18n_loading_post' => esc_html__( 'Loading post...', 'auto-load-next-post' ), |
||
| 99 | 'i18n_copied' => esc_html__( 'Copied', 'auto-load-next-post' ), |
||
| 100 | 'i18n_copy_title' => esc_html__( 'Click to copy theme selector', 'auto-load-next-post' ), |
||
| 101 | 'i18n_post_nav_missing' => esc_html__( 'Post Navigation Missing?', 'auto-load-next-post' ), |
||
| 102 | 'i18n_error_post_nav' => sprintf( esc_html__( '%1$s requires a theme with a post navigation in order to work and the setup wizard did not detect one. You may scan again to be sure. If you get the same results, %1$s may not recognise it.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
||
| 103 | ) ); |
||
| 104 | |||
| 105 | break; |
||
| 106 | default: |
||
| 107 | // Select2 - Make sure that we remove other registered Select2 to prevent plugin conflict issues. |
||
| 108 | if ( wp_script_is( 'select2', 'registered' ) ) { |
||
| 109 | wp_dequeue_script( 'select2' ); |
||
| 110 | wp_deregister_script( 'select2' ); |
||
| 111 | } |
||
| 112 | |||
| 113 | // Load Select2 |
||
| 114 | Auto_Load_Next_Post::load_file( 'select2', '/assets/js/libs/select2.min.js', true, array( 'jquery' ), '4.0.5', true ); |
||
| 115 | |||
| 116 | // Auto Load Next Post Preview. |
||
| 117 | Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_pro_preview', '/assets/js/admin/pro-preview' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.js', true, array( 'jquery', 'jquery-confirm' ), AUTO_LOAD_NEXT_POST_VERSION, true ); |
||
| 118 | |||
| 119 | // Variables for Pro Preview JavaScript. |
||
| 120 | wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_pro_preview', 'alnp_pro_preview_params', array( |
||
| 121 | 'is_rtl' => is_rtl() ? true : false, |
||
| 122 | 'i18n_coming_soon' => esc_html__( 'Coming Soon', 'auto-load-next-post' ), |
||
| 123 | 'i18n_coming_soon_content' => sprintf( esc_html__( '%1$s%3$s%2$s coming soon with more features. Sign up in the sidebar to be notified!', 'auto-load-next-post' ), '<strong>', '</strong>', esc_html__( 'Auto Load Next Post Pro', 'auto-load-next-post' ) ), |
||
| 124 | 'i18n_comments_content' => sprintf( esc_html__( '%1$sComments:%2$s More control on how comments should interact when each post loads.', 'auto-load-next-post' ), '<strong>', '</strong>' ), |
||
| 125 | 'i18n_load_scroll_content' => sprintf( esc_html__( '%1$sLoad and Scroll:%2$s Choose what loads next, enable to load split posts, scroll transistion and scroll speed.', 'auto-load-next-post' ), '<strong>', '</strong>' ), |
||
| 126 | 'i18n_restrictions_content' => sprintf( esc_html__( '%1$sRestrictions:%2$s Manage which post types %3$s should load on, how many posts to load per session and which user roles and users are excluded from loading posts.', 'auto-load-next-post' ), '<strong>', '</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
||
| 127 | 'i18n_query_content' => sprintf( esc_html__( '%1$sQuery:%2$s Customise the query of posts before %3$s loads them including excluded posts and post formats.', 'auto-load-next-post' ), '<strong>', '</strong>', esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ), |
||
| 128 | 'i18n_license_content' => esc_html__( 'License is managed here for support and remote plugin updates.', 'auto-load-next-post' ) |
||
| 129 | ) ); |
||
| 130 | |||
| 131 | // Load plugin settings. |
||
| 132 | 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 ); |
||
| 133 | |||
| 134 | // Variables for Admin Settings JavaScript. |
||
| 135 | wp_localize_script( AUTO_LOAD_NEXT_POST_SLUG . '_admin', 'alnp_settings_params', array( |
||
| 136 | 'is_rtl' => is_rtl() ? 'rtl' : 'ltr', |
||
| 137 | 'i18n_nav_warning' => esc_html__( 'The changes you made will be lost if you navigate away from this page.', 'auto-load-next-post' ), |
||
| 138 | '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' ) ), |
||
| 139 | 'i18n_setup_wizard_warning' => esc_html__( 'The setup wizard will override settings that you may already have working. Are you sure?', 'auto-load-next-post' ), |
||
| 140 | 'i18n_coming_soon' => esc_html__( 'Coming Soon', 'auto-load-next-post' ), |
||
| 141 | 'i18n_continue' => esc_html__( 'Continue', 'auto-load-next-post' ), |
||
| 142 | 'i18n_save' => esc_html__( 'Save', 'auto-load-next-post' ), |
||
| 143 | 'i18n_save_recommendation' => sprintf( esc_html__( 'Press the %1$sSave Changes%2$s button to keep changes.', 'auto-load-next-post' ), '<strong>', '</strong>' ), |
||
| 144 | 'i18n_warning' => esc_html__( 'Warning', 'auto-load-next-post' ), |
||
| 145 | ) ); |
||
| 146 | |||
| 147 | break; |
||
| 148 | } |
||
| 149 | } |
||
| 150 | } // END admin_scripts() |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Adds support for displaying plugin pages in DARK MODE. |
||
| 154 | * |
||
| 155 | * @access public |
||
| 156 | */ |
||
| 157 | public function do_dark_mode() { |
||
| 158 | $screen = get_current_screen(); |
||
| 159 | $screen_id = $screen ? $screen->id : ''; |
||
| 160 | |||
| 161 | if ( $screen_id == 'settings_page_auto-load-next-post' ) { |
||
| 162 | Auto_Load_Next_Post::load_file( AUTO_LOAD_NEXT_POST_SLUG . '_dark_mode', '/assets/css/admin/auto-load-next-post-dark-mode' . AUTO_LOAD_NEXT_POST_SCRIPT_MODE . '.css' ); |
||
| 163 | } |
||
| 164 | } // END do_dark_mode() |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Adds admin body classes depending on what page of |
||
| 168 | * Auto Load Next Post the user is viewing. |
||
| 169 | * |
||
| 170 | * @access public |
||
| 171 | * @since 1.6.0 |
||
| 172 | * @param string $classes |
||
| 173 | * @return string $classes |
||
| 174 | */ |
||
| 175 | public function admin_body_class( $classes ) { |
||
|
0 ignored issues
–
show
|
|||
| 176 | $current_view = ! empty( $_GET['view'] ) ? sanitize_title( wp_unslash( $_GET['view'] ) ) : ''; |
||
| 177 | |||
| 178 | switch( $current_view ) { |
||
| 179 | case 'getting-started': |
||
| 180 | $classes = ' alnp-getting-started '; |
||
| 181 | break; |
||
| 182 | case 'setup-wizard': |
||
| 183 | $classes = ' alnp-setup-wizard '; |
||
| 184 | break; |
||
| 185 | default: |
||
| 186 | $classes = ''; |
||
| 187 | break; |
||
| 188 | } |
||
| 189 | |||
| 190 | return $classes; |
||
| 191 | } |
||
| 192 | |||
| 193 | } // END class |
||
| 194 | |||
| 195 | } // END if class exists |
||
| 196 | |||
| 197 | return new ALNP_Admin_Assets(); |
||
| 198 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.