mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fix restrictions for not UM and JB blokcs
This commit is contained in:
@@ -199,25 +199,25 @@ wp.hooks.addFilter( 'editor.BlockEdit', 'um-block/um_block_restriction', um_bloc
|
||||
*
|
||||
* @type {{um_is_restrict: {type: string}, um_who_access: {type: string}, um_message_type: {type: string}, um_message_content: {type: string}}}
|
||||
*/
|
||||
var um_block_restrict_settings = {
|
||||
um_is_restrict: {
|
||||
type: "boolean"
|
||||
},
|
||||
um_who_access: {
|
||||
type: "select"
|
||||
},
|
||||
um_roles_access: {
|
||||
type: "select"
|
||||
},
|
||||
um_message_type: {
|
||||
type: "select"
|
||||
},
|
||||
um_message_content: {
|
||||
type: "string"
|
||||
}
|
||||
};
|
||||
|
||||
um_block_restrict_settings = wp.hooks.applyFilters( 'um_admin_blocks_restrict_settings', um_block_restrict_settings );
|
||||
// var um_block_restrict_settings = {
|
||||
// um_is_restrict: {
|
||||
// type: "boolean"
|
||||
// },
|
||||
// um_who_access: {
|
||||
// type: "select"
|
||||
// },
|
||||
// um_roles_access: {
|
||||
// type: "select"
|
||||
// },
|
||||
// um_message_type: {
|
||||
// type: "select"
|
||||
// },
|
||||
// um_message_content: {
|
||||
// type: "string"
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// um_block_restrict_settings = wp.hooks.applyFilters( 'um_admin_blocks_restrict_settings', um_block_restrict_settings );
|
||||
|
||||
|
||||
/**
|
||||
@@ -225,12 +225,12 @@ um_block_restrict_settings = wp.hooks.applyFilters( 'um_admin_blocks_restrict_se
|
||||
* @param settings
|
||||
* @returns {*}
|
||||
*/
|
||||
function um_add_block_attributes( settings ) {
|
||||
var _lodash = lodash,
|
||||
assign = _lodash.assign;
|
||||
|
||||
settings.attributes = assign( settings.attributes, um_block_restrict_settings );
|
||||
return settings;
|
||||
}
|
||||
|
||||
wp.hooks.addFilter( 'blocks.registerBlockType', 'um-block/um_add_block_attributes', um_add_block_attributes );
|
||||
// function um_add_block_attributes( settings ) {
|
||||
// var _lodash = lodash,
|
||||
// assign = _lodash.assign;
|
||||
//
|
||||
// settings.attributes = assign( settings.attributes, um_block_restrict_settings );
|
||||
// return settings;
|
||||
// }
|
||||
//
|
||||
// wp.hooks.addFilter( 'blocks.registerBlockType', 'um-block/um_add_block_attributes', um_add_block_attributes );
|
||||
|
||||
@@ -20,7 +20,39 @@ if ( ! class_exists( 'um\core\Blocks' ) ) {
|
||||
* Access constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( &$this, 'block_editor_render' ), 11 );
|
||||
add_action( 'init', array( &$this, 'block_editor_render' ), 10 );
|
||||
add_filter( 'block_type_metadata', array( &$this, 'block_type_metadata' ), 11, 1 );
|
||||
}
|
||||
|
||||
|
||||
public function block_type_metadata( $metadata ) {
|
||||
if ( empty( $metadata['attributes']['um_is_restrict'] ) ) {
|
||||
$metadata['attributes']['um_is_restrict'] = array(
|
||||
'type' => 'boolean',
|
||||
);
|
||||
}
|
||||
if ( empty( $metadata['attributes']['um_who_access'] ) ) {
|
||||
$metadata['attributes']['um_who_access'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
if ( empty( $metadata['attributes']['um_roles_access'] ) ) {
|
||||
$metadata['attributes']['um_roles_access'] = array(
|
||||
'type' => 'array',
|
||||
);
|
||||
}
|
||||
if ( empty( $metadata['attributes']['um_message_type'] ) ) {
|
||||
$metadata['attributes']['um_message_type'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
if ( empty( $metadata['attributes']['um_message_content'] ) ) {
|
||||
$metadata['attributes']['um_message_content'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user