Changeset 3225771
- Timestamp:
- 01/20/2025 06:25:17 PM (14 months ago)
- Location:
- query-loop-exclude-posts/trunk
- Files:
-
- 4 edited
-
build/index.asset.php (modified) (1 diff)
-
build/index.js (modified) (1 diff)
-
query-loop-exclude-posts.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
query-loop-exclude-posts/trunk/build/index.asset.php
r3211274 r3225771 1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => ' b45954ed15c3db4720ea');1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '9a1a082afde341deb6db'); -
query-loop-exclude-posts/trunk/build/index.js
r3211274 r3225771 1 (()=>{"use strict";const e=window.wp.hooks,t=window.wp.element,o=window.wp.blockEditor,s=window.wp.components,r=window.wp.i18n,l=window.wp.compose,n=window.wp.data,i=window.ReactJSXRuntime;(0,e.addFilter)("blocks.registerBlockType","query-loop-exclude-posts/add-exclude-current-attribute",((e,t)=>("core/query"!==t||(e.attributes={...e.attributes,excludeCurrent:{type:"boolean",default:!1}}),e)));const c=(0,l.createHigherOrderComponent)((e=>l=>{if("core/query"!==l.name)return(0,i.jsx)(e,{...l});const{setAttributes:n,attributes:c}=l,{query:u={},excludeCurrent:p=!1}=c,a=u.exclude||[],x=u.postType||"post",w=e=>{n({query:{...u,exclude:e}})};return(0,t.useEffect)((()=>{const e=wp.data.select("core/editor").getCurrentPostId(); p&&e?a.includes(e)||w([...a,e]):e&&a.includes(e)&&w(a.filter((t=>t!==e)))}),[p,a,w]),(0,i.jsxs)(t.Fragment,{children:[(0,i.jsx)(e,{...l}),(0,i.jsx)(o.InspectorControls,{children:(0,i.jsxs)(s.PanelBody,{title:(0,r.sprintf)(/* Translators: %s is the post type name */ /* Translators: %s is the post type name */1 (()=>{"use strict";const e=window.wp.hooks,t=window.wp.element,o=window.wp.blockEditor,s=window.wp.components,r=window.wp.i18n,l=window.wp.compose,n=window.wp.data,i=window.ReactJSXRuntime;(0,e.addFilter)("blocks.registerBlockType","query-loop-exclude-posts/add-exclude-current-attribute",((e,t)=>("core/query"!==t||(e.attributes={...e.attributes,excludeCurrent:{type:"boolean",default:!1}}),e)));const c=(0,l.createHigherOrderComponent)((e=>l=>{if("core/query"!==l.name)return(0,i.jsx)(e,{...l});const{setAttributes:n,attributes:c}=l,{query:u={},excludeCurrent:p=!1}=c,a=u.exclude||[],x=u.postType||"post",w=e=>{n({query:{...u,exclude:e}})};return(0,t.useEffect)((()=>{const e=wp.data.select("core/editor").getCurrentPostId();console.log(e),p&&e&&Number.isInteger(e)?a.includes(e)||w([...a,e]):e&&Number.isInteger(e)&&a.includes(e)&&w(a.filter((t=>t!==e)))}),[p,a,w]),(0,i.jsxs)(t.Fragment,{children:[(0,i.jsx)(e,{...l}),(0,i.jsx)(o.InspectorControls,{children:(0,i.jsxs)(s.PanelBody,{title:(0,r.sprintf)(/* Translators: %s is the post type name */ /* Translators: %s is the post type name */ 2 2 (0,r.__)("Exclude %ss","query-loop-exclude-posts"),x.charAt(0).toUpperCase()+x.slice(1)),initialOpen:!0,children:[(0,i.jsx)(s.PanelRow,{children:(0,i.jsx)(d,{excludePosts:a,postType:x,onChange:w})}),(0,i.jsxs)(s.PanelRow,{children:[(0,i.jsx)("div",{children:(0,i.jsx)("label",{children:(0,r.sprintf)((0,r.__)("Exclude current %s","query-loop-exclude-posts"),x)})}),(0,i.jsx)(s.FormToggle,{label:(0,r.sprintf)((0,r.__)("Exclude current %s","query-loop-exclude-posts"),x),checked:p,onChange:()=>{n({excludeCurrent:!p})}})]})]})})]})}),"withExcludePostsControl");(0,e.addFilter)("editor.BlockEdit","query-loop-exclude-posts/with-exclude-posts-control",c);const d=(0,n.withSelect)(((e,t)=>{const{postType:o}=t,{getEntityRecords:s}=e("core");return{posts:s("postType",o,{per_page:-1})}}))((({posts:e,excludePosts:t,onChange:o})=>{const l=e?e.map((e=>({id:e.id,title:e.title.rendered}))):[],n=l.filter((e=>t.includes(e.id))).map((e=>e.title));return(0,i.jsx)(s.FormTokenField,{label:(0,r.__)("Exclude by Title","query-loop-exclude-posts"),value:n,suggestions:l.map((e=>e.title)),onChange:e=>{const t=l.filter((t=>e.includes(t.title))).map((e=>e.id));o(t)},__nextHasNoMarginBottom:!0,__experimentalShowHowTo:!1})}))})(); -
query-loop-exclude-posts/trunk/query-loop-exclude-posts.php
r3211274 r3225771 3 3 * Plugin Name: Query Loop Exclude Posts 4 4 * Description: Extends the Query Loop Block to allow excluding specific posts. Select specific posts by title as well as toggle the option to exclude the current post. 5 * Version: 1. 0.05 * Version: 1.1.0 6 6 * Author: Colin Duwe 7 7 * Author URI: https://www.colinduwe.com/ -
query-loop-exclude-posts/trunk/readme.txt
r3211274 r3225771 3 3 Tags: Query Loop Block 4 4 Tested up to: 6.7.1 5 Stable tag: 1. 0.05 Stable tag: 1.1.0 6 6 Requires at least: 6.6 7 7 Requires PHP: 8.0 … … 25 25 26 26 === Development and Support === 27 27 wp 28 28 This plugin is developed on Github. You can find the uncompressed source javascript and 29 29 submit issues and pull requests there: … … 43 43 == Changelog == 44 44 45 = 1.1.0 = 46 * Fixed bug when used in the Site Editor where the exclude current post toggle 47 would cause an error resulting in an endlessly spinning loading wheel in the 48 query loop. 49 45 50 = 1.0.0 = 46 51 *initial release
Note: See TracChangeset
for help on using the changeset viewer.