mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fix restrictions for all blocks
This commit is contained in:
@@ -8,6 +8,40 @@ var um_components = wp.components,
|
||||
function um_admin_blocks_custom_fields( um_condition_fields, props ) {
|
||||
return wp.hooks.applyFilters( 'um_admin_blocks_custom_fields', [], um_condition_fields, props );
|
||||
}
|
||||
function um_add_restriction_attributes( settings, name ) {
|
||||
// add attributes for all blocks
|
||||
const restrictionAttributes = {
|
||||
um_is_restrict: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
um_who_access: {
|
||||
type: 'string',
|
||||
default: '0',
|
||||
},
|
||||
um_roles_access: {
|
||||
type: 'array',
|
||||
default: [],
|
||||
},
|
||||
um_message_type: {
|
||||
type: 'string',
|
||||
default: '0',
|
||||
},
|
||||
um_message_content: {
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
};
|
||||
|
||||
settings.attributes = Object.assign( settings.attributes, restrictionAttributes );
|
||||
return settings;
|
||||
}
|
||||
|
||||
wp.hooks.addFilter(
|
||||
'blocks.registerBlockType',
|
||||
'um-block/add-restriction-attributes',
|
||||
um_add_restriction_attributes
|
||||
);
|
||||
|
||||
var um_block_restriction = wp.compose.createHigherOrderComponent(
|
||||
function( BlockEdit ) {
|
||||
|
||||
@@ -37,27 +37,33 @@ if ( ! class_exists( 'um\core\Blocks' ) ) {
|
||||
|
||||
if ( empty( $settings['attributes']['um_is_restrict'] ) ) {
|
||||
$settings['attributes']['um_is_restrict'] = array(
|
||||
'type' => 'boolean',
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
);
|
||||
}
|
||||
if ( empty( $settings['attributes']['um_who_access'] ) ) {
|
||||
$settings['attributes']['um_who_access'] = array(
|
||||
'type' => 'string',
|
||||
'type' => 'string',
|
||||
'default' => 0,
|
||||
);
|
||||
}
|
||||
if ( empty( $settings['attributes']['um_roles_access'] ) ) {
|
||||
$settings['attributes']['um_roles_access'] = array(
|
||||
'type' => 'array',
|
||||
'type' => 'array',
|
||||
'default' => array(),
|
||||
'items' => array( 'type' => 'string' ),
|
||||
);
|
||||
}
|
||||
if ( empty( $settings['attributes']['um_message_type'] ) ) {
|
||||
$settings['attributes']['um_message_type'] = array(
|
||||
'type' => 'string',
|
||||
'type' => 'string',
|
||||
'default' => 0,
|
||||
);
|
||||
}
|
||||
if ( empty( $settings['attributes']['um_message_content'] ) ) {
|
||||
$settings['attributes']['um_message_content'] = array(
|
||||
'type' => 'string',
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user