mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- change blocks folder
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "um-block/um-account",
|
||||
"title": "Account",
|
||||
"description": "Displaying the account page of the current user",
|
||||
"icon": "id",
|
||||
"category": "um-blocks",
|
||||
"attributes": {
|
||||
"tab": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"editorScript": "file:./src/index.js",
|
||||
"textdomain": "ultimate-member"
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
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});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "um-block/um-forms",
|
||||
"title": "Form",
|
||||
"description": "Choose display form",
|
||||
"icon": "forms",
|
||||
"category": "um-blocks",
|
||||
"attributes": {
|
||||
"form_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"editorScript": "file:./src/index.js",
|
||||
"textdomain": "ultimate-member"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
|
||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||
import ServerSideRender from '@wordpress/server-side-render';
|
||||
import { registerBlockType } from '@wordpress/blocks';
|
||||
import { useMemo } from '@wordpress/element';
|
||||
|
||||
registerBlockType('um-block/um-forms', {
|
||||
edit: function (props) {
|
||||
const blockProps = useBlockProps();
|
||||
const { attributes, setAttributes } = props;
|
||||
const { form_id } = attributes;
|
||||
|
||||
const posts = useSelect(
|
||||
(select) => select('core').getEntityRecords('postType', 'um_form', { per_page: -1, _fields: ['id', 'title'] }),
|
||||
[]
|
||||
);
|
||||
|
||||
const options = useMemo(() => {
|
||||
if (!posts) {
|
||||
return [{ label: wp.i18n.__('Loading...', 'ultimate-member'), value: '' }];
|
||||
}
|
||||
if (posts.length === 0) {
|
||||
return [{ label: wp.i18n.__('No forms found.', 'ultimate-member'), value: '' }];
|
||||
}
|
||||
return [{ label: wp.i18n.__('Select Form', 'ultimate-member'), value: '' }].concat(
|
||||
posts.map((post) => ({ label: post.title.rendered, value: post.id }))
|
||||
);
|
||||
}, [posts]);
|
||||
|
||||
const onFormChange = (value) => setAttributes({ form_id: value });
|
||||
|
||||
return (
|
||||
<div {...blockProps}>
|
||||
<ServerSideRender block="um-block/um-forms" attributes={attributes} />
|
||||
<InspectorControls>
|
||||
<PanelBody title={wp.i18n.__('Select Forms', 'ultimate-member')}>
|
||||
<SelectControl
|
||||
label={wp.i18n.__('Select Forms', 'ultimate-member')}
|
||||
className="um_select_forms"
|
||||
value={form_id}
|
||||
options={options}
|
||||
onChange={onFormChange}
|
||||
/>
|
||||
</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-form').each(function() {
|
||||
let wrapper = document.querySelector('.um-form');
|
||||
|
||||
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});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "um-block/um-member-directories",
|
||||
"title": "Member Directory",
|
||||
"description": "Choose display directory",
|
||||
"icon": "groups",
|
||||
"category": "um-blocks",
|
||||
"attributes": {
|
||||
"member_id": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"editorScript": "file:./src/index.js",
|
||||
"textdomain": "ultimate-member"
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import { useSelect } from '@wordpress/data';
|
||||
import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
|
||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||
import ServerSideRender from '@wordpress/server-side-render';
|
||||
import { registerBlockType } from "@wordpress/blocks";
|
||||
import { useMemo } from '@wordpress/element';
|
||||
|
||||
registerBlockType('um-block/um-member-directories', {
|
||||
edit: function (props) {
|
||||
const blockProps = useBlockProps();
|
||||
const { attributes, setAttributes } = props;
|
||||
const { member_id } = attributes;
|
||||
|
||||
const posts = useSelect((select) => {
|
||||
return select('core').getEntityRecords('postType', 'um_directory', {
|
||||
per_page: -1,
|
||||
_fields: ['id', 'title']
|
||||
});
|
||||
}, []);
|
||||
|
||||
const options = useMemo(() => {
|
||||
if (!posts) {
|
||||
return [{ label: wp.i18n.__('Loading...', 'ultimate-member'), value: '' }];
|
||||
}
|
||||
if (posts.length === 0) {
|
||||
return [{ label: wp.i18n.__('No posts found.', 'ultimate-member'), value: '' }];
|
||||
}
|
||||
return [{ label: wp.i18n.__('Select Directory', 'ultimate-member'), value: '' }].concat(
|
||||
posts.map((post) => ({
|
||||
label: post.title.rendered,
|
||||
value: post.id
|
||||
}))
|
||||
);
|
||||
}, [posts]);
|
||||
|
||||
const onMemberIdChange = (value) => setAttributes({ member_id: value });
|
||||
|
||||
if (!posts) {
|
||||
return (
|
||||
<p>
|
||||
<Spinner />
|
||||
{wp.i18n.__('Loading...', 'ultimate-member')}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div {...blockProps}>
|
||||
<ServerSideRender block="um-block/um-member-directories" attributes={attributes} />
|
||||
<InspectorControls>
|
||||
<PanelBody title={wp.i18n.__('Select Directories', 'ultimate-member')}>
|
||||
<SelectControl
|
||||
label={wp.i18n.__('Select Directories', 'ultimate-member')}
|
||||
className="um_select_directory"
|
||||
value={member_id}
|
||||
options={options}
|
||||
onChange={onMemberIdChange}
|
||||
/>
|
||||
</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-directory').each(function() {
|
||||
let wrapper = document.querySelector('.um-directory');
|
||||
let directory = jQuery(this);
|
||||
um_ajax_get_members( directory );
|
||||
um_slider_filter_init( directory );
|
||||
um_datepicker_filter_init( directory );
|
||||
um_timepicker_filter_init( directory );
|
||||
|
||||
if (wrapper) {
|
||||
wrapper.addEventListener('click', (event) => {
|
||||
if (event.target !== wrapper) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
jQuery(mutation.addedNodes).find('.um-member').each(function() {
|
||||
let wrapper = document.querySelector('.um-member');
|
||||
let directory = jQuery(this).parent();
|
||||
UM_Member_Grid(directory);
|
||||
|
||||
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});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"apiVersion": 2,
|
||||
"name": "um-block/um-password-reset",
|
||||
"title": "Password Reset",
|
||||
"description": "Displaying the password reset form",
|
||||
"icon": "unlock",
|
||||
"category": "um-blocks",
|
||||
"editorScript": "file:./src/index.js",
|
||||
"textdomain": "ultimate-member"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { registerBlockType } from '@wordpress/blocks';
|
||||
import ServerSideRender from '@wordpress/server-side-render';
|
||||
import { useBlockProps } from '@wordpress/block-editor';
|
||||
|
||||
registerBlockType('um-block/um-password-reset', {
|
||||
edit: function () {
|
||||
const blockProps = useBlockProps();
|
||||
|
||||
return (
|
||||
<div {...blockProps}>
|
||||
<ServerSideRender block="um-block/um-password-reset" />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
save: () => null
|
||||
});
|
||||
Reference in New Issue
Block a user