Conditions | 17 |
Paths | 171 |
Total Lines | 72 |
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 |
||
131 | public function add_notices() { |
||
132 | global $current_user; |
||
133 | |||
134 | // If the current user can not install plugins then return nothing! |
||
135 | if ( ! current_user_can( 'install_plugins' ) ) { |
||
136 | return false; |
||
137 | } |
||
138 | |||
139 | $screen = get_current_screen(); |
||
140 | $screen_id = $screen ? $screen->id : ''; |
||
141 | |||
142 | // Notices should only show on the main dashboard and on the plugins screen. |
||
143 | if ( ! in_array( $screen_id, alnp_get_admin_screens() ) ) { |
||
144 | return false; |
||
145 | } |
||
146 | |||
147 | // Is admin review notice hidden? |
||
148 | $hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true ); |
||
149 | |||
150 | // Check if we need to display the review plugin notice. |
||
151 | if ( empty( $hide_review_notice ) ) { |
||
152 | // If it has been a week or more since activating the plugin then display the review notice. |
||
153 | if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) { |
||
154 | add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) ); |
||
155 | } |
||
156 | } |
||
157 | |||
158 | // Is admin setup wizard notice hidden? |
||
159 | $hide_setup_wizard_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_setup_notice', true ); |
||
160 | |||
161 | // Check if we need to show setup wizard notice. |
||
162 | if ( empty( $hide_setup_wizard_notice ) && ! is_alnp_supported() ) { |
||
163 | // Notify users of the Setup Wizard. |
||
164 | add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) ); |
||
165 | } |
||
166 | |||
167 | // Is this version of Auto Load Next Post a beta/pre-release? |
||
168 | if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) { |
||
169 | add_action( 'admin_notices', array( $this, 'beta_notice' ) ); |
||
170 | } |
||
171 | |||
172 | $template = get_option( 'template' ); |
||
173 | |||
174 | // Checks if the theme supports Auto Load Next Post and not provided via a plugin. |
||
175 | if ( is_alnp_supported() ) { |
||
176 | $plugin_supported = alnp_get_theme_support( 'plugin_support' ); |
||
177 | |||
178 | // Return if theme is supported via plugin. |
||
179 | if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) { |
||
180 | update_option( 'auto_load_next_post_theme_supported', $template ); |
||
181 | return false; |
||
182 | } |
||
183 | |||
184 | // If supported theme does not match active theme then show notice. |
||
185 | if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) { |
||
186 | add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) ); |
||
187 | update_option( 'auto_load_next_post_theme_supported', $template ); |
||
188 | } |
||
189 | } else { |
||
190 | // If theme not supported then delete option. |
||
191 | delete_option( 'auto_load_next_post_theme_supported' ); |
||
192 | } |
||
193 | |||
194 | // Upgrade warning notice that will disappear once the new release is installed. |
||
195 | $upgrade_version = '1.6.0'; |
||
196 | |||
197 | $user_hidden_upgrade = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_upgrade_notice', '1' ); |
||
198 | |||
199 | if ( ! is_alnp_beta() && version_compare( AUTO_LOAD_NEXT_POST_VERSION, $upgrade_version, '<' ) && empty( $user_hidden_upgrade ) ) { |
||
200 | add_action( 'admin_notices', array( $this, 'upgrade_warning' ) ); |
||
201 | } |
||
202 | } // END add_notices() |
||
203 | |||
274 |