Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
20 | class Auto_Load_Next_Post_Install { |
||
21 | |||
22 | /** |
||
23 | * Plugin version. |
||
24 | * |
||
25 | * @access private |
||
26 | * @static |
||
27 | * @since 1.4.10 |
||
28 | * @var string |
||
29 | */ |
||
30 | private static $current_version; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @since 1.0.0 |
||
36 | * @access public |
||
37 | */ |
||
38 | public function __construct() { |
||
51 | |||
52 | /** |
||
53 | * Check plugin version and run the updater if necessary. |
||
54 | * |
||
55 | * This check is done on all requests and runs if the versions do not match. |
||
56 | * |
||
57 | * @access public |
||
58 | * @static |
||
59 | * @since 1.4.10 |
||
60 | * @version 1.5.11 |
||
61 | */ |
||
62 | public static function check_version() { |
||
68 | |||
69 | /** |
||
70 | * Install Auto Load Next Post. |
||
71 | * |
||
72 | * @access public |
||
73 | * @static |
||
74 | * @since 1.0.0 |
||
75 | * @version 1.5.0 |
||
76 | */ |
||
77 | public static function install() { |
||
115 | |||
116 | /** |
||
117 | * Set theme selectors for the current active theme should it |
||
118 | * support Auto Load Next Post and have the theme selectors set. |
||
119 | * |
||
120 | * @access private |
||
121 | * @static |
||
122 | * @since 1.5.0 |
||
123 | */ |
||
124 | private static function set_theme_selectors() { |
||
137 | |||
138 | /** |
||
139 | * Sets Auto Load Next Post to load in the footer if the |
||
140 | * current active theme requires it and lock it so the |
||
141 | * user can not disable it should the theme not work any other way. |
||
142 | * |
||
143 | * @access private |
||
144 | * @static |
||
145 | * @since 1.5.0 |
||
146 | * @version 1.5.3 |
||
147 | */ |
||
148 | private static function set_js_in_footer() { |
||
157 | |||
158 | /** |
||
159 | * Update plugin version to current. |
||
160 | * |
||
161 | * @access private |
||
162 | * @static |
||
163 | */ |
||
164 | private static function update_version() { |
||
167 | |||
168 | /** |
||
169 | * Set the time the plugin was installed. |
||
170 | * |
||
171 | * @access public |
||
172 | * @static |
||
173 | * @since 1.4.4 |
||
174 | * @version 1.5.0 |
||
175 | */ |
||
176 | public static function set_install_date() { |
||
186 | |||
187 | /** |
||
188 | * Default Options |
||
189 | * |
||
190 | * Sets up the default options defined on the settings pages. |
||
191 | * |
||
192 | * @access public |
||
193 | * @static |
||
194 | * @since 1.0.0 |
||
195 | * @version 1.5.1 |
||
196 | */ |
||
197 | public static function create_options() { |
||
212 | |||
213 | /** |
||
214 | * Add rewrite endpoint for Auto Load Next Post. |
||
215 | * |
||
216 | * @access public |
||
217 | * @static |
||
218 | * @since 1.0.0 |
||
219 | * @version 1.5.0 |
||
220 | */ |
||
221 | public static function add_rewrite_endpoint() { |
||
224 | |||
225 | /** |
||
226 | * Flush rewrite rules. |
||
227 | * |
||
228 | * @access public |
||
229 | * @static |
||
230 | * @since 1.5.0 |
||
231 | */ |
||
232 | public static function flush_rewrite_rules() { |
||
235 | |||
236 | /** |
||
237 | * Resets all Auto Load Next Post settings. |
||
238 | * |
||
239 | * @access public |
||
240 | * @static |
||
241 | * @since 1.5.11 |
||
242 | * @global object $wpdb |
||
243 | */ |
||
244 | public static function reset_alnp() { |
||
280 | |||
281 | } // END class. |
||
282 | |||
286 |