mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- change blocks folder
This commit is contained in:
@@ -12,4 +12,4 @@
|
||||
},
|
||||
"editorScript": "file:./src/index.js",
|
||||
"textdomain": "ultimate-member"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-server-side-render'), 'version' => 'a9e99ac324b1bd5538e3');
|
||||
@@ -1,81 +1 @@
|
||||
import { registerBlockType } from '@wordpress/blocks';
|
||||
import ServerSideRender from '@wordpress/server-side-render';
|
||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||
import { PanelBody, SelectControl } from "@wordpress/components";
|
||||
import { useMemo, useCallback } from '@wordpress/element';
|
||||
|
||||
registerBlockType('um-block/um-account', {
|
||||
edit: function (props) {
|
||||
const { attributes, setAttributes } = props;
|
||||
const { tab } = attributes;
|
||||
const blockProps = useBlockProps();
|
||||
|
||||
const options = useMemo(() => {
|
||||
const option = [{ label: wp.i18n.__('All', 'ultimate-member'), value: 'all' }];
|
||||
for (const key in um_account_settings) {
|
||||
if (um_account_settings.hasOwnProperty(key) && um_account_settings[key]['enabled']) {
|
||||
option.push({
|
||||
label: um_account_settings[key]['label'],
|
||||
value: key
|
||||
});
|
||||
}
|
||||
}
|
||||
return option;
|
||||
}, []);
|
||||
|
||||
const onTabChange = useCallback((value) => {
|
||||
setAttributes({ tab: value });
|
||||
const shortcode = `[ultimatemember_account${value !== 'all' ? ` tab="${value}"` : ''}]`;
|
||||
setAttributes({ content: shortcode });
|
||||
}, [setAttributes]);
|
||||
|
||||
return (
|
||||
<div {...blockProps}>
|
||||
<ServerSideRender block="um-block/um-account" attributes={attributes} />
|
||||
<InspectorControls>
|
||||
<PanelBody title={wp.i18n.__('Account Tab', 'ultimate-member')}>
|
||||
<SelectControl
|
||||
label={wp.i18n.__('Select Tab', 'ultimate-member')}
|
||||
className="um_select_account_tab"
|
||||
value={tab}
|
||||
options={options}
|
||||
style={{ height: '35px', lineHeight: '20px', padding: '0 7px' }}
|
||||
onChange={onTabChange}
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
save: () => null
|
||||
});
|
||||
|
||||
jQuery(window).on( 'load', function($) {
|
||||
let observer = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutation) {
|
||||
|
||||
jQuery(mutation.addedNodes).find('.um.um-account').each(function() {
|
||||
let current_tab = jQuery(this).find('.um-account-main').attr('data-current_tab');
|
||||
let wrapper = document.querySelector('.um-form');
|
||||
|
||||
if ( current_tab ) {
|
||||
jQuery(this).find('.um-account-tab[data-tab="'+current_tab+'"]').show();
|
||||
jQuery(this).find('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
|
||||
um_responsive();
|
||||
}
|
||||
|
||||
if (wrapper) {
|
||||
wrapper.addEventListener('click', (event) => {
|
||||
if (event.target !== wrapper) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
|
||||
});
|
||||
(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var a in n)t.o(n,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.blocks,n=window.wp.serverSideRender;var a=t.n(n);const o=window.wp.blockEditor,c=window.wp.components,u=window.wp.element,i=window.ReactJSXRuntime;(0,e.registerBlockType)("um-block/um-account",{edit:function(t){const{attributes:e,setAttributes:n}=t,{tab:r}=e,s=(0,o.useBlockProps)(),l=(0,u.useMemo)((()=>{const t=[{label:wp.i18n.__("All","ultimate-member"),value:"all"}];for(const e in um_account_settings)um_account_settings.hasOwnProperty(e)&&um_account_settings[e].enabled&&t.push({label:um_account_settings[e].label,value:e});return t}),[]),d=(0,u.useCallback)((t=>{n({tab:t}),n({content:`[ultimatemember_account${"all"!==t?` tab="${t}"`:""}]`})}),[n]);return(0,i.jsxs)("div",{...s,children:[(0,i.jsx)(a(),{block:"um-block/um-account",attributes:e}),(0,i.jsx)(o.InspectorControls,{children:(0,i.jsx)(c.PanelBody,{title:wp.i18n.__("Account Tab","ultimate-member"),children:(0,i.jsx)(c.SelectControl,{label:wp.i18n.__("Select Tab","ultimate-member"),className:"um_select_account_tab",value:r,options:l,style:{height:"35px",lineHeight:"20px",padding:"0 7px"},onChange:d})})})]})},save:()=>null}),jQuery(window).on("load",(function(t){new MutationObserver((function(t){t.forEach((function(t){jQuery(t.addedNodes).find(".um.um-account").each((function(){let t=jQuery(this).find(".um-account-main").attr("data-current_tab"),e=document.querySelector(".um-form");t&&(jQuery(this).find('.um-account-tab[data-tab="'+t+'"]').show(),jQuery(this).find(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),um_responsive()),e&&e.addEventListener("click",(t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())}))}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
|
||||
Reference in New Issue
Block a user