| 1 |
<?php |
| 2 |
|
| 3 |
namespace WGMSRM\Traits; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Trait MediaButtons: for plugins media buttons including |
| 11 |
*/ |
| 12 |
trait MediaButtons |
| 13 |
{ |
| 14 |
|
| 15 |
public function add_wp_google_map_media_button() |
| 16 |
{ |
| 17 |
// path to my icon |
| 18 |
$img = WGM_PLUGIN_URL . 'gmap_icon_18.png'; |
| 19 |
|
| 20 |
// the id of the container I want to show in the popup |
| 21 |
$container_id = 'wp_gmap_popup_container'; |
| 22 |
|
| 23 |
// our popup's title |
| 24 |
$title = 'Select your desired map to insert into post'; |
| 25 |
|
| 26 |
// append the icon |
| 27 |
$context = "<a class='button thickbox' title='" . esc_attr($title) . "' |
| 28 |
href='#TB_inline?width=700&height=450&inlineId=" . esc_attr($container_id) . "'> |
| 29 |
" . '<span class="wp-media-buttons-icon" style="background: url(' . esc_url($img) . ') no-repeat; background-position: left bottom;"></span>' . 'WP Google Map</a>'; |
| 30 |
|
| 31 |
$allowed_html = [ |
| 32 |
'a' => [ |
| 33 |
'class' => [], |
| 34 |
'id' => [], |
| 35 |
'title' => [], |
| 36 |
'href' => [], |
| 37 |
], |
| 38 |
'span' => [ |
| 39 |
'class' => [], |
| 40 |
'style' => [] |
| 41 |
], |
| 42 |
|
| 43 |
]; |
| 44 |
// Output is escaped using wp_kses, allowed tags and attributes are strictly defined |
| 45 |
echo wp_kses($context, $allowed_html); |
| 46 |
} |
| 47 |
|
| 48 |
public function wp_google_map_media_button_content() |
| 49 |
{ ?> |
| 50 |
<div id="wp_gmap_popup_container" style="display:none;"> |
| 51 |
<!--modal contents--> |
| 52 |
<div id="wgm_all_maps"> |
| 53 |
<!---------------------------new map tab--------------> |
| 54 |
<div class="wp-gmap-tab-content active" id="wp-gmap-all"> |
| 55 |
<span class="wpgmap_msg_error" style="width:80%;"> |
| 56 |
|
| 57 |
</span> |
| 58 |
<!--all map tab--> |
| 59 |
<div class="wp-gmap-list"> |
| 60 |
<a href="<?php echo esc_url(admin_url() . 'admin.php?page=wpgmapembed&tag=new'); ?>" |
| 61 |
data-id="wp-gmap-new" class="media-menu-item" |
| 62 |
style="float:right;"><?php esc_html_e('Create New Map', 'gmap-embed'); ?> |
| 63 |
</a> |
| 64 |
<span class="spinner is-active" style="margin: 0px !important;float:left;"></span> |
| 65 |
<div id="wpgmapembed_list"></div> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<?php |
| 71 |
} |
| 72 |
} |
| 73 |
|