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

Packages

  • EPL
    • Admin
      • Actions
      • Classes
        • ContactsTable
        • EPL
          • Admin
            • Images
        • 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_Admin_Images
  • 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 
<?php
/**
 * Listing Elements Shortcode class
 *
 * @package     EPL
 * @subpackage  Classes/ListingElements
 * @copyright   Copyright (c) 2020, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.3
 */

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

/**
 * EPL_Listing_Elements Class
 *
 * @since 3.3.0
 */
class EPL_Listing_Elements {

    /**
     * Construct the shortcode.
     *
     * @since 3.3.0
     */
    public function __construct() {
        add_shortcode( 'listing_element', array( $this, 'listing_element' ) );
        add_shortcode( 'epl_listing_action', array( $this, 'epl_action' ) );
        add_shortcode( 'epl_listing_meta', array( $this, 'epl_meta' ) );
        add_shortcode( 'epl_listing_post', array( $this, 'post' ) );
        add_action( 'epl_suburb_profile', array( $this, 'epl_suburb_profile' ) );
        add_action( 'epl_listing_address', array( $this, 'epl_formatted_address' ) );
        add_shortcode( 'epl_listing_excerpt', array( $this, 'epl_the_excerpt' ) );
    }

    /**
     * Output example code or value if in th loop
     *
     * @param array $atts Array of attributes.
     *
     * @return false|string|void
     * @since 3.3
     */
    public function listing_element( $atts ) {

        global $property;

        if ( ! isset( $atts['type'] ) ) {
            return;
        }

        if ( is_null( $property ) ) {

            $key_name = '';

            switch ( $atts['type'] ) {

                case 'action':
                    $key_name = 'action_key';
                    break;

                case 'meta':
                    $key_name = 'meta_key';
                    break;

                case 'post':
                    $key_name = 'post_key';
                    break;

            }

            ob_start();
            echo '[ ' . esc_html__( 'Listing', 'easy-property-listings' ) . ' ' . esc_attr( ucwords( $atts['type'] ) );

            if ( ! empty( $key_name ) ) {
                echo ': ' . esc_attr( ucwords( str_replace( '_', ' ', $atts[ $key_name ] ) ) );
            }
            echo ' ]';

            return ob_get_clean();
        }

        $return = '';

        switch ( $atts['type'] ) {

            case 'action':
                $return = $this->epl_action( $atts );
                break;

            case 'meta':
                $return = $this->epl_meta( $atts );
                break;

            case 'post':
                $return = $this->post( $atts );
                break;

            case 'suburb_profile':
                $return = $this->epl_suburb_profile();
                break;

            case 'formatted_address':
                $return = $this->epl_formatted_address();
                break;

            case 'excerpt':
                $return = $this->epl_the_excerpt();
                break;

        }

        return $return;
    }

    /**
     * Output action
     *
     * @param array $atts Array of attributes for the action.
     *
     * @return false|string|void
     * @since 3.3
     */
    public function epl_action( $atts ) {
        if ( ! isset( $atts['action_key'] ) ) {
            return;
        }
        ob_start();
        do_action( $atts['action_key'] );
        return ob_get_clean();
    }

    /**
     * Get meta
     *
     * @param array $atts Array of attributes for the meta field.
     *
     * @return string|void
     * @since 3.3
     */
    public function epl_meta( $atts ) {

        if ( ! isset( $atts['meta_key'] ) ) {
            return;
        }

        return get_property_meta( $atts['meta_key'] );
    }

    /**
     * Get post
     *
     * @param array $atts Array of attributes for the post object.
     *
     * @return false|string
     * @since 3.3
     */
    public function post( $atts ) {

        global $property;

        $return = '';
        switch ( $atts['post_key'] ) {

            case 'permalink':
                $return = get_permalink( $property->post->ID );
                break;

            default:
                $return = isset( $property->post->{$atts['post_key']} ) ? $property->post->{$atts['post_key']} : '';
                break;

        }

        return $return;
    }

    /**
     * Get suburb profile
     *
     * @since 3.3
     */
    public function epl_suburb_profile() {

        global $property;
        echo esc_html( $property->get_suburb_profile() );
    }

    /**
     * Get formatted listing address
     *
     * @since 3.3
     */
    public function epl_formatted_address() {

        global $property;
        echo esc_html( $property->get_formatted_property_address() );
    }

    /**
     * Get the excerpt
     *
     * @since 3.3
     */
    public function epl_the_excerpt() {

        global $property;
        return esc_html( epl_get_the_excerpt() );
    }
}

new EPL_Listing_Elements();
Easy Property Listings 3.5.24 Code Reference API documentation generated by ApiGen