Conditions | 2 |
Paths | 2 |
Total Lines | 121 |
Code Lines | 94 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
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 |
||
10 | public function options(): array |
||
11 | { |
||
12 | $options = [ |
||
13 | 'glsr_group_limit' => [ |
||
14 | 'type' => 'group', |
||
15 | 'heading' => esc_html_x('Limit Reviews By', 'admin-text', 'site-reviews'), |
||
16 | 'options' => [ |
||
17 | 'assigned_posts' => [ |
||
18 | 'type' => 'select', |
||
19 | 'heading' => esc_html_x('Limit Reviews by Assigned Pages', 'admin-text', 'site-reviews'), |
||
20 | 'full_width' => true, |
||
21 | 'config' => [ |
||
22 | 'multiple' => true, |
||
23 | 'placeholder' => esc_html_x('Select a Page...', 'admin-text', 'site-reviews'), |
||
24 | 'postSelect' => 'assigned_posts_query', |
||
25 | ], |
||
26 | ], |
||
27 | 'assigned_terms' => [ |
||
28 | 'type' => 'select', |
||
29 | 'heading' => esc_html_x('Limit Reviews by Categories', 'admin-text', 'site-reviews'), |
||
30 | 'default' => '', |
||
31 | 'full_width' => true, |
||
32 | 'config' => [ |
||
33 | 'multiple' => true, |
||
34 | 'placeholder' => esc_html_x('Select a Category...', 'admin-text', 'site-reviews'), |
||
35 | 'termSelect' => [ |
||
36 | 'taxonomies' => glsr()->taxonomy, |
||
37 | ], |
||
38 | ], |
||
39 | ], |
||
40 | 'assigned_users' => [ |
||
41 | 'type' => 'select', |
||
42 | 'heading' => esc_html_x('Limit Reviews by Assigned Users', 'admin-text', 'site-reviews'), |
||
43 | 'default' => '', |
||
44 | 'full_width' => true, |
||
45 | 'config' => [ |
||
46 | 'multiple' => true, |
||
47 | 'placeholder' => esc_html_x('Select a User...', 'admin-text', 'site-reviews'), |
||
48 | 'postSelect' => 'assigned_users_query', |
||
49 | ], |
||
50 | ], |
||
51 | 'terms' => [ |
||
52 | 'type' => 'select', |
||
53 | 'heading' => esc_html_x('Limit Reviews by terms accepted', 'admin-text', 'site-reviews'), |
||
54 | 'default' => '', |
||
55 | 'full_width' => true, |
||
56 | 'options' => [ |
||
57 | '' => esc_html_x('Select Terms...', 'admin-text', 'site-reviews'), |
||
58 | 'true' => esc_html_x('Terms were accepted', 'admin-text', 'site-reviews'), |
||
59 | 'false' => esc_html_x('Terms were not accepted', 'admin-text', 'site-reviews'), |
||
60 | ], |
||
61 | ], |
||
62 | ], |
||
63 | ], |
||
64 | 'glsr_group_display' => [ |
||
65 | 'type' => 'group', |
||
66 | 'heading' => esc_html_x('Display Options', 'admin-text', 'site-reviews'), |
||
67 | 'options' => [ |
||
68 | 'rating' => [ |
||
69 | 'type' => 'slider', |
||
70 | 'heading' => esc_html_x('Minimum Rating', 'admin-text', 'site-reviews'), |
||
71 | 'default' => max(1, Rating::min()), |
||
72 | 'max' => Rating::max(), |
||
73 | 'min' => max(1, Rating::min()), |
||
74 | 'full_width' => true, |
||
75 | ], |
||
76 | 'schema' => [ |
||
77 | 'type' => 'radio-buttons', |
||
78 | 'heading' => esc_html_x('Enable the schema?', 'admin-text', 'site-reviews'), |
||
79 | 'description' => esc_html_x('The schema should only be enabled once on your page.', 'admin-text', 'site-reviews'), |
||
80 | 'default' => '', |
||
81 | 'full_width' => true, |
||
82 | 'options' => [ |
||
83 | '' => ['title' => _x('No', 'admin-text', 'site-reviews')], |
||
84 | 'true' => ['title' => _x('Yes', 'admin-text', 'site-reviews')], |
||
85 | ], |
||
86 | ], |
||
87 | ], |
||
88 | ], |
||
89 | 'glsr_group_hide' => [ |
||
90 | 'type' => 'group', |
||
91 | 'heading' => esc_html_x('Hide Options', 'admin-text', 'site-reviews'), |
||
92 | 'options' => $this->hideOptions(), |
||
93 | ], |
||
94 | 'glsr_group_advanced' => [ |
||
95 | 'type' => 'group', |
||
96 | 'heading' => esc_html_x('Advanced', 'admin-text', 'site-reviews'), |
||
97 | 'options' => [ |
||
98 | 'id' => [ |
||
99 | 'type' => 'textfield', |
||
100 | 'heading' => esc_html_x('Custom ID', 'admin-text', 'site-reviews'), |
||
101 | 'description' => esc_html_x('This should be a unique value.', 'admin-text', 'site-reviews'), |
||
102 | 'full_width' => true, |
||
103 | ], |
||
104 | 'class' => [ |
||
105 | 'type' => 'textfield', |
||
106 | 'heading' => esc_html_x('Additional CSS classes', 'admin-text', 'site-reviews'), |
||
107 | 'description' => esc_html_x('Separate multiple classes with spaces.', 'admin-text', 'site-reviews'), |
||
108 | 'full_width' => true, |
||
109 | ], |
||
110 | 'visibility' => [ |
||
111 | 'type' => 'select', |
||
112 | 'heading' => esc_html_x('Visibility', 'admin-text', 'site-reviews'), |
||
113 | 'default' => '', |
||
114 | 'options' => [ |
||
115 | '' => esc_html_x('Visible', 'admin-text', 'site-reviews'), |
||
116 | 'hidden' => esc_html_x('Hidden', 'admin-text', 'site-reviews'), |
||
117 | 'hide-for-medium' => esc_html_x('Only for Desktop', 'admin-text', 'site-reviews'), |
||
118 | 'show-for-small' => esc_html_x('Only for Mobile', 'admin-text', 'site-reviews'), |
||
119 | 'show-for-medium hide-for-small' => esc_html_x('Only for Tablet', 'admin-text', 'site-reviews'), |
||
120 | 'show-for-medium' => esc_html_x('Hide for Desktop', 'admin-text', 'site-reviews'), |
||
121 | 'hide-for-small' => esc_html_x('Hide for Mobile', 'admin-text', 'site-reviews'), |
||
122 | ], |
||
123 | ], |
||
124 | ], |
||
125 | ], |
||
126 | ]; |
||
127 | if ($types = $this->typeOptions()) { |
||
128 | $options['glsr_group_limit']['options']['type'] = $types; |
||
129 | } |
||
130 | return $options; |
||
131 | } |
||
143 |