| Conditions | 9 | 
| Paths | 14 | 
| Total Lines | 79 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 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 | |||
| 198 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.