mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- fixed logout process for WPML;
- added priority to the User Roles;
This commit is contained in:
@@ -102,7 +102,8 @@ a.um-delete{ color: #a00; }
|
||||
|
||||
.wp-list-table.roles .column-core,
|
||||
.wp-list-table.roles .column-users,
|
||||
.wp-list-table.roles .column-admin_access {
|
||||
.wp-list-table.roles .column-admin_access,
|
||||
.wp-list-table.roles .column-priority {
|
||||
width:15%;
|
||||
text-align: center !important;
|
||||
}
|
||||
@@ -110,7 +111,8 @@ a.um-delete{ color: #a00; }
|
||||
@media screen and (max-width: 782px) {
|
||||
.wp-list-table.roles .column-core,
|
||||
.wp-list-table.roles .column-users,
|
||||
.wp-list-table.roles .column-admin_access {
|
||||
.wp-list-table.roles .column-admin_access,
|
||||
.wp-list-table.roles .column-priority {
|
||||
text-align: left !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +256,11 @@ class UM_Roles_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
|
||||
function column_priority( $item ) {
|
||||
echo ! empty( $item['_um_priority'] ) ? $item['_um_priority'] : '-';
|
||||
}
|
||||
|
||||
|
||||
function um_set_pagination_args( $attr = array() ) {
|
||||
$this->set_pagination_args( $attr );
|
||||
}
|
||||
@@ -281,6 +286,7 @@ $ListTable->set_columns( array(
|
||||
'users' => __( 'No.of Members', 'ultimate-member' ),
|
||||
'core' => __( 'UM Custom Role', 'ultimate-member' ),
|
||||
'admin_access' => __( 'WP-Admin Access', 'ultimate-member' ),
|
||||
'priority' => __( 'Priority', 'ultimate-member' ),
|
||||
) );
|
||||
|
||||
$ListTable->set_sortable_columns( array(
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
$role = $object['data']; ?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php UM()->admin_forms( array(
|
||||
'class' => 'um-role-publish um-top-label',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_priority',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Role Priority', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The higher the number, the higher the priority', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_priority'] ) ? $role['_um_priority'] : '',
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
</div>
|
||||
<div class="submitbox" id="submitpost">
|
||||
<div id="major-publishing-actions">
|
||||
<input type="submit" value="<?php echo ! empty( $_GET['id'] ) ? __( 'Update Role', 'ultimate-member' ) : __( 'Create Role', 'ultimate-member' ) ?>" class="button-primary" id="create_role" name="create_role">
|
||||
|
||||
@@ -18,44 +18,32 @@ if ( ! class_exists( 'Logout' ) ) {
|
||||
***/
|
||||
function logout_page() {
|
||||
|
||||
global $sitepress;
|
||||
|
||||
$language_code = '';
|
||||
$current_page_ID = get_the_ID();
|
||||
$logout_page_id = UM()->config()->permalinks['logout'];
|
||||
$has_translation = false;
|
||||
$trid = 0;
|
||||
$not_default_lang = false;
|
||||
|
||||
if ( is_home() /*|| is_front_page()*/ ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) {
|
||||
if ( UM()->external_integrations()->is_wpml_active() ) {
|
||||
global $sitepress;
|
||||
$default_lang = $sitepress->get_default_language();
|
||||
$language_code = $sitepress->get_current_language();
|
||||
|
||||
if( function_exists('icl_get_current_language') ){
|
||||
$language_code = icl_get_current_language();
|
||||
}else if( function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE') ){ // checks if WPML exists
|
||||
$language_code = ICL_LANGUAGE_CODE;
|
||||
if ( function_exists( 'icl_object_id' ) ) {
|
||||
$trid = icl_object_id( $current_page_ID, 'page', true, $default_lang );
|
||||
} else {
|
||||
$trid = wpml_object_id_filter( $current_page_ID, 'page', true, $default_lang );
|
||||
}
|
||||
|
||||
$has_translation = true;
|
||||
|
||||
if( function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE') && isset( $sitepress ) ){ // checks if WPML exists
|
||||
$trid = $sitepress->get_element_trid( $current_page_ID );
|
||||
}
|
||||
|
||||
if( icl_get_default_language() !== $language_code ){
|
||||
$not_default_lang = true;
|
||||
}else{
|
||||
if ( $language_code == $default_lang ) {
|
||||
$language_code = '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( um_is_core_page('logout') || ( $trid > 0 && $has_translation && $trid == $logout_page_id && $not_default_lang ) ) {
|
||||
if ( um_is_core_page( 'logout' ) || ( $trid > 0 && $trid == $logout_page_id ) ) {
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
|
||||
|
||||
@@ -183,21 +183,36 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
|
||||
return false;
|
||||
|
||||
// User has roles so look for a UM Role one
|
||||
$role_keys = get_option( 'um_roles' );
|
||||
$um_roles_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( empty( $role_keys ) )
|
||||
return array_shift( $user->roles );
|
||||
|
||||
$role_keys = array_map( function( $item ) {
|
||||
if ( ! empty( $um_roles_keys ) ) {
|
||||
$um_roles_keys = array_map( function( $item ) {
|
||||
return 'um_' . $item;
|
||||
}, $role_keys );
|
||||
|
||||
$roles = array_intersect( array_values( $user->roles ), $role_keys );
|
||||
if ( ! empty( $roles ) ) {
|
||||
return array_shift( $roles );
|
||||
} else {
|
||||
return array_shift( $user->roles );
|
||||
}, $um_roles_keys );
|
||||
}
|
||||
|
||||
$orders = array();
|
||||
foreach ( array_values( $user->roles ) as $userrole ) {
|
||||
if ( ! empty( $um_roles_keys ) && in_array( $userrole, $um_roles_keys ) ) {
|
||||
$userrole_metakey = substr( $userrole, 3 );
|
||||
} else {
|
||||
$userrole_metakey = $userrole;
|
||||
}
|
||||
|
||||
$rolemeta = get_option( "um_role_{$userrole_metakey}_meta", false );
|
||||
|
||||
if ( ! $rolemeta ) {
|
||||
$orders[ $userrole ] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
$orders[ $userrole ] = ! empty( $rolemeta['_um_priority'] ) ? $rolemeta['_um_priority'] : 0;
|
||||
}
|
||||
|
||||
arsort( $orders );
|
||||
$roles_in_priority = array_keys( $orders );
|
||||
|
||||
return array_shift( $roles_in_priority );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user