Changeset 3321653
- Timestamp:
- 07/03/2025 10:08:47 AM (9 months ago)
- Location:
- wepop/trunk
- Files:
-
- 13 edited
-
includes/config.php (modified) (5 diffs)
-
js/popup.js (modified) (9 diffs)
-
languages/de.mo (modified) (previous)
-
languages/de.po (modified) (4 diffs)
-
languages/es.mo (modified) (previous)
-
languages/es.po (modified) (5 diffs)
-
languages/fr.mo (modified) (previous)
-
languages/fr.po (modified) (4 diffs)
-
languages/template.pot (modified) (4 diffs)
-
languages/zh_CN.mo (modified) (previous)
-
languages/zh_CN.po (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
wepop.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wepop/trunk/includes/config.php
r3319334 r3321653 35 35 $options = array( 36 36 'show_alt_text' => isset($_POST['show_alt_text']), 37 'gallery_only_grouping' => isset($_POST['gallery_only_grouping']), 37 'gallery_only_grouping' => isset($_POST['gallery_only_grouping']), // 旧設定(将来的に廃止) 38 38 'language' => sanitize_text_field($_POST['language']), 39 'group_mode' => sanitize_text_field($_POST['group_mode']), 39 40 ); 40 41 … … 56 57 'show_alt_text' => false, 57 58 'gallery_only_grouping' => false, 58 'language' => 'ja' 59 'language' => 'ja', 60 'group_mode' => 'gallery', 59 61 ); 60 62 … … 71 73 <?php wp_nonce_field('wedok_pop_settings_nonce', 'wedok_pop_nonce'); ?> 72 74 <table class="form-table"> 75 76 <!-- ① 代替テキストの表示 --> 73 77 <tr> 74 78 <th scope="row"><?php esc_html_e('Show Alt Text', 'wepop'); ?></th> … … 80 84 </td> 81 85 </tr> 86 87 <!-- ② グループ化モードの設定 --> 82 88 <tr> 83 <th scope="row"><?php esc_html_e(' Gallery Only Grouping', 'wepop'); ?></th>89 <th scope="row"><?php esc_html_e('Image Grouping Mode', 'wepop'); ?></th> 84 90 <td> 85 91 <label> 86 <input type="checkbox" name="gallery_only_grouping" <?php checked($options['gallery_only_grouping'], true); ?>> 87 <?php esc_html_e('Group only WordPress gallery images', 'wepop'); ?> 92 <input type="radio" name="group_mode" value="gallery" <?php checked($options['group_mode'], 'gallery'); ?>> 93 <strong><?php _e('Group only gallery images (recommended)', 'wepop'); ?></strong><br> 94 <small><?php _e('Only images inside WordPress gallery blocks will be grouped into slideshows. Each gallery will be grouped separately.', 'wepop'); ?></small> 95 </label><br><br> 96 97 <label> 98 <input type="radio" name="group_mode" value="all" <?php checked($options['group_mode'], 'all'); ?>> 99 <strong><?php _e('Group all images in the post', 'wepop'); ?></strong><br> 100 <small><?php _e('All images (both standalone and gallery) in the post will be grouped into one slideshow.', 'wepop'); ?></small> 101 </label><br><br> 102 103 <label> 104 <input type="radio" name="group_mode" value="none" <?php checked($options['group_mode'], 'none'); ?>> 105 <strong><?php _e('No grouping', 'wepop'); ?></strong><br> 106 <small><?php _e('Each image will open individually without slideshow grouping.', 'wepop'); ?></small> 88 107 </label> 89 108 </td> 90 109 </tr> 110 111 <!-- ③ 言語設定 --> 91 112 <tr> 92 113 <th scope="row"><?php esc_html_e('Language', 'wepop'); ?></th> … … 102 123 </td> 103 124 </tr> 125 104 126 </table> 105 127 <p class="submit"> -
wepop/trunk/js/popup.js
r3319334 r3321653 1 document.addEventListener('DOMContentLoaded', function () {1 document.addEventListener('DOMContentLoaded', function () { 2 2 const images = document.querySelectorAll('a[data-wepop]'); 3 3 images.forEach(image => { … … 9 9 event.preventDefault(); 10 10 const clickedImage = event.currentTarget; 11 const group = clickedImage.getAttribute('data-group'); 12 let imageUrls; 13 let currentIndex; 11 const groupMode = (typeof wedokPopSettings !== 'undefined' && wedokPopSettings.groupMode) ? wedokPopSettings.groupMode : 'gallery'; 14 12 15 if (group) { 16 const groupImages = document.querySelectorAll(`a[data-wepop][data-group="${group}"]`); 17 imageUrls = Array.from(groupImages).map(img => img.href); 13 let imageUrls = []; 14 let currentIndex = 0; 15 16 if (groupMode === 'none') { 17 imageUrls = [clickedImage.href]; 18 19 } else if (groupMode === 'all') { 20 const allImages = document.querySelectorAll('a[data-wepop]'); 21 imageUrls = Array.from(allImages).map(img => img.href); 18 22 currentIndex = imageUrls.indexOf(clickedImage.href); 19 } else { 20 imageUrls = [clickedImage.href]; 21 currentIndex = 0; 23 24 } else if (groupMode === 'gallery') { 25 const galleryFigure = clickedImage.closest('.wp-block-gallery'); 26 if (galleryFigure) { 27 const galleryImages = galleryFigure.querySelectorAll('a[data-wepop]'); 28 imageUrls = Array.from(galleryImages).map(img => img.href); 29 currentIndex = imageUrls.indexOf(clickedImage.href); 30 } else { 31 imageUrls = [clickedImage.href]; 32 } 22 33 } 23 34 24 35 showWepop(imageUrls, currentIndex); 25 36 } … … 28 39 const overlay = document.createElement('div'); 29 40 overlay.className = 'wepop-overlay'; 30 41 31 42 const content = document.createElement('div'); 32 43 content.className = 'wepop-content'; 33 44 34 45 const imgContainer = document.createElement('div'); 35 46 imgContainer.className = 'wepop-img-container'; 36 47 37 48 const img = document.createElement('img'); 38 49 img.className = 'wepop-img'; 39 50 img.src = imageUrls[currentIndex]; 40 51 img.alt = ''; 41 52 42 53 imgContainer.appendChild(img); 43 54 content.appendChild(imgContainer); 44 55 45 56 const closeBtn = document.createElement('button'); 46 57 closeBtn.className = 'wepop-close'; 47 58 closeBtn.innerHTML = '×'; 48 59 closeBtn.addEventListener('click', closeWepop); 49 60 50 61 overlay.appendChild(content); 51 62 overlay.appendChild(closeBtn); 52 63 53 64 if (imageUrls.length > 1) { 54 65 const prevBtn = document.createElement('button'); 55 66 prevBtn.className = 'wepop-prev'; 56 67 prevBtn.addEventListener('click', () => changeImage(-1)); 57 68 58 69 const nextBtn = document.createElement('button'); 59 70 nextBtn.className = 'wepop-next'; 60 71 nextBtn.addEventListener('click', () => changeImage(1)); 61 72 62 73 overlay.appendChild(prevBtn); 63 74 overlay.appendChild(nextBtn); 64 75 } 65 76 66 77 document.body.appendChild(overlay); 67 78 68 79 setTimeout(() => { 69 80 overlay.classList.add('open'); … … 81 92 } 82 93 }); 83 94 84 95 function closeWepop() { 85 96 overlay.classList.remove('open'); … … 87 98 document.body.removeChild(overlay); 88 99 }, 300); 100 document.removeEventListener('keydown', handleKeyPress); 89 101 } 90 102 91 103 function changeImage(direction) { 92 104 const currentImg = imgContainer.querySelector('.wepop-img'); 93 105 const nextIndex = (currentIndex + direction + imageUrls.length) % imageUrls.length; 94 106 95 107 const nextImg = document.createElement('img'); 96 108 nextImg.className = 'wepop-img wepop-img-next'; … … 98 110 nextImg.alt = ''; 99 111 nextImg.style.transform = `translateX(${direction > 0 ? '100%' : '-100%'})`; 100 112 101 113 imgContainer.appendChild(nextImg); 102 103 // Force a reflow104 114 void nextImg.offsetWidth; 105 115 … … 128 138 } 129 139 } 130 140 131 141 if (typeof wedokPopSettings !== 'undefined' && wedokPopSettings.showAltText) { 132 142 const altTextElement = document.createElement('div'); … … 136 146 content.appendChild(altTextElement); 137 147 } 138 148 139 149 document.addEventListener('keydown', handleKeyPress); 140 150 141 151 function handleKeyPress(e) { 142 152 if (e.key === 'Escape') { … … 149 159 } 150 160 } 151 -
wepop/trunk/languages/de.po
r3319334 r3321653 1 #, fuzzy 1 2 msgid "" 2 3 msgstr "" 3 4 "Project-Id-Version: WePOP 1.5\n" 4 "POT-Creation-Date: \n" 5 "PO-Revision-Date: \n" 5 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wepop\n" 6 "POT-Creation-Date: 2025-07-03 16:25+0900\n" 7 "PO-Revision-Date: 2025-07-03 17:12+0900\n" 6 8 "Last-Translator: \n" 7 9 "Language-Team: \n" … … 10 12 "Content-Type: text/plain; charset=UTF-8\n" 11 13 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.5\n" 14 "Plural-Forms: nplurals=2; plural=(n != 1);\n" 15 "X-Generator: Poedit 3.6\n" 13 16 14 17 msgid "WePOP Settings" … … 19 22 20 23 msgid "Show Alt Text" 21 msgstr "Alt -Text anzeigen"24 msgstr "Alternativtext anzeigen" 22 25 23 26 msgid "Display alt text below images" 24 msgstr "Alt-Text unter den Bildern anzeigen" 25 26 msgid "Gallery Only Grouping" 27 msgstr "Nur Galerie gruppieren" 28 29 msgid "Group only WordPress gallery images" 30 msgstr "Nur WordPress-Galeriebilder gruppieren" 31 32 msgid "Animation Type" 33 msgstr "Animationstyp" 34 35 msgid "Scale" 36 msgstr "Skalieren" 37 38 msgid "Fade" 39 msgstr "Verblassen" 40 41 msgid "Slide" 42 msgstr "Gleiten" 27 msgstr "Alternativtext unter Bildern anzeigen" 43 28 44 29 msgid "Language" … … 56 41 msgid "Invalid request." 57 42 msgstr "Ungültige Anfrage." 43 44 msgid "Image Grouping Mode" 45 msgstr "Bildgruppierungsmodus" 46 47 msgid "Group only gallery images (recommended)" 48 msgstr "Nur Galerie-Bilder gruppieren (empfohlen)" 49 50 msgid "" 51 "Only images inside WordPress gallery blocks will be grouped into slideshows. " 52 "Each gallery will be grouped separately." 53 msgstr "" 54 "Nur Bilder innerhalb von WordPress-Galerieblöcken werden zu Diashows " 55 "gruppiert. Jede Galerie wird separat gruppiert." 56 57 msgid "Group all images in the post" 58 msgstr "Alle Bilder im Beitrag gruppieren" 59 60 msgid "" 61 "All images (both standalone and gallery) in the post will be grouped into " 62 "one slideshow." 63 msgstr "" 64 "Alle Bilder (einzeln und in Galerien) im Beitrag werden zu einer einzigen " 65 "Diashow gruppiert." 66 67 msgid "No grouping" 68 msgstr "Keine Gruppierung" 69 70 msgid "Disables all image grouping in the post. Each image opens individually." 71 msgstr "" 72 "Deaktiviert alle Bildgruppierungen im Beitrag. Jedes Bild wird einzeln " 73 "geöffnet." -
wepop/trunk/languages/es.po
r3319334 r3321653 1 #, fuzzy 1 2 msgid "" 2 3 msgstr "" 3 4 "Project-Id-Version: WePOP 1.5\n" 4 "POT-Creation-Date: \n" 5 "PO-Revision-Date: \n" 5 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wepop\n" 6 "POT-Creation-Date: 2025-07-03 16:25+0900\n" 7 "PO-Revision-Date: 2025-07-03 17:00+0900\n" 6 8 "Last-Translator: \n" 7 9 "Language-Team: \n" … … 10 12 "Content-Type: text/plain; charset=UTF-8\n" 11 13 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.5\n" 14 "Plural-Forms: nplurals=2; plural=(n != 1);\n" 15 "X-Generator: Poedit 3.6\n" 13 16 14 17 msgid "WePOP Settings" … … 16 19 17 20 msgid "Settings saved." 18 msgstr "Configuraci ones guardadas."21 msgstr "Configuración guardada." 19 22 20 23 msgid "Show Alt Text" … … 23 26 msgid "Display alt text below images" 24 27 msgstr "Mostrar texto alternativo debajo de las imágenes" 25 26 msgid "Gallery Only Grouping"27 msgstr "Agrupar solo galerías"28 29 msgid "Group only WordPress gallery images"30 msgstr "Agrupar solo imágenes de galería de WordPress"31 32 msgid "Animation Type"33 msgstr "Tipo de animación"34 35 msgid "Scale"36 msgstr "Escala"37 38 msgid "Fade"39 msgstr "Desvanecer"40 41 msgid "Slide"42 msgstr "Deslizar"43 28 44 29 msgid "Language" … … 56 41 msgid "Invalid request." 57 42 msgstr "Solicitud no válida." 43 44 msgid "Image Grouping Mode" 45 msgstr "Modo de agrupación de imágenes" 46 47 msgid "Group only gallery images (recommended)" 48 msgstr "Agrupar solo imágenes de la galería (recomendado)" 49 50 msgid "" 51 "Only images inside WordPress gallery blocks will be grouped into slideshows. " 52 "Each gallery will be grouped separately." 53 msgstr "" 54 "Solo las imágenes dentro de bloques de galería de WordPress se agruparán en " 55 "presentaciones. Cada galería se agrupará por separado." 56 57 msgid "Group all images in the post" 58 msgstr "Agrupar todas las imágenes en la entrada" 59 60 msgid "" 61 "All images (both standalone and gallery) in the post will be grouped into " 62 "one slideshow." 63 msgstr "" 64 "Todas las imágenes (independientes y en galerías) en la entrada se agruparán " 65 "en una sola presentación." 66 67 msgid "No grouping" 68 msgstr "Sin agrupación" 69 70 msgid "Disables all image grouping in the post. Each image opens individually." 71 msgstr "" 72 "Desactiva toda la agrupación de imágenes en la entrada. Cada imagen se " 73 "abrirá individualmente." -
wepop/trunk/languages/fr.po
r3319334 r3321653 1 #, fuzzy 1 2 msgid "" 2 3 msgstr "" 3 4 "Project-Id-Version: WePOP 1.5\n" 4 "POT-Creation-Date: \n" 5 "PO-Revision-Date: \n" 5 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wepop\n" 6 "POT-Creation-Date: 2025-07-03 16:25+0900\n" 7 "PO-Revision-Date: 2025-07-03 17:05+0900\n" 6 8 "Last-Translator: \n" 7 9 "Language-Team: \n" … … 10 12 "Content-Type: text/plain; charset=UTF-8\n" 11 13 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.5\n" 14 "Plural-Forms: nplurals=2; plural=(n > 1);\n" 15 "X-Generator: Poedit 3.6\n" 13 16 14 17 msgid "WePOP Settings" 15 msgstr "Paramètres WePOP"18 msgstr "Paramètres de WePOP" 16 19 17 20 msgid "Settings saved." … … 23 26 msgid "Display alt text below images" 24 27 msgstr "Afficher le texte alternatif sous les images" 25 26 msgid "Gallery Only Grouping"27 msgstr "Grouper uniquement les galeries"28 29 msgid "Group only WordPress gallery images"30 msgstr "Grouper uniquement les images des galeries WordPress"31 32 msgid "Animation Type"33 msgstr "Type d'animation"34 35 msgid "Scale"36 msgstr "Échelle"37 38 msgid "Fade"39 msgstr "Fondu"40 41 msgid "Slide"42 msgstr "Diapositive"43 28 44 29 msgid "Language" … … 56 41 msgid "Invalid request." 57 42 msgstr "Requête invalide." 43 44 msgid "Image Grouping Mode" 45 msgstr "Mode de regroupement des images" 46 47 msgid "Group only gallery images (recommended)" 48 msgstr "Regrouper uniquement les images des galeries (recommandé)" 49 50 msgid "" 51 "Only images inside WordPress gallery blocks will be grouped into slideshows. " 52 "Each gallery will be grouped separately." 53 msgstr "" 54 "Seules les images dans les blocs de galerie WordPress seront regroupées en " 55 "diaporamas. Chaque galerie sera regroupée séparément." 56 57 msgid "Group all images in the post" 58 msgstr "Regrouper toutes les images de l’article" 59 60 msgid "" 61 "All images (both standalone and gallery) in the post will be grouped into " 62 "one slideshow." 63 msgstr "" 64 "Toutes les images (indépendantes et en galerie) de l’article seront " 65 "regroupées en un seul diaporama." 66 67 msgid "No grouping" 68 msgstr "Aucun regroupement" 69 70 msgid "Disables all image grouping in the post. Each image opens individually." 71 msgstr "" 72 "Désactive tout regroupement d’images dans l’article. Chaque image s’ouvrira " 73 "individuellement." -
wepop/trunk/languages/template.pot
r3319334 r3321653 1 #, fuzzy 1 2 msgid "" 2 3 msgstr "" 3 4 "Project-Id-Version: WePOP 1.5\n" 4 5 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wepop\n" 5 "POT-Creation-Date: 202 4-01-23 12:00+0000\n"6 "PO-Revision-Date: 202 4-01-23 12:00+0000\n"7 "La nguage: \n"6 "POT-Creation-Date: 2025-07-03 16:25+0900\n" 7 "PO-Revision-Date: 2025-07-03 16:45+0900\n" 8 "Last-Translator: \n" 8 9 "Language-Team: \n" 9 10 "MIME-Version: 1.0\n" … … 11 12 "Content-Transfer-Encoding: 8bit\n" 12 13 "Plural-Forms: nplurals=1; plural=0;\n" 14 "X-Generator: Poedit 3.6\n" 13 15 14 16 msgid "WePOP Settings" … … 22 24 23 25 msgid "Display alt text below images" 24 msgstr ""25 26 msgid "Gallery Only Grouping"27 msgstr ""28 29 msgid "Group only WordPress gallery images"30 msgstr ""31 32 msgid "Animation Type"33 msgstr ""34 35 msgid "Scale"36 msgstr ""37 38 msgid "Fade"39 msgstr ""40 41 msgid "Slide"42 26 msgstr "" 43 27 … … 56 40 msgid "Invalid request." 57 41 msgstr "" 42 43 msgid "Image Grouping Mode" 44 msgstr "" 45 46 msgid "Group only gallery images (recommended)" 47 msgstr "" 48 49 msgid "Only images inside WordPress gallery blocks will be grouped into slideshows. Each gallery will be grouped separately." 50 msgstr "" 51 52 msgid "Group all images in the post" 53 msgstr "" 54 55 msgid "All images (both standalone and gallery) in the post will be grouped into one slideshow." 56 msgstr "" 57 58 msgid "No grouping" 59 msgstr "" 60 61 msgid "Disables all image grouping in the post. Each image opens individually." 62 msgstr "" -
wepop/trunk/languages/zh_CN.po
r3319334 r3321653 1 #, fuzzy 1 2 msgid "" 2 3 msgstr "" 3 4 "Project-Id-Version: WePOP 1.5\n" 4 "POT-Creation-Date: \n" 5 "PO-Revision-Date: \n" 5 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wepop\n" 6 "POT-Creation-Date: 2025-07-03 16:25+0900\n" 7 "PO-Revision-Date: 2025-07-03 17:16+0900\n" 6 8 "Last-Translator: \n" 7 9 "Language-Team: \n" … … 10 12 "Content-Type: text/plain; charset=UTF-8\n" 11 13 "Content-Transfer-Encoding: 8bit\n" 12 "X-Generator: Poedit 3.5\n" 14 "Plural-Forms: nplurals=1; plural=0;\n" 15 "X-Generator: Poedit 3.6\n" 13 16 14 17 msgid "WePOP Settings" … … 22 25 23 26 msgid "Display alt text below images" 24 msgstr "在图像下方显示替代文本" 25 26 msgid "Gallery Only Grouping" 27 msgstr "仅分组图库" 28 29 msgid "Group only WordPress gallery images" 30 msgstr "仅分组 WordPress 图库图像" 31 32 msgid "Animation Type" 33 msgstr "动画类型" 34 35 msgid "Scale" 36 msgstr "缩放" 37 38 msgid "Fade" 39 msgstr "淡出" 40 41 msgid "Slide" 42 msgstr "滑动" 27 msgstr "在图片下方显示替代文本" 43 28 44 29 msgid "Language" … … 55 40 56 41 msgid "Invalid request." 57 msgstr "无效请求。" 42 msgstr "无效的请求。" 43 44 msgid "Image Grouping Mode" 45 msgstr "图片分组模式" 46 47 msgid "Group only gallery images (recommended)" 48 msgstr "仅分组图库中的图片(推荐)" 49 50 msgid "" 51 "Only images inside WordPress gallery blocks will be grouped into slideshows. " 52 "Each gallery will be grouped separately." 53 msgstr "只有 WordPress 图库模块中的图片会被分组为幻灯片。每个图库将分别分组。" 54 55 msgid "Group all images in the post" 56 msgstr "分组文章中的所有图片" 57 58 msgid "" 59 "All images (both standalone and gallery) in the post will be grouped into " 60 "one slideshow." 61 msgstr "文章中的所有图片(包括单独图片和图库)将被分组为一个幻灯片。" 62 63 msgid "No grouping" 64 msgstr "不分组" 65 66 msgid "Disables all image grouping in the post. Each image opens individually." 67 msgstr "禁用文章中的所有图片分组。每张图片将单独打开。" -
wepop/trunk/readme.txt
r3319461 r3321653 5 5 Tested up to: 6.8.1 6 6 Requires PHP: 7.0 7 Stable tag: 1.5. 27 Stable tag: 1.5.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
wepop/trunk/wepop.php
r3319334 r3321653 4 4 Plugin URI: https://wedok.jp/tools/wepop/ 5 5 Description: Simple image popup and gallery plugin for WordPress, built with pure JavaScript and no dependencies. 6 Version: 1.5. 26 Version: 1.5.3 7 7 Author: WeDOK Konta 8 8 Author URI: https://wedok.jp … … 23 23 $options = get_option('wedok_pop_settings', array()); 24 24 $language = isset($options['language']) ? $options['language'] : 'ja'; 25 load_textdomain('wepop', plugin_dir_path(__FILE__) . 'languages/' . $language . '.mo'); 25 26 // ファイル名マッピング(ja → ja_JP、それ以外はそのまま) 27 $map = array( 28 'ja' => 'ja_JP', 29 'en' => 'en', 30 'fr' => 'fr', 31 'de' => 'de', 32 'es' => 'es', 33 'zh_CN' => 'zh_CN', 34 ); 35 36 $mo_file = isset($map[$language]) ? $map[$language] : 'ja_JP'; 37 38 load_textdomain('wepop', plugin_dir_path(__FILE__) . 'languages/' . $mo_file . '.mo'); 26 39 } 27 40 add_action('init', 'wedok_pop_load_textdomain'); 28 41 42 // デフォルトオプション登録 29 43 register_activation_hook(__FILE__, 'wedok_pop_activate'); 30 44 function wedok_pop_activate() { 31 45 $default_options = array( 32 46 'show_alt_text' => false, 33 'g allery_only_grouping' => false,47 'group_mode' => 'gallery', 34 48 'language' => 'ja' 35 49 ); … … 39 53 } 40 54 55 // 画像に data-wepop 属性を付与 41 56 function wedok_pop_add_attribute($content) { 42 57 $options = get_option('wedok_pop_settings', array()); 43 $g alleryOnlyGrouping = !empty($options['gallery_only_grouping']);58 $groupMode = isset($options['group_mode']) ? $options['group_mode'] : 'gallery'; 44 59 45 if ( !$galleryOnlyGrouping) {60 if ($groupMode === 'all') { 46 61 $groupId = uniqid('group-'); 47 62 $content = preg_replace_callback( 48 '/<a\s+[^>]*href=(\"|\')(.*?\.(jpg|jpeg|png|gif ))\1[^>]*>/i',63 '/<a\s+[^>]*href=(\"|\')(.*?\.(jpg|jpeg|png|gif|webp))\1[^>]*>/i', 49 64 function ($matches) use ($groupId) { 50 65 if (strpos($matches[0], 'data-wepop') === false) { … … 55 70 $content 56 71 ); 57 } else {72 } elseif ($groupMode === 'none') { 58 73 $content = preg_replace_callback( 59 '/<a\s+[^>]*href=(\"|\')(.*?\.(jpg|jpeg|png|gif ))\1[^>]*>/i',74 '/<a\s+[^>]*href=(\"|\')(.*?\.(jpg|jpeg|png|gif|webp))\1[^>]*>/i', 60 75 function ($matches) { 61 76 if (strpos($matches[0], 'data-wepop') === false) { … … 66 81 $content 67 82 ); 83 } elseif ($groupMode === 'gallery') { 84 // ギャラリー以外(=.wp-block-gallery で囲まれていない)画像リンクにのみ data-wepop を付与 85 $content = preg_replace_callback( 86 '/(<a\s+[^>]*href=(\"|\')(.*?\.(jpg|jpeg|png|gif|webp))\2[^>]*>)/i', 87 function ($matches) { 88 $anchor = $matches[1]; 89 if (strpos($anchor, 'data-wepop') !== false) { 90 return $anchor; 91 } 92 // ギャラリー内の画像を除外する(.wp-block-gallery に囲まれていないもの) 93 if (!preg_match('/<figure[^>]*class=\"[^"]*wp-block-gallery[^"]*\"[^>]*>.*?' . preg_quote($anchor, '/') . '.*?<\/figure>/is', $anchor)) { 94 return str_replace('<a ', '<a data-wepop ', $anchor); 95 } 96 return $anchor; 97 }, 98 $content 99 ); 68 100 } 101 69 102 return $content; 70 103 } 71 104 add_filter('the_content', 'wedok_pop_add_attribute'); 72 105 106 // Gutenbergギャラリーへの処理 73 107 function wedok_pop_process_gutenberg_gallery($block_content, $block) { 74 108 if ($block['blockName'] !== 'core/gallery') { … … 77 111 78 112 $options = get_option('wedok_pop_settings', array()); 79 $g alleryOnlyGrouping = !empty($options['gallery_only_grouping']);113 $groupMode = isset($options['group_mode']) ? $options['group_mode'] : 'gallery'; 80 114 81 if ($g alleryOnlyGrouping) {115 if ($groupMode === 'gallery') { 82 116 $groupId = uniqid('gallery-'); 83 117 $block_content = preg_replace( … … 86 120 $block_content 87 121 ); 88 } else {122 } elseif ($groupMode === 'all' || $groupMode === 'none') { 89 123 $block_content = preg_replace( 90 124 '/<a\s+(?![^>]*data-wepop)/i', … … 98 132 add_filter('render_block', 'wedok_pop_process_gutenberg_gallery', 10, 2); 99 133 134 // [gallery] ショートコード対応 100 135 function wedok_pop_filter_gallery_shortcode($output, $attr, $instance) { 101 136 $options = get_option('wedok_pop_settings', array()); 102 $g alleryOnlyGrouping = !empty($options['gallery_only_grouping']);137 $groupMode = isset($options['group_mode']) ? $options['group_mode'] : 'gallery'; 103 138 104 if ($g alleryOnlyGrouping) {139 if ($groupMode === 'gallery') { 105 140 $groupId = uniqid('gallery-'); 106 141 $output = preg_replace( … … 109 144 $output 110 145 ); 111 } else {146 } elseif ($groupMode === 'all' || $groupMode === 'none') { 112 147 $output = preg_replace( 113 148 '/<a\s+(?![^>]*data-wepop)/i', … … 116 151 ); 117 152 } 153 118 154 return $output; 119 155 } 120 156 add_filter('post_gallery', 'wedok_pop_filter_gallery_shortcode', 10, 3); 121 157 158 // スクリプトとCSS読み込み 122 159 function wedok_pop_enqueue_scripts() { 123 160 if (wedok_pop_should_apply()) { … … 128 165 wp_localize_script('wepop-lightbox', 'wedokPopSettings', array( 129 166 'showAltText' => !empty($options['show_alt_text']), 130 'g alleryOnlyGrouping' => !empty($options['gallery_only_grouping']),167 'groupMode' => isset($options['group_mode']) ? $options['group_mode'] : 'gallery', 131 168 'language' => isset($options['language']) ? $options['language'] : 'ja', 132 169 )); … … 135 172 add_action('wp_enqueue_scripts', 'wedok_pop_enqueue_scripts'); 136 173 174 // CSS出力 137 175 function wedok_pop_print_styles() { 138 176 if (wp_style_is('wepop-style', 'registered')) { … … 142 180 add_action('wp_footer', 'wedok_pop_print_styles'); 143 181 182 // 適用条件:投稿・固定ページのみ 144 183 function wedok_pop_should_apply() { 145 184 if (is_front_page() || is_home()) {
Note: See TracChangeset
for help on using the changeset viewer.