- remove old blocks script

This commit is contained in:
ashubawork
2023-03-30 14:03:36 +03:00
parent c9dedf6d91
commit 8a2932dc11
2 changed files with 30 additions and 203 deletions
@@ -126,110 +126,3 @@ wp.blocks.registerBlockType( 'um-block/um-forms', {
}
});
//-------------------------------------\\
//------------ Um Account -------------\\
//-------------------------------------\\
wp.blocks.registerBlockType( 'um-block/um-account', {
title: wp.i18n.__( 'Account', 'ultimate-member' ),
description: wp.i18n.__( 'Displaying the account page of the current user', 'ultimate-member' ),
icon: 'id',
category: 'um-blocks',
attributes: {
content: {
source: 'html',
selector: 'p'
},
tab: {
type: 'select'
}
},
edit: function( props ) {
var content = props.attributes.content,
tab = props.attributes.tab;
function get_options() {
var option = [];
option.push( { label: wp.i18n.__( 'All', 'ultimate-member' ), value: 'all' } );
for ( var 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;
}
function umShortcode( value ) {
var shortcode = '[ultimatemember_account';
if ( value !== 'all' ) {
shortcode = shortcode + ' tab="' + value + '"';
}
shortcode = shortcode + ']';
props.setAttributes({ content: shortcode });
}
if ( content === undefined ) {
props.setAttributes({ content: '[ultimatemember_account]' });
}
return [
wp.element.createElement(
"div",
{
className: 'um-account-wrapper'
},
wp.i18n.__( 'Account', 'ultimate-member' )
),
wp.element.createElement(
wp.blockEditor.InspectorControls,
{},
wp.element.createElement(
wp.components.PanelBody,
{
title: wp.i18n.__( 'Account Tab', 'ultimate-member' )
},
wp.element.createElement(
wp.components.SelectControl,
{
label: wp.i18n.__( 'Select Tab', 'ultimate-member' ),
className: "um_select_account_tab",
type: 'number',
value: props.attributes.tab,
options: get_options(),
onChange: function onChange( value ) {
props.setAttributes({ tab: value });
umShortcode( value );
}
}
)
)
)
]
},
save: function( props ) {
return wp.element.createElement(
wp.editor.RichText.Content,
{
tagName: 'p',
className: props.className,
value: props.attributes.content
}
);
}
});
+30 -96
View File
@@ -556,102 +556,37 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
/**
* Load Gutenberg scripts
*/
// public function load_gutenberg_js() {
// //disable Gutenberg scripts to avoid the conflicts
// $disable_script = apply_filters( 'um_disable_blocks_script', false );
// if ( $disable_script ) {
// return;
// }
//
// $restricted_blocks = UM()->options()->get( 'restricted_blocks' );
// if ( empty( $restricted_blocks ) ) {
// return;
// }
//
// wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
// wp_set_script_translations( 'um_block_js', 'ultimate-member' );
//
// $restrict_options = array();
// $roles = UM()->roles()->get_roles( false );
// if ( ! empty( $roles ) ) {
// foreach ( $roles as $role_key => $title ) {
// $restrict_options[] = array(
// 'label' => $title,
// 'value' => $role_key,
// );
// }
// }
// wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
//
// wp_enqueue_script( 'um_block_js' );
//
// do_action( 'um_load_gutenberg_js' );
// }
public function load_gutenberg_js() {
//disable Gutenberg scripts to avoid the conflicts
$disable_script = apply_filters( 'um_disable_blocks_script', false );
if ( $disable_script ) {
return;
}
$restricted_blocks = UM()->options()->get( 'restricted_blocks' );
if ( empty( $restricted_blocks ) ) {
return;
}
/**
* Load Gutenberg blocks js
*/
// public function load_gutenberg_shortcode_blocks() {
// if ( ! function_exists( 'register_block_type' ) ) {
// // Gutenberg is not active.
// return;
// }
//
// //disable Gutenberg scripts to avoid the conflicts
// $disable_script = apply_filters( 'um_disable_blocks_script', false );
// if ( $disable_script ) {
// return;
// }
//
// $enable_blocks = UM()->options()->get( 'enable_blocks' );
// if ( empty( $enable_blocks ) ) {
// return;
// }
//
// wp_register_script( 'um-blocks-shortcode-js', $this->js_url . 'um-admin-blocks-shortcode.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', /*'rich-text'*/ ), ultimatemember_version, true );
// wp_set_script_translations( 'um-blocks-shortcode-js', 'ultimate-member' );
// wp_enqueue_script( 'um-blocks-shortcode-js' );
//
// $account_settings = array(
// 'password' => array(
// 'label' => __( 'Password', 'ultimate-member' ),
// 'enabled' => UM()->options()->get( 'account_tab_password' ),
// ),
// 'privacy' => array(
// 'label' => __( 'Privacy', 'ultimate-member' ),
// 'enabled' => UM()->options()->get( 'account_tab_privacy' ),
// ),
// 'notifications' => array(
// 'label' => __( 'Notifications', 'ultimate-member' ),
// 'enabled' => UM()->options()->get( 'account_tab_notifications' ),
// ),
// 'delete' => array(
// 'label' => __( 'Delete', 'ultimate-member' ),
// 'enabled' => UM()->options()->get( 'account_tab_delete' ),
// ),
// );
// wp_localize_script( 'um-blocks-shortcode-js', 'um_account_settings', $account_settings );
//
// /**
// * create gutenberg blocks
// */
// register_block_type( 'um-block/um-forms', array(
// 'editor_script' => 'um-blocks-shortcode-js',
// ) );
//
// register_block_type( 'um-block/um-member-directories', array(
// 'editor_script' => 'um-blocks-shortcode-js',
// ) );
//
// register_block_type( 'um-block/um-password-reset', array(
// 'editor_script' => 'um-blocks-shortcode-js',
// ) );
//
// register_block_type( 'um-block/um-account', array(
// 'editor_script' => 'um-blocks-shortcode-js',
// ) );
// }
wp_register_script( 'um_block_js', $this->js_url . 'um-admin-blocks.js', array( 'wp-i18n', 'wp-blocks', 'wp-components', 'wp-hooks' ), ultimatemember_version, true );
wp_set_script_translations( 'um_block_js', 'ultimate-member' );
$restrict_options = array();
$roles = UM()->roles()->get_roles( false );
if ( ! empty( $roles ) ) {
foreach ( $roles as $role_key => $title ) {
$restrict_options[] = array(
'label' => $title,
'value' => $role_key,
);
}
}
wp_localize_script( 'um_block_js', 'um_restrict_roles', $restrict_options );
wp_enqueue_script( 'um_block_js' );
do_action( 'um_load_gutenberg_js' );
}
/**
@@ -770,8 +705,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
if ( version_compare( $wp_version, '5.0', '>=' ) ) {
if ( isset( $current_screen ) && $current_screen->is_block_editor() ) {
// $this->load_gutenberg_js();
// $this->load_gutenberg_shortcode_blocks();
$this->load_gutenberg_js();
}
}
}