Plugin Directory

Changeset 3145331


Ignore:
Timestamp:
09/02/2024 12:40:00 PM (17 months ago)
Author:
gaambo
Message:

Update to version 1.1.0 from GitHub

Location:
sharable-password-protected-posts
Files:
4 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sharable-password-protected-posts/tags/1.1.0/build/index.asset.php

    r2809716 r3145331  
    1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '929f19f0796b8f796f89');
     1<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => 'eb9f3e35316836719bd7');
  • sharable-password-protected-posts/tags/1.1.0/build/index.js

    r2809716 r3145331  
    1 !function(){"use strict";var e=window.wp.plugins,t=window.wp.element,s=window.wp.editPost,o=window.wp.components,n=window.wp.i18n,i=window.wp.data,p=window.wp.editor;function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e},r.apply(this,arguments)}var a=window.wp.url,l=window.wp.compose,c={META_ENABLED:"_sppp_enabled",META_KEY:"_sppp_key",QUERY_PARAM:"_sppp_key"};const{META_KEY:d,QUERY_PARAM:w}=c,m=e=>{let{text:s,onCopy:n,children:i,...p}=e;const a=(0,l.useCopyToClipboard)(s,n);return(0,t.createElement)(o.Button,r({variant:"secondary",ref:a},p),i)};class u extends t.Component{constructor(){super(...arguments),this.state={showCopyConfirmation:!1},this.onCopy=this.onCopy.bind(this),this.onSelectInput=this.onSelectInput.bind(this)}componentWillUnmount(){clearTimeout(this.dismissCopyConfirmation)}onCopy(){this.setState({showCopyConfirmation:!0}),clearTimeout(this.dismissCopyConfirmation),this.dismissCopyConfirmation=setTimeout((()=>{this.setState({showCopyConfirmation:!1})}),4e3)}onSelectInput(e){e.target.select()}render(){const e=(0,a.addQueryArgs)(this.props.postLink,{[w]:this.props.secretKey});return(0,t.createElement)("div",null,(0,t.createElement)("label",{htmlFor:"sppp-link-field",className:"screen-reader-text"},(0,n.__)("Share this URL","sharable-password-protected-posts")),(0,t.createElement)(o.Flex,{className:"sppp__link-copy"},(0,t.createElement)(o.TextControl,{id:"sppp-link-field",className:"sppp__link-field",readOnly:!0,label:(0,n.__)("Secret URL:","sharable-password-protected-posts"),value:(0,a.safeDecodeURIComponent)(e),onFocus:this.onSelectInput}),(0,t.createElement)(m,{text:e,onCopy:this.onCopy,className:"sppp__copy-button"},this.state.showCopyConfirmation?(0,n.__)("Copied!","sharable-password-protected-posts"):(0,n.__)("Copy","sharable-password-protected-posts"))))}}var h=(0,i.withSelect)((e=>{const{getEditedPostAttribute:t,getPermalink:s}=e(p.store);return{postLink:s(),secretKey:t("meta")[d]}}))(u),y=window.wp.coreData,_=e=>{let{children:t}=e;const{isPostTypeVisible:s,postType:o,isPostPrivate:n}=(0,i.useSelect)((e=>{let t=!1;const s=e(p.store).getCurrentPostType(),o=e(y.store).getPostType(s),n=e(p.store).getEditedPostAttribute("link"),i=e(p.store).getEditedPostVisibility();return null!=o&&o.viewable&&(t=!0),n&&(t=!0),e(p.store).getPermalinkParts()&&(t=!0),{isPostTypeVisible:t,postType:s,isPostPrivate:"private"===i||"password"===i}}),[]),r=window.sppp&&window.sppp.settings.postTypes.includes(o);return window.sppp&&window.sppp.settings.hasPermissions&&s&&r&&n?t:null};const{META_ENABLED:E,META_KEY:C}=c;(0,e.registerPlugin)("sharable-password-protected-posts",{render:()=>{const{sharingEnabled:e,existingKey:r}=(0,i.useSelect)((e=>{const{getEditedPostAttribute:t}=e(p.store),s=t("meta");return{sharingEnabled:s[E],existingKey:s[C]}})),{editPost:a}=(0,i.useDispatch)(p.store);return(0,t.createElement)(s.PluginPostStatusInfo,{className:"sppp"},(0,t.createElement)(_,null,(0,t.createElement)("div",{className:"sppp__checkbox"},(0,t.createElement)(o.CheckboxControl,{label:(0,n.__)("Share post via secret URL","sharable-password-protected-posts"),checked:e,onChange:e=>{a(e?{meta:{[E]:!0,[C]:r||window.sppp.newKey||""}}:{meta:{[E]:!1,[C]:""}})}})),e&&(0,t.createElement)("div",{className:"sppp__link"},(0,t.createElement)(h,null))))}})}();
     1(()=>{"use strict";const e=window.wp.plugins,t=window.React,s=window.wp.components,o=window.wp.i18n,n=window.wp.data,i=window.wp.editor,p=window.wp.element,r=window.wp.url,a=window.wp.compose,l={META_ENABLED:"_sppp_enabled",META_KEY:"_sppp_key",QUERY_PARAM:"_sppp_key"},{META_KEY:d,QUERY_PARAM:c}=l,w=({text:e,onCopy:o,children:n,...i})=>{const p=(0,a.useCopyToClipboard)(e,o);return(0,t.createElement)(s.Button,{variant:"secondary",ref:p,...i},n)};class u extends p.Component{constructor(){super(...arguments),this.state={showCopyConfirmation:!1},this.onCopy=this.onCopy.bind(this),this.onSelectInput=this.onSelectInput.bind(this)}componentWillUnmount(){clearTimeout(this.dismissCopyConfirmation)}onCopy(){this.setState({showCopyConfirmation:!0}),clearTimeout(this.dismissCopyConfirmation),this.dismissCopyConfirmation=setTimeout((()=>{this.setState({showCopyConfirmation:!1})}),4e3)}onSelectInput(e){e.target.select()}render(){const e=(0,r.addQueryArgs)(this.props.postLink,{[c]:this.props.secretKey});return(0,t.createElement)("div",null,(0,t.createElement)("label",{htmlFor:"sppp-link-field",className:"screen-reader-text"},(0,o.__)("Share this URL","sharable-password-protected-posts")),(0,t.createElement)(s.Flex,{className:"sppp__link-copy"},(0,t.createElement)(s.TextControl,{id:"sppp-link-field",className:"sppp__link-field",readOnly:!0,label:(0,o.__)("Secret URL:","sharable-password-protected-posts"),value:(0,r.safeDecodeURIComponent)(e),onFocus:this.onSelectInput}),(0,t.createElement)(w,{text:e,onCopy:this.onCopy,className:"sppp__copy-button"},this.state.showCopyConfirmation?(0,o.__)("Copied!","sharable-password-protected-posts"):(0,o.__)("Copy","sharable-password-protected-posts"))))}}const m=(0,n.withSelect)((e=>{const{getEditedPostAttribute:t,getPermalink:s}=e(i.store);return{postLink:s(),secretKey:t("meta")[d]}}))(u),h=window.wp.coreData,y=({children:e})=>{const{isPostTypeVisible:t,postType:s,isPostPrivate:o}=(0,n.useSelect)((e=>{let t=!1;const s=e(i.store).getCurrentPostType(),o=e(h.store).getPostType(s),n=e(i.store).getEditedPostAttribute("link"),p=e(i.store).getEditedPostVisibility();return o?.viewable&&(t=!0),n&&(t=!0),e(i.store).getPermalinkParts()&&(t=!0),{isPostTypeVisible:t,postType:s,isPostPrivate:"private"===p||"password"===p}}),[]),p=window.sppp&&window.sppp.settings.postTypes.includes(s);return window.sppp&&window.sppp.settings.hasPermissions&&t&&p&&o?e:null};var _,E;const C=null!==(_=wp.editor?.PluginPostStatusInfo)&&void 0!==_?_:null!==(E=wp.editPost?.PluginPostStatusInfo)&&void 0!==E?E:wp.editSite?.PluginPostStatusInfo,{META_ENABLED:P,META_KEY:b}=l;(0,e.registerPlugin)("sharable-password-protected-posts",{render:()=>{const{sharingEnabled:e,existingKey:p}=(0,n.useSelect)((e=>{const{getEditedPostAttribute:t}=e(i.store),s=t("meta");return{sharingEnabled:s?.[P]||null,existingKey:s?.[b]||null}})),{editPost:r}=(0,n.useDispatch)(i.store);return(0,t.createElement)(C,{className:"sppp"},(0,t.createElement)(y,null,(0,t.createElement)("div",{className:"sppp__checkbox"},(0,t.createElement)(s.CheckboxControl,{label:(0,o.__)("Share post via secret URL","sharable-password-protected-posts"),checked:!!e,onChange:e=>{r(e?{meta:{[P]:!0,[b]:p||window.sppp.newKey||""}}:{meta:{[P]:!1,[b]:""}})}})),e&&(0,t.createElement)("div",{className:"sppp__link"},(0,t.createElement)(m,null))))}})})();
  • sharable-password-protected-posts/tags/1.1.0/sharable-password-protected-posts.php

    r2809749 r3145331  
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    8  * Version:           1.0.2
     8 * Version:           1.1.0
    99 * Author:            Fabian Todt
    1010 * Author URI:        https://fabiantodt.at/en/
     
    4040    ];
    4141
     42    $scriptDependencies = $assetsConfig['dependencies'];
     43    // For WordPress < 6.6 the editor script depends on wp-edit-post (because of PluginPostStatusInfo)
     44    // but the script is built against 6.6, therefore only requiring the wp-editor script.
     45    require ABSPATH . WPINC . '/version.php';
     46    if(version_compare($wp_version, '6.6', '<')) {
     47        $scriptDependencies[] = 'wp-edit-post';
     48    }
     49
    4250    wp_enqueue_script(
    4351        'sppp',
    4452        plugin_dir_url(__FILE__) . 'build/index.js',
    45         $assetsConfig['dependencies'],
     53        $scriptDependencies,
    4654        $assetsConfig['version']
    4755    );
  • sharable-password-protected-posts/tags/1.1.0/src/PostStatusSettings/index.js

    r2809716 r3145331  
    1 import { PluginPostStatusInfo } from "@wordpress/edit-post";
    21import { CheckboxControl } from "@wordpress/components";
    32import { __ } from "@wordpress/i18n";
     
    65import CopyUrl from "./CopyUrl";
    76import Check from "./Check";
     7
     8// Support < WP 6.6 and > WP 6.6
     9// See https://make.wordpress.org/core/2024/06/18/editor-unified-extensibility-apis-in-6-6/
     10const PluginPostStatusInfo = wp.editor?.PluginPostStatusInfo ?? ( wp.editPost?.PluginPostStatusInfo ?? wp.editSite?.PluginPostStatusInfo );
    811
    912import CONSTANTS from "./constants";
     
    1518    const { sharingEnabled, existingKey } = useSelect((select) => {
    1619        const { getEditedPostAttribute } = select(editorStore);
    17         const meta = getEditedPostAttribute("meta");
     20        const meta = getEditedPostAttribute("meta"); // Will be undefined in site editor.
    1821        return {
    19             sharingEnabled: meta[META_ENABLED],
    20             existingKey: meta[META_KEY],
     22            sharingEnabled: meta?.[META_ENABLED] || null,
     23            existingKey: meta?.[META_KEY] || null,
    2124        };
    2225    });
     
    4043                    <CheckboxControl
    4144                        label={__("Share post via secret URL", "sharable-password-protected-posts")}
    42                         checked={sharingEnabled}
     45                        checked={!!sharingEnabled} // Cast to bool, so null value after changing and reloading state does not trigger uncontrolled input warning.
    4346                        onChange={onChangeEnabled}
    4447                    />
  • sharable-password-protected-posts/trunk/build/index.asset.php

    r2809716 r3145331  
    1 <?php return array('dependencies' => array('wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '929f19f0796b8f796f89');
     1<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => 'eb9f3e35316836719bd7');
  • sharable-password-protected-posts/trunk/build/index.js

    r2809716 r3145331  
    1 !function(){"use strict";var e=window.wp.plugins,t=window.wp.element,s=window.wp.editPost,o=window.wp.components,n=window.wp.i18n,i=window.wp.data,p=window.wp.editor;function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(e[o]=s[o])}return e},r.apply(this,arguments)}var a=window.wp.url,l=window.wp.compose,c={META_ENABLED:"_sppp_enabled",META_KEY:"_sppp_key",QUERY_PARAM:"_sppp_key"};const{META_KEY:d,QUERY_PARAM:w}=c,m=e=>{let{text:s,onCopy:n,children:i,...p}=e;const a=(0,l.useCopyToClipboard)(s,n);return(0,t.createElement)(o.Button,r({variant:"secondary",ref:a},p),i)};class u extends t.Component{constructor(){super(...arguments),this.state={showCopyConfirmation:!1},this.onCopy=this.onCopy.bind(this),this.onSelectInput=this.onSelectInput.bind(this)}componentWillUnmount(){clearTimeout(this.dismissCopyConfirmation)}onCopy(){this.setState({showCopyConfirmation:!0}),clearTimeout(this.dismissCopyConfirmation),this.dismissCopyConfirmation=setTimeout((()=>{this.setState({showCopyConfirmation:!1})}),4e3)}onSelectInput(e){e.target.select()}render(){const e=(0,a.addQueryArgs)(this.props.postLink,{[w]:this.props.secretKey});return(0,t.createElement)("div",null,(0,t.createElement)("label",{htmlFor:"sppp-link-field",className:"screen-reader-text"},(0,n.__)("Share this URL","sharable-password-protected-posts")),(0,t.createElement)(o.Flex,{className:"sppp__link-copy"},(0,t.createElement)(o.TextControl,{id:"sppp-link-field",className:"sppp__link-field",readOnly:!0,label:(0,n.__)("Secret URL:","sharable-password-protected-posts"),value:(0,a.safeDecodeURIComponent)(e),onFocus:this.onSelectInput}),(0,t.createElement)(m,{text:e,onCopy:this.onCopy,className:"sppp__copy-button"},this.state.showCopyConfirmation?(0,n.__)("Copied!","sharable-password-protected-posts"):(0,n.__)("Copy","sharable-password-protected-posts"))))}}var h=(0,i.withSelect)((e=>{const{getEditedPostAttribute:t,getPermalink:s}=e(p.store);return{postLink:s(),secretKey:t("meta")[d]}}))(u),y=window.wp.coreData,_=e=>{let{children:t}=e;const{isPostTypeVisible:s,postType:o,isPostPrivate:n}=(0,i.useSelect)((e=>{let t=!1;const s=e(p.store).getCurrentPostType(),o=e(y.store).getPostType(s),n=e(p.store).getEditedPostAttribute("link"),i=e(p.store).getEditedPostVisibility();return null!=o&&o.viewable&&(t=!0),n&&(t=!0),e(p.store).getPermalinkParts()&&(t=!0),{isPostTypeVisible:t,postType:s,isPostPrivate:"private"===i||"password"===i}}),[]),r=window.sppp&&window.sppp.settings.postTypes.includes(o);return window.sppp&&window.sppp.settings.hasPermissions&&s&&r&&n?t:null};const{META_ENABLED:E,META_KEY:C}=c;(0,e.registerPlugin)("sharable-password-protected-posts",{render:()=>{const{sharingEnabled:e,existingKey:r}=(0,i.useSelect)((e=>{const{getEditedPostAttribute:t}=e(p.store),s=t("meta");return{sharingEnabled:s[E],existingKey:s[C]}})),{editPost:a}=(0,i.useDispatch)(p.store);return(0,t.createElement)(s.PluginPostStatusInfo,{className:"sppp"},(0,t.createElement)(_,null,(0,t.createElement)("div",{className:"sppp__checkbox"},(0,t.createElement)(o.CheckboxControl,{label:(0,n.__)("Share post via secret URL","sharable-password-protected-posts"),checked:e,onChange:e=>{a(e?{meta:{[E]:!0,[C]:r||window.sppp.newKey||""}}:{meta:{[E]:!1,[C]:""}})}})),e&&(0,t.createElement)("div",{className:"sppp__link"},(0,t.createElement)(h,null))))}})}();
     1(()=>{"use strict";const e=window.wp.plugins,t=window.React,s=window.wp.components,o=window.wp.i18n,n=window.wp.data,i=window.wp.editor,p=window.wp.element,r=window.wp.url,a=window.wp.compose,l={META_ENABLED:"_sppp_enabled",META_KEY:"_sppp_key",QUERY_PARAM:"_sppp_key"},{META_KEY:d,QUERY_PARAM:c}=l,w=({text:e,onCopy:o,children:n,...i})=>{const p=(0,a.useCopyToClipboard)(e,o);return(0,t.createElement)(s.Button,{variant:"secondary",ref:p,...i},n)};class u extends p.Component{constructor(){super(...arguments),this.state={showCopyConfirmation:!1},this.onCopy=this.onCopy.bind(this),this.onSelectInput=this.onSelectInput.bind(this)}componentWillUnmount(){clearTimeout(this.dismissCopyConfirmation)}onCopy(){this.setState({showCopyConfirmation:!0}),clearTimeout(this.dismissCopyConfirmation),this.dismissCopyConfirmation=setTimeout((()=>{this.setState({showCopyConfirmation:!1})}),4e3)}onSelectInput(e){e.target.select()}render(){const e=(0,r.addQueryArgs)(this.props.postLink,{[c]:this.props.secretKey});return(0,t.createElement)("div",null,(0,t.createElement)("label",{htmlFor:"sppp-link-field",className:"screen-reader-text"},(0,o.__)("Share this URL","sharable-password-protected-posts")),(0,t.createElement)(s.Flex,{className:"sppp__link-copy"},(0,t.createElement)(s.TextControl,{id:"sppp-link-field",className:"sppp__link-field",readOnly:!0,label:(0,o.__)("Secret URL:","sharable-password-protected-posts"),value:(0,r.safeDecodeURIComponent)(e),onFocus:this.onSelectInput}),(0,t.createElement)(w,{text:e,onCopy:this.onCopy,className:"sppp__copy-button"},this.state.showCopyConfirmation?(0,o.__)("Copied!","sharable-password-protected-posts"):(0,o.__)("Copy","sharable-password-protected-posts"))))}}const m=(0,n.withSelect)((e=>{const{getEditedPostAttribute:t,getPermalink:s}=e(i.store);return{postLink:s(),secretKey:t("meta")[d]}}))(u),h=window.wp.coreData,y=({children:e})=>{const{isPostTypeVisible:t,postType:s,isPostPrivate:o}=(0,n.useSelect)((e=>{let t=!1;const s=e(i.store).getCurrentPostType(),o=e(h.store).getPostType(s),n=e(i.store).getEditedPostAttribute("link"),p=e(i.store).getEditedPostVisibility();return o?.viewable&&(t=!0),n&&(t=!0),e(i.store).getPermalinkParts()&&(t=!0),{isPostTypeVisible:t,postType:s,isPostPrivate:"private"===p||"password"===p}}),[]),p=window.sppp&&window.sppp.settings.postTypes.includes(s);return window.sppp&&window.sppp.settings.hasPermissions&&t&&p&&o?e:null};var _,E;const C=null!==(_=wp.editor?.PluginPostStatusInfo)&&void 0!==_?_:null!==(E=wp.editPost?.PluginPostStatusInfo)&&void 0!==E?E:wp.editSite?.PluginPostStatusInfo,{META_ENABLED:P,META_KEY:b}=l;(0,e.registerPlugin)("sharable-password-protected-posts",{render:()=>{const{sharingEnabled:e,existingKey:p}=(0,n.useSelect)((e=>{const{getEditedPostAttribute:t}=e(i.store),s=t("meta");return{sharingEnabled:s?.[P]||null,existingKey:s?.[b]||null}})),{editPost:r}=(0,n.useDispatch)(i.store);return(0,t.createElement)(C,{className:"sppp"},(0,t.createElement)(y,null,(0,t.createElement)("div",{className:"sppp__checkbox"},(0,t.createElement)(s.CheckboxControl,{label:(0,o.__)("Share post via secret URL","sharable-password-protected-posts"),checked:!!e,onChange:e=>{r(e?{meta:{[P]:!0,[b]:p||window.sppp.newKey||""}}:{meta:{[P]:!1,[b]:""}})}})),e&&(0,t.createElement)("div",{className:"sppp__link"},(0,t.createElement)(m,null))))}})})();
  • sharable-password-protected-posts/trunk/sharable-password-protected-posts.php

    r2809749 r3145331  
    66 * Requires at least: 6.0
    77 * Requires PHP:      7.4
    8  * Version:           1.0.2
     8 * Version:           1.1.0
    99 * Author:            Fabian Todt
    1010 * Author URI:        https://fabiantodt.at/en/
     
    4040    ];
    4141
     42    $scriptDependencies = $assetsConfig['dependencies'];
     43    // For WordPress < 6.6 the editor script depends on wp-edit-post (because of PluginPostStatusInfo)
     44    // but the script is built against 6.6, therefore only requiring the wp-editor script.
     45    require ABSPATH . WPINC . '/version.php';
     46    if(version_compare($wp_version, '6.6', '<')) {
     47        $scriptDependencies[] = 'wp-edit-post';
     48    }
     49
    4250    wp_enqueue_script(
    4351        'sppp',
    4452        plugin_dir_url(__FILE__) . 'build/index.js',
    45         $assetsConfig['dependencies'],
     53        $scriptDependencies,
    4654        $assetsConfig['version']
    4755    );
  • sharable-password-protected-posts/trunk/src/PostStatusSettings/index.js

    r2809716 r3145331  
    1 import { PluginPostStatusInfo } from "@wordpress/edit-post";
    21import { CheckboxControl } from "@wordpress/components";
    32import { __ } from "@wordpress/i18n";
     
    65import CopyUrl from "./CopyUrl";
    76import Check from "./Check";
     7
     8// Support < WP 6.6 and > WP 6.6
     9// See https://make.wordpress.org/core/2024/06/18/editor-unified-extensibility-apis-in-6-6/
     10const PluginPostStatusInfo = wp.editor?.PluginPostStatusInfo ?? ( wp.editPost?.PluginPostStatusInfo ?? wp.editSite?.PluginPostStatusInfo );
    811
    912import CONSTANTS from "./constants";
     
    1518    const { sharingEnabled, existingKey } = useSelect((select) => {
    1619        const { getEditedPostAttribute } = select(editorStore);
    17         const meta = getEditedPostAttribute("meta");
     20        const meta = getEditedPostAttribute("meta"); // Will be undefined in site editor.
    1821        return {
    19             sharingEnabled: meta[META_ENABLED],
    20             existingKey: meta[META_KEY],
     22            sharingEnabled: meta?.[META_ENABLED] || null,
     23            existingKey: meta?.[META_KEY] || null,
    2124        };
    2225    });
     
    4043                    <CheckboxControl
    4144                        label={__("Share post via secret URL", "sharable-password-protected-posts")}
    42                         checked={sharingEnabled}
     45                        checked={!!sharingEnabled} // Cast to bool, so null value after changing and reloading state does not trigger uncontrolled input warning.
    4346                        onChange={onChangeEnabled}
    4447                    />
Note: See TracChangeset for help on using the changeset viewer.