mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed content restriction;
This commit is contained in:
@@ -31,8 +31,23 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
function is_UM_admin_screen() {
|
||||
global $current_screen;
|
||||
$screen_id = $current_screen->id;
|
||||
if ( is_admin() && ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr($screen_id, 'user') || strstr($screen_id, 'profile') ) )
|
||||
|
||||
if ( strstr( $screen_id, 'ultimatemember') ||
|
||||
strstr( $screen_id, 'um_') ||
|
||||
strstr( $screen_id, 'user' ) ||
|
||||
strstr( $screen_id, 'profile' ) ||
|
||||
$screen_id == 'nav-menus' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $this->is_plugin_post_type() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $this->is_restricted_entity() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,19 +58,43 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
|
||||
* @return bool
|
||||
*/
|
||||
function is_plugin_post_type() {
|
||||
$cpt = UM()->cpt_list();
|
||||
|
||||
if ( isset( $_REQUEST['post_type'] ) ) {
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
if ( in_array( $post_type, array( 'um_form','um_directory' ) ) ) {
|
||||
if ( in_array( $post_type, $cpt ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array( $post_type, array( 'um_form', 'um_directory' ) ) ) {
|
||||
if ( in_array( $post_type, $cpt ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If page now show content with restricted post/taxonomy
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_restricted_entity() {
|
||||
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
|
||||
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
||||
|
||||
global $typenow, $taxnow;
|
||||
if ( ! empty( $typenow ) && ! empty( $restricted_posts[ $typenow ] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! empty( $taxnow ) && ! empty( $restricted_taxonomies[ $taxnow ] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user