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