Conditions | 1 |
Paths | 1 |
Total Lines | 94 |
Code Lines | 33 |
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 |
||
18 | function lighthouse_setup() { |
||
19 | // This theme styles the visual editor to resemble the theme style. |
||
20 | $font_url_Questrial = 'https://fonts.googleapis.com/css?family=Questrial'; |
||
21 | |||
22 | $font_url_Raleway = 'https://fonts.googleapis.com/css?family=Raleway:400,300,500,700,600,100'; |
||
23 | |||
24 | $font_url_Montserrat = 'https://fonts.googleapis.com/css?family=Montserrat:400,700'; |
||
25 | |||
26 | add_editor_style( |
||
27 | array( |
||
28 | 'style.css', str_replace( ',', '%2C', $font_url_Questrial), str_replace( ',', '%2C', $font_url_Raleway), str_replace( ',', '%2C', $font_url_Montserrat) |
||
29 | ) |
||
30 | ); |
||
31 | /* |
||
32 | * Make theme available for translation. |
||
33 | * Translations can be filed in the /languages/ directory. |
||
34 | * If you're building a theme based on Lighthouse, use a find and replace |
||
35 | * to change 'lighthouse' to the name of your theme in all the template files. |
||
36 | */ |
||
37 | load_theme_textdomain( 'lighthouse', get_template_directory() . '/languages' ); |
||
38 | |||
39 | // Add default posts and comments RSS feed links to head. |
||
40 | add_theme_support( 'automatic-feed-links' ); |
||
41 | |||
42 | /* |
||
43 | * Let WordPress manage the document title. |
||
44 | * By adding theme support, we declare that this theme does not use a |
||
45 | * hard-coded <title> tag in the document head, and expect WordPress to |
||
46 | * provide it for us. |
||
47 | */ |
||
48 | add_theme_support( 'title-tag' ); |
||
49 | |||
50 | /* |
||
51 | * Enable support for Post Thumbnails on posts and pages. |
||
52 | * |
||
53 | * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ |
||
54 | */ |
||
55 | add_theme_support( 'post-thumbnails' ); |
||
56 | |||
57 | add_image_size( 'lighthouse_feature_img', 1000, 310, array( 'center', 'center' ) ); |
||
58 | |||
59 | add_image_size( 'lighthouse_blog_listing', 714, 274, array( 'center', 'center' ) ); |
||
60 | |||
61 | add_image_size( 'lighthouse_related_post', 475, 280, array( 'center', 'center' ) ); |
||
62 | |||
63 | |||
64 | /* |
||
65 | * Enable support for Shortcode in text widget |
||
66 | * |
||
67 | */ |
||
68 | add_filter('widget_text', 'do_shortcode'); |
||
69 | |||
70 | /* |
||
71 | * Default HTML5 Form |
||
72 | * |
||
73 | * @link https://codex.wordpress.org/Function_Reference/get_search_form |
||
74 | */ |
||
75 | add_theme_support( 'html5', array( 'search-form' ) ); |
||
76 | |||
77 | // This theme uses wp_nav_menu() in one location. |
||
78 | register_nav_menus( array( |
||
79 | 'primary' => esc_html__( 'Primary', 'lighthouse' ), |
||
80 | ) ); |
||
81 | |||
82 | /* |
||
83 | * Switch default core markup for search form, comment form, and comments |
||
84 | * to output valid HTML5. |
||
85 | */ |
||
86 | add_theme_support( 'html5', array( |
||
87 | 'search-form', |
||
88 | 'comment-form', |
||
89 | 'comment-list', |
||
90 | 'gallery', |
||
91 | 'caption', |
||
92 | ) ); |
||
93 | |||
94 | /* |
||
95 | * Enable support for Post Formats. |
||
96 | * See https://developer.wordpress.org/themes/functionality/post-formats/ |
||
97 | */ |
||
98 | add_theme_support( 'post-formats', array( |
||
99 | 'aside', |
||
100 | 'image', |
||
101 | 'video', |
||
102 | 'quote', |
||
103 | 'link', |
||
104 | ) ); |
||
105 | |||
106 | // Set up the WordPress core custom background feature. |
||
107 | add_theme_support( 'custom-background', apply_filters( 'lighthouse_custom_background_args', array( |
||
108 | 'default-color' => 'ffffff', |
||
109 | 'default-image' => '', |
||
110 | ) ) ); |
||
111 | } |
||
112 | endif; |
||
212 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.