| 1 |
<?php defined( 'ABSPATH' ) || exit; ?> |
| 2 |
<style> |
| 3 |
/* Override ThickBox container padding */ |
| 4 |
#TB_ajaxContent { |
| 5 |
padding: 0 !important; |
| 6 |
width: 100% !important; |
| 7 |
height: auto !important; |
| 8 |
overflow: visible !important; |
| 9 |
} |
| 10 |
#TB_window { |
| 11 |
overflow: hidden; |
| 12 |
} |
| 13 |
.wgm-icon-selector-wrapper { |
| 14 |
padding: 15px; |
| 15 |
background: #fff; |
| 16 |
width: 100%; |
| 17 |
min-height: 100%; |
| 18 |
box-sizing: border-box; |
| 19 |
overflow: hidden; |
| 20 |
} |
| 21 |
.wgm-icon-search-container { |
| 22 |
margin-bottom: 20px; |
| 23 |
position: relative; |
| 24 |
} |
| 25 |
.wgm-icon-search-input { |
| 26 |
width: 100%; |
| 27 |
padding: 10px 40px 10px 15px; |
| 28 |
font-size: 14px; |
| 29 |
border: 2px solid #ddd; |
| 30 |
border-radius: 6px; |
| 31 |
box-sizing: border-box; |
| 32 |
transition: border-color 0.3s ease; |
| 33 |
} |
| 34 |
.wgm-icon-search-input:focus { |
| 35 |
outline: none; |
| 36 |
border-color: #2271b1; |
| 37 |
box-shadow: 0 0 0 1px #2271b1; |
| 38 |
} |
| 39 |
.wgm-icon-search-clear { |
| 40 |
position: absolute; |
| 41 |
right: 10px; |
| 42 |
top: 50%; |
| 43 |
transform: translateY(-50%); |
| 44 |
background: none; |
| 45 |
border: none; |
| 46 |
font-size: 20px; |
| 47 |
color: #999; |
| 48 |
cursor: pointer; |
| 49 |
padding: 5px 10px; |
| 50 |
line-height: 1; |
| 51 |
display: none; |
| 52 |
} |
| 53 |
.wgm-icon-search-clear:hover { |
| 54 |
color: #333; |
| 55 |
} |
| 56 |
.wgm-icon-search-input:not(:placeholder-shown) ~ .wgm-icon-search-clear { |
| 57 |
display: block; |
| 58 |
} |
| 59 |
.wgm_gmap_embed_marker_icons { |
| 60 |
list-style: none; |
| 61 |
margin: 0; |
| 62 |
padding: 0; |
| 63 |
display: grid; |
| 64 |
grid-template-columns: repeat(9, 1fr); |
| 65 |
gap: 8px; |
| 66 |
max-width: 100%; |
| 67 |
} |
| 68 |
.wgm_gmap_embed_marker_icons li { |
| 69 |
display: flex; |
| 70 |
align-items: center; |
| 71 |
justify-content: center; |
| 72 |
padding: 6px; |
| 73 |
border: 2px solid #ddd; |
| 74 |
border-radius: 6px; |
| 75 |
cursor: pointer; |
| 76 |
transition: all 0.2s ease; |
| 77 |
background: #fff; |
| 78 |
aspect-ratio: 1; |
| 79 |
box-sizing: border-box; |
| 80 |
} |
| 81 |
.wgm_gmap_embed_marker_icons li:hover { |
| 82 |
border-color: #2271b1; |
| 83 |
background: #f0f6fc; |
| 84 |
transform: translateY(-2px); |
| 85 |
box-shadow: 0 2px 8px rgba(0,0,0,0.1); |
| 86 |
} |
| 87 |
.wgm_gmap_embed_marker_icons li.wgm-icon-hidden { |
| 88 |
display: none; |
| 89 |
} |
| 90 |
.wgm_gmap_embed_marker_icons li img { |
| 91 |
max-width: 32px; |
| 92 |
max-height: 32px; |
| 93 |
width: auto; |
| 94 |
height: auto; |
| 95 |
display: block; |
| 96 |
} |
| 97 |
.wgm-no-results { |
| 98 |
text-align: center; |
| 99 |
padding: 40px 20px; |
| 100 |
color: #666; |
| 101 |
font-size: 14px; |
| 102 |
display: none; |
| 103 |
} |
| 104 |
.wgm-no-results.wgm-show { |
| 105 |
display: block; |
| 106 |
} |
| 107 |
|
| 108 |
/* Responsive breakpoints */ |
| 109 |
@media (max-width: 600px) { |
| 110 |
.wgm_gmap_embed_marker_icons { |
| 111 |
grid-template-columns: repeat(6, 1fr); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
@media (max-width: 400px) { |
| 116 |
.wgm_gmap_embed_marker_icons { |
| 117 |
grid-template-columns: repeat(4, 1fr); |
| 118 |
} |
| 119 |
} |
| 120 |
</style> |
| 121 |
|
| 122 |
<div class="wgm-icon-selector-wrapper"> |
| 123 |
<div class="wgm-icon-search-container"> |
| 124 |
<input |
| 125 |
type="text" |
| 126 |
id="wgm-icon-search" |
| 127 |
class="wgm-icon-search-input" |
| 128 |
placeholder="<?php esc_attr_e('Search icons...', 'gmap-embed'); ?>" |
| 129 |
autocomplete="off" |
| 130 |
aria-label="<?php esc_attr_e('Search marker icons', 'gmap-embed'); ?>" |
| 131 |
/> |
| 132 |
<button type="button" class="wgm-icon-search-clear" aria-label="<?php esc_attr_e('Clear search', 'gmap-embed'); ?>">×</button> |
| 133 |
</div> |
| 134 |
|
| 135 |
<div class="wgm-no-results" id="wgm-no-results"> |
| 136 |
<?php esc_html_e('No icons found matching your search.', 'gmap-embed'); ?> |
| 137 |
</div> |
| 138 |
|
| 139 |
<ul class="wgm_gmap_embed_marker_icons" id="wgm-icon-list"> |
| 140 |
<?php |
| 141 |
global $wpdb; |
| 142 |
$gmap_embed_admin_icon_fetch = false; |
| 143 |
$gmap_embed_admin_marker_icons = wp_cache_get('gmap_embed_marker_icons', 'gmap_embed'); |
| 144 |
if (false === $gmap_embed_admin_marker_icons) { |
| 145 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 146 |
$gmap_embed_admin_marker_icons = $wpdb->get_results("SELECT type, file_name FROM {$wpdb->prefix}wgm_icons", OBJECT); |
| 147 |
wp_cache_set('gmap_embed_marker_icons', $gmap_embed_admin_marker_icons, 'gmap_embed'); |
| 148 |
} |
| 149 |
|
| 150 |
if (count($gmap_embed_admin_marker_icons) > 0) { |
| 151 |
foreach ($gmap_embed_admin_marker_icons as $gmap_embed_icon_key => $gmap_embed_marker_icon) { |
| 152 |
$gmap_embed_admin_icon_fetch = true; |
| 153 |
$gmap_embed_admin_image_path = $gmap_embed_marker_icon->file_name; |
| 154 |
if ($gmap_embed_marker_icon->type === 'pre_uploaded_icon') { |
| 155 |
$gmap_embed_admin_image_path = plugin_dir_url(__FILE__) . '../assets/images/markers/' . basename($gmap_embed_marker_icon->file_name); |
| 156 |
} |
| 157 |
$gmap_embed_admin_icon_name = basename($gmap_embed_admin_image_path, '.' . pathinfo($gmap_embed_admin_image_path, PATHINFO_EXTENSION)); |
| 158 |
?> |
| 159 |
<li data-icon-name="<?php echo esc_attr(strtolower($gmap_embed_admin_icon_name)); ?>"> |
| 160 |
<img width="32" height="32" src="<?php echo esc_url($gmap_embed_admin_image_path); ?>" |
| 161 |
onclick="wpgmapChangeCurrentMarkerIcon(this);" |
| 162 |
alt="<?php echo esc_attr($gmap_embed_admin_icon_name); ?>" |
| 163 |
title="<?php echo esc_attr($gmap_embed_admin_icon_name); ?>" /> |
| 164 |
</li> |
| 165 |
<?php |
| 166 |
} |
| 167 |
} |
| 168 |
// Load default icons from directory |
| 169 |
$gmap_embed_dir = WGM_ICONS_DIR; |
| 170 |
$gmap_embed_file_display = array('jpg', 'jpeg', 'png', 'gif'); |
| 171 |
|
| 172 |
if (file_exists($gmap_embed_dir) == false) { |
| 173 |
echo '<li style="grid-column: 1/-1; text-align: center; padding: 20px;">'; |
| 174 |
echo esc_html__('Directory not found!', 'gmap-embed'); |
| 175 |
echo '</li>'; |
| 176 |
} else { |
| 177 |
$gmap_embed_admin_icon_fetch = true; |
| 178 |
$gmap_embed_dir_contents = scandir($gmap_embed_dir); |
| 179 |
foreach ($gmap_embed_dir_contents as $gmap_embed_file) { |
| 180 |
$gmap_embed_image_data = explode('.', $gmap_embed_file); |
| 181 |
$gmap_embed_file_type = strtolower(end($gmap_embed_image_data)); |
| 182 |
if ('.' !== $gmap_embed_file && '..' !== $gmap_embed_file && true === in_array($gmap_embed_file_type, $gmap_embed_file_display, true)) { |
| 183 |
$gmap_embed_admin_icon_name = $gmap_embed_image_data[0]; |
| 184 |
?> |
| 185 |
<li data-icon-name="<?php echo esc_attr(strtolower($gmap_embed_admin_icon_name)); ?>"> |
| 186 |
<img onclick="wpgmapChangeCurrentMarkerIcon(this);" |
| 187 |
alt="<?php echo esc_attr($gmap_embed_admin_icon_name); ?>" |
| 188 |
title="<?php echo esc_attr($gmap_embed_admin_icon_name); ?>" |
| 189 |
src="<?php echo esc_url(WGM_ICONS . $gmap_embed_file); ?>" /> |
| 190 |
</li> |
| 191 |
<?php |
| 192 |
} |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
if (!$gmap_embed_admin_icon_fetch) { |
| 197 |
echo '<li style="grid-column: 1/-1; text-align: center; padding: 20px;">'; |
| 198 |
echo esc_html__('No icon found, please upload icon by clicking the Upload Icon button', 'gmap-embed'); |
| 199 |
echo '</li>'; |
| 200 |
} |
| 201 |
?> |
| 202 |
</ul> |
| 203 |
</div> |
| 204 |
|