Plugin Directory

Changeset 3384247


Ignore:
Timestamp:
10/24/2025 10:10:05 PM (7 weeks ago)
Author:
slaFFik
Message:

Content Randomizer v1.3.0

Location:
blocks-randomizer
Files:
16 added
8 edited

Legend:

Unmodified
Added
Removed
  • blocks-randomizer/trunk/blocks-randomizer.php

    r3383662 r3384247  
    44 * Plugin URI:        https://github.com/slaffik/blocks-randomizer
    55 * Description:       Display randomly any of the top-level blocks within the "Blocks Randomizer" main block.
    6  * Version:           1.2.1
     6 * Version:           1.3.0
    77 * Requires at least: 6.7
    88 * Requires PHP:      7.4
  • blocks-randomizer/trunk/build/blocks-manifest.php

    r3383662 r3384247  
    66        'apiVersion' => 3,
    77        'name' => 'blocks-randomizer/holder',
    8         'version' => '1.2.1',
     8        'version' => '1.3.0',
    99        'title' => 'Blocks Randomizer',
    1010        'category' => 'widgets',
     
    1515                'type' => 'number',
    1616                'default' => 1
     17            ),
     18            'shuffle' => array(
     19                'type' => 'boolean',
     20                'default' => false
    1721            )
    1822        ),
  • blocks-randomizer/trunk/build/blocks-randomizer/block.json

    r3383662 r3384247  
    33  "apiVersion": 3,
    44  "name": "blocks-randomizer/holder",
    5   "version": "1.2.1",
     5  "version": "1.3.0",
    66  "title": "Blocks Randomizer",
    77  "category": "widgets",
     
    1212      "type": "number",
    1313      "default": 1
     14    },
     15    "shuffle": {
     16      "type": "boolean",
     17      "default": false
    1418    }
    1519  },
  • blocks-randomizer/trunk/build/blocks-randomizer/index.asset.php

    r3383662 r3384247  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '4a78a1fe1e829ba58e1e');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'b299acc927e402914736');
  • blocks-randomizer/trunk/build/blocks-randomizer/index.js

    r3378435 r3384247  
    1 (()=>{"use strict";var e,o={334:()=>{const e=window.wp.blocks,o=window.wp.i18n,r=window.wp.blockEditor,n=window.wp.components,t=window.wp.element,a=window.ReactJSXRuntime,l=JSON.parse('{"UU":"blocks-randomizer/holder"}');(0,e.registerBlockType)(l.UU,{keywords:[(0,o.__)("content","blocks-randomizer"),(0,o.__)("random","blocks-randomizer"),(0,o.__)("randomizer","blocks-randomizer")],example:{innerBlocks:[{name:"core/heading",attributes:{level:1,content:(0,o.__)("Randomly display custom block inside","blocks-randomizer")}},{name:"core/spacer",attributes:{height:"25px"}},{name:"core/heading",attributes:{level:2,content:(0,o.__)("it can be images ...","blocks-randomizer")}},{name:"core/heading",attributes:{level:2,content:(0,o.__)("... or any text blocks","blocks-randomizer")}}]},edit:function({attributes:l,setAttributes:s}){const{numberOfItems:i}=l,c=(0,r.useBlockProps)({}),d=(0,t.useMemo)(()=>(0,e.getBlockTypes)().map(e=>e.name).filter(e=>"blocks-randomizer/holder"!==e),[]),m=(0,r.useInnerBlocksProps)({...c,className:"wp-block-blocks-randomizer-holder-inner"},{allowedBlocks:d,orientation:"vertical",defaultBlock:{name:"core/paragraph",attributes:{placeholder:(0,o.__)("Start typing or add any block inside this container...","blocks-randomizer")}},templateLock:!1});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.InspectorControls,{children:(0,a.jsx)(n.PanelBody,{title:(0,o.__)("Display","blocks-randomizer"),initialOpen:!0,children:(0,a.jsx)(n.__experimentalNumberControl,{__next40pxDefaultSize:!0,label:(0,o.__)("Number of child blocks to display","blocks-randomizer"),help:(0,o.__)("How many random blocks to show on the front-end. If you specify more than available, all blocks will be displayed.","blocks-randomizer"),value:i,onChange:e=>{console.log("value:",e);const o=Math.max(0,parseInt(e,10));console.log("numValue:",o),s({numberOfItems:o})},required:!0,min:0,step:1})})}),(0,a.jsx)("div",{...c,children:(0,a.jsx)("div",{...m})})]})},save:function({attributes:e,innerBlocks:o}){const n=r.useBlockProps.save({}),t=r.useInnerBlocksProps.save({...n});return(0,a.jsx)("div",{...t})}})}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var a=r[e]={exports:{}};return o[e](a,a.exports,n),a.exports}n.m=o,e=[],n.O=(o,r,t,a)=>{if(!r){var l=1/0;for(d=0;d<e.length;d++){for(var[r,t,a]=e[d],s=!0,i=0;i<r.length;i++)(!1&a||l>=a)&&Object.keys(n.O).every(e=>n.O[e](r[i]))?r.splice(i--,1):(s=!1,a<l&&(l=a));if(s){e.splice(d--,1);var c=t();void 0!==c&&(o=c)}}return o}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[r,t,a]},n.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={414:0,650:0};n.O.j=o=>0===e[o];var o=(o,r)=>{var t,a,[l,s,i]=r,c=0;if(l.some(o=>0!==e[o])){for(t in s)n.o(s,t)&&(n.m[t]=s[t]);if(i)var d=i(n)}for(o&&o(r);c<l.length;c++)a=l[c],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return n.O(d)},r=globalThis.webpackChunkblocks_randomizer=globalThis.webpackChunkblocks_randomizer||[];r.forEach(o.bind(null,0)),r.push=o.bind(null,r.push.bind(r))})();var t=n.O(void 0,[650],()=>n(334));t=n.O(t)})();
     1(()=>{"use strict";var e,o={334:()=>{const e=window.wp.blocks,o=window.wp.i18n,r=window.wp.blockEditor,n=window.wp.components,l=window.wp.element,a=window.ReactJSXRuntime,t=JSON.parse('{"UU":"blocks-randomizer/holder"}');(0,e.registerBlockType)(t.UU,{keywords:[(0,o.__)("content","blocks-randomizer"),(0,o.__)("random","blocks-randomizer"),(0,o.__)("randomizer","blocks-randomizer")],example:{innerBlocks:[{name:"core/heading",attributes:{level:1,content:(0,o.__)("Randomly display custom block inside","blocks-randomizer")}},{name:"core/spacer",attributes:{height:"25px"}},{name:"core/heading",attributes:{level:2,content:(0,o.__)("it can be images ...","blocks-randomizer")}},{name:"core/heading",attributes:{level:2,content:(0,o.__)("... or any text blocks","blocks-randomizer")}}]},edit:function({attributes:t,setAttributes:s}){const{numberOfItems:i,shuffle:c}=t,d=(0,r.useBlockProps)({}),m=(0,l.useMemo)(()=>(0,e.getBlockTypes)().map(e=>e.name).filter(e=>"blocks-randomizer/holder"!==e),[]),b=(0,r.useInnerBlocksProps)({...d,className:"wp-block-blocks-randomizer-holder-inner"},{allowedBlocks:m,orientation:"vertical",defaultBlock:{name:"core/paragraph",attributes:{placeholder:(0,o.__)("Start typing or add any block inside this container...","blocks-randomizer")}},templateLock:!1});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.InspectorControls,{children:(0,a.jsxs)(n.PanelBody,{title:(0,o.__)("Display","blocks-randomizer"),initialOpen:!0,children:[(0,a.jsx)(n.__experimentalNumberControl,{__next40pxDefaultSize:!0,label:(0,o.__)("Number of child blocks to display","blocks-randomizer"),help:(0,o.__)("How many random blocks to show on the front-end. If you specify more than available, all blocks will be displayed.","blocks-randomizer"),value:i,onChange:e=>{const o=Math.max(0,parseInt(e,10));s({numberOfItems:o})},required:!0,min:0,step:1}),(0,a.jsx)(n.ToggleControl,{label:(0,o.__)("Shuffle Random Blocks","blocks-randomizer"),help:(0,o.__)("Randomize the order of randomly selected child blocks.","blocks-randomizer"),checked:c,disabled:i<2,onChange:e=>s({shuffle:e})})]})}),(0,a.jsx)("div",{...d,children:(0,a.jsx)("div",{...b})})]})},save:function({attributes:e,innerBlocks:o}){const n=r.useBlockProps.save({}),l=r.useInnerBlocksProps.save({...n});return(0,a.jsx)("div",{...l})}})}},r={};function n(e){var l=r[e];if(void 0!==l)return l.exports;var a=r[e]={exports:{}};return o[e](a,a.exports,n),a.exports}n.m=o,e=[],n.O=(o,r,l,a)=>{if(!r){var t=1/0;for(d=0;d<e.length;d++){for(var[r,l,a]=e[d],s=!0,i=0;i<r.length;i++)(!1&a||t>=a)&&Object.keys(n.O).every(e=>n.O[e](r[i]))?r.splice(i--,1):(s=!1,a<t&&(t=a));if(s){e.splice(d--,1);var c=l();void 0!==c&&(o=c)}}return o}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[r,l,a]},n.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),(()=>{var e={414:0,650:0};n.O.j=o=>0===e[o];var o=(o,r)=>{var l,a,[t,s,i]=r,c=0;if(t.some(o=>0!==e[o])){for(l in s)n.o(s,l)&&(n.m[l]=s[l]);if(i)var d=i(n)}for(o&&o(r);c<t.length;c++)a=t[c],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return n.O(d)},r=globalThis.webpackChunkblocks_randomizer=globalThis.webpackChunkblocks_randomizer||[];r.forEach(o.bind(null,0)),r.push=o.bind(null,r.push.bind(r))})();var l=n.O(void 0,[650],()=>n(334));l=n.O(l)})();
  • blocks-randomizer/trunk/build/blocks-randomizer/render.php

    r3378435 r3384247  
    4545    }
    4646
     47    // Shuffle the selected blocks if shuffle is enabled and more than 1 block is displayed.
     48    $shuffle = isset( $attributes['shuffle'] ) && (bool) $attributes['shuffle'];
     49
     50    if ( $shuffle && $number_of_items > 1 && count( $random_blocks ) > 1 ) {
     51        shuffle( $random_blocks );
     52    }
     53
    4754    // Render each selected block.
    4855    foreach ( $random_blocks as $random_block ) {
  • blocks-randomizer/trunk/readme.txt

    r3383662 r3384247  
    55Requires PHP: 7.4
    66Tested up to: 6.8
    7 Stable tag: 1.2.1
     7Stable tag: 1.3.0
    88License: GPL-2.0-or-later
    99
     
    340340== Changelog ==
    341341
     342= 1.3.0 =
     343* Added: New "Shuffle" option to randomize the order of randomly selected blocks. Enabled and works only if there is more than 1 block to display.
     344
    342345= 1.2.1 =
    343346* Fixed: In the Block Editor the white background of the Block Randomizer inner container is no longer set - so users of dark themes can actually see the text inside the randomizer while editing the block.
Note: See TracChangeset for help on using the changeset viewer.