| Conditions | 2 |
| Paths | 2 |
| Total Lines | 68 |
| Code Lines | 56 |
| 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 |
||
| 147 | function get_options( $wp_customize ) { |
||
| 148 | $transport = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh'; |
||
| 149 | return apply_filters( |
||
| 150 | 'jetpack_related_posts_customize_options', array( |
||
| 151 | 'show_headline' => array( |
||
| 152 | 'label' => esc_html__( 'Show a headline', 'jetpack' ), |
||
| 153 | 'description' => esc_html__( 'This helps to clearly separate the related posts from post content.', 'jetpack' ), |
||
| 154 | 'control_type' => 'checkbox', |
||
| 155 | 'default' => 1, |
||
| 156 | 'setting_type' => 'option', |
||
| 157 | 'transport' => $transport, |
||
| 158 | ), |
||
| 159 | 'headline' => array( |
||
| 160 | 'label' => '', |
||
| 161 | 'description' => esc_html__( 'Enter text to use as headline.', 'jetpack' ), |
||
| 162 | 'control_type' => 'text', |
||
| 163 | 'default' => esc_html__( 'Related', 'jetpack' ), |
||
| 164 | 'setting_type' => 'option', |
||
| 165 | 'transport' => $transport, |
||
| 166 | ), |
||
| 167 | 'show_thumbnails' => array( |
||
| 168 | 'label' => esc_html__( 'Show thumbnails', 'jetpack' ), |
||
| 169 | 'description' => esc_html__( 'Use a large and visually striking layout.', 'jetpack' ), |
||
| 170 | 'control_type' => 'checkbox', |
||
| 171 | 'default' => 1, |
||
| 172 | 'setting_type' => 'option', |
||
| 173 | 'transport' => $transport, |
||
| 174 | ), |
||
| 175 | 'show_date' => array( |
||
| 176 | 'label' => esc_html__( 'Show date', 'jetpack' ), |
||
| 177 | 'description' => esc_html__( 'Display date when entry was published.', 'jetpack' ), |
||
| 178 | 'control_type' => 'checkbox', |
||
| 179 | 'default' => 1, |
||
| 180 | 'setting_type' => 'option', |
||
| 181 | 'transport' => $transport, |
||
| 182 | ), |
||
| 183 | 'show_context' => array( |
||
| 184 | 'label' => esc_html__( 'Show context', 'jetpack' ), |
||
| 185 | 'description' => esc_html__( "Display entry's category or tag.", 'jetpack' ), |
||
| 186 | 'control_type' => 'checkbox', |
||
| 187 | 'default' => 1, |
||
| 188 | 'setting_type' => 'option', |
||
| 189 | 'transport' => $transport, |
||
| 190 | ), |
||
| 191 | 'layout' => array( |
||
| 192 | 'label' => esc_html__( 'Layout', 'jetpack' ), |
||
| 193 | 'description' => esc_html__( 'Arrange entries in different layouts.', 'jetpack' ), |
||
| 194 | 'control_type' => 'select', |
||
| 195 | 'choices' => array( |
||
| 196 | 'grid' => esc_html__( 'Grid', 'jetpack' ), |
||
| 197 | 'list' => esc_html__( 'List', 'jetpack' ), |
||
| 198 | ), |
||
| 199 | 'default' => 'grid', |
||
| 200 | 'setting_type' => 'option', |
||
| 201 | 'transport' => $transport, |
||
| 202 | ), |
||
| 203 | 'msg_go_to_single' => array( |
||
| 204 | 'description' => esc_html__( 'Please visit a single post view to reveal the customization options.', 'jetpack' ), |
||
| 205 | 'control_type' => 'message', |
||
| 206 | 'active_callback' => __CLASS__ . '::is_not_single', |
||
| 207 | ), |
||
| 208 | 'msg_example' => array( |
||
| 209 | 'description' => esc_html__( 'Please note that the related posts displayed now are only for previewing purposes.', 'jetpack' ), |
||
| 210 | 'control_type' => 'message', |
||
| 211 | ), |
||
| 212 | ) |
||
| 213 | ); |
||
| 214 | } |
||
| 215 | |||
| 245 | new Jetpack_Related_Posts_Customize; |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.