Conditions | 2 |
Paths | 2 |
Total Lines | 98 |
Code Lines | 75 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
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 |
||
52 | public function settings( $cmb ) { |
||
53 | $cmb->add_field( |
||
54 | array( |
||
55 | 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
||
56 | 'id' => 'meal_disabled', |
||
57 | 'type' => 'checkbox', |
||
58 | 'value' => 1, |
||
59 | 'default' => 0, |
||
60 | 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
||
61 | ) |
||
62 | ); |
||
63 | |||
64 | $cmb->add_field( |
||
65 | array( |
||
66 | 'id' => 'meal_archive_description', |
||
67 | 'type' => 'wysiwyg', |
||
68 | 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
||
69 | 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
||
70 | 'options' => array( |
||
71 | 'textarea_rows' => get_option('default_post_edit_rows', 6), |
||
72 | ), |
||
73 | ) |
||
74 | ); |
||
75 | |||
76 | $cmb->add_field( |
||
77 | array( |
||
78 | 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
||
79 | 'id' => 'meal_plan_intro', |
||
80 | 'type' => 'textarea_small', |
||
81 | 'value' => '', |
||
82 | 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
||
83 | ) |
||
84 | ); |
||
85 | |||
86 | $cmb->add_field( |
||
87 | array( |
||
88 | 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
||
89 | 'name' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
||
90 | 'id' => 'endpoint_meal', |
||
91 | 'type' => 'input', |
||
92 | 'value' => '', |
||
93 | 'default' => 'meal', |
||
94 | ) |
||
95 | ); |
||
96 | $cmb->add_field( |
||
97 | array( |
||
98 | 'name' => __( 'Meals Archive Endpoint', 'lsx-health-plan' ), |
||
99 | 'id' => 'endpoint_meal_archive', |
||
100 | 'type' => 'input', |
||
101 | 'value' => '', |
||
102 | 'default' => 'meals', |
||
103 | ) |
||
104 | ); |
||
105 | $cmb->add_field( |
||
106 | array( |
||
107 | 'name' => __( 'Single Meal Slu', 'lsx-health-plan' ), |
||
108 | 'id' => 'meal_single_slug', |
||
109 | 'type' => 'input', |
||
110 | 'value' => '', |
||
111 | 'default' => 'meal', |
||
112 | ) |
||
113 | ); |
||
114 | |||
115 | $cmb->add_field( |
||
116 | array( |
||
117 | 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
||
118 | 'name' => __( 'Default Meal Plan', 'lsx-health-plan' ), |
||
119 | 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
||
120 | 'limit' => 1, |
||
121 | 'id' => 'connected_meals', |
||
122 | 'type' => 'post_search_ajax', |
||
123 | 'query_args' => array( |
||
124 | 'post_type' => 'meal', |
||
125 | 'post_status' => array( 'publish' ), |
||
126 | 'posts_per_page' => -1, |
||
127 | ), |
||
128 | ) |
||
129 | ); |
||
130 | if ( function_exists( 'download_monitor' ) ) { |
||
131 | $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
||
132 | $plugin_name = 'Download Monitor'; |
||
133 | $description = sprintf( |
||
134 | /* translators: %s: The subscription info */ |
||
135 | __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
||
136 | $page_url, |
||
137 | $plugin_name |
||
138 | ); |
||
139 | $cmb->add_field( |
||
140 | array( |
||
141 | 'name' => __( 'Default Meal Plan PDF', 'lsx-health-plan' ), |
||
142 | 'description' => $description, |
||
143 | 'id' => 'download_meal', |
||
144 | 'type' => 'post_search_ajax', |
||
145 | 'limit' => 1, |
||
146 | 'query_args' => array( |
||
147 | 'post_type' => array( 'dlm_download' ), |
||
148 | 'post_status' => array( 'publish' ), |
||
149 | 'posts_per_page' => -1, |
||
150 | ), |
||
158 |