Changeset 3375732
- Timestamp:
- 10/09/2025 01:03:25 PM (6 months ago)
- Location:
- glycerine/trunk
- Files:
-
- 3 edited
-
assets/js/annotation-cutouts.js (modified) (1 diff)
-
glycerine.php (modified) (3 diffs)
-
includes/annotation-table.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
glycerine/trunk/assets/js/annotation-cutouts.js
r3367216 r3375732 61 61 img.addEventListener("mouseover", (event) => { 62 62 let tooltipContent = ``; 63 for (let key in annotationData.fields) { 64 const capitalizedKey = key 63 annotationData.fields.forEach((field) => { 64 let key = field.field.name; 65 let capitalizedKey = key 65 66 .replace(/_/g, " ") 66 67 .replace(/\b\w/g, (l) => l.toUpperCase()); 67 const rawValue = annotationData.fields[key]?.en?.values[0]; 68 let value = ""; 69 70 if (typeof rawValue === "object" && rawValue !== null) { 71 value = 72 rawValue.term_label || 73 rawValue.label || 74 rawValue.value || 75 rawValue.url || 76 JSON.stringify(rawValue); 77 } else { 78 value = rawValue || "N/A"; 79 } 68 let value = field.values.en ? field.values.en[0] : ""; 80 69 81 70 tooltipContent += `<strong>${capitalizedKey}:</strong> ${value}<br>`; 82 } 71 }); 72 83 73 tooltip.innerHTML = tooltipContent; 84 74 tooltip.style.display = "block"; -
glycerine/trunk/glycerine.php
r3367216 r3375732 104 104 } 105 105 106 if ((is_singular() && has_block('glycerine/annotation-cutouts')) || $force_enqueue) {106 if ((is_singular() && has_block('glycerine/annotation-cutouts')) || $force_enqueue) { 107 107 108 108 wp_enqueue_script( … … 114 114 ); 115 115 } 116 117 116 } 118 117 add_action('wp_enqueue_scripts', 'glycerine_enqueue_assets'); … … 366 365 } 367 366 368 $annotationTitle = isset($attributes['annotationTitle']) ? $attributes['annotationTitle'] : null; 369 $annotationDescription = isset($attributes['annotationDescription']) ? $attributes['annotationDescription'] : null; 367 $annotationTitle = null; 368 $annotationDescription = null; 369 $annotationDataFields = isset($annotationData['fields']) ? $annotationData['fields'] : []; 370 foreach ($annotationDataFields as $field) { 371 if ($field['field']['name'] == 'Title' && isset($field['values']['en'])) { 372 $annotationTitle = $field['values']['en'][0]; 373 } 374 375 if ($field['field']['name'] == 'Description' && isset($field['values']['en'])) { 376 $annotationDescription = $field['values']['en'][0]; 377 } 378 } 370 379 371 380 // Prevent rendering inside the block editor -
glycerine/trunk/includes/annotation-table.php
r3367216 r3375732 83 83 break; 84 84 case 'Tags': 85 if (!empty($annotation[' fields']['tag']['en']['values']) && is_array($annotation['fields']['tag']['en']['values'])) {86 foreach ($annotation[' fields']['tag']['en']['values'] as $tag) {85 if (!empty($annotation['tags']) && is_array($annotation['tags'])) { 86 foreach ($annotation['tags'] as $tag) { 87 87 $value = $tag['term_label'] ?? ''; 88 88 if (!empty($value)) { … … 159 159 break; 160 160 case 'Title': 161 echo esc_html($annotation['fields']['title']['en']['values'][0] ?? ''); 161 foreach ($annotation['fields'] as $field) { 162 if ($field['field']['name'] == 'Title' && isset($field['values']['en'])) { 163 echo esc_html($field['values']['en'][0] ?? '') ; 164 break; 165 } 166 } 162 167 break; 163 168 case 'Description': 164 echo esc_html($annotation['fields']['description']['en']['values'][0] ?? ''); 169 foreach ($annotation['fields'] as $field) { 170 if ($field['field']['name'] == 'Description' && isset($field['values']['en'])) { 171 echo esc_html($field['values']['en'][0] ?? '') ; 172 break; 173 } 174 } 165 175 break; 166 176 case 'Notes': 167 echo esc_html($annotation['fields']['note']['en']['values'][0] ?? ''); 177 foreach ($annotation['fields'] as $field) { 178 if ($field['field']['name'] == 'Note' && isset($field['values']['en'])) { 179 echo esc_html($field['values']['en'][0] ?? '') ; 180 break; 181 } 182 } 168 183 break; 169 184 case 'Tags': 170 if (!empty($annotation[' fields']['tag']['en']['values']) && is_array($annotation['fields']['tag']['en']['values'])) {171 foreach ($annotation[' fields']['tag']['en']['values'] as $tag) {185 if (!empty($annotation['tags']) && is_array($annotation['tags'])) { 186 foreach ($annotation['tags'] as $tag) { 172 187 $tag_label = $tag['term_label'] ?? ''; 173 188 if (!empty($tag_label)) {
Note: See TracChangeset
for help on using the changeset viewer.