Changeset 3378879
- Timestamp:
- 10/15/2025 12:21:05 PM (6 months ago)
- Location:
- shutterpress-gallery
- Files:
-
- 12 edited
- 1 copied
-
tags/1.7.7 (copied) (copied from shutterpress-gallery/trunk)
-
tags/1.7.7/README.txt (modified) (2 diffs)
-
tags/1.7.7/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block-render.php (modified) (4 diffs)
-
tags/1.7.7/shutterpress-gallery.php (modified) (2 diffs)
-
tags/1.7.7/src/admin/Shutterpress_Gallery_Admin.php (modified) (1 diff)
-
tags/1.7.7/src/shutterpress-gallery-block/shutterpress-gallery-block-render.php (modified) (4 diffs)
-
tags/1.7.7/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block-render.php (modified) (4 diffs)
-
trunk/shutterpress-gallery.php (modified) (2 diffs)
-
trunk/src/admin/Shutterpress_Gallery_Admin.php (modified) (1 diff)
-
trunk/src/shutterpress-gallery-block/shutterpress-gallery-block-render.php (modified) (4 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shutterpress-gallery/tags/1.7.7/README.txt
r3378680 r3378879 6 6 Tested up to: 6.8 7 7 Requires PHP: 8.0 8 Stable tag: 1.7. 68 Stable tag: 1.7.7 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 119 119 120 120 == Changelog == 121 122 = 1.7.7 = 123 124 * Fix - Gallery Block not rendering correctly 121 125 122 126 = 1.7.6 = -
shutterpress-gallery/tags/1.7.7/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block-render.php
r3378680 r3378879 19 19 $gallery_attributes = [ 20 20 'gallery_id' => isset($attributes['galleryId']) && intval($attributes['galleryId']) !== 0 ? intval($attributes['galleryId']) : '', 21 22 'post_id' => isset($attributes['postId']) ? intval($attributes['postId']) : (isset($_GET['post']) ? intval($_GET['post']) : (get_the_ID() ? intval(get_the_ID()) : 0)), 21 23 'use_lightbox' => isset($attributes['useLightbox']) ? filter_var($attributes['useLightbox'], FILTER_VALIDATE_BOOLEAN) : filter_var($defaults['use_lightbox'], FILTER_VALIDATE_BOOLEAN), 22 24 'layout' => isset($attributes['galleryLayout']) ? sanitize_text_field($attributes['galleryLayout']) : sanitize_text_field($defaults['layout']), … … 39 41 40 42 $gallery_attributes = is_array($gallery_attributes) ? $gallery_attributes : []; 41 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : 0;43 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : -1; 42 44 43 45 if ($gallery_id === -1) { 44 46 45 $gallery_id = (int) get_the_ID(); 46 $gallery_attributes['gallery_id'] = $gallery_id; 47 $context_post_id = 0; 48 49 if (!empty($gallery_attributes['post_id'])) { 50 $context_post_id = (int) $gallery_attributes['post_id']; 51 } 52 53 if ($context_post_id <= 0 && isset($_GET['post'])) { 54 $context_post_id = (int) $_GET['post']; 55 } 56 57 if ($context_post_id <= 0 && isset($GLOBALS['post']) && $GLOBALS['post'] instanceof \WP_Post) { 58 $context_post_id = (int) $GLOBALS['post']->ID; 59 } 60 61 if ($context_post_id <= 0) { 62 $context_post_id = (int) get_the_ID(); 63 } 64 65 if ($context_post_id > 0) { 66 $gallery_id = $context_post_id; 67 $gallery_attributes['gallery_id'] = $gallery_id; 68 69 $linked_gallery_id = 0; 70 $candidate_meta_keys = ['sp_gallery_id', '_sp_gallery_id', 'shutterpress_gallery_id', '_shutterpress_gallery_id', 'sp_post_gallery_id', '_sp_post_gallery_id']; 71 foreach ($candidate_meta_keys as $mk) { 72 $val = (int) get_post_meta($context_post_id, $mk, true); 73 if ($val > 0) { 74 $linked_gallery_id = $val; 75 break; 76 } 77 } 78 79 if ($linked_gallery_id > 0) { 80 $gallery_id = $linked_gallery_id; 81 $gallery_attributes['gallery_id'] = $gallery_id; 82 $gallery_attributes['post_id'] = $context_post_id; 83 } else { 84 85 $gallery_attributes['post_id'] = $context_post_id; 86 } 87 } 47 88 } 48 89 49 if ($gallery_id <= 0 ) {90 if ($gallery_id <= 0 && empty($gallery_attributes['post_id'])) { 50 91 return '<div ' . \get_block_wrapper_attributes() . '></div>'; 51 92 } … … 54 95 55 96 if (!$renderer) { 56 if (!isset($renderers[$gallery_id])) { 57 $renderers[$gallery_id] = new Shutterpress_Gallery_Gallery($gallery_id); 97 $cache_key = (int) ($gallery_id > 0 ? $gallery_id : $gallery_attributes['post_id'] ?? 0); 98 if ($cache_key <= 0) { 99 $cache_key = 0; 58 100 } 59 $renderer = $renderers[$gallery_id]; 101 if (!isset($renderers[$cache_key])) { 102 103 $renderers[$cache_key] = new Shutterpress_Gallery_Gallery($gallery_id > 0 ? $gallery_id : 0); 104 } 105 $renderer = $renderers[$cache_key]; 60 106 } 61 107 … … 64 110 $output = '<div ' . \get_block_wrapper_attributes() . '>'; 65 111 66 if (method_exists($renderer, 'get_gallery_images') && !empty($renderer->get_gallery_images())) { 67 if (defined('REST_REQUEST') && REST_REQUEST && 'edit' === $_GET['context']) { 68 $gallery_attributes['infinite_scroll'] = '0'; 69 $gallery_attributes['use_lightbox'] = '0'; 70 } 112 if (defined('REST_REQUEST') && REST_REQUEST && isset($_GET['context']) && 'edit' === $_GET['context']) { 113 $gallery_attributes['infinite_scroll'] = '0'; 114 $gallery_attributes['use_lightbox'] = '0'; 115 } 71 116 72 if (method_exists($renderer, 'set_attributes')) {73 $renderer->set_attributes($gallery_attributes);74 }117 if (method_exists($renderer, 'set_attributes')) { 118 $renderer->set_attributes($gallery_attributes); 119 } 75 120 121 if (method_exists($renderer, 'set_post_id') && !empty($gallery_attributes['post_id'])) { 122 $renderer->set_post_id((int) $gallery_attributes['post_id']); 123 } 124 if (method_exists($renderer, 'set_is_post_gallery') && isset($linked_gallery_id) && (int) $linked_gallery_id === 0 && !empty($gallery_attributes['post_id'])) { 125 $renderer->set_is_post_gallery(true); 126 } 127 128 $has_images = method_exists($renderer, 'get_gallery_images') ? (array) $renderer->get_gallery_images() : []; 129 130 if (!empty($has_images)) { 76 131 if (method_exists($renderer, 'get_buttons')) { 77 132 $output .= $renderer->get_buttons(); -
shutterpress-gallery/tags/1.7.7/shutterpress-gallery.php
r3378680 r3378879 11 11 * Plugin URI: https://shutterpress.io 12 12 * Description: WordPress photo gallery plugin for photographers and creatives. Build fast, responsive image galleries with Masonry, Justified, and Grid layouts, lightbox support, and Infinite Scroll. 13 * Version: 1.7. 613 * Version: 1.7.7 14 14 * Author: ShutterPress 15 15 * Author URI: https://shutterpress.io … … 27 27 * Current plugin version. 28 28 */ 29 define('SHUTTERPRESS_GALLERY_VERSION', '1.7. 6');29 define('SHUTTERPRESS_GALLERY_VERSION', '1.7.7'); 30 30 31 31 define('SP_GALLERY_DIR', plugin_dir_path(__FILE__)); -
shutterpress-gallery/tags/1.7.7/src/admin/Shutterpress_Gallery_Admin.php
r3378680 r3378879 105 105 } 106 106 107 $should_load = true;108 if (function_exists('wp_should_load_block_editor_scripts_and_styles')) {109 $should_load = wp_should_load_block_editor_scripts_and_styles();110 }111 if (!$should_load && !defined('SHUTTERPRESS_TESTING')) {112 return;113 }114 115 107 wp_enqueue_style($this->plugin_name . '-public', SP_GALLERY_URL . 'includes/css/shutterpress-gallery-public.css', [], $this->version, 'all'); 116 108 117 109 $vendor_base = SP_GALLERY_URL . 'includes/js/'; 118 110 119 111 wp_register_script('isotope', $vendor_base . 'isotope.pkgd.min.js', ['jquery'], '3.0.0', false); 120 112 -
shutterpress-gallery/tags/1.7.7/src/shutterpress-gallery-block/shutterpress-gallery-block-render.php
r3378680 r3378879 19 19 $gallery_attributes = [ 20 20 'gallery_id' => isset($attributes['galleryId']) && intval($attributes['galleryId']) !== 0 ? intval($attributes['galleryId']) : '', 21 22 'post_id' => isset($attributes['postId']) ? intval($attributes['postId']) : (isset($_GET['post']) ? intval($_GET['post']) : (get_the_ID() ? intval(get_the_ID()) : 0)), 21 23 'use_lightbox' => isset($attributes['useLightbox']) ? filter_var($attributes['useLightbox'], FILTER_VALIDATE_BOOLEAN) : filter_var($defaults['use_lightbox'], FILTER_VALIDATE_BOOLEAN), 22 24 'layout' => isset($attributes['galleryLayout']) ? sanitize_text_field($attributes['galleryLayout']) : sanitize_text_field($defaults['layout']), … … 39 41 40 42 $gallery_attributes = is_array($gallery_attributes) ? $gallery_attributes : []; 41 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : 0;43 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : -1; 42 44 43 45 if ($gallery_id === -1) { 44 46 45 $gallery_id = (int) get_the_ID(); 46 $gallery_attributes['gallery_id'] = $gallery_id; 47 $context_post_id = 0; 48 49 if (!empty($gallery_attributes['post_id'])) { 50 $context_post_id = (int) $gallery_attributes['post_id']; 51 } 52 53 if ($context_post_id <= 0 && isset($_GET['post'])) { 54 $context_post_id = (int) $_GET['post']; 55 } 56 57 if ($context_post_id <= 0 && isset($GLOBALS['post']) && $GLOBALS['post'] instanceof \WP_Post) { 58 $context_post_id = (int) $GLOBALS['post']->ID; 59 } 60 61 if ($context_post_id <= 0) { 62 $context_post_id = (int) get_the_ID(); 63 } 64 65 if ($context_post_id > 0) { 66 $gallery_id = $context_post_id; 67 $gallery_attributes['gallery_id'] = $gallery_id; 68 69 $linked_gallery_id = 0; 70 $candidate_meta_keys = ['sp_gallery_id', '_sp_gallery_id', 'shutterpress_gallery_id', '_shutterpress_gallery_id', 'sp_post_gallery_id', '_sp_post_gallery_id']; 71 foreach ($candidate_meta_keys as $mk) { 72 $val = (int) get_post_meta($context_post_id, $mk, true); 73 if ($val > 0) { 74 $linked_gallery_id = $val; 75 break; 76 } 77 } 78 79 if ($linked_gallery_id > 0) { 80 $gallery_id = $linked_gallery_id; 81 $gallery_attributes['gallery_id'] = $gallery_id; 82 $gallery_attributes['post_id'] = $context_post_id; 83 } else { 84 85 $gallery_attributes['post_id'] = $context_post_id; 86 } 87 } 47 88 } 48 89 49 if ($gallery_id <= 0 ) {90 if ($gallery_id <= 0 && empty($gallery_attributes['post_id'])) { 50 91 return '<div ' . \get_block_wrapper_attributes() . '></div>'; 51 92 } … … 54 95 55 96 if (!$renderer) { 56 if (!isset($renderers[$gallery_id])) { 57 $renderers[$gallery_id] = new Shutterpress_Gallery_Gallery($gallery_id); 97 $cache_key = (int) ($gallery_id > 0 ? $gallery_id : $gallery_attributes['post_id'] ?? 0); 98 if ($cache_key <= 0) { 99 $cache_key = 0; 58 100 } 59 $renderer = $renderers[$gallery_id]; 101 if (!isset($renderers[$cache_key])) { 102 103 $renderers[$cache_key] = new Shutterpress_Gallery_Gallery($gallery_id > 0 ? $gallery_id : 0); 104 } 105 $renderer = $renderers[$cache_key]; 60 106 } 61 107 … … 64 110 $output = '<div ' . \get_block_wrapper_attributes() . '>'; 65 111 66 if (method_exists($renderer, 'get_gallery_images') && !empty($renderer->get_gallery_images())) { 67 if (defined('REST_REQUEST') && REST_REQUEST && 'edit' === $_GET['context']) { 68 $gallery_attributes['infinite_scroll'] = '0'; 69 $gallery_attributes['use_lightbox'] = '0'; 70 } 112 if (defined('REST_REQUEST') && REST_REQUEST && isset($_GET['context']) && 'edit' === $_GET['context']) { 113 $gallery_attributes['infinite_scroll'] = '0'; 114 $gallery_attributes['use_lightbox'] = '0'; 115 } 71 116 72 if (method_exists($renderer, 'set_attributes')) {73 $renderer->set_attributes($gallery_attributes);74 }117 if (method_exists($renderer, 'set_attributes')) { 118 $renderer->set_attributes($gallery_attributes); 119 } 75 120 121 if (method_exists($renderer, 'set_post_id') && !empty($gallery_attributes['post_id'])) { 122 $renderer->set_post_id((int) $gallery_attributes['post_id']); 123 } 124 if (method_exists($renderer, 'set_is_post_gallery') && isset($linked_gallery_id) && (int) $linked_gallery_id === 0 && !empty($gallery_attributes['post_id'])) { 125 $renderer->set_is_post_gallery(true); 126 } 127 128 $has_images = method_exists($renderer, 'get_gallery_images') ? (array) $renderer->get_gallery_images() : []; 129 130 if (!empty($has_images)) { 76 131 if (method_exists($renderer, 'get_buttons')) { 77 132 $output .= $renderer->get_buttons(); -
shutterpress-gallery/tags/1.7.7/vendor/composer/installed.php
r3378680 r3378879 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' ee154d9281e430a177064ec382dda47bc35fbef9',6 'reference' => '8a9aecb868d4d8701c7225e6220bc9f9a2e2e09e', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 35 35 'pretty_version' => 'dev-master', 36 36 'version' => 'dev-master', 37 'reference' => ' ee154d9281e430a177064ec382dda47bc35fbef9',37 'reference' => '8a9aecb868d4d8701c7225e6220bc9f9a2e2e09e', 38 38 'type' => 'wordpress-plugin', 39 39 'install_path' => __DIR__ . '/../../', -
shutterpress-gallery/trunk/README.txt
r3378680 r3378879 6 6 Tested up to: 6.8 7 7 Requires PHP: 8.0 8 Stable tag: 1.7. 68 Stable tag: 1.7.7 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 119 119 120 120 == Changelog == 121 122 = 1.7.7 = 123 124 * Fix - Gallery Block not rendering correctly 121 125 122 126 = 1.7.6 = -
shutterpress-gallery/trunk/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block-render.php
r3378680 r3378879 19 19 $gallery_attributes = [ 20 20 'gallery_id' => isset($attributes['galleryId']) && intval($attributes['galleryId']) !== 0 ? intval($attributes['galleryId']) : '', 21 22 'post_id' => isset($attributes['postId']) ? intval($attributes['postId']) : (isset($_GET['post']) ? intval($_GET['post']) : (get_the_ID() ? intval(get_the_ID()) : 0)), 21 23 'use_lightbox' => isset($attributes['useLightbox']) ? filter_var($attributes['useLightbox'], FILTER_VALIDATE_BOOLEAN) : filter_var($defaults['use_lightbox'], FILTER_VALIDATE_BOOLEAN), 22 24 'layout' => isset($attributes['galleryLayout']) ? sanitize_text_field($attributes['galleryLayout']) : sanitize_text_field($defaults['layout']), … … 39 41 40 42 $gallery_attributes = is_array($gallery_attributes) ? $gallery_attributes : []; 41 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : 0;43 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : -1; 42 44 43 45 if ($gallery_id === -1) { 44 46 45 $gallery_id = (int) get_the_ID(); 46 $gallery_attributes['gallery_id'] = $gallery_id; 47 $context_post_id = 0; 48 49 if (!empty($gallery_attributes['post_id'])) { 50 $context_post_id = (int) $gallery_attributes['post_id']; 51 } 52 53 if ($context_post_id <= 0 && isset($_GET['post'])) { 54 $context_post_id = (int) $_GET['post']; 55 } 56 57 if ($context_post_id <= 0 && isset($GLOBALS['post']) && $GLOBALS['post'] instanceof \WP_Post) { 58 $context_post_id = (int) $GLOBALS['post']->ID; 59 } 60 61 if ($context_post_id <= 0) { 62 $context_post_id = (int) get_the_ID(); 63 } 64 65 if ($context_post_id > 0) { 66 $gallery_id = $context_post_id; 67 $gallery_attributes['gallery_id'] = $gallery_id; 68 69 $linked_gallery_id = 0; 70 $candidate_meta_keys = ['sp_gallery_id', '_sp_gallery_id', 'shutterpress_gallery_id', '_shutterpress_gallery_id', 'sp_post_gallery_id', '_sp_post_gallery_id']; 71 foreach ($candidate_meta_keys as $mk) { 72 $val = (int) get_post_meta($context_post_id, $mk, true); 73 if ($val > 0) { 74 $linked_gallery_id = $val; 75 break; 76 } 77 } 78 79 if ($linked_gallery_id > 0) { 80 $gallery_id = $linked_gallery_id; 81 $gallery_attributes['gallery_id'] = $gallery_id; 82 $gallery_attributes['post_id'] = $context_post_id; 83 } else { 84 85 $gallery_attributes['post_id'] = $context_post_id; 86 } 87 } 47 88 } 48 89 49 if ($gallery_id <= 0 ) {90 if ($gallery_id <= 0 && empty($gallery_attributes['post_id'])) { 50 91 return '<div ' . \get_block_wrapper_attributes() . '></div>'; 51 92 } … … 54 95 55 96 if (!$renderer) { 56 if (!isset($renderers[$gallery_id])) { 57 $renderers[$gallery_id] = new Shutterpress_Gallery_Gallery($gallery_id); 97 $cache_key = (int) ($gallery_id > 0 ? $gallery_id : $gallery_attributes['post_id'] ?? 0); 98 if ($cache_key <= 0) { 99 $cache_key = 0; 58 100 } 59 $renderer = $renderers[$gallery_id]; 101 if (!isset($renderers[$cache_key])) { 102 103 $renderers[$cache_key] = new Shutterpress_Gallery_Gallery($gallery_id > 0 ? $gallery_id : 0); 104 } 105 $renderer = $renderers[$cache_key]; 60 106 } 61 107 … … 64 110 $output = '<div ' . \get_block_wrapper_attributes() . '>'; 65 111 66 if (method_exists($renderer, 'get_gallery_images') && !empty($renderer->get_gallery_images())) { 67 if (defined('REST_REQUEST') && REST_REQUEST && 'edit' === $_GET['context']) { 68 $gallery_attributes['infinite_scroll'] = '0'; 69 $gallery_attributes['use_lightbox'] = '0'; 70 } 112 if (defined('REST_REQUEST') && REST_REQUEST && isset($_GET['context']) && 'edit' === $_GET['context']) { 113 $gallery_attributes['infinite_scroll'] = '0'; 114 $gallery_attributes['use_lightbox'] = '0'; 115 } 71 116 72 if (method_exists($renderer, 'set_attributes')) {73 $renderer->set_attributes($gallery_attributes);74 }117 if (method_exists($renderer, 'set_attributes')) { 118 $renderer->set_attributes($gallery_attributes); 119 } 75 120 121 if (method_exists($renderer, 'set_post_id') && !empty($gallery_attributes['post_id'])) { 122 $renderer->set_post_id((int) $gallery_attributes['post_id']); 123 } 124 if (method_exists($renderer, 'set_is_post_gallery') && isset($linked_gallery_id) && (int) $linked_gallery_id === 0 && !empty($gallery_attributes['post_id'])) { 125 $renderer->set_is_post_gallery(true); 126 } 127 128 $has_images = method_exists($renderer, 'get_gallery_images') ? (array) $renderer->get_gallery_images() : []; 129 130 if (!empty($has_images)) { 76 131 if (method_exists($renderer, 'get_buttons')) { 77 132 $output .= $renderer->get_buttons(); -
shutterpress-gallery/trunk/shutterpress-gallery.php
r3378680 r3378879 11 11 * Plugin URI: https://shutterpress.io 12 12 * Description: WordPress photo gallery plugin for photographers and creatives. Build fast, responsive image galleries with Masonry, Justified, and Grid layouts, lightbox support, and Infinite Scroll. 13 * Version: 1.7. 613 * Version: 1.7.7 14 14 * Author: ShutterPress 15 15 * Author URI: https://shutterpress.io … … 27 27 * Current plugin version. 28 28 */ 29 define('SHUTTERPRESS_GALLERY_VERSION', '1.7. 6');29 define('SHUTTERPRESS_GALLERY_VERSION', '1.7.7'); 30 30 31 31 define('SP_GALLERY_DIR', plugin_dir_path(__FILE__)); -
shutterpress-gallery/trunk/src/admin/Shutterpress_Gallery_Admin.php
r3378680 r3378879 105 105 } 106 106 107 $should_load = true;108 if (function_exists('wp_should_load_block_editor_scripts_and_styles')) {109 $should_load = wp_should_load_block_editor_scripts_and_styles();110 }111 if (!$should_load && !defined('SHUTTERPRESS_TESTING')) {112 return;113 }114 115 107 wp_enqueue_style($this->plugin_name . '-public', SP_GALLERY_URL . 'includes/css/shutterpress-gallery-public.css', [], $this->version, 'all'); 116 108 117 109 $vendor_base = SP_GALLERY_URL . 'includes/js/'; 118 110 119 111 wp_register_script('isotope', $vendor_base . 'isotope.pkgd.min.js', ['jquery'], '3.0.0', false); 120 112 -
shutterpress-gallery/trunk/src/shutterpress-gallery-block/shutterpress-gallery-block-render.php
r3378680 r3378879 19 19 $gallery_attributes = [ 20 20 'gallery_id' => isset($attributes['galleryId']) && intval($attributes['galleryId']) !== 0 ? intval($attributes['galleryId']) : '', 21 22 'post_id' => isset($attributes['postId']) ? intval($attributes['postId']) : (isset($_GET['post']) ? intval($_GET['post']) : (get_the_ID() ? intval(get_the_ID()) : 0)), 21 23 'use_lightbox' => isset($attributes['useLightbox']) ? filter_var($attributes['useLightbox'], FILTER_VALIDATE_BOOLEAN) : filter_var($defaults['use_lightbox'], FILTER_VALIDATE_BOOLEAN), 22 24 'layout' => isset($attributes['galleryLayout']) ? sanitize_text_field($attributes['galleryLayout']) : sanitize_text_field($defaults['layout']), … … 39 41 40 42 $gallery_attributes = is_array($gallery_attributes) ? $gallery_attributes : []; 41 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : 0;43 $gallery_id = isset($gallery_attributes['gallery_id']) ? (int) $gallery_attributes['gallery_id'] : -1; 42 44 43 45 if ($gallery_id === -1) { 44 46 45 $gallery_id = (int) get_the_ID(); 46 $gallery_attributes['gallery_id'] = $gallery_id; 47 $context_post_id = 0; 48 49 if (!empty($gallery_attributes['post_id'])) { 50 $context_post_id = (int) $gallery_attributes['post_id']; 51 } 52 53 if ($context_post_id <= 0 && isset($_GET['post'])) { 54 $context_post_id = (int) $_GET['post']; 55 } 56 57 if ($context_post_id <= 0 && isset($GLOBALS['post']) && $GLOBALS['post'] instanceof \WP_Post) { 58 $context_post_id = (int) $GLOBALS['post']->ID; 59 } 60 61 if ($context_post_id <= 0) { 62 $context_post_id = (int) get_the_ID(); 63 } 64 65 if ($context_post_id > 0) { 66 $gallery_id = $context_post_id; 67 $gallery_attributes['gallery_id'] = $gallery_id; 68 69 $linked_gallery_id = 0; 70 $candidate_meta_keys = ['sp_gallery_id', '_sp_gallery_id', 'shutterpress_gallery_id', '_shutterpress_gallery_id', 'sp_post_gallery_id', '_sp_post_gallery_id']; 71 foreach ($candidate_meta_keys as $mk) { 72 $val = (int) get_post_meta($context_post_id, $mk, true); 73 if ($val > 0) { 74 $linked_gallery_id = $val; 75 break; 76 } 77 } 78 79 if ($linked_gallery_id > 0) { 80 $gallery_id = $linked_gallery_id; 81 $gallery_attributes['gallery_id'] = $gallery_id; 82 $gallery_attributes['post_id'] = $context_post_id; 83 } else { 84 85 $gallery_attributes['post_id'] = $context_post_id; 86 } 87 } 47 88 } 48 89 49 if ($gallery_id <= 0 ) {90 if ($gallery_id <= 0 && empty($gallery_attributes['post_id'])) { 50 91 return '<div ' . \get_block_wrapper_attributes() . '></div>'; 51 92 } … … 54 95 55 96 if (!$renderer) { 56 if (!isset($renderers[$gallery_id])) { 57 $renderers[$gallery_id] = new Shutterpress_Gallery_Gallery($gallery_id); 97 $cache_key = (int) ($gallery_id > 0 ? $gallery_id : $gallery_attributes['post_id'] ?? 0); 98 if ($cache_key <= 0) { 99 $cache_key = 0; 58 100 } 59 $renderer = $renderers[$gallery_id]; 101 if (!isset($renderers[$cache_key])) { 102 103 $renderers[$cache_key] = new Shutterpress_Gallery_Gallery($gallery_id > 0 ? $gallery_id : 0); 104 } 105 $renderer = $renderers[$cache_key]; 60 106 } 61 107 … … 64 110 $output = '<div ' . \get_block_wrapper_attributes() . '>'; 65 111 66 if (method_exists($renderer, 'get_gallery_images') && !empty($renderer->get_gallery_images())) { 67 if (defined('REST_REQUEST') && REST_REQUEST && 'edit' === $_GET['context']) { 68 $gallery_attributes['infinite_scroll'] = '0'; 69 $gallery_attributes['use_lightbox'] = '0'; 70 } 112 if (defined('REST_REQUEST') && REST_REQUEST && isset($_GET['context']) && 'edit' === $_GET['context']) { 113 $gallery_attributes['infinite_scroll'] = '0'; 114 $gallery_attributes['use_lightbox'] = '0'; 115 } 71 116 72 if (method_exists($renderer, 'set_attributes')) {73 $renderer->set_attributes($gallery_attributes);74 }117 if (method_exists($renderer, 'set_attributes')) { 118 $renderer->set_attributes($gallery_attributes); 119 } 75 120 121 if (method_exists($renderer, 'set_post_id') && !empty($gallery_attributes['post_id'])) { 122 $renderer->set_post_id((int) $gallery_attributes['post_id']); 123 } 124 if (method_exists($renderer, 'set_is_post_gallery') && isset($linked_gallery_id) && (int) $linked_gallery_id === 0 && !empty($gallery_attributes['post_id'])) { 125 $renderer->set_is_post_gallery(true); 126 } 127 128 $has_images = method_exists($renderer, 'get_gallery_images') ? (array) $renderer->get_gallery_images() : []; 129 130 if (!empty($has_images)) { 76 131 if (method_exists($renderer, 'get_buttons')) { 77 132 $output .= $renderer->get_buttons(); -
shutterpress-gallery/trunk/vendor/composer/installed.php
r3378680 r3378879 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' ee154d9281e430a177064ec382dda47bc35fbef9',6 'reference' => '8a9aecb868d4d8701c7225e6220bc9f9a2e2e09e', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 35 35 'pretty_version' => 'dev-master', 36 36 'version' => 'dev-master', 37 'reference' => ' ee154d9281e430a177064ec382dda47bc35fbef9',37 'reference' => '8a9aecb868d4d8701c7225e6220bc9f9a2e2e09e', 38 38 'type' => 'wordpress-plugin', 39 39 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.