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
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function epl_add_elements_gui_button() {
echo '<style>
.epl_am_elements_gui_icon:before {
font: 400 18px/1 dashicons;
content: "\f478";
vertical-align: middle;
}
</style>
<a href="#TB_inline?width=480&height=700&inlineId=epl_select_gui_opts"
class="thickbox button epl_listing_elements_link"
id="epl_add_elements_shortcode"
title="' . esc_html__( 'Add Listing Elements', 'easy-property-listings' ) . '">
<span class="epl_am_elements_gui_icon"></span> ' . esc_html__( 'Add Listing Elements', 'easy-property-listings' ) . '</a>';
}
add_action( 'media_buttons', 'epl_add_elements_gui_button', 20 );
function epl_listing_elements_gui() {
?>
<style>
overflow:auto;
}
width: 200px;
margin: 7px 25px 10px 0;
}
width: 100%;
display: block;
}
</style>
<script>
function eplInsertElementsShortcode(){
var shortcode = "[listing_element ";
var type = jQuery('#epl_elements_shortcode_types').val();
if (type != '') {
shortcode += "type='"+type+"' ";
}
var val = jQuery('#epl_element_gui_val').val();
if (val != '') {
switch( type ) {
case 'action' :
shortcode += "action_key='"+val+"' ";
break;
case 'meta' :
shortcode += "meta_key='"+val+"' ";
break;
case 'post' :
shortcode += "post_key='"+val+"' ";
break;
}
}
shortcode += "]";
window.send_to_editor(shortcode);
}
</script>
<div id="epl_select_gui_opts" style="display:none;">
<div class="wrap">
<div class="epl-popover-element epl-clearfix">
<h3 class="epl-popover-title">
<?php esc_html_e( 'Insert Shortcode', 'easy-property-listings' ); ?>
</h3>
</div>
<div class="epl-popover-element epl-clearfix">
<h4 class="epl-popover-title">
<?php esc_html_e( 'Select Shortcode Type', 'easy-property-listings' ); ?>
</h4>
<select aria-label="<?php esc_attr_e( 'Select Shortcode Type', 'easy-property-listings' ); ?>" id="epl_elements_shortcode_types">
<option value=""><?php esc_html_e( 'type', 'easy-property-listings' ); ?></option>
<?php
$types = array( 'action', 'meta', 'post', 'suburb_profile', 'formatted_address', 'excerpt' );
foreach ( $types as $type ) {
?>
<option value="<?php echo esc_html( $type ); ?>"><?php echo esc_html( $type ); ?></option>
<?php
}
?>
</select>
</div>
<div class="epl-popover-element epl-clearfix">
<label class="epl-label" style="display: block;" for="epl_element_gui_val">
<?php esc_html_e( 'Value', 'easy-property-listings' ); ?>
</label>
<input type="text" id="epl_element_gui_val" />
<div class="epl-gui-help"><span><?php esc_html_e( 'Required for Types : action, meta, post', 'easy-property-listings' ); ?></span></div>
</div>
<div class="epl-popover-element epl-clearfix">
<input type="button" class="button-primary" value="<?php esc_html_e( 'Insert', 'easy-property-listings' ); ?>" onclick="eplInsertElementsShortcode();"/>
<a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php esc_html_e( 'Cancel', 'easy-property-listings' ); ?></a>
</div>
</div>
<div class="epl-popover-element epl-shortcode-gui-help epl-clearfix">
<h4><?php esc_html_e( 'How to use this shortcode', 'easy-property-listings' ); ?></h4>
<div class="epl-popover-table">
<table class="widefat striped">
<thead>
<tr>
<th>
<strong>
<?php esc_html_e( 'Actions', 'easy-property-listings' ); ?>
</strong>
</th>
<th>
<strong>
<?php esc_html_e( 'Meta Fields', 'easy-property-listings' ); ?>
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
epl_property_price
</td>
<td>
property_price
</td>
</tr>
<tr>
<td>
epl_property_heading
</td>
<td>
property_heading
</td>
</tr>
<tr>
<td>
epl_property_icons
</td>
<td>
property_bedrooms
</td>
</tr>
<tr>
<td>
epl_property_map
</td>
<td>
property_bathrooms
</td>
</tr>
</tbody>
</table>
</div>
<p>
<?php esc_html_e( 'For complete action reference visit', 'easy-property-listings' ); ?>
<a target="_blank" href="https://docs.easypropertylistings.com.au/hook-docs.html">
<?php esc_html_e( 'Here', 'easy-property-listings' ); ?>.
</a>
</p>
</div>
</div>
<?php
}
add_action( 'admin_footer', 'epl_listing_elements_gui' );