Easy Property Listings 3.5.22 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 217 218 219 220 221 222 223 224 225 226 227 
<?php
/**
 * Extension Settings
 *
 * @package     EPL
 * @subpackage  Admin/MenusExtensions
 * @copyright   Copyright (c) 2020, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       2.0
 * @since       3.4.44 Added field type class for field wrapper and custom wrapper class support through wrapper_class.
 * @since       3.5 Unique IDs for all field wrappers.
 * @since       3.5.16 added epl_extension_settings_fields filter for active tab.
 */

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

$epl_extensions = epl_get_new_admin_option_fields();
$active_tab     = isset( $_GET['tab'] ) ? sanitize_title( wp_unslash( $_GET['tab'] ) ) : current( array_keys( $epl_extensions ) );
$active_sub_tab = isset( $_GET['sub_tab'] ) ? sanitize_title( wp_unslash( $_GET['sub_tab'] ) ) : '';

if ( isset( $_REQUEST['action'] ) && 'epl_settings' === $_REQUEST['action'] ) {

    if (
        ! isset( $_POST['epl_nonce_extension_form'] ) ||
        ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['epl_nonce_extension_form'] ) ), 'epl_nonce_extension_form' )
    ) {
        wp_die( esc_html__( 'Sorry, your nonce did not verify.', 'easy-property-listings' ) );
    }

    if ( ! empty( $epl_extensions ) ) {
        if ( array_key_exists( $active_tab, $epl_extensions ) ) {
            $epl_settings     = get_option( 'epl_settings' );
            $ext_field_groups = $epl_extensions[ $active_tab ];
            $ext_field_groups = apply_filters( 'epl_extension_settings_fields', $ext_field_groups, $active_tab );
            foreach ( $ext_field_groups['fields'] as $ext_field_group ) {
                foreach ( $ext_field_group['fields'] as $field ) {
                    if ( 'radio' === $field['type'] || 'checkbox' === $field['type'] ) {

                        if ( ! isset( $_REQUEST[ $field['name'] ] ) ) {
                            $_REQUEST[ $field['name'] ] = '';
                        } else {
                            if ( is_array( $_REQUEST[ $field['name'] ] ) ) {
                                $_REQUEST[ $field['name'] ] = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST[ $field['name'] ] ) );
                            } else {
                                $_REQUEST[ $field['name'] ] = sanitize_text_field( wp_unslash( $_REQUEST[ $field['name'] ] ) );
                            }
                        }
                    }

                    if ( 'text' === $field['type'] ) {
                        if ( isset( $_REQUEST[ $field['name'] ] ) && is_array( $_REQUEST[ $field['name'] ] ) ) {
                            array_walk_recursive( wp_unslash( $_REQUEST[ $field['name'] ] ), 'sanitize_text_field' ); //phpcs:ignore
                        }

                        if ( isset( $_REQUEST[ $field['name'] ] ) && is_string( $_REQUEST[ $field['name'] ] ) ) {
                            $_REQUEST[ $field['name'] ] = sanitize_text_field( wp_unslash( $_REQUEST[ $field['name'] ] ) );
                        }
                    }

                    if ( isset( $_REQUEST[ $field['name'] ] ) ) {
                        $epl_settings[ $field['name'] ] = wp_unslash( $_REQUEST[ $field['name'] ] ); //phpcs:ignore

                        // Remove fields after adding them to epl_settings.
                        unset( $_REQUEST[ $field['name'] ] );
                    }
                }
            }

            // Adding some way for dynamic fields to be added to epl_settings array.
            // Settings page params.
            $page_params = apply_filters( 'epl_settings_page_params', array( 'tab', 'page', 'sub_tab', 'action', 'submit' ) );

            // Remove all settings page params from $_REQUEST.
            foreach ( $page_params as $page_param ) {
                if ( isset( $_REQUEST[ $page_param ] ) ) {
                    unset( $_REQUEST[ $page_param ] );
                }
            }

            // Remaining fields are probably dynamic fields added via javascript/jquery save them as well if they are not already in $epl_settings.
            foreach ( $_REQUEST as $dynamic_key  => $dynamic_value ) {
                if ( ! empty( $dynamic_value ) ) {
                    $epl_settings[ $dynamic_key ] = $dynamic_value;
                }
            }

            update_option( 'epl_settings', $epl_settings );
        }
    }
}

global $epl_settings;
$epl_settings = get_option( 'epl_settings' );

?>
<div class="wrap">
    <h2><?php esc_html_e( 'Extensions Settings', 'easy-property-listings' ); ?></h2>
    <p><?php esc_html_e( 'Configure your extension settings here. Visit the main settings page for more extension settings.', 'easy-property-listings' ); ?></p>
    <h2 class="nav-tab-wrapper epl-nav-tab-wrapper">
        <?php
        foreach ( $epl_extensions as $ext_key => $epl_extension ) {
            $nav_active = $active_tab === $ext_key ? 'nav-tab-active' : '';
            ?>
            <a class="nav-tab <?php echo esc_attr( $nav_active ); ?>"
                href="<?php echo esc_url( admin_url( 'admin.php?page=epl-extensions&tab=' . sanitize_title( $ext_key ) ) ); ?>">
                <?php echo esc_attr( $epl_extension['label'] ); ?>
            </a>
            <?php
        }
        ?>
    </h2>
    <?php
    // Get fields so that we can get updated fields if added via hook.
    $epl_extensions = epl_get_new_admin_option_fields();
    if ( array_key_exists( $active_tab, $epl_extensions ) ) :
        $ext_field_groups = $epl_extensions[ $active_tab ];
        ?>
        <div class="epl-content">
            <?php
            echo '<div class="epl-fields-help-content">';
            foreach ( $ext_field_groups['fields'] as $ext_field_group ) {

                if ( isset( $ext_field_group['intro'] ) && ! empty( $ext_field_group['intro'] ) ) {
                    echo '<div class="epl-field epl-field-intro" data-help="tab-menu-' . esc_attr( sanitize_title( $ext_field_group['label'] ) ) . '">';
                    echo wp_kses_post( $ext_field_group['intro'] );
                    echo '</div>';
                }
            }
            echo '</div>';
            ?>

            <form action="" method="post" id="epl_extension_settings_form">
                <div class="epl-fields">
                <?php
                $counter = 1;
                echo '
                    <div class="epl-fields-tab-menu">
                        <ul>';
                foreach ( $ext_field_groups['fields'] as $ext_field_group ) {

                    $current_class = 'tab-menu-' . esc_attr( sanitize_title( $ext_field_group['label'] ) ) === $active_sub_tab ? 'epl-fields-menu-current' : '';

                    if ( empty( $active_sub_tab ) && 1 === $counter ) {
                        $current_class = 'epl-fields-menu-current';
                    }
                    if ( ! empty( $ext_field_group['label'] ) ) {
                        ?>
                        <li class="<?php echo esc_attr( $current_class ); ?>" data-tab="<?php echo 'tab-menu-' . esc_attr( sanitize_title( $ext_field_group['label'] ) ); ?>">
                            <?php echo esc_attr( $ext_field_group['label'] ); ?>
                        </li>
                        <?php
                    }
                    ++$counter;
                }
                            echo '
                        </ul>
                    </div>
                ';

                if ( ! empty( $ext_field_groups['fields'] ) ) {

                    echo '<div class="epl-fields-tab-content">';
                    $counter = 1;
                    foreach ( $ext_field_groups['fields'] as $field_group ) {
                        $current_class = 'tab-menu-' . sanitize_title( $field_group['label'] ) === $active_sub_tab ? 'epl-fields-field-current' : '';
                        if ( empty( $active_sub_tab ) && 1 === $counter ) {
                            $current_class = 'epl-fields-field-current';
                        }
                        ?>

                        <div class="<?php echo esc_attr( $current_class ); ?> epl-fields-single-menu" id="<?php echo 'tab-menu-' . esc_attr( sanitize_title( $field_group['label'] ) ); ?>">
                            <?php foreach ( $field_group['fields'] as $field ) { ?>
                            <div id="epl-field-<?php echo esc_attr( $field['name'] ); ?>" class="epl-field epl-field-<?php echo esc_attr( $field['type'] ); ?> epl-field-<?php echo esc_attr( $field['name'] ); ?> <?php echo ! empty( $field['wrapper_class'] ) ? esc_attr( $field['wrapper_class'] ) : ''; ?>">
                                <div class="epl-help-entry-header">
                                    <div class="epl_help_entry_content"></div>
                                </div>
                                <?php if ( 'help' !== $field['type'] ) { ?>
                                    <div class="epl-half-left">
                                        <label for="<?php echo esc_attr( $field['name'] ); ?>"><?php echo esc_attr( $field['label'] ); ?></label>
                                    </div>
                                <?php } ?>
                                <div class="<?php echo 'help' === $field['type'] ? 'epl-full' : 'epl-half-right'; ?>">
                                    <?php
                                    $default_val = isset( $field['default'] ) ? $field['default'] : '';
                                    $val         = $default_val;
                                    if ( isset( $epl_settings[ $field['name'] ] ) ) {
                                        $val = $epl_settings[ $field['name'] ];
                                    }
                                    epl_render_html_fields( $field, $val );
                                    ?>
                                </div>
                            </div>
                            <?php } ?>
                        </div>
                        <?php ++$counter; ?>
                    <?php } ?>
                    </div>
                <?php } ?>
                <div class="epl-clear"></div>
                <div class="epl-content-footer">
                    <input type="hidden" name="action" value="epl_settings" />
                    <?php wp_nonce_field( 'epl_nonce_extension_form', 'epl_nonce_extension_form' ); ?>
                    <input type="hidden" name="sub_tab" id="sub_tab" value="" />
                    <p class="submit">
                        <input type="submit" value="<?php esc_html_e( 'Save Changes', 'easy-property-listings' ); ?>" class="button button-primary" id="submit" name="submit">
                    </p>
                </div>
            </form>
        </div>
    <?php endif; ?>
</div>
<?php

/**
 * Get Extension Settings
 *
 * @since 2.0
 */
function epl_get_new_admin_option_fields() {
    $fields = array();
    $fields = apply_filters( 'epl_extensions_options_filter_new', $fields );
    return $fields;
}
Easy Property Listings 3.5.22 Code Reference API documentation generated by ApiGen