Conditions | 1 |
Paths | 1 |
Total Lines | 38 |
Code Lines | 17 |
Lines | 38 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
7 | View Code Duplication | function example_my_user_starter( $wp_fields ) { |
|
|
|||
8 | |||
9 | // Object type: User |
||
10 | $object_type = 'user'; |
||
11 | |||
12 | // Object name: n/a |
||
13 | $object_name = null; |
||
14 | |||
15 | // Form: User Edit Profile |
||
16 | $form_id = 'user-edit'; |
||
17 | |||
18 | ///////////////////////// |
||
19 | // Section: My Section // |
||
20 | ///////////////////////// |
||
21 | |||
22 | $section_id = ''; // @todo Fill in section ID |
||
23 | $section_args = array( |
||
24 | 'title' => __( '', 'my-text-domain' ), // @todo Fill in section heading, update text domain |
||
25 | 'form' => $form_id, |
||
26 | ); |
||
27 | |||
28 | $wp_fields->add_section( $object_type, $section_id, $object_name, $section_args ); |
||
29 | |||
30 | // My Field |
||
31 | $field_id = ''; |
||
32 | $field_args = array( |
||
33 | // You can register a control for this field at the same time |
||
34 | 'control' => array( |
||
35 | 'type' => 'text', // @todo Change control type if needed |
||
36 | 'section' => $section_id, |
||
37 | 'label' => __( '', 'my-text-domain' ), // @todo Fill in label, update text domain |
||
38 | 'description' => __( '', 'my-text-domain' ), // @todo Fill in description, update text domain |
||
39 | ), |
||
40 | ); |
||
41 | |||
42 | $wp_fields->add_field( $object_type, $field_id, $object_name, $field_args ); |
||
43 | |||
44 | } |
||
45 | |||
46 | add_action( 'fields_register', 'example_my_user_starter' ); |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.