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 |
||
| 7 | class Jetpack_Sync_Functions { |
||
| 8 | |||
| 9 | public static function get_modules() { |
||
| 10 | require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php' ); |
||
| 11 | return Jetpack_Admin::init()->get_modules(); |
||
| 12 | } |
||
| 13 | |||
| 14 | public static function get_taxonomies() { |
||
| 15 | global $wp_taxonomies; |
||
| 16 | |||
| 17 | return $wp_taxonomies; |
||
| 18 | } |
||
| 19 | |||
| 20 | public static function get_post_types() { |
||
| 25 | |||
| 26 | public static function rest_api_allowed_post_types() { |
||
| 27 | /** This filter is already documented in class.json-api-endpoints.php */ |
||
| 28 | return apply_filters( 'rest_api_allowed_post_types', array( 'post', 'page', 'revision' ) ); |
||
| 29 | } |
||
| 30 | |||
| 31 | public static function rest_api_allowed_public_metadata() { |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Finds out if a site is using a version control system. |
||
| 38 | * @return bool |
||
| 39 | **/ |
||
| 40 | public static function is_version_controlled() { |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Returns true if the site has file write access false otherwise. |
||
| 51 | * @return bool |
||
| 52 | **/ |
||
| 53 | public static function file_system_write_access() { |
||
| 74 | |||
| 75 | public static function home_url() { |
||
| 78 | |||
| 79 | public static function site_url() { |
||
| 82 | |||
| 83 | public static function main_network_site_url() { |
||
| 86 | |||
| 87 | public static function preserve_scheme( $option, $url, $normalize_www = false ) { |
||
| 125 | |||
| 126 | public static function get_plugins() { |
||
| 133 | |||
| 134 | public static function wp_version() { |
||
| 138 | } |
||
| 139 |