Plugin Directory

Changeset 3352663


Ignore:
Timestamp:
08/29/2025 01:59:33 PM (7 months ago)
Author:
shutterpressgallery
Message:

Update to version 1.6.6 from GitHub

Location:
shutterpress-gallery
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shutterpress-gallery/tags/1.6.6/README.txt

    r3351546 r3352663  
    66Tested up to: 6.8.2
    77Requires PHP: 7.0
    8 Stable tag: 1.6.5
     8Stable tag: 1.6.6
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    112112== Changelog ==
    113113
     114= 1.6.6 =
     115
     116* Fix - Only showing 10 most recent galleries in Gutenberg block drop down - Now show all and search.
     117* Fix - Only showing 10 most recent galleries in Elementor Widget drop down - Now show all and search.
     118* Fix - Defult icon size set on first load of plugin
     119
    114120= 1.6.5 =
    115121
  • shutterpress-gallery/tags/1.6.6/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block.asset.php

    r3351397 r3352663  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'bcf30abbbf7f79fc0309');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'c2424e3babb8943f46ab');
  • shutterpress-gallery/tags/1.6.6/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block.js

    r3351397 r3352663  
    1 (()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var o in t)e.o(t,o)&&!e.o(l,o)&&Object.defineProperty(l,o,{enumerable:!0,get:t[o]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,t=window.wp.element,o=window.wp.components,s=window.wp.i18n,r=window.wp.blockEditor,a=window.wp.apiFetch;var n=e.n(a);const u=JSON.parse('{"UU":"shutterpress-gallery/shutterpress-gallery-block"}'),i=window.wp.serverSideRender;var c=e.n(i);const d=window.ReactJSXRuntime;(0,l.registerBlockType)(u.UU,{attributes:{galleryId:{type:"number",default:0},useLightbox:{type:"boolean",default:!0},showDefaultButtons:{type:"boolean",default:!0},galleryLayout:{type:"string",default:"masonry"},galleryGap:{type:"number",default:20},rowHeight:{type:"number",default:300},columns_desktop:{type:"number",default:3},columns_tablet:{type:"number",default:2},columns_mobile:{type:"number",default:1},hasLoadedDefaults:{type:"boolean",default:!1}},edit:function(e){const{attributes:l,setAttributes:a}=e,{galleryId:i,useLightbox:p,showDefaultButtons:b,galleryLayout:g,galleryGap:h,rowHeight:y,columns_desktop:m,columns_tablet:_,columns_mobile:v}=l,[f,w]=(0,t.useState)([]),[x,j]=(0,t.useState)(!0),[S,L]=(0,t.useState)(null),k=(0,r.useBlockProps)();(0,t.useEffect)((()=>{j(!0),n()({path:"wp/v2/shutterpress-gallery"}).then((e=>{w(e),j(!1)})).catch((e=>{L(e.message),w([]),j(!1)})),l.hasLoadedDefaults||n()({path:"shutterpress/v1/options"}).then((e=>{const t=(e,l)=>{const t=parseInt(e,10);return Number.isFinite(t)?t:l},o={};void 0!==l.useLightbox&&null!==l.useLightbox||(o.useLightbox=!!e.sp_gallery_use_lightbox),void 0!==l.galleryLayout&&null!==l.galleryLayout||(o.galleryLayout=e.sp_gallery_layout||"masonry"),void 0!==l.galleryGap&&null!==l.galleryGap||(o.galleryGap=t(e.sp_gallery_column_gap,20)),void 0!==l.rowHeight&&null!==l.rowHeight||(o.rowHeight=t(e.sp_gallery_justified_row_height,300)),void 0!==l.columns_desktop&&null!==l.columns_desktop||(o.columns_desktop=t(e.sp_gallery_columns_desktop,3)),void 0!==l.columns_tablet&&null!==l.columns_tablet||(o.columns_tablet=t(e.sp_gallery_columns_tablet,2)),void 0!==l.columns_mobile&&null!==l.columns_mobile||(o.columns_mobile=t(e.sp_gallery_columns_mobile,1)),a({...o,hasLoadedDefaults:!0})})).catch((e=>{console.error("Error fetching options:",e),a({hasLoadedDefaults:!0})}))}),[l.hasLoadedDefaults]),(0,t.useEffect)((()=>{!x&&!S&&0===i&&Array.isArray(f)&&f.length>0&&a({galleryId:parseInt(f[0].id,10)})}),[x,S,f]);const C=(()=>{if(!x&&f.length>0){const e=f.map((e=>({label:e.title.rendered||"Untitled Gallery",value:e.id})));return[{label:(0,s.__)("Use Post Gallery","shutterpress-gallery"),value:-1},...e]}return[{label:x?(0,s.__)("Loading galleries…","shutterpress-gallery"):(0,s.__)("No galleries found","shutterpress-gallery"),value:0}]})(),N=(e,l)=>Number.isFinite(e)?e:l,I={galleryId:N(i,0),useLightbox:!!p,showDefaultButtons:!!b,galleryLayout:g||"masonry",galleryGap:N(h,20),rowHeight:"justified"===g?N(y,300):void 0,columns_desktop:"grid"===g||"masonry"===g?N(m,3):void 0,columns_tablet:"grid"===g||"masonry"===g?N(_,2):void 0,columns_mobile:"grid"===g||"masonry"===g?N(v,1):void 0},G=Object.fromEntries(Object.entries(I).filter((([,e])=>null!=e))),P=G;return(0,d.jsxs)("div",{...k,children:[x&&(0,d.jsx)(o.Spinner,{}),Number.isFinite(i)&&-1===i&&!x&&!S&&(0,d.jsx)("div",{className:"sp-gallery-block-preview",children:(0,d.jsx)("div",{className:"components-placeholder",children:(0,d.jsx)("p",{children:(0,s.__)("ShutterPress Gallery. View the post to see images.","shutterpress-gallery")})})}),Number.isFinite(i)&&i>0&&!x&&!S&&(0,d.jsxs)("div",{className:"sp-gallery-block-preview",children:[console&&"function"==typeof console.log?console.log("[ShutterPress] SSR attributes",G):null,(0,d.jsx)(c(),{block:u.UU,httpMethod:"GET",attributes:P,LoadingResponsePlaceholder:()=>(0,d.jsx)(o.Spinner,{}),ErrorResponsePlaceholder:e=>{const l=e&&e.error?e.error:null;console&&"function"==typeof console.error&&console.error("[ShutterPress] SSR error props",e);let t=(0,s.__)("Error rendering block","shutterpress-gallery");if(l)if("string"==typeof l)t=l;else if(l&&"string"==typeof l.message)t=l.message;else try{t=JSON.stringify(l)}catch(e){t=String(l)}return console&&"function"==typeof console.error&&console.error("[ShutterPress] Block render error",l),(0,d.jsx)("div",{className:"components-error",children:(0,d.jsx)("p",{children:t})})}})]}),S&&(0,d.jsxs)("p",{style:{color:"red"},children:[(0,s.__)("Error: ","shutterpress-gallery"),S]}),(0,d.jsx)(r.InspectorControls,{children:(0,d.jsxs)(o.PanelBody,{title:(0,s.__)("Gallery Settings"),initialOpen:!0,children:[(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Select Gallery"),value:i,options:C,onChange:e=>{const l=parseInt(e,10);a({galleryId:Number.isFinite(l)?l:0})},disabled:x||S}),(0,d.jsx)(o.ToggleControl,{label:(0,s.__)("Use Lightbox"),checked:p,onChange:e=>a({useLightbox:!!e})}),(0,d.jsx)(o.ToggleControl,{label:(0,s.__)("Use Default Buttons"),checked:b,onChange:e=>a({showDefaultButtons:!!e})}),(0,d.jsxs)("p",{className:"components-base-control__help",children:[(0,s.__)(`If you want to add custom buttons, create a button and set the button HTML ANCHOR to "sp-gallery-filter-liked-photos-${i}". See `,"shutterpress-gallery"),(0,d.jsx)("a",{href:"https://shutterpress.io",target:"_blank",rel:"noopener noreferrer",children:"ShutterPress.io"})," for more info."]}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Layout"),value:g,options:[{label:"Masonry",value:"masonry"},{label:"Grid",value:"grid"},{label:"Justified",value:"justified"}],onChange:e=>a({galleryLayout:e})}),(0,d.jsx)(o.RangeControl,{label:(0,s.__)("Image Gap"),value:h,onChange:e=>a({galleryGap:parseInt(e,10)}),min:0,max:100}),"justified"===g&&(0,d.jsx)(o.RangeControl,{label:(0,s.__)("Row Height"),value:y,onChange:e=>a({rowHeight:parseInt(e,10)}),min:0,max:1e3}),("grid"===g||"masonry"===g)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Desktop Columns"),value:m,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8},{label:"9",value:9},{label:"10",value:10}],onChange:e=>a({columns_desktop:parseInt(e,10)})}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Tablet Columns"),value:_,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8}],onChange:e=>a({columns_tablet:parseInt(e,10)})}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Mobile Columns"),value:v,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4}],onChange:e=>a({columns_mobile:parseInt(e,10)})})]})]})})]})},save:function(){return null}})})();
     1(()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var o in t)e.o(t,o)&&!e.o(l,o)&&Object.defineProperty(l,o,{enumerable:!0,get:t[o]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,t=window.wp.element,o=window.wp.components,r=window.wp.i18n,s=window.wp.blockEditor,a=window.wp.apiFetch;var n=e.n(a);const u=JSON.parse('{"UU":"shutterpress-gallery/shutterpress-gallery-block"}'),i=window.wp.serverSideRender;var p=e.n(i);const c=window.ReactJSXRuntime;(0,l.registerBlockType)(u.UU,{attributes:{galleryId:{type:"number",default:-1},useLightbox:{type:"boolean",default:!0},showDefaultButtons:{type:"boolean",default:!0},galleryLayout:{type:"string",default:"masonry"},galleryGap:{type:"number",default:20},rowHeight:{type:"number",default:300},columns_desktop:{type:"number",default:3},columns_tablet:{type:"number",default:2},columns_mobile:{type:"number",default:1},hasLoadedDefaults:{type:"boolean",default:!1}},edit:function(e){const{attributes:l,setAttributes:a}=e,{galleryId:i,useLightbox:d,showDefaultButtons:g,galleryLayout:b,galleryGap:h,rowHeight:y,columns_desktop:m,columns_tablet:_,columns_mobile:v}=l,[f,w]=(0,t.useState)([]),[x,j]=(0,t.useState)(!0),[S,C]=(0,t.useState)(null),L=(0,s.useBlockProps)();(0,t.useEffect)((()=>{j(!0),C(null);let e=[];const t=async(l=1)=>{const o=await n()({path:`wp/v2/shutterpress-gallery?per_page=100&page=${l}`,parse:!1}),r=await o.json();if(e=e.concat(Array.isArray(r)?r:[]),l<parseInt(o.headers.get("X-WP-TotalPages")||"1",10))return t(l+1)};t(1).then((()=>{w(e),j(!1)})).catch((e=>{C(e&&e.message?e.message:String(e)),w([]),j(!1)})),l.hasLoadedDefaults||n()({path:"shutterpress/v1/options"}).then((e=>{const t=(e,l)=>{const t=parseInt(e,10);return Number.isFinite(t)?t:l},o={};void 0!==l.useLightbox&&null!==l.useLightbox||(o.useLightbox=!!e.sp_gallery_use_lightbox),void 0!==l.galleryLayout&&null!==l.galleryLayout||(o.galleryLayout=e.sp_gallery_layout||"masonry"),void 0!==l.galleryGap&&null!==l.galleryGap||(o.galleryGap=t(e.sp_gallery_column_gap,20)),void 0!==l.rowHeight&&null!==l.rowHeight||(o.rowHeight=t(e.sp_gallery_justified_row_height,300)),void 0!==l.columns_desktop&&null!==l.columns_desktop||(o.columns_desktop=t(e.sp_gallery_columns_desktop,3)),void 0!==l.columns_tablet&&null!==l.columns_tablet||(o.columns_tablet=t(e.sp_gallery_columns_tablet,2)),void 0!==l.columns_mobile&&null!==l.columns_mobile||(o.columns_mobile=t(e.sp_gallery_columns_mobile,1)),a({...o,hasLoadedDefaults:!0})})).catch((e=>{console.error("Error fetching options:",e),a({hasLoadedDefaults:!0})}))}),[l.hasLoadedDefaults]);const k=(()=>{if(!x&&Array.isArray(f)&&f.length>0){const e=f.map((e=>({label:e.title?.rendered||"Untitled Gallery",value:String(e.id)})));return[{label:(0,r.__)("Use Post Gallery","shutterpress-gallery"),value:"-1"},...e]}return[]})(),N=(e,l)=>Number.isFinite(e)?e:l,G={galleryId:N(i,0),useLightbox:!!d,showDefaultButtons:!!g,galleryLayout:b||"masonry",galleryGap:N(h,20),rowHeight:"justified"===b?N(y,300):void 0,columns_desktop:"grid"===b||"masonry"===b?N(m,3):void 0,columns_tablet:"grid"===b||"masonry"===b?N(_,2):void 0,columns_mobile:"grid"===b||"masonry"===b?N(v,1):void 0},I=Object.fromEntries(Object.entries(G).filter((([,e])=>null!=e))),P=I;return(0,c.jsxs)("div",{...L,children:[x&&(0,c.jsx)(o.Spinner,{}),Number.isFinite(i)&&-1===i&&!x&&!S&&(0,c.jsx)("div",{className:"sp-gallery-block-preview",children:(0,c.jsx)("div",{className:"components-placeholder",children:(0,c.jsx)("p",{children:(0,r.__)("ShutterPress Gallery. View the post to see images.","shutterpress-gallery")})})}),Number.isFinite(i)&&i>0&&!x&&!S&&(0,c.jsxs)("div",{className:"sp-gallery-block-preview",children:[console&&"function"==typeof console.log?console.log("[ShutterPress] SSR attributes",I):null,(0,c.jsx)(p(),{block:u.UU,httpMethod:"GET",attributes:P,LoadingResponsePlaceholder:()=>(0,c.jsx)(o.Spinner,{}),ErrorResponsePlaceholder:e=>{const l=e&&e.error?e.error:null;console&&"function"==typeof console.error&&console.error("[ShutterPress] SSR error props",e);let t=(0,r.__)("Error rendering block","shutterpress-gallery");if(l)if("string"==typeof l)t=l;else if(l&&"string"==typeof l.message)t=l.message;else try{t=JSON.stringify(l)}catch(e){t=String(l)}return console&&"function"==typeof console.error&&console.error("[ShutterPress] Block render error",l),(0,c.jsx)("div",{className:"components-error",children:(0,c.jsx)("p",{children:t})})}})]}),S&&(0,c.jsxs)("p",{style:{color:"red"},children:[(0,r.__)("Error: ","shutterpress-gallery"),S]}),(0,c.jsx)(s.InspectorControls,{children:(0,c.jsxs)(o.PanelBody,{title:(0,r.__)("Gallery Settings"),initialOpen:!0,children:[(0,c.jsx)(o.ComboboxControl,{label:(0,r.__)("Select Gallery","shutterpress-gallery"),value:String(Number.isFinite(i)?i:""),options:k,onChange:e=>{const l=parseInt(e,10);a({galleryId:Number.isFinite(l)?l:0})},help:x?(0,r.__)("Loading galleries…","shutterpress-gallery"):S?(0,r.__)("Error loading galleries","shutterpress-gallery"):(0,r.__)("Type to search by gallery name","shutterpress-gallery"),disabled:x||!!S}),(0,c.jsx)(o.ToggleControl,{label:(0,r.__)("Use Lightbox"),checked:d,onChange:e=>a({useLightbox:!!e})}),(0,c.jsx)(o.ToggleControl,{label:(0,r.__)("Use Default Buttons"),checked:g,onChange:e=>a({showDefaultButtons:!!e})}),(0,c.jsxs)("p",{className:"components-base-control__help",children:[(0,r.__)(`If you want to add custom buttons, create a button and set the button HTML ANCHOR to "sp-gallery-filter-liked-photos-${i}". See `,"shutterpress-gallery"),(0,c.jsx)("a",{href:"https://shutterpress.io",target:"_blank",rel:"noopener noreferrer",children:"ShutterPress.io"})," for more info."]}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Layout"),value:b,options:[{label:"Masonry",value:"masonry"},{label:"Grid",value:"grid"},{label:"Justified",value:"justified"}],onChange:e=>a({galleryLayout:e})}),(0,c.jsx)(o.RangeControl,{label:(0,r.__)("Image Gap"),value:h,onChange:e=>a({galleryGap:parseInt(e,10)}),min:0,max:100}),"justified"===b&&(0,c.jsx)(o.RangeControl,{label:(0,r.__)("Row Height"),value:y,onChange:e=>a({rowHeight:parseInt(e,10)}),min:0,max:1e3}),("grid"===b||"masonry"===b)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Desktop Columns"),value:m,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8},{label:"9",value:9},{label:"10",value:10}],onChange:e=>a({columns_desktop:parseInt(e,10)})}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Tablet Columns"),value:_,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8}],onChange:e=>a({columns_tablet:parseInt(e,10)})}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Mobile Columns"),value:v,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4}],onChange:e=>a({columns_mobile:parseInt(e,10)})})]})]})})]})},save:function(){return null}})})();
  • shutterpress-gallery/tags/1.6.6/shutterpress-gallery.php

    r3351546 r3352663  
    1212 * Plugin URI:        shutterpress.io
    1313 * Description:       The ultimate WordPress gallery plugin for professional photographers. Deliver an unforgettable experience to your clients.
    14  * Version:           1.6.5
     14 * Version:           1.6.6
    1515 * Author:            Shutterpress
    1616 * Author URI:        https://shutterpress.io
     
    2828 * Current plugin version.
    2929 */
    30 define('SHUTTERPRESS_GALLERY_VERSION', '1.6.5');
     30define('SHUTTERPRESS_GALLERY_VERSION', '1.6.6');
    3131
    3232define('SP_GALLERY_DIR', plugin_dir_path(__FILE__));
  • shutterpress-gallery/tags/1.6.6/src/admin/Shutterpress_Gallery_Elementor_Widget.php

    r3351397 r3352663  
    9393        $this->add_control('sp_gallery_id', [
    9494            'label' => esc_html__('Gallery', 'shutterpress-gallery'),
    95             'type' => \Elementor\Controls_Manager::SELECT,
    96             'default' => '0',
     95            'type' => \Elementor\Controls_Manager::SELECT2,
     96            'default' => '-1',
    9797            'options' => $this->sp_gallery_get_galleries(),
    9898            'dynamic' => [
  • shutterpress-gallery/tags/1.6.6/src/includes/Shutterpress_Gallery_Utils.php

    r3351397 r3352663  
    197197        $color = esc_attr($this->sp_gallery_get_site_color());
    198198        $color_hover = $this->sp_gallery_darken_color($color, 0.1);
    199         $icon_size = get_option('sp_gallery_icon_size');
     199        $icon_size = get_option('sp_gallery_icon_size', 30);
    200200        $output = ":root {
    201201        --sp-gallery-color-primary: {$color};
  • shutterpress-gallery/tags/1.6.6/src/shutterpress-gallery-block/shutterpress-gallery-block.js

    r3351397 r3352663  
    11import { registerBlockType } from '@wordpress/blocks';
    22import { useState, useEffect } from '@wordpress/element';
    3 import { SelectControl, ToggleControl, RangeControl, TextControl, PanelBody, Spinner } from '@wordpress/components';
     3import { SelectControl, ToggleControl, RangeControl, TextControl, PanelBody, Spinner, ComboboxControl } from '@wordpress/components';
    44import { __ } from '@wordpress/i18n';
    55import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
     
    1313    galleryId: {
    1414      type: 'number',
    15       default: 0,
     15      default: -1,
    1616    },
    1717    useLightbox: {
     
    6666      // always fetch galleries list
    6767      setLoading(true);
    68       apiFetch({ path: 'wp/v2/shutterpress-gallery' })
    69         .then((data) => {
    70           setGalleries(data);
     68      setError(null);
     69
     70      const perPage = 100;
     71      let all = [];
     72
     73      const fetchPage = async (page = 1) => {
     74        // Use parse:false so we can read headers for total pages
     75        const res = await apiFetch({
     76          path: `wp/v2/shutterpress-gallery?per_page=${perPage}&page=${page}`,
     77          parse: false,
     78        });
     79        const json = await res.json();
     80        all = all.concat(Array.isArray(json) ? json : []);
     81        const totalPages = parseInt(res.headers.get('X-WP-TotalPages') || '1', 10);
     82        if (page < totalPages) {
     83          return fetchPage(page + 1);
     84        }
     85      };
     86
     87      fetchPage(1)
     88        .then(() => {
     89          setGalleries(all);
    7190          setLoading(false);
    7291        })
    73         .catch((error) => {
    74           setError(error.message);
     92        .catch((err) => {
     93          setError(err && err.message ? err.message : String(err));
    7594          setGalleries([]);
    7695          setLoading(false);
     
    105124    }, [attributes.hasLoadedDefaults]);
    106125
    107     useEffect(() => {
    108       if (!loading && !error && galleryId === 0 && Array.isArray(galleries) && galleries.length > 0) {
    109         setAttributes({ galleryId: parseInt(galleries[0].id, 10) });
     126    const galleryOptions = (() => {
     127      if (!loading && Array.isArray(galleries) && galleries.length > 0) {
     128        const base = galleries.map((g) => ({
     129          label: g.title?.rendered || 'Untitled Gallery',
     130          value: String(g.id),
     131        }));
     132        return [{ label: __('Use Post Gallery', 'shutterpress-gallery'), value: '-1' }, ...base];
    110133      }
    111     }, [loading, error, galleries]);
    112 
    113     const galleryOptions = (() => {
    114       if (!loading && galleries.length > 0) {
    115         const base = galleries.map((gallery) => ({
    116           label: gallery.title.rendered || 'Untitled Gallery',
    117           value: gallery.id,
    118         }));
    119         return [{ label: __('Use Post Gallery', 'shutterpress-gallery'), value: -1 }, ...base];
    120       }
    121       return [{ label: loading ? __('Loading galleries…', 'shutterpress-gallery') : __('No galleries found', 'shutterpress-gallery'), value: 0 }];
     134      return [];
    122135    })();
    123136
     
    198211        <InspectorControls>
    199212          <PanelBody title={__('Gallery Settings')} initialOpen={true}>
    200             <SelectControl
    201               label={__('Select Gallery')}
    202               value={galleryId}
     213            <ComboboxControl
     214              label={__('Select Gallery', 'shutterpress-gallery')}
     215              value={String(Number.isFinite(galleryId) ? galleryId : '')}
    203216              options={galleryOptions}
    204217              onChange={(newValue) => {
     
    206219                setAttributes({ galleryId: Number.isFinite(id) ? id : 0 });
    207220              }}
    208               disabled={loading || error}
     221              help={
     222                loading
     223                  ? __('Loading galleries…', 'shutterpress-gallery')
     224                  : error
     225                    ? __('Error loading galleries', 'shutterpress-gallery')
     226                    : __('Type to search by gallery name', 'shutterpress-gallery')
     227              }
     228              disabled={loading || !!error}
    209229            />
    210230            <ToggleControl label={__('Use Lightbox')} checked={useLightbox} onChange={(newValue) => setAttributes({ useLightbox: newValue ? true : false })} />
  • shutterpress-gallery/trunk/README.txt

    r3351546 r3352663  
    66Tested up to: 6.8.2
    77Requires PHP: 7.0
    8 Stable tag: 1.6.5
     8Stable tag: 1.6.6
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    112112== Changelog ==
    113113
     114= 1.6.6 =
     115
     116* Fix - Only showing 10 most recent galleries in Gutenberg block drop down - Now show all and search.
     117* Fix - Only showing 10 most recent galleries in Elementor Widget drop down - Now show all and search.
     118* Fix - Defult icon size set on first load of plugin
     119
    114120= 1.6.5 =
    115121
  • shutterpress-gallery/trunk/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block.asset.php

    r3351397 r3352663  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'bcf30abbbf7f79fc0309');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'c2424e3babb8943f46ab');
  • shutterpress-gallery/trunk/includes/blocks/shutterpress-gallery-block/shutterpress-gallery-block.js

    r3351397 r3352663  
    1 (()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var o in t)e.o(t,o)&&!e.o(l,o)&&Object.defineProperty(l,o,{enumerable:!0,get:t[o]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,t=window.wp.element,o=window.wp.components,s=window.wp.i18n,r=window.wp.blockEditor,a=window.wp.apiFetch;var n=e.n(a);const u=JSON.parse('{"UU":"shutterpress-gallery/shutterpress-gallery-block"}'),i=window.wp.serverSideRender;var c=e.n(i);const d=window.ReactJSXRuntime;(0,l.registerBlockType)(u.UU,{attributes:{galleryId:{type:"number",default:0},useLightbox:{type:"boolean",default:!0},showDefaultButtons:{type:"boolean",default:!0},galleryLayout:{type:"string",default:"masonry"},galleryGap:{type:"number",default:20},rowHeight:{type:"number",default:300},columns_desktop:{type:"number",default:3},columns_tablet:{type:"number",default:2},columns_mobile:{type:"number",default:1},hasLoadedDefaults:{type:"boolean",default:!1}},edit:function(e){const{attributes:l,setAttributes:a}=e,{galleryId:i,useLightbox:p,showDefaultButtons:b,galleryLayout:g,galleryGap:h,rowHeight:y,columns_desktop:m,columns_tablet:_,columns_mobile:v}=l,[f,w]=(0,t.useState)([]),[x,j]=(0,t.useState)(!0),[S,L]=(0,t.useState)(null),k=(0,r.useBlockProps)();(0,t.useEffect)((()=>{j(!0),n()({path:"wp/v2/shutterpress-gallery"}).then((e=>{w(e),j(!1)})).catch((e=>{L(e.message),w([]),j(!1)})),l.hasLoadedDefaults||n()({path:"shutterpress/v1/options"}).then((e=>{const t=(e,l)=>{const t=parseInt(e,10);return Number.isFinite(t)?t:l},o={};void 0!==l.useLightbox&&null!==l.useLightbox||(o.useLightbox=!!e.sp_gallery_use_lightbox),void 0!==l.galleryLayout&&null!==l.galleryLayout||(o.galleryLayout=e.sp_gallery_layout||"masonry"),void 0!==l.galleryGap&&null!==l.galleryGap||(o.galleryGap=t(e.sp_gallery_column_gap,20)),void 0!==l.rowHeight&&null!==l.rowHeight||(o.rowHeight=t(e.sp_gallery_justified_row_height,300)),void 0!==l.columns_desktop&&null!==l.columns_desktop||(o.columns_desktop=t(e.sp_gallery_columns_desktop,3)),void 0!==l.columns_tablet&&null!==l.columns_tablet||(o.columns_tablet=t(e.sp_gallery_columns_tablet,2)),void 0!==l.columns_mobile&&null!==l.columns_mobile||(o.columns_mobile=t(e.sp_gallery_columns_mobile,1)),a({...o,hasLoadedDefaults:!0})})).catch((e=>{console.error("Error fetching options:",e),a({hasLoadedDefaults:!0})}))}),[l.hasLoadedDefaults]),(0,t.useEffect)((()=>{!x&&!S&&0===i&&Array.isArray(f)&&f.length>0&&a({galleryId:parseInt(f[0].id,10)})}),[x,S,f]);const C=(()=>{if(!x&&f.length>0){const e=f.map((e=>({label:e.title.rendered||"Untitled Gallery",value:e.id})));return[{label:(0,s.__)("Use Post Gallery","shutterpress-gallery"),value:-1},...e]}return[{label:x?(0,s.__)("Loading galleries…","shutterpress-gallery"):(0,s.__)("No galleries found","shutterpress-gallery"),value:0}]})(),N=(e,l)=>Number.isFinite(e)?e:l,I={galleryId:N(i,0),useLightbox:!!p,showDefaultButtons:!!b,galleryLayout:g||"masonry",galleryGap:N(h,20),rowHeight:"justified"===g?N(y,300):void 0,columns_desktop:"grid"===g||"masonry"===g?N(m,3):void 0,columns_tablet:"grid"===g||"masonry"===g?N(_,2):void 0,columns_mobile:"grid"===g||"masonry"===g?N(v,1):void 0},G=Object.fromEntries(Object.entries(I).filter((([,e])=>null!=e))),P=G;return(0,d.jsxs)("div",{...k,children:[x&&(0,d.jsx)(o.Spinner,{}),Number.isFinite(i)&&-1===i&&!x&&!S&&(0,d.jsx)("div",{className:"sp-gallery-block-preview",children:(0,d.jsx)("div",{className:"components-placeholder",children:(0,d.jsx)("p",{children:(0,s.__)("ShutterPress Gallery. View the post to see images.","shutterpress-gallery")})})}),Number.isFinite(i)&&i>0&&!x&&!S&&(0,d.jsxs)("div",{className:"sp-gallery-block-preview",children:[console&&"function"==typeof console.log?console.log("[ShutterPress] SSR attributes",G):null,(0,d.jsx)(c(),{block:u.UU,httpMethod:"GET",attributes:P,LoadingResponsePlaceholder:()=>(0,d.jsx)(o.Spinner,{}),ErrorResponsePlaceholder:e=>{const l=e&&e.error?e.error:null;console&&"function"==typeof console.error&&console.error("[ShutterPress] SSR error props",e);let t=(0,s.__)("Error rendering block","shutterpress-gallery");if(l)if("string"==typeof l)t=l;else if(l&&"string"==typeof l.message)t=l.message;else try{t=JSON.stringify(l)}catch(e){t=String(l)}return console&&"function"==typeof console.error&&console.error("[ShutterPress] Block render error",l),(0,d.jsx)("div",{className:"components-error",children:(0,d.jsx)("p",{children:t})})}})]}),S&&(0,d.jsxs)("p",{style:{color:"red"},children:[(0,s.__)("Error: ","shutterpress-gallery"),S]}),(0,d.jsx)(r.InspectorControls,{children:(0,d.jsxs)(o.PanelBody,{title:(0,s.__)("Gallery Settings"),initialOpen:!0,children:[(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Select Gallery"),value:i,options:C,onChange:e=>{const l=parseInt(e,10);a({galleryId:Number.isFinite(l)?l:0})},disabled:x||S}),(0,d.jsx)(o.ToggleControl,{label:(0,s.__)("Use Lightbox"),checked:p,onChange:e=>a({useLightbox:!!e})}),(0,d.jsx)(o.ToggleControl,{label:(0,s.__)("Use Default Buttons"),checked:b,onChange:e=>a({showDefaultButtons:!!e})}),(0,d.jsxs)("p",{className:"components-base-control__help",children:[(0,s.__)(`If you want to add custom buttons, create a button and set the button HTML ANCHOR to "sp-gallery-filter-liked-photos-${i}". See `,"shutterpress-gallery"),(0,d.jsx)("a",{href:"https://shutterpress.io",target:"_blank",rel:"noopener noreferrer",children:"ShutterPress.io"})," for more info."]}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Layout"),value:g,options:[{label:"Masonry",value:"masonry"},{label:"Grid",value:"grid"},{label:"Justified",value:"justified"}],onChange:e=>a({galleryLayout:e})}),(0,d.jsx)(o.RangeControl,{label:(0,s.__)("Image Gap"),value:h,onChange:e=>a({galleryGap:parseInt(e,10)}),min:0,max:100}),"justified"===g&&(0,d.jsx)(o.RangeControl,{label:(0,s.__)("Row Height"),value:y,onChange:e=>a({rowHeight:parseInt(e,10)}),min:0,max:1e3}),("grid"===g||"masonry"===g)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Desktop Columns"),value:m,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8},{label:"9",value:9},{label:"10",value:10}],onChange:e=>a({columns_desktop:parseInt(e,10)})}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Tablet Columns"),value:_,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8}],onChange:e=>a({columns_tablet:parseInt(e,10)})}),(0,d.jsx)(o.SelectControl,{label:(0,s.__)("Number of Mobile Columns"),value:v,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4}],onChange:e=>a({columns_mobile:parseInt(e,10)})})]})]})})]})},save:function(){return null}})})();
     1(()=>{"use strict";var e={n:l=>{var t=l&&l.__esModule?()=>l.default:()=>l;return e.d(t,{a:t}),t},d:(l,t)=>{for(var o in t)e.o(t,o)&&!e.o(l,o)&&Object.defineProperty(l,o,{enumerable:!0,get:t[o]})},o:(e,l)=>Object.prototype.hasOwnProperty.call(e,l)};const l=window.wp.blocks,t=window.wp.element,o=window.wp.components,r=window.wp.i18n,s=window.wp.blockEditor,a=window.wp.apiFetch;var n=e.n(a);const u=JSON.parse('{"UU":"shutterpress-gallery/shutterpress-gallery-block"}'),i=window.wp.serverSideRender;var p=e.n(i);const c=window.ReactJSXRuntime;(0,l.registerBlockType)(u.UU,{attributes:{galleryId:{type:"number",default:-1},useLightbox:{type:"boolean",default:!0},showDefaultButtons:{type:"boolean",default:!0},galleryLayout:{type:"string",default:"masonry"},galleryGap:{type:"number",default:20},rowHeight:{type:"number",default:300},columns_desktop:{type:"number",default:3},columns_tablet:{type:"number",default:2},columns_mobile:{type:"number",default:1},hasLoadedDefaults:{type:"boolean",default:!1}},edit:function(e){const{attributes:l,setAttributes:a}=e,{galleryId:i,useLightbox:d,showDefaultButtons:g,galleryLayout:b,galleryGap:h,rowHeight:y,columns_desktop:m,columns_tablet:_,columns_mobile:v}=l,[f,w]=(0,t.useState)([]),[x,j]=(0,t.useState)(!0),[S,C]=(0,t.useState)(null),L=(0,s.useBlockProps)();(0,t.useEffect)((()=>{j(!0),C(null);let e=[];const t=async(l=1)=>{const o=await n()({path:`wp/v2/shutterpress-gallery?per_page=100&page=${l}`,parse:!1}),r=await o.json();if(e=e.concat(Array.isArray(r)?r:[]),l<parseInt(o.headers.get("X-WP-TotalPages")||"1",10))return t(l+1)};t(1).then((()=>{w(e),j(!1)})).catch((e=>{C(e&&e.message?e.message:String(e)),w([]),j(!1)})),l.hasLoadedDefaults||n()({path:"shutterpress/v1/options"}).then((e=>{const t=(e,l)=>{const t=parseInt(e,10);return Number.isFinite(t)?t:l},o={};void 0!==l.useLightbox&&null!==l.useLightbox||(o.useLightbox=!!e.sp_gallery_use_lightbox),void 0!==l.galleryLayout&&null!==l.galleryLayout||(o.galleryLayout=e.sp_gallery_layout||"masonry"),void 0!==l.galleryGap&&null!==l.galleryGap||(o.galleryGap=t(e.sp_gallery_column_gap,20)),void 0!==l.rowHeight&&null!==l.rowHeight||(o.rowHeight=t(e.sp_gallery_justified_row_height,300)),void 0!==l.columns_desktop&&null!==l.columns_desktop||(o.columns_desktop=t(e.sp_gallery_columns_desktop,3)),void 0!==l.columns_tablet&&null!==l.columns_tablet||(o.columns_tablet=t(e.sp_gallery_columns_tablet,2)),void 0!==l.columns_mobile&&null!==l.columns_mobile||(o.columns_mobile=t(e.sp_gallery_columns_mobile,1)),a({...o,hasLoadedDefaults:!0})})).catch((e=>{console.error("Error fetching options:",e),a({hasLoadedDefaults:!0})}))}),[l.hasLoadedDefaults]);const k=(()=>{if(!x&&Array.isArray(f)&&f.length>0){const e=f.map((e=>({label:e.title?.rendered||"Untitled Gallery",value:String(e.id)})));return[{label:(0,r.__)("Use Post Gallery","shutterpress-gallery"),value:"-1"},...e]}return[]})(),N=(e,l)=>Number.isFinite(e)?e:l,G={galleryId:N(i,0),useLightbox:!!d,showDefaultButtons:!!g,galleryLayout:b||"masonry",galleryGap:N(h,20),rowHeight:"justified"===b?N(y,300):void 0,columns_desktop:"grid"===b||"masonry"===b?N(m,3):void 0,columns_tablet:"grid"===b||"masonry"===b?N(_,2):void 0,columns_mobile:"grid"===b||"masonry"===b?N(v,1):void 0},I=Object.fromEntries(Object.entries(G).filter((([,e])=>null!=e))),P=I;return(0,c.jsxs)("div",{...L,children:[x&&(0,c.jsx)(o.Spinner,{}),Number.isFinite(i)&&-1===i&&!x&&!S&&(0,c.jsx)("div",{className:"sp-gallery-block-preview",children:(0,c.jsx)("div",{className:"components-placeholder",children:(0,c.jsx)("p",{children:(0,r.__)("ShutterPress Gallery. View the post to see images.","shutterpress-gallery")})})}),Number.isFinite(i)&&i>0&&!x&&!S&&(0,c.jsxs)("div",{className:"sp-gallery-block-preview",children:[console&&"function"==typeof console.log?console.log("[ShutterPress] SSR attributes",I):null,(0,c.jsx)(p(),{block:u.UU,httpMethod:"GET",attributes:P,LoadingResponsePlaceholder:()=>(0,c.jsx)(o.Spinner,{}),ErrorResponsePlaceholder:e=>{const l=e&&e.error?e.error:null;console&&"function"==typeof console.error&&console.error("[ShutterPress] SSR error props",e);let t=(0,r.__)("Error rendering block","shutterpress-gallery");if(l)if("string"==typeof l)t=l;else if(l&&"string"==typeof l.message)t=l.message;else try{t=JSON.stringify(l)}catch(e){t=String(l)}return console&&"function"==typeof console.error&&console.error("[ShutterPress] Block render error",l),(0,c.jsx)("div",{className:"components-error",children:(0,c.jsx)("p",{children:t})})}})]}),S&&(0,c.jsxs)("p",{style:{color:"red"},children:[(0,r.__)("Error: ","shutterpress-gallery"),S]}),(0,c.jsx)(s.InspectorControls,{children:(0,c.jsxs)(o.PanelBody,{title:(0,r.__)("Gallery Settings"),initialOpen:!0,children:[(0,c.jsx)(o.ComboboxControl,{label:(0,r.__)("Select Gallery","shutterpress-gallery"),value:String(Number.isFinite(i)?i:""),options:k,onChange:e=>{const l=parseInt(e,10);a({galleryId:Number.isFinite(l)?l:0})},help:x?(0,r.__)("Loading galleries…","shutterpress-gallery"):S?(0,r.__)("Error loading galleries","shutterpress-gallery"):(0,r.__)("Type to search by gallery name","shutterpress-gallery"),disabled:x||!!S}),(0,c.jsx)(o.ToggleControl,{label:(0,r.__)("Use Lightbox"),checked:d,onChange:e=>a({useLightbox:!!e})}),(0,c.jsx)(o.ToggleControl,{label:(0,r.__)("Use Default Buttons"),checked:g,onChange:e=>a({showDefaultButtons:!!e})}),(0,c.jsxs)("p",{className:"components-base-control__help",children:[(0,r.__)(`If you want to add custom buttons, create a button and set the button HTML ANCHOR to "sp-gallery-filter-liked-photos-${i}". See `,"shutterpress-gallery"),(0,c.jsx)("a",{href:"https://shutterpress.io",target:"_blank",rel:"noopener noreferrer",children:"ShutterPress.io"})," for more info."]}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Layout"),value:b,options:[{label:"Masonry",value:"masonry"},{label:"Grid",value:"grid"},{label:"Justified",value:"justified"}],onChange:e=>a({galleryLayout:e})}),(0,c.jsx)(o.RangeControl,{label:(0,r.__)("Image Gap"),value:h,onChange:e=>a({galleryGap:parseInt(e,10)}),min:0,max:100}),"justified"===b&&(0,c.jsx)(o.RangeControl,{label:(0,r.__)("Row Height"),value:y,onChange:e=>a({rowHeight:parseInt(e,10)}),min:0,max:1e3}),("grid"===b||"masonry"===b)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Desktop Columns"),value:m,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8},{label:"9",value:9},{label:"10",value:10}],onChange:e=>a({columns_desktop:parseInt(e,10)})}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Tablet Columns"),value:_,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4},{label:"5",value:5},{label:"6",value:6},{label:"7",value:7},{label:"8",value:8}],onChange:e=>a({columns_tablet:parseInt(e,10)})}),(0,c.jsx)(o.SelectControl,{label:(0,r.__)("Number of Mobile Columns"),value:v,options:[{label:"1",value:1},{label:"2",value:2},{label:"3",value:3},{label:"4",value:4}],onChange:e=>a({columns_mobile:parseInt(e,10)})})]})]})})]})},save:function(){return null}})})();
  • shutterpress-gallery/trunk/shutterpress-gallery.php

    r3351546 r3352663  
    1212 * Plugin URI:        shutterpress.io
    1313 * Description:       The ultimate WordPress gallery plugin for professional photographers. Deliver an unforgettable experience to your clients.
    14  * Version:           1.6.5
     14 * Version:           1.6.6
    1515 * Author:            Shutterpress
    1616 * Author URI:        https://shutterpress.io
     
    2828 * Current plugin version.
    2929 */
    30 define('SHUTTERPRESS_GALLERY_VERSION', '1.6.5');
     30define('SHUTTERPRESS_GALLERY_VERSION', '1.6.6');
    3131
    3232define('SP_GALLERY_DIR', plugin_dir_path(__FILE__));
  • shutterpress-gallery/trunk/src/admin/Shutterpress_Gallery_Elementor_Widget.php

    r3351397 r3352663  
    9393        $this->add_control('sp_gallery_id', [
    9494            'label' => esc_html__('Gallery', 'shutterpress-gallery'),
    95             'type' => \Elementor\Controls_Manager::SELECT,
    96             'default' => '0',
     95            'type' => \Elementor\Controls_Manager::SELECT2,
     96            'default' => '-1',
    9797            'options' => $this->sp_gallery_get_galleries(),
    9898            'dynamic' => [
  • shutterpress-gallery/trunk/src/includes/Shutterpress_Gallery_Utils.php

    r3351397 r3352663  
    197197        $color = esc_attr($this->sp_gallery_get_site_color());
    198198        $color_hover = $this->sp_gallery_darken_color($color, 0.1);
    199         $icon_size = get_option('sp_gallery_icon_size');
     199        $icon_size = get_option('sp_gallery_icon_size', 30);
    200200        $output = ":root {
    201201        --sp-gallery-color-primary: {$color};
  • shutterpress-gallery/trunk/src/shutterpress-gallery-block/shutterpress-gallery-block.js

    r3351397 r3352663  
    11import { registerBlockType } from '@wordpress/blocks';
    22import { useState, useEffect } from '@wordpress/element';
    3 import { SelectControl, ToggleControl, RangeControl, TextControl, PanelBody, Spinner } from '@wordpress/components';
     3import { SelectControl, ToggleControl, RangeControl, TextControl, PanelBody, Spinner, ComboboxControl } from '@wordpress/components';
    44import { __ } from '@wordpress/i18n';
    55import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
     
    1313    galleryId: {
    1414      type: 'number',
    15       default: 0,
     15      default: -1,
    1616    },
    1717    useLightbox: {
     
    6666      // always fetch galleries list
    6767      setLoading(true);
    68       apiFetch({ path: 'wp/v2/shutterpress-gallery' })
    69         .then((data) => {
    70           setGalleries(data);
     68      setError(null);
     69
     70      const perPage = 100;
     71      let all = [];
     72
     73      const fetchPage = async (page = 1) => {
     74        // Use parse:false so we can read headers for total pages
     75        const res = await apiFetch({
     76          path: `wp/v2/shutterpress-gallery?per_page=${perPage}&page=${page}`,
     77          parse: false,
     78        });
     79        const json = await res.json();
     80        all = all.concat(Array.isArray(json) ? json : []);
     81        const totalPages = parseInt(res.headers.get('X-WP-TotalPages') || '1', 10);
     82        if (page < totalPages) {
     83          return fetchPage(page + 1);
     84        }
     85      };
     86
     87      fetchPage(1)
     88        .then(() => {
     89          setGalleries(all);
    7190          setLoading(false);
    7291        })
    73         .catch((error) => {
    74           setError(error.message);
     92        .catch((err) => {
     93          setError(err && err.message ? err.message : String(err));
    7594          setGalleries([]);
    7695          setLoading(false);
     
    105124    }, [attributes.hasLoadedDefaults]);
    106125
    107     useEffect(() => {
    108       if (!loading && !error && galleryId === 0 && Array.isArray(galleries) && galleries.length > 0) {
    109         setAttributes({ galleryId: parseInt(galleries[0].id, 10) });
     126    const galleryOptions = (() => {
     127      if (!loading && Array.isArray(galleries) && galleries.length > 0) {
     128        const base = galleries.map((g) => ({
     129          label: g.title?.rendered || 'Untitled Gallery',
     130          value: String(g.id),
     131        }));
     132        return [{ label: __('Use Post Gallery', 'shutterpress-gallery'), value: '-1' }, ...base];
    110133      }
    111     }, [loading, error, galleries]);
    112 
    113     const galleryOptions = (() => {
    114       if (!loading && galleries.length > 0) {
    115         const base = galleries.map((gallery) => ({
    116           label: gallery.title.rendered || 'Untitled Gallery',
    117           value: gallery.id,
    118         }));
    119         return [{ label: __('Use Post Gallery', 'shutterpress-gallery'), value: -1 }, ...base];
    120       }
    121       return [{ label: loading ? __('Loading galleries…', 'shutterpress-gallery') : __('No galleries found', 'shutterpress-gallery'), value: 0 }];
     134      return [];
    122135    })();
    123136
     
    198211        <InspectorControls>
    199212          <PanelBody title={__('Gallery Settings')} initialOpen={true}>
    200             <SelectControl
    201               label={__('Select Gallery')}
    202               value={galleryId}
     213            <ComboboxControl
     214              label={__('Select Gallery', 'shutterpress-gallery')}
     215              value={String(Number.isFinite(galleryId) ? galleryId : '')}
    203216              options={galleryOptions}
    204217              onChange={(newValue) => {
     
    206219                setAttributes({ galleryId: Number.isFinite(id) ? id : 0 });
    207220              }}
    208               disabled={loading || error}
     221              help={
     222                loading
     223                  ? __('Loading galleries…', 'shutterpress-gallery')
     224                  : error
     225                    ? __('Error loading galleries', 'shutterpress-gallery')
     226                    : __('Type to search by gallery name', 'shutterpress-gallery')
     227              }
     228              disabled={loading || !!error}
    209229            />
    210230            <ToggleControl label={__('Use Lightbox')} checked={useLightbox} onChange={(newValue) => setAttributes({ useLightbox: newValue ? true : false })} />
Note: See TracChangeset for help on using the changeset viewer.