| Conditions | 13 |
| Paths | 48 |
| Total Lines | 192 |
| Code Lines | 137 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 10 | ||
| 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 |
||
| 283 | public function search_fields( $cmb, $section, $args ) { |
||
| 284 | $this->set_facetwp_vars(); |
||
| 285 | $cmb->add_field( |
||
| 286 | array( |
||
| 287 | 'id' => 'settings_' . $section . '_search', |
||
| 288 | 'type' => 'title', |
||
| 289 | 'name' => $args['title'], |
||
| 290 | 'default' => $args['title'], |
||
| 291 | 'description' => $args['desc'], |
||
| 292 | ) |
||
| 293 | ); |
||
| 294 | do_action( 'lsx_search_settings_section', $cmb, 'top' ); |
||
| 295 | $cmb->add_field( |
||
| 296 | array( |
||
| 297 | 'name' => esc_html__( 'Enable Search Filters', 'lsx-search' ), |
||
| 298 | 'id' => $section . '_search_enable', |
||
| 299 | 'description' => esc_html__( 'Display FacetWP filters on your search results page.', 'lsx-search' ), |
||
| 300 | 'type' => 'checkbox', |
||
| 301 | ) |
||
| 302 | ); |
||
| 303 | |||
| 304 | $cmb->add_field( |
||
| 305 | array( |
||
| 306 | 'name' => esc_html__( 'Page Layout', 'lsx-search' ), |
||
| 307 | 'id' => $section . '_search_layout', |
||
| 308 | 'type' => 'select', |
||
| 309 | 'options' => array( |
||
| 310 | '' => esc_html__( 'Follow the theme layout', 'lsx-search' ), |
||
| 311 | '2cr' => esc_html__( 'Sidebar on left', 'lsx-search' ), |
||
| 312 | '2cl' => esc_html__( 'Sidebar on right', 'lsx-search' ), |
||
| 313 | ), |
||
| 314 | 'default' => '', |
||
| 315 | ) |
||
| 316 | ); |
||
| 317 | |||
| 318 | if ( 'product' === $section ) { |
||
| 319 | $cmb->add_field( |
||
| 320 | array( |
||
| 321 | 'name' => esc_html__( 'Results Layout', 'lsx-search' ), |
||
| 322 | 'id' => $section . '_search_grid_list', |
||
| 323 | 'type' => 'select', |
||
| 324 | 'show_option_none' => false, |
||
| 325 | 'description' => __( 'Set a default layout for the search results.', 'lsx-search' ), |
||
| 326 | 'options' => array( |
||
| 327 | 'grid' => esc_html__( 'Grid', 'lsx-search' ), |
||
| 328 | 'list' => esc_html__( 'List', 'lsx-search' ), |
||
| 329 | ), |
||
| 330 | 'default' => 'grid', |
||
| 331 | ) |
||
| 332 | ); |
||
| 333 | $cmb->add_field( |
||
| 334 | array( |
||
| 335 | 'name' => esc_html__( 'Layout Switcher', 'lsx-search' ), |
||
| 336 | 'id' => $section . '_search_layout_switcher_enable', |
||
| 337 | 'type' => 'checkbox', |
||
| 338 | 'description' => __( 'Display the layout switcher to allow the user to toggle between the list and grid layouts.', 'lsx-search' ), |
||
| 339 | ) |
||
| 340 | ); |
||
| 341 | } |
||
| 342 | if ( 'engine' === $section && function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) ) { |
||
| 343 | $cmb->add_field( |
||
| 344 | array( |
||
| 345 | 'name' => esc_html__( 'List layout images', 'lsx-search' ), |
||
| 346 | 'id' => $section . '_search_list_layout_image_style', |
||
| 347 | 'type' => 'select', |
||
| 348 | 'options' => array( |
||
| 349 | '' => esc_html__( 'Full Height', 'lsx-search' ), |
||
| 350 | 'max-height' => esc_html__( 'Max Height', 'lsx-search' ), |
||
| 351 | ), |
||
| 352 | 'default' => '', |
||
| 353 | ) |
||
| 354 | ); |
||
| 355 | } |
||
| 356 | if ( 'engine' === $section ) { |
||
| 357 | $cmb->add_field( |
||
| 358 | array( |
||
| 359 | 'name' => esc_html__( 'Display Excerpt', 'lsx-search' ), |
||
| 360 | 'id' => $section . '_excerpt_enable', |
||
| 361 | 'type' => 'checkbox', |
||
| 362 | 'description' => __( 'Display the excerpt of a listing.', 'lsx-search' ), |
||
| 363 | ) |
||
| 364 | ); |
||
| 365 | $cmb->add_field( |
||
| 366 | array( |
||
| 367 | 'name' => esc_html__( 'Enable Post Type Label', 'lsx-search' ), |
||
| 368 | 'id' => $section . '_search_enable_pt_label', |
||
| 369 | 'type' => 'checkbox', |
||
| 370 | 'description' => __( 'This enables the post type label from entries on search results page.', 'lsx-search' ), |
||
| 371 | ) |
||
| 372 | ); |
||
| 373 | if ( function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) ) { |
||
| 374 | $cmb->add_field( |
||
| 375 | array( |
||
| 376 | 'name' => esc_html__( 'Enable Continent Filter', 'lsx-search' ), |
||
| 377 | 'id' => $section . '_search_enable_continent_filter', |
||
| 378 | 'type' => 'checkbox', |
||
| 379 | 'description' => __( 'This enables the continent filter in FacetWP destinations filter.', 'lsx-search' ), |
||
| 380 | ) |
||
| 381 | ); |
||
| 382 | $cmb->add_field( |
||
| 383 | array( |
||
| 384 | 'name' => esc_html__( 'Enable Continental Regions', 'lsx-search' ), |
||
| 385 | 'id' => $section . '_search_enable_continental_regions', |
||
| 386 | 'type' => 'checkbox', |
||
| 387 | 'description' => __( 'This disable continents and enabled the sub regions.', 'lsx-search' ), |
||
| 388 | ) |
||
| 389 | ); |
||
| 390 | } |
||
| 391 | } |
||
| 392 | |||
| 393 | if ( function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) && 'accommodation' === $section ) { |
||
| 394 | $cmb->add_field( |
||
| 395 | array( |
||
| 396 | 'name' => esc_html__( 'Results Layout - list vs map', 'lsx-search' ), |
||
| 397 | 'id' => $section . '_search_results_layout', |
||
| 398 | 'type' => 'select', |
||
| 399 | 'options' => array( |
||
| 400 | 'list_map' => esc_html__( 'List and Map', 'lsx-search' ), |
||
| 401 | 'list' => esc_html__( 'List only', 'lsx-search' ), |
||
| 402 | ), |
||
| 403 | 'default' => '', |
||
| 404 | ) |
||
| 405 | ); |
||
| 406 | } |
||
| 407 | |||
| 408 | $cmb->add_field( |
||
| 409 | array( |
||
| 410 | 'name' => esc_html__( 'Enable Collapse', 'lsx-search' ), |
||
| 411 | 'id' => $section . '_search_collapse', |
||
| 412 | 'type' => 'checkbox', |
||
| 413 | 'description' => __( 'Enable collapsible filters on search results.', 'lsx-search' ), |
||
| 414 | ) |
||
| 415 | ); |
||
| 416 | |||
| 417 | $cmb->add_field( |
||
| 418 | array( |
||
| 419 | 'name' => esc_html__( 'Disable Sorting', 'lsx-search' ), |
||
| 420 | 'id' => $section . '_search_disable_sorting', |
||
| 421 | 'type' => 'checkbox', |
||
| 422 | 'description' => __( 'Toggle the sorting drop down menu on your search results.', 'lsx-search' ), |
||
| 423 | ) |
||
| 424 | ); |
||
| 425 | |||
| 426 | $cmb->add_field( |
||
| 427 | array( |
||
| 428 | 'name' => esc_html__( 'Disable the Date Sorting Option', 'lsx-search' ), |
||
| 429 | 'id' => $section . '_search_disable_date', |
||
| 430 | 'type' => 'checkbox', |
||
| 431 | ) |
||
| 432 | ); |
||
| 433 | |||
| 434 | $cmb->add_field( |
||
| 435 | array( |
||
| 436 | 'name' => esc_html__( 'Display Clear Button', 'lsx-search' ), |
||
| 437 | 'id' => $section . '_search_display_clear_button', |
||
| 438 | 'type' => 'checkbox', |
||
| 439 | 'description' => __( 'Check this to turn on a button that will clear your search results.', 'lsx-search' ), |
||
| 440 | ) |
||
| 441 | ); |
||
| 442 | |||
| 443 | $cmb->add_field( |
||
| 444 | array( |
||
| 445 | 'name' => esc_html__( 'Display Result Count', 'lsx-search' ), |
||
| 446 | 'id' => $section . '_search_display_result_count', |
||
| 447 | 'type' => 'checkbox', |
||
| 448 | ) |
||
| 449 | ); |
||
| 450 | if ( function_exists('is_plugin_active') && is_plugin_active( 'facetwp-alpha/index.php' ) ) { |
||
| 451 | $cmb->add_field( |
||
| 452 | array( |
||
| 453 | 'name' => esc_html__( 'Alphabet Facet', 'lsx-search' ), |
||
| 454 | 'description' => esc_html__( 'Select the alphabetical sorter facet.', 'lsx-search' ), |
||
| 455 | 'id' => $section . '_search_az_pagination', |
||
| 456 | 'type' => 'select', |
||
| 457 | 'options' => $this->az_facets, |
||
| 458 | ) |
||
| 459 | ); |
||
| 460 | } |
||
| 461 | $cmb->add_field( |
||
| 462 | array( |
||
| 463 | 'name' => esc_html__( 'Facets', 'lsx-search' ), |
||
| 464 | 'description' => esc_html__( 'Choose the filters to display in the sidebar. Edit FacetWP filters to change individual filters.', 'lsx-search' ), |
||
| 465 | 'id' => $section . '_search_facets', |
||
| 466 | 'type' => 'multicheck', |
||
| 467 | 'options' => $this->facet_data, |
||
| 468 | ) |
||
| 469 | ); |
||
| 470 | do_action( 'lsx_search_settings_section', $cmb, 'bottom' ); |
||
| 471 | $cmb->add_field( |
||
| 472 | array( |
||
| 473 | 'id' => 'settings_' . $section . '_search_closing', |
||
| 474 | 'type' => 'tab_closing', |
||
| 475 | ) |
||
| 526 |