Easy Property Listings 3.5.14 Code Reference
  • Package
  • Class
  • Tree
  • Todo
  • Hook Reference

Packages

  • EPL
    • Admin
      • Actions
      • Classes
        • ContactsTable
        • ReportsGraph
        • Welcome
      • Contacts
      • ContactsActions
      • ContactsFunctions
      • Elements
      • Functions
      • Help
      • HelpSingle
      • Menus
      • MenusAddons
      • MenusExtensions
      • MenusLicenses
      • Plugins
      • Reports
      • ReportsGraphing
      • User
    • Assets
      • ScriptsStyles
      • SVG
    • Classes
      • AuthorLoader
      • AuthorMeta
      • Contact
      • Cron
      • CustomPostType
      • Forms
      • License
      • ListingAdvanced
      • ListingElements
      • MetaboxesCustomFields
      • Pagination
      • PropertyMeta
      • RenderFields
      • RestAPI
      • Search
      • Session
      • Updater
    • Compatibility
      • Extensions
      • Functions
      • Shortcodes
    • Functions
      • Actions
      • ConditionalTags
      • ErrorTracking
      • Formatting
      • Front
      • Global
      • Install
      • Pagination
      • Settings
      • Templates
    • Hooks
      • EnergyCertificate
      • ExternalLinks
      • FloorPlan
      • Map
      • ReadMore
      • WebLink
    • Meta
      • InitCustomFields
      • Meta
    • PostTypes
      • Business
      • Commercial
      • CommercialLand
      • Contact
      • Functions
      • Land
      • Property
      • Rental
      • Rural
    • Shortcode
      • CommercialListingSearch
      • ContactForm
      • Listing
      • ListingAdvanced
      • ListingAuction
      • ListingCategory
      • ListingFeature
      • ListingLocation
      • ListingMetaDoc
      • ListingOpen
      • ListingResults
      • ListingSearch
      • Map
    • Taxonomy
      • BusinessCategories
      • ContactTag
      • Features
      • Location
    • Templates
      • Themes
        • iThemes
        • iThemesBuilder
    • Widget
      • Admin
        • Dashboard
      • Classes
        • Author
        • ContactCapture
        • Gallery
        • Listing
        • Search
      • Functions
  • None
  • WordPress
    • Session

Classes

  • EPL_Advanced_Shortcode_Listing
  • EPL_Author
  • EPL_Author_Loader
  • EPL_Author_Meta
  • EPL_Contact
  • EPL_Contact_Reports_Table
  • EPL_CPT
  • EPL_Cron
  • EPL_FORM_BUILDER
  • EPL_Graph
  • EPL_License
  • EPL_Listing_Elements
  • EPL_METABOX
  • EPL_Pagination_Call
  • EPL_Property_Meta
  • EPL_Render_Fields
  • EPL_Rest_API
  • EPL_SEARCH
  • EPL_Search_Fields
  • EPL_Session
  • EPL_SL_Plugin_Updater
  • EPL_Welcome
  • EPL_Widget_Author
  • EPL_Widget_Contact_Capture
  • EPL_Widget_Property_Gallery
  • EPL_Widget_Property_Search
  • EPL_Widget_Recent_Property

Functions

  • EPL
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 
<?php
/**
 * Search Object
 *
 * @package     EPL
 * @subpackage  Classes/Search
 * @copyright   Copyright (c) 2019, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * EPL_Search_Fields Class
 *
 * @since      3.0
 * @author     Taher Atashbar <taher.atashbar@gmail.com>
 */
class EPL_Search_Fields {

    /**
     * Initialize hooks.
     *
     * @since  3.0
     *
     * @return void
     */
    public function init() {
        // Initialize hooks for displaying search frontend fields.
        add_action( 'epl_frontend_search_field_text', array( $this, 'render_text' ), 10, 5 );
        add_action( 'epl_frontend_search_field_checkbox', array( $this, 'render_checkbox' ), 10, 5 );
        add_action( 'epl_frontend_search_field_select', array( $this, 'render_select' ), 10, 5 );
        add_action( 'epl_frontend_search_field_multiple_select', array( $this, 'render_multiple_select' ), 10, 5 );
        add_action( 'epl_frontend_search_field_number', array( $this, 'render_number' ), 10, 5 );
        add_action( 'epl_frontend_search_field_hidden', array( $this, 'render_hidden' ), 10, 5 );
        add_action( 'epl_frontend_search_field_radio', array( $this, 'render_radio' ), 10, 5 );
        add_action( 'epl_frontend_search_field_checkbox_multiple', array( $this, 'render_checkbox_multiple' ), 10, 5 );

    }

    /**
     * Renders search frontend Text field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     * @since  3.5.10 Icon support added.
     */
    public function render_text( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
        ?>
        <div class="epl-search-row epl-search-row-text epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                        <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <input
                    placeholder="<?php echo esc_attr( $placeholder ); ?>"
                    type="text"
                    class="in-field field-width <?php echo esc_attr( $field['meta_key'] ); ?>"
                    name="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    id="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    value="<?php echo esc_attr( $value ); ?>"
                />
            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Checkbox field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     * @since  3.5.10 Icon support added.
     */
    public function render_checkbox( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        ?>
        <?php if ( ! empty( $field['icon'] ) ) : ?>
            <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
        <?php endif; ?>
        <span class="epl-search-row epl-search-row-checkbox <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <input type="checkbox" name="<?php echo esc_attr( $field['meta_key'] ); ?>" id="<?php echo esc_attr( $field['meta_key'] ); ?>" class="in-field <?php echo esc_attr( $field['meta_key'] ); ?>"
            <?php
            if ( isset( $value ) && ! empty( $value ) ) {
                echo 'checked="checked"'; }
            ?>
            />
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="check-label">
            <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
        </span>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Select field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     * @since  3.5.10 Icon support added.
     */
    public function render_select( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {

        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }

        $min_max_atts = '';

        if ( isset( $field['query']['type'] ) && 'numeric' === $field['query']['type'] ) {
            current( $field['options'] );
            $opt_min = key( $field['options'] );
            end( $field['options'] );
            $opt_max      = key( $field['options'] );
            $min_max_atts = ' data-min="' . $opt_min . '" data-max="' . $opt_max . '" ';
        }

        ?>
        <div class="epl-search-row epl-search-row-select epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                        <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <select
                    name="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    id="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    <?php echo $min_max_atts; //phpcs:ignore ?>
                    class="in-field field-width <?php echo esc_attr( $field['meta_key'] ); ?>">
                    <option value="">
                        <?php echo esc_attr( apply_filters( 'epl_search_widget_option_label_' . $field['option_filter'], __( 'Any', 'easy-property-listings' ) ) ); ?>
                    </option>
                    <?php
                    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
                        foreach ( $field['options'] as $k => $v ) {
                            echo '<option value="' . esc_attr( $k ) . '"' . selected( $k, $value, false ) . '>' . esc_attr( $v ) . '</option>';
                        }
                    }
                    ?>
                </select>
            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Multiple Select field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since 3.0
     * @since 3.4.36 Fix: Corrected issue with multi select where values are numbers.
     * @since 3.4.48 Tweak: Accessibility label added for select field.
     * @since 3.5.10 Icon support added.
     */
    public function render_multiple_select( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        $field_label = apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] );
        ?>
        <div class="epl-search-row epl-search-row-select epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_html( $field_label ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                    <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <select aria-label="<?php echo esc_attr( $field_label ); ?>" name="<?php echo esc_attr( $field['meta_key'] ); ?>[]"
                    id="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    class="in-field field-width field-multiple <?php echo esc_attr( $field['meta_key'] ); ?>" multiple>
                    <option value="">
                        <?php echo esc_attr( apply_filters( 'epl_search_widget_option_label_' . $field['option_filter'], __( 'Any', 'easy-property-listings' ) ) ); ?>
                    </option>
                    <?php
                    if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
                        foreach ( $field['options'] as $k => $v ) {
                            $selected = in_array( $k, (array) $value ) ? true : false;
                            echo '<option value="' . esc_attr( $k ) . '"' . selected( $selected, true, false ) . '>' . esc_attr( $v ) . '</option>';
                        }
                    }
                    ?>
                </select>
            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Number field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     * @since  3.5.10 Icon support added.
     */
    public function render_number( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        $placeholder = isset( $field['placeholder'] ) ? $field['placeholder'] : '';
        ?>
        <div class="epl-search-row epl-search-row-number epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                    <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <input type="number" class="in-field field-width <?php echo esc_attr( $field['meta_key'] ); ?>"
                    placeholder="<?php echo esc_attr( $placeholder ); ?>"
                    name="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    id="<?php echo esc_attr( $field['meta_key'] ); ?>"
                    value="<?php echo esc_attr( $value ); ?>"
                />
            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Hidden field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     */
    public function render_hidden( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        ?>
        <input type="hidden" class="in-field field-width <?php echo esc_attr( $field['meta_key'] ); ?>"
            name="<?php echo esc_attr( $field['meta_key'] ); ?>"
            id="<?php echo esc_attr( $field['meta_key'] ); ?>"
            value="<?php echo esc_attr( $value ); ?>"
        />
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

    /**
     * Renders search frontend Radio field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0
     * @since  3.5.10 Icon support added.
     */
    public function render_radio( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        ?>
        <div class="epl-search-row epl-search-row-radio epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                    <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <?php
                if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
                    foreach ( $field['options'] as $k => $v ) {
                        ?>
                        <input
                            type="radio"
                            <?php checked( $k, $value, true ); ?>
                            name="<?php echo esc_attr( $field['meta_key'] ); ?>"
                            id="<?php echo esc_attr( $field['meta_key'] ) . '_' . esc_attr( $k ); ?>"
                            value="<?php echo esc_attr( $k ); ?>"
                            class="in-field field-width <?php echo esc_attr( $field['meta_key'] ) . '_' . esc_attr( $k ); ?>" />
                        <label class="epl-search-radio-label"><?php echo esc_attr( $v ); ?></label>
                                                                        <?php
                    }
                }
                ?>

            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }

    }

    /**
     * Renders search frontend Radio field.
     *
     * @param  array  $field The field.
     * @param  string $config Configuration.
     * @param  string $value Value.
     * @param  string $post_type Post type name.
     * @param  string $property_status Listing status.
     *
     * @return void
     *
     * @since  3.0.0
     * @since  3.4.22 For attribute added for checkbox labels.
     * @since  3.5.10 Icon support added.
     */
    public function render_checkbox_multiple( array $field, $config = '', $value = '', $post_type = '', $property_status = '' ) {
        if ( isset( $field['wrap_start'] ) ) {
            echo '<div class="' . esc_attr( $field['wrap_start'] ) . '">';
        }
        ?>
        <div class="epl-search-row epl-search-row-checkbox-multiple epl-<?php echo esc_attr( $field['meta_key'] ); ?> fm-block <?php echo isset( $field['class'] ) ? esc_attr( $field['class'] ) : ''; ?>">
            <label for="<?php echo esc_attr( $field['meta_key'] ); ?>" class="epl-search-label fm-label">
                <?php echo esc_attr( apply_filters( 'epl_search_widget_label_' . $field['meta_key'], $field['label'] ) ); ?>
            </label>
            <div class="field">
                <?php if ( ! empty( $field['icon'] ) ) : ?>
                    <i class="epl-icon <?php echo esc_attr( $field['icon'] ); ?>"></i>
                <?php endif; ?>
                <?php
                if ( isset( $field['options'] ) && ! empty( $field['options'] ) ) {
                    foreach ( $field['options'] as $k => $v ) {
                        $checked = in_array( $k, (array) $value, true ) ? 'checked' : '';
                        ?>
                        <input
                            type="checkbox"
                            <?php echo ' ' . esc_attr( $checked ) . ' '; ?>
                            name="<?php echo esc_attr( $field['meta_key'] ); ?>[]"
                            id="<?php echo esc_attr( $field['meta_key'] ) . '_' . esc_attr( $k ); ?>"
                            value="<?php echo esc_attr( $k ); ?>"
                            class="in-field field-width <?php echo esc_attr( $field['meta_key'] ) . '_' . esc_attr( $k ); ?>" />
                        <label for="<?php echo esc_attr( $field['meta_key'] ) . '_' . esc_attr( $k ); ?>" class="epl-search-checkbox-label"><?php echo esc_attr( $v ); ?></label>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
        <?php
        if ( isset( $field['wrap_end'] ) ) {
            echo '</div>';
        }
    }

}
Easy Property Listings 3.5.14 Code Reference API documentation generated by ApiGen