Conditions | 13 |
Paths | 55 |
Total Lines | 53 |
Lines | 9 |
Ratio | 16.98 % |
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 |
||
115 | public function add_notices() { |
||
116 | global $current_user; |
||
117 | |||
118 | $template = get_option( 'template' ); |
||
119 | |||
120 | // Checks if the theme supports Auto Load Next Post and not provided via a plugin. |
||
121 | if ( is_alnp_supported() ) { |
||
122 | $plugin_supported = alnp_get_theme_support( 'plugin_support' ); |
||
123 | |||
124 | // Return if theme is supported via plugin. |
||
125 | if ( ! empty( $plugin_supported ) && $plugin_supported == 'yes' ) { |
||
126 | update_option( 'auto_load_next_post_theme_supported', $template ); |
||
127 | return false; |
||
128 | } |
||
129 | |||
130 | // If supported theme does not match active theme then show notice. |
||
131 | if ( get_option( 'auto_load_next_post_theme_supported' ) !== $template ) { |
||
132 | add_action( 'admin_notices', array( $this, 'theme_ready_notice' ) ); |
||
133 | update_option( 'auto_load_next_post_theme_supported', $template ); |
||
134 | } |
||
135 | } |
||
136 | else { |
||
137 | // If theme not supported then delete option. |
||
138 | delete_option( 'auto_load_next_post_theme_supported' ); |
||
139 | } |
||
140 | |||
141 | // Is admin review notice hidden? |
||
142 | $hide_review_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_review_notice', true ); |
||
143 | |||
144 | // Check if we need to display the review plugin notice. |
||
145 | View Code Duplication | if ( current_user_can( 'install_plugins' ) && empty( $hide_review_notice ) ) { |
|
146 | // If it has been a week or more since activating the plugin then display the review notice. |
||
147 | if ( ( intval( time() - self::$install_date ) ) > WEEK_IN_SECONDS ) { |
||
148 | add_action( 'admin_notices', array( $this, 'plugin_review_notice' ) ); |
||
149 | } |
||
150 | } |
||
151 | |||
152 | // Is admin welcome notice hidden? |
||
153 | $hide_welcome_notice = get_user_meta( $current_user->ID, 'auto_load_next_post_hide_welcome_notice', true ); |
||
154 | |||
155 | // Check if we need to display the welcome notice. |
||
156 | if ( current_user_can( 'install_plugins' ) && empty( $hide_welcome_notice ) ) { |
||
157 | // If the user has just installed the plugin for the first time then welcome the user. |
||
158 | View Code Duplication | if ( ( intval( time() - strtotime( self::$install_date ) ) / WEEK_IN_SECONDS ) % 52 <= 2 ) { |
|
159 | add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); |
||
160 | } |
||
161 | } |
||
162 | |||
163 | // Is this version of Auto Load Next Post a beta release? |
||
164 | if ( is_alnp_beta() && empty( get_transient( 'alnp_beta_notice_hidden' ) ) ) { |
||
165 | add_action( 'admin_notices', array( $this, 'beta_notice' ) ); |
||
166 | } |
||
167 | } // END add_notices() |
||
168 | |||
227 |