| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Auto Load Next Post - Admin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @since    1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @version  1.6.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author   Sébastien Dumont | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @category Admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @package  Auto Load Next Post/Admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @license  GPL-2.0+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | // Exit if accessed directly. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	exit; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | if ( ! class_exists( 'ALNP_Admin' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	class ALNP_Admin { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		 * Constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		 * @access  public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		 * @since   1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		 * @version 1.6.0 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 		public function __construct() { | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 			// Include classes. | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | 			self::includes(); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 			// Add settings page. | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 			add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 		} // END __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		 * Include any classes we need within admin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		 * @access  public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		 * @since   1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		 * @version 1.6.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		 * @global  string $wp_version - The version of WordPress | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		public function includes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			global $wp_version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-admin-action-links.php' );        // Action Links | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-admin-assets.php' );              // Admin Assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-admin-notices.php' );             // Plugin Notices | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 			if ( apply_filters( 'alnp_enable_admin_help_tab', true ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 				include( dirname( __FILE__ ) . '/class-alnp-admin-help.php' );            // Plugin Help Tab | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			include_once( dirname( __FILE__ ) . '/class-alnp-getting-started.php');       // Getting Started. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 			include_once( dirname( __FILE__ ) . '/class-alnp-setup-wizard.php');          // Setup Wizard. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			include_once( dirname( __FILE__ ) . '/class-alnp-extensions.php');            // Extensions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			if ( ! is_alnp_pro_version_installed() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 				include_once( dirname( __FILE__ ) . '/class-alnp-admin-pro-preview.php'); // Pro Preview. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-sidebar.php' );                   // Sidebar | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-admin-footer.php' );              // Admin Footer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 			include( dirname( __FILE__ ) . '/class-alnp-privacy.php' );                   // Plugin Privacy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			if ( version_compare( $wp_version, '5.2', '>=' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				include( dirname( __FILE__ ) . '/class-alnp-admin-site-health.php' );     // Site Health | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		} // END includes() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 		 * Add Auto Load Next Post to the settings menu. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		 * @access  public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		 * @since   1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		 * @version 1.6.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 		public function admin_menu() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			$current_view = ! empty( $_GET['view'] ) ? sanitize_title( wp_unslash( $_GET['view'] ) ) : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			$title = ''; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			switch( $current_view ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 				case 'getting-started': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 					$title = sprintf( esc_attr__( 'Getting Started with %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 				case 'setup-wizard': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 					$title = sprintf( esc_attr__( 'Setup Wizard for %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 				case 'extensions': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 					$title = sprintf( esc_attr__( '%s | Extensions', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 				default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 					$title = sprintf( esc_attr__( '%s Settings', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			$settings_page = add_options_page( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 				$title, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 				esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 				'manage_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 				'auto-load-next-post', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 				array( $this, 'settings_page' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			add_action( 'load-' . $settings_page, array( $this, 'settings_page_init' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		} // END admin_menu() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		 * Loads settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		 * @access  public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		 * @since   1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 		 * @version 1.6.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		 * @global  string $current_view | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 		 * @global  string $current_section | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		public function settings_page_init() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			global $current_view, $current_section; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 			// Include settings pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			ALNP_Admin_Settings::get_settings_pages(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 			// Get current view/section. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			$current_view    = empty( $_GET['view'] ) ? 'theme-selectors' : sanitize_title( wp_unslash( $_GET['view'] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			// Save settings if data has been posted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			if ( apply_filters( '' !== $current_section ? "alnp_save_settings_{$current_view}_{$current_section}" : "alnp_save_settings_{$current_view}", ! empty( $_POST ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 				ALNP_Admin_Settings::save(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 			// Add any posted messages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 			if ( ! empty( $_GET['auto_load_next_post_error'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				ALNP_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_error'] ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 			if ( ! empty( $_GET['auto_load_next_post_message'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 				ALNP_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['auto_load_next_post_message'] ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 			do_action( 'auto_load_next_post_settings_page_init' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		} // END settings_page_init() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		 * Initialize the Auto Load Next Post settings page. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 		 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 		 * @since  1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		public function settings_page() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 			include_once( dirname( __FILE__ ) . '/class-alnp-admin-settings.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 			ALNP_Admin_Settings::output(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		} // END settings_page() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	} // END class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | } // END if class exists | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 164 |  |  | return new ALNP_Admin(); | 
            
                                                        
            
                                    
            
            
                | 165 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.