- profile tabs privacy;

- fixed issue with added wpautop for UM pages; (remove wpautop)
This commit is contained in:
nikitasinelnikov
2019-07-05 16:08:09 +03:00
parent 090588fe88
commit 9015b6c34d
4 changed files with 62 additions and 64 deletions
+15 -1
View File
@@ -137,6 +137,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
foreach ( $tabs as $id => $tab ) {
if ( isset( $tab['hidden'] ) ) {
continue;
}
if ( isset( $tab['default_privacy'] ) ) {
$fields = array(
array(
@@ -181,13 +185,23 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields );
}
$active_tabs = array();
$tabs = UM()->profile()->tabs_active();
if ( ! empty( $tabs ) ) {
foreach ( $tabs as $id => $info ) {
if ( isset( $info['name'] ) ) {
$active_tabs[ $id ] = $info['name'];
}
}
}
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array(
array(
'id' => 'profile_menu_default_tab',
'type' => 'select',
'label' => __( 'Profile menu default tab', 'ultimate-member' ),
'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ),
'options' => UM()->profile()->tabs_enabled(),
'options' => $active_tabs,
'conditional' => array( 'profile_menu', '=', 1 ),
'size' => 'small'
),
+6 -6
View File
@@ -545,18 +545,18 @@ if ( ! class_exists( 'um\Config' ) ) {
$tabs = UM()->profile()->tabs();
foreach ( $tabs as $id => $tab ) {
$this->settings_defaults['profile_tab_' . $id] = 1;
$this->settings_defaults[ 'profile_tab_' . $id ] = 1;
if ( ! isset( $tab['default_privacy'] ) ) {
$this->settings_defaults['profile_tab_' . $id . '_privacy'] = 0;
$this->settings_defaults['profile_tab_' . $id . '_roles'] = '';
$this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
$this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
}
}
foreach ( $this->email_notifications as $key => $notification ) {
$this->settings_defaults[$key . '_on'] = ! empty( $notification['default_active'] );
$this->settings_defaults[$key . '_sub'] = $notification['subject'];
$this->settings_defaults[$key] = $notification['body'];
$this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
$this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
$this->settings_defaults[ $key ] = $notification['body'];
}
foreach ( $this->core_pages as $page_s => $page ) {
+41 -55
View File
@@ -77,6 +77,24 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
}
/**
* Pre-defined privacy options
*
* @return array
*/
function tabs_privacy() {
$privacy = array(
0 => __( 'Anyone', 'ultimate-member' ),
1 => __( 'Guests only', 'ultimate-member' ),
2 => __( 'Members only', 'ultimate-member' ),
3 => __( 'Only the owner', 'ultimate-member' ),
4 => __( 'Specific roles', 'ultimate-member' ),
);
return $privacy;
}
/**
* All tab data
*
@@ -123,7 +141,7 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
// disable private tabs
if ( ! is_admin() ) {
if ( is_user_logged_in() ) {
$user_id = um_user('ID');
$user_id = um_user( 'ID' );
um_fetch_user( get_current_user_id() );
}
@@ -142,60 +160,6 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
}
/**
* Tabs that are active
*
* @return array
*/
function tabs_active() {
$tabs = $this->tabs();
foreach ( $tabs as $id => $info ) {
if ( ! UM()->options()->get( 'profile_tab_' . $id ) ) {
unset( $tabs[ $id ] );
}
}
return $tabs;
}
/**
* Activated tabs in backend
*
* @return string
*/
function tabs_enabled() {
$tabs = $this->tabs_active();
foreach ( $tabs as $id => $info ) {
if ( isset( $info['name'] ) ) {
$primary[ $id ] = $info['name'];
}
}
return isset( $primary ) ? $primary : '';
}
/**
* Privacy options
*
* @return array
*/
function tabs_privacy() {
$privacy = array(
0 => __( 'Anyone', 'ultimate-member' ),
1 => __( 'Guests only', 'ultimate-member' ),
2 => __( 'Members only', 'ultimate-member' ),
3 => __( 'Only the owner', 'ultimate-member' ),
4 => __( 'Specific roles', 'ultimate-member' ),
);
return $privacy;
}
/**
* Check if the user can view the current tab
*
@@ -260,6 +224,28 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
}
/**
* Tabs that are active
*
* @return array
*/
function tabs_active() {
$tabs = $this->tabs();
foreach ( $tabs as $id => $info ) {
if ( ! empty( $info['hidden'] ) ) {
continue;
}
if ( ! UM()->options()->get( 'profile_tab_' . $id ) ) {
unset( $tabs[ $id ] );
}
}
return $tabs;
}
/**
* Get active_tab
*
-2
View File
@@ -36,9 +36,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
add_shortcode( 'um_show_content', array( &$this, 'um_shortcode_show_content_for_role' ) );
add_shortcode( 'ultimatemember_searchform', array( &$this, 'ultimatemember_searchform' ) );
add_filter( 'body_class', array( &$this, 'body_class' ), 0 );
add_action( 'template_redirect', array( &$this, 'is_um_page' ) );
add_filter( 'um_shortcode_args_filter', array( &$this, 'display_logout_form' ), 99 );
add_filter( 'um_shortcode_args_filter', array( &$this, 'parse_shortcode_args' ), 99 );