| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | if ( ! defined( 'ABSPATH' ) ) { |
| 14: | exit; |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | function epl_add_elements_gui_button() { |
| 23: | |
| 24: | echo '<style> |
| 25: | .epl_am_elements_gui_icon:before { |
| 26: | font: 400 18px/1 dashicons; |
| 27: | content: "\f478"; |
| 28: | vertical-align: middle; |
| 29: | } |
| 30: | </style> |
| 31: | <a href="#TB_inline?width=480&height=700&inlineId=epl_select_gui_opts" |
| 32: | class="thickbox button epl_listing_elements_link" |
| 33: | id="epl_add_elements_shortcode" |
| 34: | title="' . esc_html__( 'Add Listing Elements', 'easy-property-listings' ) . '"> |
| 35: | <span class="epl_am_elements_gui_icon"></span> ' . esc_html__( 'Add Listing Elements', 'easy-property-listings' ) . '</a>'; |
| 36: | } |
| 37: | add_action( 'media_buttons', 'epl_add_elements_gui_button', 20 ); |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | function epl_listing_elements_gui() { |
| 46: | ?> |
| 47: | <style> |
| 48: | #TB_window { |
| 49: | overflow:auto; |
| 50: | } |
| 51: | #TB_ajaxContent .wrap select, #TB_ajaxContent .wrap input { |
| 52: | width: 200px; |
| 53: | margin: 7px 25px 10px 0; |
| 54: | } |
| 55: | #TB_ajaxContent .wrap span { |
| 56: | width: 100%; |
| 57: | display: block; |
| 58: | } |
| 59: | </style> |
| 60: | |
| 61: | <script> |
| 62: | function eplInsertElementsShortcode(){ |
| 63: | |
| 64: | var shortcode = "[listing_element "; |
| 65: | |
| 66: | var type = jQuery('#epl_elements_shortcode_types').val(); |
| 67: | |
| 68: | if (type != '') { |
| 69: | shortcode += "type='"+type+"' "; |
| 70: | } |
| 71: | |
| 72: | var val = jQuery('#epl_element_gui_val').val(); |
| 73: | |
| 74: | if (val != '') { |
| 75: | |
| 76: | switch( type ) { |
| 77: | |
| 78: | case 'action' : |
| 79: | shortcode += "action_key='"+val+"' "; |
| 80: | break; |
| 81: | |
| 82: | case 'meta' : |
| 83: | shortcode += "meta_key='"+val+"' "; |
| 84: | break; |
| 85: | |
| 86: | case 'post' : |
| 87: | shortcode += "post_key='"+val+"' "; |
| 88: | break; |
| 89: | } |
| 90: | |
| 91: | |
| 92: | } |
| 93: | |
| 94: | shortcode += "]"; |
| 95: | window.send_to_editor(shortcode); |
| 96: | } |
| 97: | </script> |
| 98: | |
| 99: | <div id="epl_select_gui_opts" style="display:none;"> |
| 100: | <div class="wrap"> |
| 101: | |
| 102: | <div class="epl-popover-element epl-clearfix"> |
| 103: | <h3 class="epl-popover-title"> |
| 104: | <?php esc_html_e( 'Insert Shortcode', 'easy-property-listings' ); ?> |
| 105: | </h3> |
| 106: | </div> |
| 107: | |
| 108: | <div class="epl-popover-element epl-clearfix"> |
| 109: | |
| 110: | <h4 class="epl-popover-title"> |
| 111: | <?php esc_html_e( 'Select Shortcode Type', 'easy-property-listings' ); ?> |
| 112: | </h4> |
| 113: | |
| 114: | <select aria-label="<?php esc_attr_e( 'Select Shortcode Type', 'easy-property-listings' ); ?>" id="epl_elements_shortcode_types"> |
| 115: | <option value=""><?php esc_html_e( 'type', 'easy-property-listings' ); ?></option> |
| 116: | <?php |
| 117: | $types = array( 'action', 'meta', 'post', 'suburb_profile', 'formatted_address', 'excerpt' ); |
| 118: | foreach ( $types as $type ) { |
| 119: | ?> |
| 120: | <option value="<?php echo esc_html( $type ); ?>"><?php echo esc_html( $type ); ?></option> |
| 121: | <?php |
| 122: | } |
| 123: | ?> |
| 124: | </select> |
| 125: | </div> |
| 126: | |
| 127: | <div class="epl-popover-element epl-clearfix"> |
| 128: | |
| 129: | <label class="epl-label" style="display: block;" for="epl_element_gui_val"> |
| 130: | <?php esc_html_e( 'Value', 'easy-property-listings' ); ?> |
| 131: | </label> |
| 132: | |
| 133: | <input type="text" id="epl_element_gui_val" /> |
| 134: | |
| 135: | <div class="epl-gui-help"><span><?php esc_html_e( 'Required for Types : action, meta, post', 'easy-property-listings' ); ?></span></div> |
| 136: | </div> |
| 137: | |
| 138: | <div class="epl-popover-element epl-clearfix"> |
| 139: | <input type="button" class="button-primary" value="<?php esc_html_e( 'Insert', 'easy-property-listings' ); ?>" onclick="eplInsertElementsShortcode();"/> |
| 140: | <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php esc_html_e( 'Cancel', 'easy-property-listings' ); ?></a> |
| 141: | </div> |
| 142: | |
| 143: | </div> |
| 144: | |
| 145: | <div class="epl-popover-element epl-shortcode-gui-help epl-clearfix"> |
| 146: | <h4><?php esc_html_e( 'How to use this shortcode', 'easy-property-listings' ); ?></h4> |
| 147: | <div class="epl-popover-table"> |
| 148: | <table class="widefat striped"> |
| 149: | <thead> |
| 150: | <tr> |
| 151: | <th> |
| 152: | <strong> |
| 153: | <?php esc_html_e( 'Actions', 'easy-property-listings' ); ?> |
| 154: | </strong> |
| 155: | |
| 156: | </th> |
| 157: | <th> |
| 158: | <strong> |
| 159: | <?php esc_html_e( 'Meta Fields', 'easy-property-listings' ); ?> |
| 160: | </strong> |
| 161: | |
| 162: | </th> |
| 163: | </tr> |
| 164: | </thead> |
| 165: | <tbody> |
| 166: | <tr> |
| 167: | <td> |
| 168: | epl_property_price |
| 169: | </td> |
| 170: | <td> |
| 171: | property_price |
| 172: | </td> |
| 173: | </tr> |
| 174: | <tr> |
| 175: | <td> |
| 176: | epl_property_heading |
| 177: | </td> |
| 178: | <td> |
| 179: | property_heading |
| 180: | </td> |
| 181: | </tr> |
| 182: | <tr> |
| 183: | <td> |
| 184: | epl_property_icons |
| 185: | </td> |
| 186: | <td> |
| 187: | property_bedrooms |
| 188: | </td> |
| 189: | </tr> |
| 190: | <tr> |
| 191: | <td> |
| 192: | epl_property_map |
| 193: | </td> |
| 194: | <td> |
| 195: | property_bathrooms |
| 196: | </td> |
| 197: | </tr> |
| 198: | </tbody> |
| 199: | </table> |
| 200: | </div> |
| 201: | |
| 202: | <p> |
| 203: | <?php esc_html_e( 'For complete action reference visit', 'easy-property-listings' ); ?> |
| 204: | <a target="_blank" href="https://docs.easypropertylistings.com.au/hook-docs.html"> |
| 205: | <?php esc_html_e( 'Here', 'easy-property-listings' ); ?>. |
| 206: | </a> |
| 207: | </p> |
| 208: | </div> |
| 209: | </div> |
| 210: | |
| 211: | <?php |
| 212: | } |
| 213: | add_action( 'admin_footer', 'epl_listing_elements_gui' ); |
| 214: | |