| Conditions | 2 |
| Paths | 2 |
| Total Lines | 80 |
| Code Lines | 61 |
| 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 Recipes', 'lsx-health-plan' ), |
||
| 56 | 'id' => 'recipe_disabled', |
||
| 57 | 'type' => 'checkbox', |
||
| 58 | 'value' => 1, |
||
| 59 | 'default' => 0, |
||
| 60 | 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
||
| 61 | ) |
||
| 62 | ); |
||
| 63 | |||
| 64 | $cmb->add_field( |
||
| 65 | array( |
||
| 66 | 'id' => 'recipe_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' => __( 'Recipes Intro', 'lsx-health-plan' ), |
||
| 79 | 'id' => 'recipes_intro', |
||
| 80 | 'type' => 'textarea_small', |
||
| 81 | 'value' => '', |
||
| 82 | 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", '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' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
||
| 90 | 'id' => 'endpoint_recipe', |
||
| 91 | 'type' => 'input', |
||
| 92 | 'value' => '', |
||
| 93 | 'default' => 'recipe', |
||
| 94 | ) |
||
| 95 | ); |
||
| 96 | |||
| 97 | $cmb->add_field( |
||
| 98 | array( |
||
| 99 | 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
||
| 100 | 'name' => __( 'Recipe', 'lsx-health-plan' ), |
||
| 101 | 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
||
| 102 | 'limit' => 1, |
||
| 103 | 'id' => 'connected_recipes', |
||
| 104 | 'type' => 'post_search_ajax', |
||
| 105 | 'query_args' => array( |
||
| 106 | 'post_type' => 'recipe', |
||
| 107 | 'post_status' => array( 'publish' ), |
||
| 108 | 'posts_per_page' => -1, |
||
| 109 | ), |
||
| 110 | ) |
||
| 111 | ); |
||
| 112 | if ( function_exists( 'download_monitor' ) ) { |
||
| 113 | $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
||
| 114 | $plugin_name = 'Download Monitor'; |
||
| 115 | $description = sprintf( |
||
| 116 | /* translators: %s: The subscription info */ |
||
| 117 | __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your recipe here.', 'lsx-search' ), |
||
| 118 | $page_url, |
||
| 119 | $plugin_name |
||
| 120 | ); |
||
| 121 | $cmb->add_field( |
||
| 122 | array( |
||
| 123 | 'name' => __( 'Default Recipe PDF', 'lsx-health-plan' ), |
||
| 124 | 'description' => $description, |
||
| 125 | 'id' => 'download_recipe', |
||
| 126 | 'type' => 'post_search_ajax', |
||
| 127 | 'limit' => 1, |
||
| 128 | 'query_args' => array( |
||
| 129 | 'post_type' => array( 'dlm_download' ), |
||
| 130 | 'post_status' => array( 'publish' ), |
||
| 131 | 'posts_per_page' => -1, |
||
| 132 | ), |
||
| 139 |