| @@ -8,21 +8,19 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 11 | 11 | |
| 12 | -global $propertyhive, $wp_query; | |
| 12 | +global $propertyhive; | |
| 13 | 13 | |
| 14 | -if ( $wp_query->found_posts < 2 ) | |
| 15 | - return; | |
| 16 | 14 | ?> |
| 17 | 15 | <form class="propertyhive-ordering" method="get"> |
| 18 | 16 | <?php |
| 19 | - | |
| 20 | 17 | if ( |
| 21 | - ( isset($_REQUEST['department']) && $_REQUEST['department'] != 'commercial' ) || | |
| 22 | - ( !isset($_REQUEST['department']) && get_option( 'propertyhive_primary_department' ) != 'commercial' ) | |
| 18 | + ( !in_array( $department, array('', 'commercial') ) && ph_get_custom_department_based_on($department) != 'commercial' ) || | |
| 19 | + ( $department == '' && get_option( 'propertyhive_primary_department' ) != 'commercial' && ph_get_custom_department_based_on(get_option( 'propertyhive_primary_department' )) != 'commercial' ) | |
| 23 | 20 | ) |
| 24 | 21 | { |
| 22 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable; the template is included through a helper/function scope, so PrefixAllGlobals misclassifies the file when checked standalone. | |
| 25 | 23 | $results_orderby = apply_filters( 'propertyhive_results_orderby', array( |
| 26 | 24 | 'price-desc' => __( 'Default sorting', 'propertyhive' ), |
| 27 | 25 | 'date' => __( 'Sort by date added', 'propertyhive' ), |
| 28 | 26 | 'price-asc' => __( 'Sort by price: low to high', 'propertyhive' ), |
| @@ -30,8 +28,9 @@ | ||
| 30 | 28 | ) ); |
| 31 | 29 | } |
| 32 | 30 | else |
| 33 | 31 | { |
| 32 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable; the template is included through a helper/function scope, so PrefixAllGlobals misclassifies the file when checked standalone. | |
| 34 | 33 | $results_orderby = apply_filters( 'propertyhive_results_orderby', array( |
| 35 | 34 | 'floor_area-desc' => __( 'Default sorting', 'propertyhive' ), |
| 36 | 35 | 'date' => __( 'Sort by date added', 'propertyhive' ), |
| 37 | 36 | 'floor_area-asc' => __( 'Sort by floor area: low to high', 'propertyhive' ), |
| @@ -45,8 +44,9 @@ | ||
| 45 | 44 | { |
| 46 | 45 | ?> |
| 47 | 46 | <select name="orderby" class="orderby"> |
| 48 | 47 | <?php |
| 48 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable; the template is included through a helper/function scope, so PrefixAllGlobals misclassifies the file when checked standalone. | |
| 49 | 49 | foreach ( $results_orderby as $id => $name ) |
| 50 | 50 | { |
| 51 | 51 | echo '<option value="' . esc_attr( $id ) . '" ' . selected( $orderby, $id, false ) . '>' . esc_attr( $name ) . '</option>'; |
| 52 | 52 | } |
| @@ -55,13 +55,15 @@ | ||
| 55 | 55 | <?php |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Keep query string vars intact |
| 59 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound, WordPress.Security.NonceVerification.Recommended -- Function-scoped template locals preserve read-only search filters; every hidden-field name/value is escaped below. | |
| 59 | 60 | foreach ( $_GET as $key => $val ) { |
| 60 | 61 | if ( 'orderby' === $key || 'submit' === $key ) |
| 61 | 62 | continue; |
| 62 | 63 | |
| 63 | 64 | if ( is_array( $val ) ) { |
| 65 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-local variable; the template is included through a helper/function scope, so PrefixAllGlobals misclassifies the file when checked standalone. | |
| 64 | 66 | foreach( $val as $innerVal ) { |
| 65 | 67 | echo '<input type="hidden" name="' . esc_attr( $key ) . '[]" value="' . esc_attr( $innerVal ) . '" />'; |
| 66 | 68 | } |
| 67 | 69 | |