mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed transferring from 1.3.88 to 2.0;
- hide restrict options for administrator role;
This commit is contained in:
@@ -22,9 +22,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 );
|
||||
add_action( 'load-post-new.php', array(&$this, 'add_metabox'), 9 );
|
||||
|
||||
|
||||
add_action( 'plugins_loaded', array(&$this, 'add_taxonomy_metabox'), 9 );
|
||||
|
||||
add_action( 'admin_init', array(&$this, 'add_taxonomy_metabox'), 9 );
|
||||
|
||||
//roles metaboxes
|
||||
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
|
||||
@@ -629,15 +627,21 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
'screen' => 'um_role_meta',
|
||||
'context' => 'normal',
|
||||
'priority' => 'default'
|
||||
),
|
||||
array(
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! isset( $_GET['id'] ) || 'administrator' != $_GET['id'] ) {
|
||||
$roles_metaboxes[] = array(
|
||||
'id' => 'um-admin-form-home',
|
||||
'title' => __( 'Homepage Options', 'ultimate-member' ),
|
||||
'callback' => $callback,
|
||||
'screen' => 'um_role_meta',
|
||||
'context' => 'normal',
|
||||
'priority' => 'default'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$roles_metaboxes = array_merge( $roles_metaboxes, array(
|
||||
array(
|
||||
'id' => 'um-admin-form-register',
|
||||
'title' => __( 'Registration Options', 'ultimate-member' ),
|
||||
@@ -678,7 +682,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
'context' => 'side',
|
||||
'priority' => 'default'
|
||||
)
|
||||
);
|
||||
) );
|
||||
|
||||
$roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
|
||||
|
||||
|
||||
@@ -1015,17 +1015,37 @@ if ( ! empty( $um_roles ) ) {
|
||||
update_option( 'um_roles', $role_keys );
|
||||
|
||||
global $wp_roles, $wp_version;
|
||||
if ( version_compare( $wp_version, '4.9.0', '<' ) && method_exists( $wp_roles, '_init' ) ) {
|
||||
wp_roles()->_init();
|
||||
if ( version_compare( $wp_version, '4.9', '<' ) ) {
|
||||
$wp_roles->_init();
|
||||
} elseif ( method_exists( $wp_roles, 'for_site' ) ) {
|
||||
wp_roles()->for_site( get_current_blog_id() );
|
||||
$wp_roles->for_site( get_current_blog_id() );
|
||||
}
|
||||
|
||||
//Content Restriction transfer
|
||||
global $wp_roles;
|
||||
if( method_exists($wp_roles,'_init') ){
|
||||
$wp_roles->_init();
|
||||
|
||||
//for check all post types and taxonomies
|
||||
$all_post_types = get_post_types( array( 'public' => true ) );
|
||||
|
||||
$all_taxonomies = get_taxonomies( array( 'public' => true ) );
|
||||
$exclude_taxonomies = UM()->excluded_taxonomies();
|
||||
|
||||
foreach ( $all_taxonomies as $key => $taxonomy ) {
|
||||
if( in_array( $key, $exclude_taxonomies ) )
|
||||
unset( $all_taxonomies[ $key ] );
|
||||
}
|
||||
|
||||
foreach ( $all_post_types as $key => $value ) {
|
||||
$all_post_types[ $key ] = true;
|
||||
}
|
||||
|
||||
foreach ( $all_taxonomies as $key => $value ) {
|
||||
$all_taxonomies[ $key ] = true;
|
||||
}
|
||||
|
||||
um_update_option( 'restricted_access_post_metabox', $all_post_types );
|
||||
um_update_option( 'restricted_access_taxonomy_metabox', $all_taxonomies );
|
||||
|
||||
|
||||
$roles_array = UM()->roles()->get_roles( false, array( 'administrator' ) );
|
||||
|
||||
$posts = get_posts( array(
|
||||
@@ -1086,31 +1106,36 @@ foreach ( $all_taxonomies as $key => $taxonomy ) {
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
|
||||
if ( empty( $terms ) )
|
||||
continue;
|
||||
|
||||
foreach ( $terms as $term_id ) {
|
||||
$term_meta = get_option( "{$taxonomy}_{$term_id}" );
|
||||
$term_meta = get_option( "category_{$term_id}" );
|
||||
|
||||
if ( empty( $term_meta ) )
|
||||
continue;
|
||||
|
||||
$um_accessible = $term_meta['_um_accessible'];
|
||||
$um_access_roles = $term_meta['_um_access_roles'];
|
||||
$um_access_redirect = ( $um_accessible == '2' ) ? $term_meta['_um_access_redirect'] : $term_meta['_um_access_redirect2'];
|
||||
$um_accessible = ! empty( $term_meta['_um_accessible'] ) ? $term_meta['_um_accessible'] : false;
|
||||
$um_access_roles = ! empty( $term_meta['_um_roles'] ) ? $term_meta['_um_roles'] : array();
|
||||
$redirect = ! empty( $term_meta['_um_redirect'] ) ? $term_meta['_um_redirect'] : '';
|
||||
$redirect2 = ! empty( $term_meta['_um_redirect2'] ) ? $term_meta['_um_redirect2'] : '';
|
||||
$um_access_redirect = ( $um_accessible == '2' ) ? $redirect : $redirect2;
|
||||
|
||||
$access_roles = array();
|
||||
if ( ! empty( $um_access_roles ) ) {
|
||||
foreach ( $roles_array as $role ) {
|
||||
if ( in_array( substr( $role, 3 ), $um_access_roles ) )
|
||||
$access_roles[$role] = '1';
|
||||
else
|
||||
$access_roles[$role] = '0';
|
||||
}
|
||||
} else {
|
||||
foreach ( $roles_array as $role ) {
|
||||
$access_roles[$role] = '0';
|
||||
}
|
||||
}
|
||||
$access_roles = array();
|
||||
if ( ! empty( $um_access_roles ) ) {
|
||||
foreach ( $roles_array as $role => $role_label ) {
|
||||
if ( in_array( substr( $role, 3 ), $um_access_roles ) )
|
||||
$access_roles[ $role ] = '1';
|
||||
else
|
||||
$access_roles[ $role ] = '0';
|
||||
}
|
||||
} else {
|
||||
foreach ( $roles_array as $role => $role_label ) {
|
||||
$access_roles[ $role ] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$restrict_options = array(
|
||||
$restrict_options = array(
|
||||
'_um_custom_access_settings' => '1',
|
||||
'_um_accessible' => $um_accessible,
|
||||
'_um_access_roles' => $access_roles,
|
||||
|
||||
Reference in New Issue
Block a user