mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,7 +542,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) {
|
||||
$this->add_notice( 'upgrade', array(
|
||||
'class' => 'updated',
|
||||
'message' => '<p>' . __( 'Successfully Upgraded', 'ultimate-member' ) . '</p>',
|
||||
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> Successfully Upgraded', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version ) . '</p>',
|
||||
), 4 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
|
||||
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
|
||||
|
||||
//invalid licenses notice
|
||||
//add_action( 'admin_notices', array( $this, 'check_wrong_licenses' ) );
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1666,52 +1662,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function check_wrong_licenses() {
|
||||
$invalid_license = 0;
|
||||
$arr_inactive_license_keys = array();
|
||||
|
||||
if ( empty( $this->settings_structure['licenses']['fields'] ) )
|
||||
return;
|
||||
|
||||
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
|
||||
$license = get_option( "{$field_data['id']}_edd_answer" );
|
||||
|
||||
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license )
|
||||
continue;
|
||||
|
||||
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ){
|
||||
$arr_inactive_license_keys[ ] = $license->item_name;
|
||||
}
|
||||
|
||||
$invalid_license++;
|
||||
|
||||
}
|
||||
|
||||
if ( ! empty( $arr_inactive_license_keys ) ) { ?>
|
||||
|
||||
<div class="error">
|
||||
<p>
|
||||
<?php printf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.UltimateMember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) ; ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
|
||||
if ( $invalid_license ) { ?>
|
||||
|
||||
<div class="error">
|
||||
<p>
|
||||
<?php printf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -39,30 +39,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
||||
$this->necessary_packages = $this->need_run_upgrades();
|
||||
|
||||
if ( ! empty( $this->necessary_packages ) ) {
|
||||
//add_action( 'admin_notices', array( $this, 'need_upgrade' ) );
|
||||
|
||||
$this->init_packages_ajax();
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 0 );
|
||||
|
||||
add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) );
|
||||
add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) );
|
||||
} /*else {
|
||||
//add_action( 'admin_notices', array( $this, 'updated_successfully' ) );
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
function need_upgrade() {
|
||||
?>
|
||||
<div class="error"><p><?php printf( __( '<strong>%s version %s</strong> needs to be updated. Please visit to "Upgrade" page <a href="%s">here</a> and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) ) ) ?></p></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function updated_successfully() {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) { ?>
|
||||
<div class="updated"><p><?php _e( 'Successfully Upgraded', 'ultimate-member' ) ?></p></div>
|
||||
<?php }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -343,5 +343,32 @@ if ( ! class_exists( 'UM_Functions' ) ) {
|
||||
return apply_filters( 'um_locate_template', $template, $template_name, $path );
|
||||
}
|
||||
|
||||
|
||||
function cpt_list() {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_cpt_list
|
||||
* @description Extend UM Custom Post Types
|
||||
* @input_vars
|
||||
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
|
||||
* function my_admin_pending_queue( $list ) {
|
||||
* // your code here
|
||||
* return $list;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
|
||||
return $cpt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -322,8 +322,9 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
//if current page not in exclude URLs
|
||||
//get redirect URL if not set get login page by default
|
||||
$redirect = UM()->options()->get( 'access_redirect' );
|
||||
if ( ! $redirect )
|
||||
if ( ! $redirect ) {
|
||||
$redirect = um_get_core_page( 'login' );
|
||||
}
|
||||
|
||||
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
|
||||
} else {
|
||||
@@ -604,6 +605,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
||||
//if post for not logged in users and user is not logged in
|
||||
if ( ! is_user_logged_in() ) {
|
||||
$this->singular_page = true;
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
} else {
|
||||
@@ -700,6 +703,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
|
||||
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
|
||||
if ( $custom_restrict ) {
|
||||
$this->singular_page = true;
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
@@ -707,6 +712,8 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
|
||||
|
||||
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
|
||||
$this->singular_page = true;
|
||||
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user