| Conditions | 22 | 
| Paths | 6 | 
| Total Lines | 88 | 
| Code Lines | 66 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| 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 | ||
| 92 | 	public function configure_archive_fields( $cmb ) { | ||
| 93 | $archives = array(); | ||
| 94 | $post_type_args = array( | ||
| 95 | 'public' => true, | ||
| 96 | ); | ||
| 97 | $post_types = get_post_types( $post_type_args ); | ||
| 98 | 		if ( ! empty( $post_types ) ) { | ||
| 99 | 			foreach ( $post_types as $post_type_key => $post_type_value ) { | ||
| 100 | 				switch ( $post_type_key ) { | ||
| 101 | case 'post': | ||
| 102 | $page_url = home_url(); | ||
| 103 | $page_title = __( 'Home', 'lsx-search' ); | ||
| 104 | $show_on_front = get_option( 'show_on_front' ); | ||
| 105 | 						if ( 'page' === $show_on_front ) { | ||
| 106 | $page_for_posts = get_option( 'page_for_posts' ); | ||
| 107 | 							if ( '' !== $page_for_posts ) { | ||
| 108 | $page_title = get_the_title( $page_for_posts ); | ||
| 109 | $page_url = get_permalink( $page_for_posts ); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | $description = sprintf( | ||
| 113 | /* translators: %s: The subscription info */ | ||
| 114 | __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> posts.', 'lsx-search' ), | ||
| 115 | $page_url, | ||
| 116 | $page_title | ||
| 117 | ); | ||
| 118 | $archives[ $post_type_key ] = array( | ||
| 119 | 'title' => __( 'Blog', 'lsx-search' ), | ||
| 120 | 'desc' => $description, | ||
| 121 | ); | ||
| 122 | break; | ||
| 123 | |||
| 124 | case 'product': | ||
| 125 | $page_url = home_url(); | ||
| 126 | $page_title = __( 'Shop', 'lsx-search' ); | ||
| 127 | 						if ( function_exists( 'wc_get_page_id' ) ) { | ||
| 128 | $shop_page = wc_get_page_id( 'shop' ); | ||
| 129 | $page_url = get_permalink( $shop_page ); | ||
| 130 | $page_title = get_the_title( $shop_page ); | ||
| 131 | } | ||
| 132 | $description = sprintf( | ||
| 133 | /* translators: %s: The subscription info */ | ||
| 134 | __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> product pages.', 'lsx-search' ), | ||
| 135 | $page_url, | ||
| 136 | $page_title | ||
| 137 | ); | ||
| 138 | $archives[ $post_type_key ] = array( | ||
| 139 | 'title' => __( 'Shop', 'lsx-search' ), | ||
| 140 | 'desc' => $description, | ||
| 141 | ); | ||
| 142 | break; | ||
| 143 | |||
| 144 | case 'page': | ||
| 145 | case 'attachment': | ||
| 146 | case 'forum': | ||
| 147 | case 'topic': | ||
| 148 | case 'lesson': | ||
| 149 | case 'quizz': | ||
| 150 | case 'reply': | ||
| 151 | case 'popup': | ||
| 152 | case 'message': | ||
| 153 | case 'envira': | ||
| 154 | case 'soliloquy': | ||
| 155 | break; | ||
| 156 | |||
| 157 | default: | ||
| 158 | $temp_post_type = get_post_type_object( $post_type_key ); | ||
| 159 | 						if ( ! is_wp_error( $temp_post_type ) ) { | ||
| 160 | $page_url = get_post_type_archive_link( $temp_post_type->name ); | ||
| 161 | $description = sprintf( | ||
| 162 | /* translators: %s: The subscription info */ | ||
| 163 | __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> singles.', 'lsx-search' ), | ||
| 164 | $page_url, | ||
| 165 | $temp_post_type->label | ||
| 166 | ); | ||
| 167 | |||
| 168 | $archives[ $post_type_key ] = array( | ||
| 169 | 'title' => $temp_post_type->label, | ||
| 170 | 'desc' => $description, | ||
| 171 | ); | ||
| 172 | } | ||
| 173 | break; | ||
| 174 | } | ||
| 175 | } | ||
| 176 | } | ||
| 177 | 		if ( ! empty( $archives ) ) { | ||
| 178 | 			foreach ( $archives as $archive_key => $archive_args ) { | ||
| 179 | $this->get_fields( $cmb, $archive_key, $archive_args ); | ||
| 180 | } | ||
| 270 |