| Conditions | 4 |
| Paths | 8 |
| Total Lines | 190 |
| Code Lines | 139 |
| 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 |
||
| 183 | public function details_metaboxes() { |
||
| 184 | $cmb = new_cmb2_box( array( |
||
| 185 | 'id' => $this->slug . '_shopping_list_metabox', |
||
| 186 | 'title' => __( 'Shopping List', 'lsx-health-plan' ), |
||
| 187 | 'object_types' => array( $this->slug ), // Post type |
||
| 188 | 'context' => 'normal', |
||
| 189 | 'priority' => 'high', |
||
| 190 | 'show_names' => true, |
||
| 191 | ) ); |
||
| 192 | $cmb->add_field( array( |
||
| 193 | 'name' => __( 'Shopping List', 'lsx-health-plan' ), |
||
| 194 | 'desc' => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ), |
||
| 195 | 'id' => $this->slug . '_shopping_list', |
||
| 196 | 'type' => 'post_search_ajax', |
||
| 197 | // Optional : |
||
| 198 | 'limit' => 1, // Limit selection to X items only (default 1) |
||
| 199 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
| 200 | 'query_args' => array( |
||
| 201 | 'post_type' => array( 'page' ), |
||
| 202 | 'post_status' => array( 'publish' ), |
||
| 203 | 'posts_per_page' => -1, |
||
| 204 | ), |
||
| 205 | ) ); |
||
| 206 | $cmb = new_cmb2_box( array( |
||
| 207 | 'id' => $this->slug . '_details_metabox', |
||
| 208 | 'title' => __( 'Meal Details', 'lsx-health-plan' ), |
||
| 209 | 'object_types' => array( $this->slug ), // Post type |
||
| 210 | 'context' => 'normal', |
||
| 211 | 'priority' => 'high', |
||
| 212 | 'show_names' => true, |
||
| 213 | ) ); |
||
| 214 | |||
| 215 | $cmb->add_field( array( |
||
| 216 | 'name' => __( 'Meal Short Description', 'lsx-health-plan' ), |
||
| 217 | 'id' => $this->slug . '_short_description', |
||
| 218 | 'type' => 'textarea_small', |
||
| 219 | 'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ), |
||
| 220 | ) ); |
||
| 221 | |||
| 222 | $cmb->add_field( array( |
||
| 223 | 'name' => __( 'Pre Breakfast Snack', 'lsx-health-plan' ), |
||
| 224 | 'id' => $this->slug . '_pre_breakfast_snack', |
||
| 225 | 'type' => 'wysiwyg', |
||
| 226 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 227 | 'options' => array( |
||
| 228 | 'textarea_rows' => 5, |
||
| 229 | ), |
||
| 230 | ) ); |
||
| 231 | $cmb->add_field( array( |
||
| 232 | 'name' => __( 'Breakfast', 'lsx-health-plan' ), |
||
| 233 | 'id' => $this->slug . '_breakfast', |
||
| 234 | 'type' => 'wysiwyg', |
||
| 235 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 236 | 'options' => array( |
||
| 237 | 'textarea_rows' => 5, |
||
| 238 | ), |
||
| 239 | ) ); |
||
| 240 | |||
| 241 | $cmb->add_field( |
||
| 242 | array( |
||
| 243 | 'name' => __( 'Post Breakfast Snack', 'lsx-health-plan' ), |
||
| 244 | 'id' => $this->slug . '_breakfast_snack', |
||
| 245 | 'type' => 'wysiwyg', |
||
| 246 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 247 | 'options' => array( |
||
| 248 | 'textarea_rows' => 5, |
||
| 249 | ), |
||
| 250 | ) |
||
| 251 | ); |
||
| 252 | |||
| 253 | if ( post_type_exists( 'recipe' ) ) { |
||
| 254 | $cmb->add_field( |
||
| 255 | array( |
||
| 256 | 'name' => __( 'Breakfast Recipes', 'lsx-health-plan' ), |
||
| 257 | 'desc' => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ), |
||
| 258 | 'id' => 'breakfast_recipes', |
||
| 259 | 'type' => 'post_search_ajax', |
||
| 260 | // Optional : |
||
| 261 | 'limit' => 15, // Limit selection to X items only (default 1) |
||
| 262 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
| 263 | 'query_args' => array( |
||
| 264 | 'post_type' => array( 'recipe' ), |
||
| 265 | 'post_status' => array( 'publish' ), |
||
| 266 | 'posts_per_page' => -1, |
||
| 267 | ), |
||
| 268 | ) |
||
| 269 | ); |
||
| 270 | } |
||
| 271 | |||
| 272 | $cmb->add_field( |
||
| 273 | array( |
||
| 274 | 'name' => __( 'Pre Lunch Snack', 'lsx-health-plan' ), |
||
| 275 | 'id' => $this->slug . '_pre_lunch_snack', |
||
| 276 | 'type' => 'wysiwyg', |
||
| 277 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 278 | 'options' => array( |
||
| 279 | 'textarea_rows' => 5, |
||
| 280 | ), |
||
| 281 | ) |
||
| 282 | ); |
||
| 283 | $cmb->add_field( |
||
| 284 | array( |
||
| 285 | 'name' => __( 'Lunch', 'lsx-health-plan' ), |
||
| 286 | 'id' => $this->slug . '_lunch', |
||
| 287 | 'type' => 'wysiwyg', |
||
| 288 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 289 | 'options' => array( |
||
| 290 | 'textarea_rows' => 5, |
||
| 291 | ), |
||
| 292 | ) |
||
| 293 | ); |
||
| 294 | $cmb->add_field( |
||
| 295 | array( |
||
| 296 | 'name' => __( 'Post Lunch Snack', 'lsx-health-plan' ), |
||
| 297 | 'id' => $this->slug . '_lunch_snack', |
||
| 298 | 'type' => 'wysiwyg', |
||
| 299 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 300 | 'options' => array( |
||
| 301 | 'textarea_rows' => 5, |
||
| 302 | ), |
||
| 303 | ) |
||
| 304 | ); |
||
| 305 | |||
| 306 | if ( post_type_exists( 'recipe' ) ) { |
||
| 307 | $cmb->add_field( |
||
| 308 | array( |
||
| 309 | 'name' => __( 'Lunch Recipes', 'lsx-health-plan' ), |
||
| 310 | 'desc' => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ), |
||
| 311 | 'id' => 'lunch_recipes', |
||
| 312 | 'type' => 'post_search_ajax', |
||
| 313 | // Optional : |
||
| 314 | 'limit' => 15, // Limit selection to X items only (default 1) |
||
| 315 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
| 316 | 'query_args' => array( |
||
| 317 | 'post_type' => array( 'recipe' ), |
||
| 318 | 'post_status' => array( 'publish' ), |
||
| 319 | 'posts_per_page' => -1, |
||
| 320 | ), |
||
| 321 | ) |
||
| 322 | ); |
||
| 323 | } |
||
| 324 | |||
| 325 | $cmb->add_field( |
||
| 326 | array( |
||
| 327 | 'name' => __( 'Pre Dinner Snack', 'lsx-health-plan' ), |
||
| 328 | 'id' => $this->slug . '_pre_dinner_snack', |
||
| 329 | 'type' => 'wysiwyg', |
||
| 330 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 331 | 'options' => array( |
||
| 332 | 'textarea_rows' => 5, |
||
| 333 | ), |
||
| 334 | ) |
||
| 335 | ); |
||
| 336 | $cmb->add_field( |
||
| 337 | array( |
||
| 338 | 'name' => __( 'Dinner', 'lsx-health-plan' ), |
||
| 339 | 'id' => $this->slug . '_dinner', |
||
| 340 | 'type' => 'wysiwyg', |
||
| 341 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 342 | 'options' => array( |
||
| 343 | 'textarea_rows' => 5, |
||
| 344 | ), |
||
| 345 | ) |
||
| 346 | ); |
||
| 347 | $cmb->add_field( |
||
| 348 | array( |
||
| 349 | 'name' => __( 'Post Dinner Snack', 'lsx-health-plan' ), |
||
| 350 | 'id' => $this->slug . '_dinner_snack', |
||
| 351 | 'type' => 'wysiwyg', |
||
| 352 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
||
| 353 | 'options' => array( |
||
| 354 | 'textarea_rows' => 5, |
||
| 355 | ), |
||
| 356 | ) |
||
| 357 | ); |
||
| 358 | |||
| 359 | if ( post_type_exists( 'recipe' ) ) { |
||
| 360 | $cmb->add_field( |
||
| 361 | array( |
||
| 362 | 'name' => __( 'Dinner Recipes', 'lsx-health-plan' ), |
||
| 363 | 'desc' => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ), |
||
| 364 | 'id' => 'dinner_recipes', |
||
| 365 | 'type' => 'post_search_ajax', |
||
| 366 | // Optional : |
||
| 367 | 'limit' => 15, // Limit selection to X items only (default 1) |
||
| 368 | 'sortable' => true, // Allow selected items to be sortable (default false) |
||
| 369 | 'query_args' => array( |
||
| 370 | 'post_type' => array( 'recipe' ), |
||
| 371 | 'post_status' => array( 'publish' ), |
||
| 372 | 'posts_per_page' => -1, |
||
| 373 | ), |
||
| 379 |