| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | if ( ! defined( 'ABSPATH' ) ) { |
| 15: | exit; |
| 16: | } |
| 17: | |
| 18: | |
| 19: | |
| 20: | $epl_license = (array) get_option( 'epl_license' ); |
| 21: | |
| 22: | $fields = epl_get_admin_option_licence_fields(); |
| 23: | |
| 24: | if ( isset( $_REQUEST['action'] ) && 'epl_settings' === $_REQUEST['action'] ) { |
| 25: | |
| 26: | if ( |
| 27: | ! isset( $_POST['epl_nonce_license_form'] ) || |
| 28: | ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['epl_nonce_license_form'] ) ), 'epl_nonce_license_form' ) |
| 29: | ) { |
| 30: | wp_die( esc_html__( 'Sorry, your nonce did not verify.', 'easy-property-listings' ) ); |
| 31: | } |
| 32: | |
| 33: | if ( ! empty( $fields ) ) { |
| 34: | |
| 35: | foreach ( $fields as $field_group ) { |
| 36: | foreach ( $field_group['fields'] as $field ) { |
| 37: | |
| 38: | $field_value = isset( $_REQUEST['epl_license'][ 'epl_' . $field['name'] ] ) ? |
| 39: | wp_unslash( $_REQUEST['epl_license'][ 'epl_' . $field['name'] ] ) : ''; |
| 40: | |
| 41: | if ( 'text' === $field['type'] ) { |
| 42: | |
| 43: | $field_value = sanitize_text_field( $field_value ); |
| 44: | |
| 45: | $epl_license[ $field['name'] ] = $field_value; |
| 46: | } |
| 47: | } |
| 48: | } |
| 49: | |
| 50: | update_option( 'epl_license', $epl_license ); |
| 51: | } |
| 52: | } |
| 53: | |
| 54: | |
| 55: | ?> |
| 56: | |
| 57: | <div class="wrap"> |
| 58: | <h2><?php esc_html_e( 'Licenses Keys For Extensions', 'easy-property-listings' ); ?></h2> |
| 59: | <p><?php esc_html_e( 'Activate extension updates by entering your license key below. Thanks for purchasing software for Easy Property Listings. You\'re awesome!', 'easy-property-listings' ); ?></p> |
| 60: | <p><?php esc_html_e( 'Enter Your Activated Extension License Keys', 'easy-property-listings' ); ?></p> |
| 61: | |
| 62: | <div id="epl-menu-licences" class="epl-content metabox-holder"> |
| 63: | <form action="" method="post" class="tba-epl-general-form"> |
| 64: | <div class="epl-fields epl-menu-page"> |
| 65: | <?php if ( ! empty( $fields ) ) { ?> |
| 66: | <?php |
| 67: | foreach ( $fields as $field_group ) { |
| 68: | foreach ( $field_group['fields'] as $field ) { |
| 69: | ?> |
| 70: | <div id="meta-sortables" class="meta-box-sortables tba-ui-sortable epl-menu-content"> |
| 71: | <div id="epl-<?php echo esc_attr( $field['label'] ); ?>" class="postbox epl-menu-section epl-menu-license epl-<?php esc_attr( $field['type'] ); ?>"> |
| 72: | |
| 73: | <!--<div class="handlediv" title="Click to toggle"><br></div>--> |
| 74: | <h3 class="hndle ui-sortable-handle epl-section-title"><?php echo esc_attr( $field['label'] ); ?></h3> |
| 75: | |
| 76: | <div class="inside epl-field"> |
| 77: | <div class="epl-full epl-license-label"> |
| 78: | <label for="<?php echo esc_attr( $field['name'] ); ?>"><?php esc_html_e( 'Enter your license key', 'easy-property-listings' ); ?></label> |
| 79: | </div> |
| 80: | <div class="epl-full"> |
| 81: | <?php |
| 82: | $val = get_option( $field['name'] ); |
| 83: | switch ( $field['type'] ) { |
| 84: | case 'select': |
| 85: | echo '<select aria-label="' . esc_attr( $field['name'] ) . '" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['name'] ) . '">'; |
| 86: | if ( ! empty( $field['default'] ) ) { |
| 87: | echo '<option value="" selected="selected">' . esc_attr( $field['default'] ) . '</option>'; |
| 88: | } |
| 89: | |
| 90: | if ( ! empty( $field['opts'] ) ) { |
| 91: | foreach ( $field['opts'] as $k => $v ) { |
| 92: | $selected = ''; |
| 93: | if ( $val === $k ) { |
| 94: | $selected = 'selected="selected"'; |
| 95: | } |
| 96: | echo '<option value="' . esc_attr( $k ) . '" ' . $selected . '>' . esc_attr( $v ) . '</option>'; |
| 97: | } |
| 98: | } |
| 99: | echo '</select>'; |
| 100: | break; |
| 101: | |
| 102: | case 'checkbox': |
| 103: | if ( ! empty( $field['opts'] ) ) { |
| 104: | foreach ( $field['opts'] as $k => $v ) { |
| 105: | $checked = ''; |
| 106: | if ( ! empty( $val ) ) { |
| 107: | if ( in_array( $k, $val, true ) ) { |
| 108: | $checked = 'checked="checked"'; |
| 109: | } |
| 110: | } |
| 111: | echo '<span class="epl-field-row"><input type="checkbox" name="' . esc_attr( $field['name'] ) . '[]" id="' . esc_attr( $field['name'] ) . '_' . esc_attr( $k ) . '" value="' . esc_attr( $k ) . '" ' . $checked . ' /> <label for="' . esc_attr( $field['name'] ) . '_' . esc_attr( $k ) . '">' . esc_attr( $v ) . '</label></span>'; |
| 112: | } |
| 113: | } |
| 114: | break; |
| 115: | |
| 116: | case 'radio': |
| 117: | if ( ! empty( $field['opts'] ) ) { |
| 118: | foreach ( $field['opts'] as $k => $v ) { |
| 119: | $checked = ''; |
| 120: | if ( $val === $k ) { |
| 121: | $checked = 'checked="checked"'; |
| 122: | } |
| 123: | echo '<span class="epl-field-row"><input type="radio" name="' . esc_attr( $field['name'] ) . '" id="' . esc_attr( $field['name'] ) . '_' . esc_attr( $k ) . '" value="' . esc_attr( $k ) . '" ' . $checked . ' /> <label for="' . esc_attr( $field['name'] ) . '_' . esc_attr( $k ) . '">' . esc_attr( $v ) . '</label></span>'; |
| 124: | } |
| 125: | } |
| 126: | break; |
| 127: | |
| 128: | default: |
| 129: | $val = ''; |
| 130: | if ( ! empty( $epl_license ) && isset( $epl_license[ $field['name'] ] ) ) { |
| 131: | $val = $epl_license[ $field['name'] ]; |
| 132: | } |
| 133: | echo '<input type="text" class="epl-field-license" name="epl_license[epl_' . esc_attr( $field['name'] ) . ']" id="' . esc_attr( $field['name'] ) . '" value="' . esc_attr( $val ) . '" />'; |
| 134: | $status = get_option( 'epl_' . $field['name'] . '_license_active' ); |
| 135: | |
| 136: | if ( empty( $status ) || is_null( $status ) || false === $status ) { |
| 137: | $status = 'invalid'; |
| 138: | } else { |
| 139: | |
| 140: | if ( is_object( $status ) ) { |
| 141: | $status = $status->license; |
| 142: | } |
| 143: | } |
| 144: | |
| 145: | if ( ! empty( $status ) ) { |
| 146: | echo '<span class="epl-license-status epl-license-status-' . esc_attr( $status ) . '"></span>'; |
| 147: | |
| 148: | if ( 'valid' === $status ) { |
| 149: | echo '<span class="epl-license-status-text epl-license-status-text-' . esc_attr( $status ) . '">'; |
| 150: | echo '<span class="epl-license-status-text-label">' . esc_html__( 'Valid Key :', 'easy-property-listings' ) . '</span>'; |
| 151: | echo '<span class="epl-license-status-text-value">' . esc_html__( 'Your license key has been successfully validated.', 'easy-property-listings' ) . '</span>'; |
| 152: | echo '</span>'; |
| 153: | } else { |
| 154: | echo '<span class="epl-license-status-text epl-license-status-text-' . esc_attr( $status ) . '">'; |
| 155: | echo '<span class="epl-license-status-text-label">' . esc_html__( 'Invalid or Expired Key :', 'easy-property-listings' ) . '</span>'; |
| 156: | echo '<span class="epl-license-status-text-value">' . esc_html__( 'Please make sure you have entered the correct value and that your key is not expired.', 'easy-property-listings' ) . '</span>'; |
| 157: | echo '</span>'; |
| 158: | } |
| 159: | } |
| 160: | } |
| 161: | |
| 162: | if ( isset( $field['help'] ) ) { |
| 163: | $field['help'] = trim( $field['help'] ); |
| 164: | if ( ! empty( $field['help'] ) ) { |
| 165: | echo '<span class="epl-help-text">' . wp_kses_post( $field['help'] ) . '</span>'; |
| 166: | } |
| 167: | } |
| 168: | ?> |
| 169: | </div> |
| 170: | </div> |
| 171: | |
| 172: | </div> |
| 173: | </div> |
| 174: | <?php |
| 175: | } |
| 176: | } |
| 177: | } |
| 178: | ?> |
| 179: | </div> |
| 180: | <div class="epl-clear"></div> |
| 181: | |
| 182: | <div class="epl-content-footer"> |
| 183: | <input type="hidden" name="action" value="epl_settings" /> |
| 184: | <?php wp_nonce_field( 'epl_nonce_license_form', 'epl_nonce_license_form' ); ?> |
| 185: | <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> |
| 186: | </div> |
| 187: | </form> |
| 188: | </div> |
| 189: | </div> |
| 190: | <?php |
| 191: | |
| 192: | |
| 193: | |
| 194: | |
| 195: | |
| 196: | |
| 197: | function epl_get_admin_option_licence_fields() { |
| 198: | $opts_epl_gallery_n = array(); |
| 199: | for ( $i = 1; $i <= 10; $i++ ) { |
| 200: | $opts_epl_gallery_n[ $i ] = $i; |
| 201: | } |
| 202: | |
| 203: | $opts_epl_property_card_excerpt_length = array(); |
| 204: | for ( $i = 10; $i <= 55; $i++ ) { |
| 205: | $opts_epl_property_card_excerpt_length[ $i ] = $i; |
| 206: | } |
| 207: | |
| 208: | $opts_pages = array( '' => __( 'Select Page', 'easy-property-listings' ) ); |
| 209: | $pages = get_pages(); |
| 210: | if ( ! empty( $pages ) ) { |
| 211: | foreach ( $pages as $page ) { |
| 212: | $opts_pages[ $page->ID ] = $page->post_title; |
| 213: | } |
| 214: | } |
| 215: | |
| 216: | $fields = apply_filters( 'epl_license_options_filter', array() ); |
| 217: | return $fields; |
| 218: | } |
| 219: | |