| Conditions | 12 |
| Paths | 32 |
| Total Lines | 81 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 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 |
||
| 181 | public function get_fields( $cmb, $section, $args ) { |
||
| 182 | $cmb->add_field( |
||
| 183 | array( |
||
| 184 | 'id' => 'settings_' . $section . '_sharing', |
||
| 185 | 'type' => 'title', |
||
| 186 | 'name' => $args['title'], |
||
| 187 | 'default' => $args['title'], |
||
| 188 | 'description' => $args['desc'], |
||
| 189 | ) |
||
| 190 | ); |
||
| 191 | if ( 'global' === $section ) { |
||
| 192 | $cmb->add_field( |
||
| 193 | array( |
||
| 194 | 'name' => esc_html__('Disable all', 'lsx-sharing'), |
||
| 195 | 'id' => $section . '_disable_all', |
||
| 196 | 'description' => esc_html__('Disable all sharing buttons on the site', 'lsx-sharing'), |
||
| 197 | 'type' => 'checkbox', |
||
| 198 | ) |
||
| 199 | ); |
||
| 200 | } else { |
||
| 201 | $cmb->add_field( |
||
| 202 | array( |
||
| 203 | 'name' => esc_html__('Disable', 'lsx-sharing'), |
||
| 204 | 'id' => $section . '_disable_pt', |
||
| 205 | 'description' => esc_html__('Disable the share buttons on this post type', 'lsx-sharing'), |
||
| 206 | 'type' => 'checkbox', |
||
| 207 | ) |
||
| 208 | ); |
||
| 209 | } |
||
| 210 | |||
| 211 | if ( 'global' === $section ) { |
||
| 212 | $label_text_description = esc_html__( 'If no text is specified per post type this text will display.' , 'lsx-sharing' ); |
||
| 213 | } else { |
||
| 214 | $label_text_description = esc_html__( 'This text will display alongside the sharing buttons.', 'lsx-sharing' ); |
||
| 215 | } |
||
| 216 | |||
| 217 | $cmb->add_field( |
||
| 218 | array( |
||
| 219 | 'name' => esc_html__( 'Label text', 'lsx-sharing' ), |
||
| 220 | 'id' => $section . '_label_text', |
||
| 221 | 'type' => 'text', |
||
| 222 | 'description' => $label_text_description, |
||
| 223 | ) |
||
| 224 | ); |
||
| 225 | |||
| 226 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled('global', 'facebook') ) ) { |
||
| 227 | $cmb->add_field( |
||
| 228 | array( |
||
| 229 | 'name' => esc_html__('Disable Facebook', 'lsx-sharing'), |
||
| 230 | 'id' => $section . '_disable_facebook', |
||
| 231 | 'description' => esc_html__('Disable Facebook share button.', 'lsx-sharing'), |
||
| 232 | 'type' => 'checkbox', |
||
| 233 | ) |
||
| 234 | ); |
||
| 235 | } |
||
| 236 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled('global', 'twitter') ) ) { |
||
| 237 | $cmb->add_field( |
||
| 238 | array( |
||
| 239 | 'name' => esc_html__('Disable Twitter', 'lsx-sharing'), |
||
| 240 | 'id' => $section . '_disable_twitter', |
||
| 241 | 'description' => esc_html__('Disable Twitter share button.', 'lsx-sharing'), |
||
| 242 | 'type' => 'checkbox', |
||
| 243 | ) |
||
| 244 | ); |
||
| 245 | } |
||
| 246 | if ( 'global' === $section || ( 'global' !== $section && ! \lsx\sharing\includes\functions\is_button_disabled('global', 'pinterest') ) ) { |
||
| 247 | $cmb->add_field( |
||
| 248 | array( |
||
| 249 | 'name' => esc_html__('Disable Pinterest', 'lsx-sharing'), |
||
| 250 | 'id' => $section . '_disable_pinterest', |
||
| 251 | 'description' => esc_html__('Disable Pinterest button.', 'lsx-sharing'), |
||
| 252 | 'type' => 'checkbox', |
||
| 253 | ) |
||
| 254 | ); |
||
| 255 | } |
||
| 256 | |||
| 257 | do_action('lsx_sharing_settings_section', $cmb, $section); |
||
| 258 | $cmb->add_field( |
||
| 259 | array( |
||
| 260 | 'id' => $section . '_title_closing', |
||
| 261 | 'type' => 'tab_closing', |
||
| 262 | ) |
||
| 266 |