Plugin Directory

Changeset 3482379


Ignore:
Timestamp:
03/14/2026 06:33:17 AM (3 weeks ago)
Author:
davexpression
Message:

Update to version 1.2.0 from GitHub

Location:
todo-block
Files:
4 added
4 deleted
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • todo-block/tags/1.2.0/assets/script.js

    r3062122 r3482379  
    11document.addEventListener('alpine:init', () => {
    2   // console.log('fdfd')
    32  Alpine.data('todo', () => ({
    43    checked: false,
    54
    65    toggle(e) {
    7       var $this = this;
     6      // Find the closest checklist wrapper for nonce and post_id
     7      const wrapper = e.target.closest('.tdb-checklist-wrapper');
     8      const nonce = wrapper.dataset.nonce;
     9      const post_id = wrapper.dataset.postId;
    810
    9       // Toggle the checkbox value
    10       this.checked = !this.checked;
    11 
    12       // Get nonce value from the DOM
    13       const nonce = document.querySelector('#tdb_nonce_input_id').value;
    14       const post_id = document.querySelector('#tdb_post_id').value;
    15 
     11      // Alpine x-model has already toggled `checked` before @change fires,
     12      // so send the current value directly.
    1613      window.wp.ajax.post( 'update_checkbox_state', {
    17         checked: !$this.checked,
     14        checked: this.checked,
    1815        value: e.target.value,
    1916        post_id: post_id,
    20         nonce: nonce // Include nonce in the request
     17        nonce: nonce
    2118      })
    22       .done(function(response) {
    23         $this.checked = !$this.checked;
    24       })
    25 
    26       // Send a request to the backend
    27       // fetch('/your-backend-endpoint', {
    28       //   method: 'POST', // or 'PUT', 'DELETE', etc. depending on your backend
    29       //   headers: {
    30       //     'Content-Type': 'application/json',
    31       //     // Add any other headers if required
    32       //   },
    33       //   body: JSON.stringify({
    34       //     action: 'update_checkbox_state', // Action hook name
    35       //     data: {
    36       //       checked: this.checked,
    37       //       nonce: nonce // Include nonce in the request
    38       //     }
    39       //   }),
    40       // })
    41       //   .then(response => {
    42       //     if (!response.ok) {
    43       //       throw new Error('Network response was not ok');
    44       //     }
    45       //     // Handle successful response
    46       //     console.log('Checkbox state sent to backend successfully');
    47       //   })
    48       //   .catch(error => {
    49       //     // Handle error
    50       //     console.error('There was a problem sending checkbox state to the backend:', error);
    51       //   });
     19      .fail(() => {
     20        // Revert on failure
     21        this.checked = !this.checked;
     22      });
    5223    }
    5324  }))
    54 
    5525});
  • todo-block/tags/1.2.0/blocks/todo-item/build/index.asset.php

    r3062122 r3482379  
    1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'c0774f6789d9ec5949dafa7d24e70840');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'fa9ea5cddbfb2e74ba31');
  • todo-block/tags/1.2.0/blocks/todo-item/build/index.css

    r3062122 r3482379  
    1 .wp-block-pluginette-todo-block-item{align-items:center;display:flex}.wp-block-pluginette-todo-block-item .components-base-control__field{margin:0}.feather.feather-check-square{fill:none!important}.inspector-disabled{opacity:.5}
     1.block-editor-block-list__block.wp-block-pluginette-todo-block-item{align-items:center;cursor:text!important;display:flex}.block-editor-block-list__block.wp-block-pluginette-todo-block-item .components-base-control__field{margin:0}.block-editor-block-list__block.wp-block-pluginette-todo-block-item .block-editor-rich-text,.block-editor-block-list__block.wp-block-pluginette-todo-block-item [role=textbox]{flex:1;min-width:0}.feather.feather-check-square{fill:none!important}.inspector-disabled{opacity:.5}
  • todo-block/tags/1.2.0/blocks/todo-item/build/index.js

    r3062122 r3482379  
    1 !function(){"use strict";var e,t={874:function(){var e=window.wp.element,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.blockEditor,l=window.wp.components;window.wp.data,(0,t.registerBlockType)("pluginette/todo-block-item",{icon:{src:(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-check-square"},(0,e.createElement)("polyline",{points:"9 11 12 14 22 4"}),(0,e.createElement)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"}))},edit:function(r){let{attributes:i,mergeBlocks:c,replaceBlocks:a,onReplace:u,setAttributes:s,style:d,clientId:p,context:g}=r;const f=(0,o.useBlockProps)({style:d}),h=React.createRef(),[v,m]=(0,e.useState)(!0);function k(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1?arguments[1]:void 0;return t=t||"",e?k(--e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(60*Math.random()))+t):t}(0,e.useEffect)((()=>{if(v&&!i.uuid){const e=k(10).toLowerCase();s({...i,uuid:e}),m(!1)}}),[v,i.uuid,s]),(0,e.useEffect)((()=>{if(!v&&!i.uuid){const e=uuidv4();s({...i,uuid:e})}}),[i.uuid,v,s]),g["pluginette/todo-block-list/enableSave"]&&(s({checked:!1}),s({toggleReadOnly:!1}),s({toggleDisable:!1}));const b=()=>(0,e.createElement)(l.CheckboxControl,{checked:!!i.checked,onChange:("checked",e=>{s({checked:e})}),identifier:"input"}),w=(0,e.createElement)(l.PanelBody,{title:"General",initialOpen:!0},(0,e.createElement)(l.PanelRow,null,(0,e.createElement)(l.ToggleControl,{label:"Read Only",checked:i.toggleReadOnly,onChange:e=>s({toggleReadOnly:e})})),(0,e.createElement)(l.PanelRow,null,(0,e.createElement)(l.ToggleControl,{label:"Disabled",checked:i.toggleDisable,onChange:e=>s({toggleDisable:e})})));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.InspectorControls,null,g["pluginette/todo-block-list/enableSave"]?(0,e.createElement)("div",{className:"inspector-disabled"},w):w),(0,e.createElement)("div",f,g["pluginette/todo-block-list/enableSave"]?(0,e.createElement)(l.Disabled,null,b()):b(),(0,e.createElement)(o.RichText,{ref:h,isSelected:!0,identifier:"content","aria-label":(0,n.__)("Todo text","pluginette-todo-list"),tagName:"div",multiline:!1,value:i.content,onChange:e=>s({content:e}),onSplit:(e,n)=>{let o;(n||e)&&(o={...i,content:e});const l=(0,t.createBlock)("pluginette/todo-block-item",o);return n&&(l.clientId=p),l},onMerge:c,onReplace:u,onRemove:()=>u([]),placeholder:(0,n.__)("Add Item","pluginette-todo-list")})))},save:function(t){let{attributes:n}=t;return(0,e.createElement)("div",o.useBlockProps.save(),(0,e.createElement)(o.RichText.Content,{value:n.content}))}})}},n={};function o(e){var l=n[e];if(void 0!==l)return l.exports;var r=n[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.m=t,e=[],o.O=function(t,n,l,r){if(!n){var i=1/0;for(s=0;s<e.length;s++){n=e[s][0],l=e[s][1],r=e[s][2];for(var c=!0,a=0;a<n.length;a++)(!1&r||i>=r)&&Object.keys(o.O).every((function(e){return o.O[e](n[a])}))?n.splice(a--,1):(c=!1,r<i&&(i=r));if(c){e.splice(s--,1);var u=l();void 0!==u&&(t=u)}}return t}r=r||0;for(var s=e.length;s>0&&e[s-1][2]>r;s--)e[s]=e[s-1];e[s]=[n,l,r]},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={826:0,46:0};o.O.j=function(t){return 0===e[t]};var t=function(t,n){var l,r,i=n[0],c=n[1],a=n[2],u=0;if(i.some((function(t){return 0!==e[t]}))){for(l in c)o.o(c,l)&&(o.m[l]=c[l]);if(a)var s=a(o)}for(t&&t(n);u<i.length;u++)r=i[u],o.o(e,r)&&e[r]&&e[r][0](),e[i[u]]=0;return o.O(s)},n=self.webpackChunktodo_list=self.webpackChunktodo_list||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}();var l=o.O(void 0,[46],(function(){return o(874)}));l=o.O(l)}();
     1(()=>{"use strict";var e,t={252(){const e=window.wp.blocks,t=window.wp.primitives,o=window.ReactJSXRuntime;var n=(0,o.jsx)(t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(t.Path,{d:"M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z"})});const l=window.wp.i18n,i=window.wp.blockEditor,r=window.wp.components,c=window.wp.element,s=(window.wp.data,"pluginette/todo-block-item");function a(e=10,t=""){return e?a(--e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(61*Math.random()))+t):t}(0,e.registerBlockType)("pluginette/todo-block-item",{icon:n,edit:function({attributes:t,mergeBlocks:n,replaceBlocks:d,onReplace:u,setAttributes:h,style:p,clientId:g,context:w}){const v=(0,i.useBlockProps)({style:p}),b=React.createRef(),x=w["pluginette/todo-block-list/enableSave"];(0,c.useEffect)(()=>{t.uuid||h({uuid:a(10).toLowerCase()})},[t.uuid]),(0,c.useEffect)(()=>{x&&h({checked:!1,toggleReadOnly:!1,toggleDisable:!1})},[x]);const k=()=>{return(0,o.jsx)(r.CheckboxControl,{checked:!!t.checked,onChange:(e="checked",t=>{h({[e]:t})}),identifier:"input"});var e},f=(0,o.jsxs)(r.PanelBody,{title:"General",initialOpen:!0,children:[(0,o.jsx)(r.PanelRow,{children:(0,o.jsx)(r.ToggleControl,{label:"Read Only",checked:t.toggleReadOnly,onChange:e=>h({toggleReadOnly:e})})}),(0,o.jsx)(r.PanelRow,{children:(0,o.jsx)(r.ToggleControl,{label:"Disabled",checked:t.toggleDisable,onChange:e=>h({toggleDisable:e})})})]});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InspectorControls,{children:x?(0,o.jsx)("div",{className:"inspector-disabled",children:f}):f}),(0,o.jsxs)("div",{...v,children:[x?(0,o.jsx)(r.Disabled,{children:k()}):k(),(0,o.jsx)(i.RichText,{ref:b,isSelected:!0,identifier:"content","aria-label":(0,l.__)("Todo text","pluginette-todo-list"),tagName:"div",multiline:!1,value:t.content,onChange:e=>h({content:e}),onSplit:(o,n)=>n?(0,e.createBlock)(s,{...t,content:o}):(0,e.createBlock)(s,{content:o||"",checked:!1,uuid:""}),onMerge:n,onReplace:u,onRemove:()=>u([]),placeholder:(0,l.__)("Add Item","pluginette-todo-list")})]})]})},save:function({attributes:e}){return(0,o.jsx)("div",{...i.useBlockProps.save(),children:(0,o.jsx)(i.RichText.Content,{value:e.content})})}})}},o={};function n(e){var l=o[e];if(void 0!==l)return l.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,o,l,i)=>{if(!o){var r=1/0;for(d=0;d<e.length;d++){for(var[o,l,i]=e[d],c=!0,s=0;s<o.length;s++)(!1&i||r>=i)&&Object.keys(n.O).every(e=>n.O[e](o[s]))?o.splice(s--,1):(c=!1,i<r&&(r=i));if(c){e.splice(d--,1);var a=l();void 0!==a&&(t=a)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[o,l,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={57:0,350:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var l,i,[r,c,s]=o,a=0;if(r.some(t=>0!==e[t])){for(l in c)n.o(c,l)&&(n.m[l]=c[l]);if(s)var d=s(n)}for(t&&t(o);a<r.length;a++)i=r[a],n.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return n.O(d)},o=globalThis.webpackChunktodo_list=globalThis.webpackChunktodo_list||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=n.O(void 0,[350],()=>n(252));l=n.O(l)})();
  • todo-block/tags/1.2.0/blocks/todo-list/build/index.asset.php

    r3062122 r3482379  
    1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'bd486c2ce311334f002f379f94ffc3c5');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '71ba997b1cd4ace37f41');
  • todo-block/tags/1.2.0/blocks/todo-list/build/index.js

    r3062122 r3482379  
    1 !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.element,n=window.wp.i18n,o=window.wp.blocks,r=window.wp.blockEditor,l=window.wp.components,c=window.wp.data,a=window.wp.apiFetch,i=e.n(a);(0,o.registerBlockType)("pluginette/todo-block-list",{icon:{src:(0,t.createElement)("svg",{width:"24",strokeWidth:"1.5",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)("path",{d:"M9 6L20 6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 5.79999L4.60002 6.59998L6.60001 4.59999",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 11.8L4.60002 12.6L6.60001 10.6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 17.8L4.60002 18.6L6.60001 16.6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M9 12L20 12",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M9 18L20 18",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}))},edit:function(e){let{attributes:o,mergeBlocks:a,replaceBlocks:s,onReplace:d,setAttributes:u,style:p,clientId:k}=e;const m=(0,r.useBlockProps)({style:p}),w=(0,c.useSelect)((e=>e("core/block-editor").getBlocksByClientId(k)));return(0,t.useEffect)((()=>{const e=w[0].innerBlocks.map((e=>e.attributes.uuid));i()({path:"/custom/v1/process-uuids",method:"POST",data:{fields:e}}).then((e=>{console.log(e)}))}),[]),(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,(0,t.createElement)(l.PanelBody,{title:"Generall",initialOpen:!0},(0,t.createElement)(l.PanelRow,null,(0,t.createElement)(l.ToggleControl,{label:"Enable Save",checked:o.enableSave,onChange:e=>u({enableSave:e}),help:"If enabled, logged in users can save state"})))),(0,t.createElement)("div",m,(0,t.createElement)(r.InnerBlocks,{template:[["pluginette/todo-block-item",{placeholder:(0,n.__)("Add Item","pluginette-todo-list")}]],templateInsertUpdatesSelection:!0})))},save:()=>{const e=r.useBlockProps.save();return(0,t.createElement)("div",e,(0,t.createElement)(r.InnerBlocks.Content,null))}})}();
     1(()=>{"use strict";const e=window.wp.i18n,t=window.wp.blocks,n=window.wp.blockEditor,o=window.wp.primitives,l=window.ReactJSXRuntime;var s=(0,l.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(o.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})});const i=window.wp.components;(0,t.registerBlockType)("pluginette/todo-block-list",{icon:s,edit:function({attributes:t,setAttributes:o,style:s}){const c=(0,n.useBlockProps)({style:s});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.InspectorControls,{children:(0,l.jsx)(i.PanelBody,{title:"General",initialOpen:!0,children:(0,l.jsx)(i.PanelRow,{children:(0,l.jsx)(i.ToggleControl,{label:"Enable Save",checked:t.enableSave,onChange:e=>o({enableSave:e}),help:"If enabled, logged in users can save state"})})})}),(0,l.jsx)("div",{...c,children:(0,l.jsx)(n.InnerBlocks,{allowedBlocks:["pluginette/todo-block-item"],template:[["pluginette/todo-block-item",{placeholder:(0,e.__)("Add Item","pluginette-todo-list")}]],templateInsertUpdatesSelection:!0})})]})},save:()=>{const e=n.useBlockProps.save();return(0,l.jsx)("div",{...e,children:(0,l.jsx)(n.InnerBlocks.Content,{})})}})})();
  • todo-block/tags/1.2.0/class-todo-block.php

    r3062122 r3482379  
    6666    public function run_hooks()
    6767    {
    68         add_action('plugins_laoded', array($this, 'set_locale'));
     68        add_action('plugins_loaded', array($this, 'set_locale'));
    6969        add_action('admin_init', array($this, 'create_table'));
    7070        add_action('init', array($this, 'todo_list_block_init'));
     
    7272        add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
    7373        add_action('wp_ajax_update_checkbox_state', [$this, 'update_checkbox_state_callback']);
    74         add_action('rest_api_init', [$this, 'register_custom_endpoint']);
    75 
    76     }
    77 
    78     function register_custom_endpoint() {
    79     register_rest_route('custom/v1', '/process-uuids', array(
    80             'methods' => 'POST',
    81             'callback' => [$this, 'process_uuids_callback'],
    82             'permission_callback' => function () {
    83                 return current_user_can('edit_posts');
    84             },
    85     ));
    86     }
    87 
    88     function process_uuids_callback($request) {
    89     // $fields = $request->get_json_params(); // Get the UUIDs sent in the request
    90     $fields = $request->get_param('fields'); // Get the UUIDs sent in the request
    91     // Process the UUIDs here (example: save to database, perform actions, etc.)
    92     // Return a response if needed
    93     return rest_ensure_response('UUIDs received successfully');
     74
    9475    }
    9576
     
    10081     * @access private
    10182     */
    102     private function set_locale()
     83    public function set_locale()
    10384    {
    10485        load_plugin_textdomain(
     
    132113
    133114            if (!isset($block['innerBlocks']) || !is_array($block['innerBlocks'])) {
    134                 return;
     115                return $block_content;
    135116            }
    136117
     
    147128            }
    148129
    149             $block_content = '<div>';
    150             foreach ($block['innerBlocks'] as $key => $block) {
    151                 $rows = $this->get_where([
     130            $current_user_id = get_current_user_id();
     131            $block_content = '<div class="tdb-checklist-wrapper" data-nonce="' . esc_attr(wp_create_nonce('update_checkbox_state_nonce')) . '" data-post-id="' . esc_attr(get_the_ID()) . '">';
     132            foreach ($block['innerBlocks'] as $key => $inner_block) {
     133                $rows = $current_user_id ? $this->get_where([
     134                    'user_id' => $current_user_id,
    152135                    'post_id' => $post_id,
    153                     'field' => $block['attrs']['uuid'],
     136                    'field' => $inner_block['attrs']['uuid'],
    154137                    'checked' => 'true'
    155                 ]);
    156                 $block_content .= $this->render_list_item($block['innerHTML'], $block, $enableSave, $fieldName, $meta, $rows);
     138                ]) : null;
     139                $block_content .= $this->render_list_item($inner_block['innerHTML'], $inner_block, $enableSave, $fieldName, $meta, $rows);
    157140            }
    158             $block_content .= '<input type="hidden" id="tdb_nonce_input_id" value="' . wp_create_nonce('update_checkbox_state_nonce') . '">';
    159             $block_content .= '<input type="hidden" id="tdb_post_id" value="' . get_the_ID() . '">';
    160 
    161141            $block_content .= '</div>';
    162142        }
     
    224204        $blog_id = get_current_blog_id();
    225205
    226         // does record exists
     206        // does record exist for this user
    227207        $record = $this->get_where([
    228             // 'user_id' => $user_id,
     208            'user_id' => $user_id,
    229209            'post_id' => $post_id,
    230210            'blog_id' => $blog_id,
     
    232212        ]);
    233213
    234         if($record){
    235             // only author can edit
    236             if($record->user_id != $user_id){
    237                 wp_send_json_error();
    238             }
     214        if ($record) {
    239215            $this->update($record->id, ['checked' => $status]);
    240216            wp_send_json_success();
  • todo-block/tags/1.2.0/readme.txt

    r3062160 r3482379  
    11=== Todo Block ===
    22Contributors:      davexpression, pluginette
    3 Tags:              block
    4 Tested up to:      6.4
    5 Stable tag:        1.1.1
     3Tags:              block, todo, checklist, checkbox, tasks
     4Tested up to:      6.7
     5Stable tag:        1.2.0
     6Requires at least: 6.3
     7Requires PHP:      7.0
    68License:           GPL-2.0-or-later
    79License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    1012
    1113== Description ==
    12 *Logged In users can s=now save selection (if enabled)*
     14
    1315Gutenberg is a great block editor but it does not come with a todo block.
    1416
     
    1618Your todo checkboxes will appear both on the **frontend** and **backend**. It will even keep the current state of the checkbox when shown on the frontend.
    1719
    18 You can use this block to
    19 - add tasks to your posts and pages
    20 - create a checklist of items
    21 - let users save selection
    22 - set goals
     20Logged-in users can save their checkbox selections (if enabled per checklist).
     21
     22You can use this block to:
     23
     24- Add tasks to your posts and pages
     25- Create a checklist of items
     26- Let logged-in users save their selections
     27- Set goals and track progress
    2328
    2429[youtube https://www.youtube.com/watch?v=xbmKzLUItqU&t]
     
    2631== Installation ==
    2732
    28 This section describes how to install the plugin and get it working.
    29 
    30 e.g.
    31 
    32 1. Upload the plugin files to the `/wp-content/plugins/todo-list` directory, or install the plugin through the WordPress plugins screen directly.
    33 1. Activate the plugin through the 'Plugins' screen in WordPress
    34 
     331. Upload the plugin files to the `/wp-content/plugins/todo-block` directory, or install the plugin through the WordPress plugins screen directly.
     341. Activate the plugin through the 'Plugins' screen in WordPress.
    3535
    3636== Frequently Asked Questions ==
    3737
    38 = What is the minimum WordPress version =
     38= What is the minimum WordPress version? =
    3939
    40 5.0
     406.3
     41
     42= Can users save their checkbox state? =
     43
     44Yes. Enable the "Enable Save" toggle in the Checklist block settings. Logged-in users will have their selections saved per user.
    4145
    4246== Screenshots ==
    4347
    44481. The ToDo block on the backend.
    45 2. The ToDo block on the frontend
     492. The ToDo block on the frontend.
    4650
    4751== Changelog ==
     52
     53= 1.2.0 =
     54* Fix: Press Enter to create new checkbox items
     55* Fix: Support multiple todo lists on the same post/page
     56* Fix: Per-user save state now works correctly for all users
     57* Fix: Editor UX improvements (cursor, full-width text input)
     58* Fix: Internationalization loading
     59* Improvement: Use WordPress built-in block icons
     60* Improvement: Upgraded build tooling
     61
     62= 1.1.1 =
     63* Added blueprints
    4864
    4965= 1.1 =
  • todo-block/tags/1.2.0/todo-block.php

    r3062160 r3482379  
    1313 * Requires at least: 6.3
    1414 * Requires PHP:      7.0
    15  * Version:           1.1.1
     15 * Version:           1.2.0
    1616 * Author:            David Towoju
    1717 * Author URI:        https://pluginette.com
     
    2626
    2727if (!defined('TDB_VERSION')) {
    28   define('TDB_VERSION', '1.1.1');
     28  define('TDB_VERSION', '1.2.0');
    2929}
    3030
     
    4141}
    4242
    43 if (!defined('PGNT_META_NAME')) {
    44   define('PGNT_META_NAME', 'pgnt_checklist_'.get_current_user_id());
    45 }
    46 
    4743// Load the core plugin class that contains all hooks.
    4844require plugin_dir_path(__FILE__) . 'class-db.php';
  • todo-block/trunk/assets/script.js

    r3062122 r3482379  
    11document.addEventListener('alpine:init', () => {
    2   // console.log('fdfd')
    32  Alpine.data('todo', () => ({
    43    checked: false,
    54
    65    toggle(e) {
    7       var $this = this;
     6      // Find the closest checklist wrapper for nonce and post_id
     7      const wrapper = e.target.closest('.tdb-checklist-wrapper');
     8      const nonce = wrapper.dataset.nonce;
     9      const post_id = wrapper.dataset.postId;
    810
    9       // Toggle the checkbox value
    10       this.checked = !this.checked;
    11 
    12       // Get nonce value from the DOM
    13       const nonce = document.querySelector('#tdb_nonce_input_id').value;
    14       const post_id = document.querySelector('#tdb_post_id').value;
    15 
     11      // Alpine x-model has already toggled `checked` before @change fires,
     12      // so send the current value directly.
    1613      window.wp.ajax.post( 'update_checkbox_state', {
    17         checked: !$this.checked,
     14        checked: this.checked,
    1815        value: e.target.value,
    1916        post_id: post_id,
    20         nonce: nonce // Include nonce in the request
     17        nonce: nonce
    2118      })
    22       .done(function(response) {
    23         $this.checked = !$this.checked;
    24       })
    25 
    26       // Send a request to the backend
    27       // fetch('/your-backend-endpoint', {
    28       //   method: 'POST', // or 'PUT', 'DELETE', etc. depending on your backend
    29       //   headers: {
    30       //     'Content-Type': 'application/json',
    31       //     // Add any other headers if required
    32       //   },
    33       //   body: JSON.stringify({
    34       //     action: 'update_checkbox_state', // Action hook name
    35       //     data: {
    36       //       checked: this.checked,
    37       //       nonce: nonce // Include nonce in the request
    38       //     }
    39       //   }),
    40       // })
    41       //   .then(response => {
    42       //     if (!response.ok) {
    43       //       throw new Error('Network response was not ok');
    44       //     }
    45       //     // Handle successful response
    46       //     console.log('Checkbox state sent to backend successfully');
    47       //   })
    48       //   .catch(error => {
    49       //     // Handle error
    50       //     console.error('There was a problem sending checkbox state to the backend:', error);
    51       //   });
     19      .fail(() => {
     20        // Revert on failure
     21        this.checked = !this.checked;
     22      });
    5223    }
    5324  }))
    54 
    5525});
  • todo-block/trunk/blocks/todo-item/build/index.asset.php

    r3062122 r3482379  
    1 <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'c0774f6789d9ec5949dafa7d24e70840');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'fa9ea5cddbfb2e74ba31');
  • todo-block/trunk/blocks/todo-item/build/index.css

    r3062122 r3482379  
    1 .wp-block-pluginette-todo-block-item{align-items:center;display:flex}.wp-block-pluginette-todo-block-item .components-base-control__field{margin:0}.feather.feather-check-square{fill:none!important}.inspector-disabled{opacity:.5}
     1.block-editor-block-list__block.wp-block-pluginette-todo-block-item{align-items:center;cursor:text!important;display:flex}.block-editor-block-list__block.wp-block-pluginette-todo-block-item .components-base-control__field{margin:0}.block-editor-block-list__block.wp-block-pluginette-todo-block-item .block-editor-rich-text,.block-editor-block-list__block.wp-block-pluginette-todo-block-item [role=textbox]{flex:1;min-width:0}.feather.feather-check-square{fill:none!important}.inspector-disabled{opacity:.5}
  • todo-block/trunk/blocks/todo-item/build/index.js

    r3062122 r3482379  
    1 !function(){"use strict";var e,t={874:function(){var e=window.wp.element,t=window.wp.blocks,n=window.wp.i18n,o=window.wp.blockEditor,l=window.wp.components;window.wp.data,(0,t.registerBlockType)("pluginette/todo-block-item",{icon:{src:(0,e.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-check-square"},(0,e.createElement)("polyline",{points:"9 11 12 14 22 4"}),(0,e.createElement)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"}))},edit:function(r){let{attributes:i,mergeBlocks:c,replaceBlocks:a,onReplace:u,setAttributes:s,style:d,clientId:p,context:g}=r;const f=(0,o.useBlockProps)({style:d}),h=React.createRef(),[v,m]=(0,e.useState)(!0);function k(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1?arguments[1]:void 0;return t=t||"",e?k(--e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(60*Math.random()))+t):t}(0,e.useEffect)((()=>{if(v&&!i.uuid){const e=k(10).toLowerCase();s({...i,uuid:e}),m(!1)}}),[v,i.uuid,s]),(0,e.useEffect)((()=>{if(!v&&!i.uuid){const e=uuidv4();s({...i,uuid:e})}}),[i.uuid,v,s]),g["pluginette/todo-block-list/enableSave"]&&(s({checked:!1}),s({toggleReadOnly:!1}),s({toggleDisable:!1}));const b=()=>(0,e.createElement)(l.CheckboxControl,{checked:!!i.checked,onChange:("checked",e=>{s({checked:e})}),identifier:"input"}),w=(0,e.createElement)(l.PanelBody,{title:"General",initialOpen:!0},(0,e.createElement)(l.PanelRow,null,(0,e.createElement)(l.ToggleControl,{label:"Read Only",checked:i.toggleReadOnly,onChange:e=>s({toggleReadOnly:e})})),(0,e.createElement)(l.PanelRow,null,(0,e.createElement)(l.ToggleControl,{label:"Disabled",checked:i.toggleDisable,onChange:e=>s({toggleDisable:e})})));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(o.InspectorControls,null,g["pluginette/todo-block-list/enableSave"]?(0,e.createElement)("div",{className:"inspector-disabled"},w):w),(0,e.createElement)("div",f,g["pluginette/todo-block-list/enableSave"]?(0,e.createElement)(l.Disabled,null,b()):b(),(0,e.createElement)(o.RichText,{ref:h,isSelected:!0,identifier:"content","aria-label":(0,n.__)("Todo text","pluginette-todo-list"),tagName:"div",multiline:!1,value:i.content,onChange:e=>s({content:e}),onSplit:(e,n)=>{let o;(n||e)&&(o={...i,content:e});const l=(0,t.createBlock)("pluginette/todo-block-item",o);return n&&(l.clientId=p),l},onMerge:c,onReplace:u,onRemove:()=>u([]),placeholder:(0,n.__)("Add Item","pluginette-todo-list")})))},save:function(t){let{attributes:n}=t;return(0,e.createElement)("div",o.useBlockProps.save(),(0,e.createElement)(o.RichText.Content,{value:n.content}))}})}},n={};function o(e){var l=n[e];if(void 0!==l)return l.exports;var r=n[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.m=t,e=[],o.O=function(t,n,l,r){if(!n){var i=1/0;for(s=0;s<e.length;s++){n=e[s][0],l=e[s][1],r=e[s][2];for(var c=!0,a=0;a<n.length;a++)(!1&r||i>=r)&&Object.keys(o.O).every((function(e){return o.O[e](n[a])}))?n.splice(a--,1):(c=!1,r<i&&(i=r));if(c){e.splice(s--,1);var u=l();void 0!==u&&(t=u)}}return t}r=r||0;for(var s=e.length;s>0&&e[s-1][2]>r;s--)e[s]=e[s-1];e[s]=[n,l,r]},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={826:0,46:0};o.O.j=function(t){return 0===e[t]};var t=function(t,n){var l,r,i=n[0],c=n[1],a=n[2],u=0;if(i.some((function(t){return 0!==e[t]}))){for(l in c)o.o(c,l)&&(o.m[l]=c[l]);if(a)var s=a(o)}for(t&&t(n);u<i.length;u++)r=i[u],o.o(e,r)&&e[r]&&e[r][0](),e[i[u]]=0;return o.O(s)},n=self.webpackChunktodo_list=self.webpackChunktodo_list||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}();var l=o.O(void 0,[46],(function(){return o(874)}));l=o.O(l)}();
     1(()=>{"use strict";var e,t={252(){const e=window.wp.blocks,t=window.wp.primitives,o=window.ReactJSXRuntime;var n=(0,o.jsx)(t.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,o.jsx)(t.Path,{d:"M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z"})});const l=window.wp.i18n,i=window.wp.blockEditor,r=window.wp.components,c=window.wp.element,s=(window.wp.data,"pluginette/todo-block-item");function a(e=10,t=""){return e?a(--e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".charAt(Math.floor(61*Math.random()))+t):t}(0,e.registerBlockType)("pluginette/todo-block-item",{icon:n,edit:function({attributes:t,mergeBlocks:n,replaceBlocks:d,onReplace:u,setAttributes:h,style:p,clientId:g,context:w}){const v=(0,i.useBlockProps)({style:p}),b=React.createRef(),x=w["pluginette/todo-block-list/enableSave"];(0,c.useEffect)(()=>{t.uuid||h({uuid:a(10).toLowerCase()})},[t.uuid]),(0,c.useEffect)(()=>{x&&h({checked:!1,toggleReadOnly:!1,toggleDisable:!1})},[x]);const k=()=>{return(0,o.jsx)(r.CheckboxControl,{checked:!!t.checked,onChange:(e="checked",t=>{h({[e]:t})}),identifier:"input"});var e},f=(0,o.jsxs)(r.PanelBody,{title:"General",initialOpen:!0,children:[(0,o.jsx)(r.PanelRow,{children:(0,o.jsx)(r.ToggleControl,{label:"Read Only",checked:t.toggleReadOnly,onChange:e=>h({toggleReadOnly:e})})}),(0,o.jsx)(r.PanelRow,{children:(0,o.jsx)(r.ToggleControl,{label:"Disabled",checked:t.toggleDisable,onChange:e=>h({toggleDisable:e})})})]});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.InspectorControls,{children:x?(0,o.jsx)("div",{className:"inspector-disabled",children:f}):f}),(0,o.jsxs)("div",{...v,children:[x?(0,o.jsx)(r.Disabled,{children:k()}):k(),(0,o.jsx)(i.RichText,{ref:b,isSelected:!0,identifier:"content","aria-label":(0,l.__)("Todo text","pluginette-todo-list"),tagName:"div",multiline:!1,value:t.content,onChange:e=>h({content:e}),onSplit:(o,n)=>n?(0,e.createBlock)(s,{...t,content:o}):(0,e.createBlock)(s,{content:o||"",checked:!1,uuid:""}),onMerge:n,onReplace:u,onRemove:()=>u([]),placeholder:(0,l.__)("Add Item","pluginette-todo-list")})]})]})},save:function({attributes:e}){return(0,o.jsx)("div",{...i.useBlockProps.save(),children:(0,o.jsx)(i.RichText.Content,{value:e.content})})}})}},o={};function n(e){var l=o[e];if(void 0!==l)return l.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=(t,o,l,i)=>{if(!o){var r=1/0;for(d=0;d<e.length;d++){for(var[o,l,i]=e[d],c=!0,s=0;s<o.length;s++)(!1&i||r>=i)&&Object.keys(n.O).every(e=>n.O[e](o[s]))?o.splice(s--,1):(c=!1,i<r&&(r=i));if(c){e.splice(d--,1);var a=l();void 0!==a&&(t=a)}}return t}i=i||0;for(var d=e.length;d>0&&e[d-1][2]>i;d--)e[d]=e[d-1];e[d]=[o,l,i]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={57:0,350:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var l,i,[r,c,s]=o,a=0;if(r.some(t=>0!==e[t])){for(l in c)n.o(c,l)&&(n.m[l]=c[l]);if(s)var d=s(n)}for(t&&t(o);a<r.length;a++)i=r[a],n.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return n.O(d)},o=globalThis.webpackChunktodo_list=globalThis.webpackChunktodo_list||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=n.O(void 0,[350],()=>n(252));l=n.O(l)})();
  • todo-block/trunk/blocks/todo-list/build/index.asset.php

    r3062122 r3482379  
    1 <?php return array('dependencies' => array('wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'bd486c2ce311334f002f379f94ffc3c5');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '71ba997b1cd4ace37f41');
  • todo-block/trunk/blocks/todo-list/build/index.js

    r3062122 r3482379  
    1 !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.element,n=window.wp.i18n,o=window.wp.blocks,r=window.wp.blockEditor,l=window.wp.components,c=window.wp.data,a=window.wp.apiFetch,i=e.n(a);(0,o.registerBlockType)("pluginette/todo-block-list",{icon:{src:(0,t.createElement)("svg",{width:"24",strokeWidth:"1.5",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)("path",{d:"M9 6L20 6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 5.79999L4.60002 6.59998L6.60001 4.59999",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 11.8L4.60002 12.6L6.60001 10.6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M3.80002 17.8L4.60002 18.6L6.60001 16.6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M9 12L20 12",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.createElement)("path",{d:"M9 18L20 18",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}))},edit:function(e){let{attributes:o,mergeBlocks:a,replaceBlocks:s,onReplace:d,setAttributes:u,style:p,clientId:k}=e;const m=(0,r.useBlockProps)({style:p}),w=(0,c.useSelect)((e=>e("core/block-editor").getBlocksByClientId(k)));return(0,t.useEffect)((()=>{const e=w[0].innerBlocks.map((e=>e.attributes.uuid));i()({path:"/custom/v1/process-uuids",method:"POST",data:{fields:e}}).then((e=>{console.log(e)}))}),[]),(0,t.createElement)(t.Fragment,null,(0,t.createElement)(r.InspectorControls,null,(0,t.createElement)(l.PanelBody,{title:"Generall",initialOpen:!0},(0,t.createElement)(l.PanelRow,null,(0,t.createElement)(l.ToggleControl,{label:"Enable Save",checked:o.enableSave,onChange:e=>u({enableSave:e}),help:"If enabled, logged in users can save state"})))),(0,t.createElement)("div",m,(0,t.createElement)(r.InnerBlocks,{template:[["pluginette/todo-block-item",{placeholder:(0,n.__)("Add Item","pluginette-todo-list")}]],templateInsertUpdatesSelection:!0})))},save:()=>{const e=r.useBlockProps.save();return(0,t.createElement)("div",e,(0,t.createElement)(r.InnerBlocks.Content,null))}})}();
     1(()=>{"use strict";const e=window.wp.i18n,t=window.wp.blocks,n=window.wp.blockEditor,o=window.wp.primitives,l=window.ReactJSXRuntime;var s=(0,l.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(o.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})});const i=window.wp.components;(0,t.registerBlockType)("pluginette/todo-block-list",{icon:s,edit:function({attributes:t,setAttributes:o,style:s}){const c=(0,n.useBlockProps)({style:s});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.InspectorControls,{children:(0,l.jsx)(i.PanelBody,{title:"General",initialOpen:!0,children:(0,l.jsx)(i.PanelRow,{children:(0,l.jsx)(i.ToggleControl,{label:"Enable Save",checked:t.enableSave,onChange:e=>o({enableSave:e}),help:"If enabled, logged in users can save state"})})})}),(0,l.jsx)("div",{...c,children:(0,l.jsx)(n.InnerBlocks,{allowedBlocks:["pluginette/todo-block-item"],template:[["pluginette/todo-block-item",{placeholder:(0,e.__)("Add Item","pluginette-todo-list")}]],templateInsertUpdatesSelection:!0})})]})},save:()=>{const e=n.useBlockProps.save();return(0,l.jsx)("div",{...e,children:(0,l.jsx)(n.InnerBlocks.Content,{})})}})})();
  • todo-block/trunk/class-todo-block.php

    r3062122 r3482379  
    6666    public function run_hooks()
    6767    {
    68         add_action('plugins_laoded', array($this, 'set_locale'));
     68        add_action('plugins_loaded', array($this, 'set_locale'));
    6969        add_action('admin_init', array($this, 'create_table'));
    7070        add_action('init', array($this, 'todo_list_block_init'));
     
    7272        add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
    7373        add_action('wp_ajax_update_checkbox_state', [$this, 'update_checkbox_state_callback']);
    74         add_action('rest_api_init', [$this, 'register_custom_endpoint']);
    75 
    76     }
    77 
    78     function register_custom_endpoint() {
    79     register_rest_route('custom/v1', '/process-uuids', array(
    80             'methods' => 'POST',
    81             'callback' => [$this, 'process_uuids_callback'],
    82             'permission_callback' => function () {
    83                 return current_user_can('edit_posts');
    84             },
    85     ));
    86     }
    87 
    88     function process_uuids_callback($request) {
    89     // $fields = $request->get_json_params(); // Get the UUIDs sent in the request
    90     $fields = $request->get_param('fields'); // Get the UUIDs sent in the request
    91     // Process the UUIDs here (example: save to database, perform actions, etc.)
    92     // Return a response if needed
    93     return rest_ensure_response('UUIDs received successfully');
     74
    9475    }
    9576
     
    10081     * @access private
    10182     */
    102     private function set_locale()
     83    public function set_locale()
    10384    {
    10485        load_plugin_textdomain(
     
    132113
    133114            if (!isset($block['innerBlocks']) || !is_array($block['innerBlocks'])) {
    134                 return;
     115                return $block_content;
    135116            }
    136117
     
    147128            }
    148129
    149             $block_content = '<div>';
    150             foreach ($block['innerBlocks'] as $key => $block) {
    151                 $rows = $this->get_where([
     130            $current_user_id = get_current_user_id();
     131            $block_content = '<div class="tdb-checklist-wrapper" data-nonce="' . esc_attr(wp_create_nonce('update_checkbox_state_nonce')) . '" data-post-id="' . esc_attr(get_the_ID()) . '">';
     132            foreach ($block['innerBlocks'] as $key => $inner_block) {
     133                $rows = $current_user_id ? $this->get_where([
     134                    'user_id' => $current_user_id,
    152135                    'post_id' => $post_id,
    153                     'field' => $block['attrs']['uuid'],
     136                    'field' => $inner_block['attrs']['uuid'],
    154137                    'checked' => 'true'
    155                 ]);
    156                 $block_content .= $this->render_list_item($block['innerHTML'], $block, $enableSave, $fieldName, $meta, $rows);
     138                ]) : null;
     139                $block_content .= $this->render_list_item($inner_block['innerHTML'], $inner_block, $enableSave, $fieldName, $meta, $rows);
    157140            }
    158             $block_content .= '<input type="hidden" id="tdb_nonce_input_id" value="' . wp_create_nonce('update_checkbox_state_nonce') . '">';
    159             $block_content .= '<input type="hidden" id="tdb_post_id" value="' . get_the_ID() . '">';
    160 
    161141            $block_content .= '</div>';
    162142        }
     
    224204        $blog_id = get_current_blog_id();
    225205
    226         // does record exists
     206        // does record exist for this user
    227207        $record = $this->get_where([
    228             // 'user_id' => $user_id,
     208            'user_id' => $user_id,
    229209            'post_id' => $post_id,
    230210            'blog_id' => $blog_id,
     
    232212        ]);
    233213
    234         if($record){
    235             // only author can edit
    236             if($record->user_id != $user_id){
    237                 wp_send_json_error();
    238             }
     214        if ($record) {
    239215            $this->update($record->id, ['checked' => $status]);
    240216            wp_send_json_success();
  • todo-block/trunk/readme.txt

    r3062160 r3482379  
    11=== Todo Block ===
    22Contributors:      davexpression, pluginette
    3 Tags:              block
    4 Tested up to:      6.4
    5 Stable tag:        1.1.1
     3Tags:              block, todo, checklist, checkbox, tasks
     4Tested up to:      6.7
     5Stable tag:        1.2.0
     6Requires at least: 6.3
     7Requires PHP:      7.0
    68License:           GPL-2.0-or-later
    79License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     
    1012
    1113== Description ==
    12 *Logged In users can s=now save selection (if enabled)*
     14
    1315Gutenberg is a great block editor but it does not come with a todo block.
    1416
     
    1618Your todo checkboxes will appear both on the **frontend** and **backend**. It will even keep the current state of the checkbox when shown on the frontend.
    1719
    18 You can use this block to
    19 - add tasks to your posts and pages
    20 - create a checklist of items
    21 - let users save selection
    22 - set goals
     20Logged-in users can save their checkbox selections (if enabled per checklist).
     21
     22You can use this block to:
     23
     24- Add tasks to your posts and pages
     25- Create a checklist of items
     26- Let logged-in users save their selections
     27- Set goals and track progress
    2328
    2429[youtube https://www.youtube.com/watch?v=xbmKzLUItqU&t]
     
    2631== Installation ==
    2732
    28 This section describes how to install the plugin and get it working.
    29 
    30 e.g.
    31 
    32 1. Upload the plugin files to the `/wp-content/plugins/todo-list` directory, or install the plugin through the WordPress plugins screen directly.
    33 1. Activate the plugin through the 'Plugins' screen in WordPress
    34 
     331. Upload the plugin files to the `/wp-content/plugins/todo-block` directory, or install the plugin through the WordPress plugins screen directly.
     341. Activate the plugin through the 'Plugins' screen in WordPress.
    3535
    3636== Frequently Asked Questions ==
    3737
    38 = What is the minimum WordPress version =
     38= What is the minimum WordPress version? =
    3939
    40 5.0
     406.3
     41
     42= Can users save their checkbox state? =
     43
     44Yes. Enable the "Enable Save" toggle in the Checklist block settings. Logged-in users will have their selections saved per user.
    4145
    4246== Screenshots ==
    4347
    44481. The ToDo block on the backend.
    45 2. The ToDo block on the frontend
     492. The ToDo block on the frontend.
    4650
    4751== Changelog ==
     52
     53= 1.2.0 =
     54* Fix: Press Enter to create new checkbox items
     55* Fix: Support multiple todo lists on the same post/page
     56* Fix: Per-user save state now works correctly for all users
     57* Fix: Editor UX improvements (cursor, full-width text input)
     58* Fix: Internationalization loading
     59* Improvement: Use WordPress built-in block icons
     60* Improvement: Upgraded build tooling
     61
     62= 1.1.1 =
     63* Added blueprints
    4864
    4965= 1.1 =
  • todo-block/trunk/todo-block.php

    r3062160 r3482379  
    1313 * Requires at least: 6.3
    1414 * Requires PHP:      7.0
    15  * Version:           1.1.1
     15 * Version:           1.2.0
    1616 * Author:            David Towoju
    1717 * Author URI:        https://pluginette.com
     
    2626
    2727if (!defined('TDB_VERSION')) {
    28   define('TDB_VERSION', '1.1.1');
     28  define('TDB_VERSION', '1.2.0');
    2929}
    3030
     
    4141}
    4242
    43 if (!defined('PGNT_META_NAME')) {
    44   define('PGNT_META_NAME', 'pgnt_checklist_'.get_current_user_id());
    45 }
    46 
    4743// Load the core plugin class that contains all hooks.
    4844require plugin_dir_path(__FILE__) . 'class-db.php';
Note: See TracChangeset for help on using the changeset viewer.