PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.0
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.0
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / assets / misc / gutenberg / block-content-restriction / build / index.js

index.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.0, at assets/misc/gutenberg/block-content-restriction/build/index.js

1 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";const e=window.wp.element,t=window.lodash,n=window.wp.hooks,o=window.wp.compose,l=window.wp.i18n,s=window.wp.blockEditor,r=window.wp.components,i=window.React,a=window.wp.htmlEntities;function _(n){const{name:o,attributes:s,setAttributes:_}=n;if(!(0,t.has)(s,"wppbContentRestriction"))return null;const{wppbContentRestriction:p}=s,g=JSON.parse(wppbBlockEditorData.userRoles);if(!JSON.parse(wppbBlockEditorData.content_restriction_activated))return null;let c=!1;["wppb/content-restriction-start","wppb/content-restriction-end"].includes(o)&&(c=!0);let u="",d=!1;switch(p.display_to){case"all":u=(0,l.__)("This content is not restricted and can be seen by all users.","profile-builder");break;case"":u=(0,l.__)("This content is restricted and can only be seen by logged in users","profile-builder"),p.user_roles&&0!==p.user_roles.length&&(d=!0,u+=(0,l.__)(" that have the following user roles: ","profile-builder"),p.user_roles.map((e=>{g.map((t=>{t.slug===e&&(u+=t.name+", ")}))})),u=u.slice(0,-2)),p.users_ids&&0!==p.users_ids.length&&(d&&(u+=(0,l.__)(" and","profile-builder")),u+=(0,l.__)(" that have the following user IDs: ","profile-builder"),u+=p.users_ids),u+=".";break;case"not_logged_in":u=(0,l.__)("This content is restricted and can only be seen by logged out users.","profile-builder");break;default:u=(0,l.__)("Please select an option.","profile-builder")}return(0,e.createElement)(i.Fragment,null,(0,e.createElement)("p",null,u),(0,e.createElement)("br",null),(0,e.createElement)(r.__experimentalToggleGroupControl,{isBlock:!0,label:(0,l.__)("Show content to","profile-builder"),value:p.display_to,onChange:e=>_({wppbContentRestriction:(0,t.assign)({...p},{display_to:e})})},!c&&(0,e.createElement)(r.__experimentalToggleGroupControlOption,{label:(0,l.__)("All Users","profile-builder"),value:"all"}),(0,e.createElement)(r.__experimentalToggleGroupControlOption,{label:(0,l.__)("Logged In Users","profile-builder"),value:""}),(0,e.createElement)(r.__experimentalToggleGroupControlOption,{label:(0,l.__)("Logged Out Users","profile-builder"),value:"not_logged_in"})),"all"==p.display_to&&(0,e.createElement)("p",null),""==p.display_to&&(0,e.createElement)("div",null,(0,e.createElement)(r.BaseControl,{label:(0,l.__)("User Roles","profile-builder")},(0,e.createElement)(r.SelectControl,{help:(0,l.__)("The desired valid user roles. Select none for all roles to be valid.","profile-builder"),multiple:!0,value:p.user_roles,onChange:e=>_({wppbContentRestriction:(0,t.assign)({...p},{user_roles:e})}),className:"components-select-control__input"},g?.map((t=>(0,e.createElement)("option",{key:t.slug,value:t.slug},(0,a.decodeEntities)(t.name)))))),(0,e.createElement)(r.BaseControl,{label:(0,l.__)("User IDs","profile-builder")},(0,e.createElement)(r.__experimentalInputControl,{help:(0,l.__)("A comma-separated list of user IDs.","profile-builder"),value:p.users_ids,onChange:e=>_({wppbContentRestriction:(0,t.assign)({...p},{users_ids:e})}),className:"components-input-control__input"})),(0,e.createElement)(i.Fragment,null,(0,e.createElement)(r.ToggleControl,{label:(0,l.__)("Enable Custom Message","profile-builder"),checked:!!p.enable_message_logged_in&&p.enable_message_logged_in,onChange:()=>_({wppbContentRestriction:(0,t.assign)({...p},{enable_message_logged_in:!p.enable_message_logged_in})})}),p.enable_message_logged_in&&(0,e.createElement)(r.TextareaControl,{help:(0,l.__)("Custom message for logged-in users.","profile-builder"),value:p.message_logged_in,onChange:e=>_({wppbContentRestriction:(0,t.assign)({...p},{message_logged_in:e})})}))),"not_logged_in"==p.display_to&&(0,e.createElement)(i.Fragment,null,(0,e.createElement)(r.ToggleControl,{label:(0,l.__)("Enable Custom Message","profile-builder"),checked:!!p.enable_message_logged_out&&p.enable_message_logged_out,onChange:()=>_({wppbContentRestriction:(0,t.assign)({...p},{enable_message_logged_out:!p.enable_message_logged_out})})}),p.enable_message_logged_out&&(0,e.createElement)(r.TextareaControl,{help:(0,l.__)("Custom message for logged-out users","profile-builder"),value:p.message_logged_out,onChange:e=>_({wppbContentRestriction:(0,t.assign)({...p},{message_logged_out:e})})})))}function p(n){const{name:o,attributes:i,setAttributes:a}=n,{wppbContentRestriction:p}=i;return JSON.parse(wppbBlockEditorData.content_restriction_activated)&&(0,t.has)(i,"wppbContentRestriction")&&!["wppb/content-restriction-start","wppb/content-restriction-end","wppb/content-restriction-start","wppb/content-restriction-start"].includes(o)?(0,e.createElement)(s.InspectorControls,null,(0,e.createElement)(r.PanelBody,{title:(0,l.__)("Profile Builder Content Restriction","profile-builder"),className:"profile-builder-content-restriction-settings",initialOpen:p.panel_open,onToggle:e=>a({wppbContentRestriction:(0,t.assign)({...p},{panel_open:!p.panel_open})})},(0,e.createElement)(_,{...n}))):null}(0,n.addFilter)("blocks.registerBlockType","profile-builder/attributes",(function(e){let n={wppbContentRestriction:{type:"object",properties:{user_roles:{type:"array"},users_ids:{type:"string"},display_to:{type:"string"},enable_message_logged_in:{type:"bool"},enable_message_logged_out:{type:"bool"},message_logged_in:{type:"string"},message_logged_out:{type:"string"},panel_open:{type:"bool"}},default:{user_roles:[],users_ids:"",display_to:"all",enable_message_logged_in:!1,enable_message_logged_out:!1,message_logged_in:"",message_logged_out:"",panel_open:!1}}};return e.attributes.wppb_content_restriction_block_start&&(n.wppbContentRestriction.default.display_to=""),e.attributes.wppb_content_restriction_block_end||e.attributes.pms_content_restriction_block_start||e.attributes.pms_content_restriction_block_end||(e.attributes=(0,t.assign)(e.attributes,n)),e}));const g=(0,o.createHigherOrderComponent)((t=>n=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...n}),(0,e.createElement)(p,{...n}))),"blockWPPBContentRestrictionControls");(0,n.addFilter)("editor.BlockEdit","profile-builder/inspector-controls",g,100)})();