Easy Property Listings 3.5.15 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 
<?php
/**
 * Hook for External Link Buttons on Property Templates
 *
 * @package     EPL
 * @subpackage  Hooks/ExternalLinks
 * @copyright   Copyright (c) 2020, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       1.0.0
 */

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

/**
 * Outputs any external links for virtual tours on the property templates
 *
 * When the hook epl_buttons_single_property is used and the property
 * has external links they will be output on the template
 *
 * @since 1.0.0
 * @since 3.4.25 filter epl_show_{key} e.g. epl_show_property_external_link to disable button rendering.
 * @since 3.4.38 Added filter epl_external_link_keys to support additional external links.
 * @since 3.5 Fix for label to use esc_html instead of esc_attr.
 */
function epl_button_external_link() {

    $keys = apply_filters(
        'epl_external_link_keys',
        array(
            'property_external_link',
            'property_external_link_2',
            'property_external_link_3',
        )
    );

    foreach ( $keys as $key ) {
        $link       = get_post_meta( get_the_ID(), $key, true );
        $count      = 'property_external_link' === $key ? '' : substr( $key, - 1 );
        $default    = __( 'Tour ', 'easy-property-listings' ) . $count;
        $meta_label = get_post_meta( get_the_ID(), $key . '_label', true );
        $meta_label = empty( $meta_label ) ? $default : $meta_label;

        if ( is_array( $link ) ) { // Fallback if metadata is saved as an array.

            if ( ! empty( $link['image_url_or_path'] ) ) {
                $link = $link['image_url_or_path'];
            } else {
                $link = '';
            }
        }

        if ( ! empty( $link ) && apply_filters( 'epl_show_' . $key, true ) ) { ?>
            <button type="button" class="epl-button epl-external-link"
                    onclick="window.open('<?php echo esc_url( $link ); ?>')">
                <?php

                if ( has_filter( 'epl_button_label_' . $key ) ) {
                    $label = apply_filters( 'epl_button_label_' . $key, $meta_label );
                } else {
                    $label = apply_filters( 'epl_button_label_tour', $meta_label );
                }
                ?>
                <?php echo esc_html( $label ); ?>
            </button>
            <?php

        }
    }
}

add_action( 'epl_buttons_single_property', 'epl_button_external_link' );
Easy Property Listings 3.5.15 Code Reference API documentation generated by ApiGen