diff --git a/includes/admin/class-admin.php b/includes/admin/class-admin.php index 992a2052..985630fc 100644 --- a/includes/admin/class-admin.php +++ b/includes/admin/class-admin.php @@ -6,9 +6,20 @@ if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin' ) ) { + + /** + * Class Admin + * @package um\admin + */ class Admin { + + + /** + * @var string + */ var $templates_path; + /** * Admin constructor. */ @@ -16,7 +27,6 @@ if ( ! class_exists( 'Admin' ) ) { $this->templates_path = um_path . 'includes/admin/templates/'; add_action( 'admin_init', array( &$this, 'admin_init' ), 0 ); - add_action( 'admin_notices', array( $this, 'check_wrong_install_folder' ), 3 ); } diff --git a/includes/admin/core/class-admin-columns.php b/includes/admin/core/class-admin-columns.php index 7c779aba..a13e51b1 100644 --- a/includes/admin/core/class-admin-columns.php +++ b/includes/admin/core/class-admin-columns.php @@ -156,7 +156,7 @@ if ( ! class_exists( 'Admin_Columns' ) ) { $page_id = UM()->options()->get( UM()->options()->get_core_page_id( $page_key ) ); if ( $page_id == $post->ID ) { - $post_states['um_core_page_' . $page_key] = sprintf( 'UM %s', $page_value['title'] ); + $post_states[ 'um_core_page_' . $page_key ] = sprintf( 'UM %s', $page_value['title'] ); } } diff --git a/includes/admin/core/class-admin-forms-settings.php b/includes/admin/core/class-admin-forms-settings.php index 5fef3440..47121681 100644 --- a/includes/admin/core/class-admin-forms-settings.php +++ b/includes/admin/core/class-admin-forms-settings.php @@ -5,6 +5,12 @@ namespace um\admin\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin_Forms_Settings' ) ) { + + + /** + * Class Admin_Forms_Settings + * @package um\admin\core + */ class Admin_Forms_Settings extends Admin_Forms { /** diff --git a/includes/admin/core/class-admin-functions.php b/includes/admin/core/class-admin-functions.php index ae37c426..d7974daa 100644 --- a/includes/admin/core/class-admin-functions.php +++ b/includes/admin/core/class-admin-functions.php @@ -5,82 +5,111 @@ namespace um\admin\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin_Functions' ) ) { - class Admin_Functions { - - function __construct() { - - $this->slug = 'ultimatemember'; - - add_action('parent_file', array(&$this, 'parent_file'), 9); - - add_filter('gettext', array(&$this, 'gettext'), 10, 4); - - add_filter('post_updated_messages', array(&$this, 'post_updated_messages') ); - - } - - /*** - *** @updated post messages - ***/ - function post_updated_messages($messages) { - global $post, $post_ID; - - $post_type = get_post_type( $post_ID ); - if ($post_type == 'um_form') { - - $messages['um_form'] = array( - 0 => '', - 1 => __('Form updated.'), - 2 => __('Custom field updated.'), - 3 => __('Custom field deleted.'), - 4 => __('Form updated.'), - 5 => isset($_GET['revision']) ? __('Form restored to revision.') : false, - 6 => __('Form created.'), - 7 => __('Form saved.'), - 8 => __('Form submitted.'), - 9 => __('Form scheduled.'), - 10=> __('Form draft updated.'), - ); - - } - - return $messages; - } - /*** - *** @gettext filters - ***/ - function gettext($translation, $text, $domain) { - global $post; - //$screen = get_current_screen(); - if ( isset( $post->post_type ) && UM()->admin()->is_plugin_post_type() ) { - $translations = get_translations_for_domain( $domain); - if ( $text == 'Publish') { - return $translations->translate( 'Create' ); - } - if ( $text == 'Move to Trash') { - return $translations->translate( 'Delete' ); - } - } + /** + * Class Admin_Functions + * @package um\admin\core + */ + class Admin_Functions { - return $translation; - } - /*** - *** @Fix parent file for correct highlighting - ***/ - function parent_file($parent_file){ - global $current_screen; - $screen_id = $current_screen->id; - if ( strstr($screen_id, 'um_') ) { - $parent_file = $this->slug; - } - return $parent_file; - } + /** + * Admin_Functions constructor. + */ + function __construct() { + add_action( 'parent_file', array( &$this, 'parent_file' ), 9 ); + add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 ); + add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages' ) ); + } + + + /** + * Updated post messages + * + * @param array $messages + * + * @return array + */ + function post_updated_messages( $messages ) { + global $post_ID; + + $post_type = get_post_type( $post_ID ); + + if ( $post_type == 'um_form' ) { + $messages['um_form'] = array( + 0 => '', + 1 => __( 'Form updated.', 'ultimate-member' ), + 2 => __( 'Custom field updated.', 'ultimate-member' ), + 3 => __( 'Custom field deleted.', 'ultimate-member' ), + 4 => __( 'Form updated.', 'ultimate-member' ), + 5 => isset( $_GET['revision'] ) ? __( 'Form restored to revision.', 'ultimate-member' ) : false, + 6 => __( 'Form created.', 'ultimate-member' ), + 7 => __( 'Form saved.', 'ultimate-member' ), + 8 => __( 'Form submitted.', 'ultimate-member' ), + 9 => __( 'Form scheduled.', 'ultimate-member' ), + 10 => __( 'Form draft updated.', 'ultimate-member' ), + ); + } + + return $messages; + } + + + /** + * Gettext filters + * + * @param $translation + * @param $text + * @param $domain + * + * @return string + */ + function gettext( $translation, $text, $domain ) { + global $post; + if ( isset( $post->post_type ) && UM()->admin()->is_plugin_post_type() ) { + $translations = get_translations_for_domain( $domain ); + if ( $text == 'Publish' ) { + return $translations->translate( 'Create' ); + } elseif ( $text == 'Move to Trash' ) { + return $translations->translate( 'Delete' ); + } + } + + return $translation; + } + + + /** + * Fix parent file for correct highlighting + * + * @param $parent_file + * + * @return string + */ + function parent_file( $parent_file ) { + global $current_screen; + $screen_id = $current_screen->id; + if ( strstr( $screen_id, 'um_' ) ) { + $parent_file = 'ultimatemember'; + } + return $parent_file; + } - - } + /** + * Boolean check if we're viewing UM backend + * + * @todo global for all admin classes + * @return bool + */ + 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') ) ) + return true; + return false; + } + } } \ No newline at end of file diff --git a/includes/admin/core/class-admin-menu.php b/includes/admin/core/class-admin-menu.php index 1ab6303a..da5ac2c0 100644 --- a/includes/admin/core/class-admin-menu.php +++ b/includes/admin/core/class-admin-menu.php @@ -7,312 +7,385 @@ use \RecursiveDirectoryIterator; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin_Menu' ) ) { - class Admin_Menu { - - function __construct() { - $this->slug = 'ultimatemember'; - - add_action('admin_menu', array(&$this, 'primary_admin_menu'), 0); - add_action('admin_menu', array(&$this, 'secondary_menu_items'), 1000); - add_action('admin_menu', array(&$this, 'extension_menu'), 9999); - - add_action( 'admin_head', array( $this, 'menu_order_count' ) ); - - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1000 ); - } - - /** - * Change the admin footer text on UM admin pages - */ - public function admin_footer_text( $footer_text ) { - $current_screen = get_current_screen(); - - // Add the dashboard pages - $um_pages[] = 'toplevel_page_ultimatemember'; - $um_pages[] = 'ultimate-member_page_um_options'; - $um_pages[] = 'edit-um_form'; - $um_pages[] = 'edit-um_role'; - $um_pages[] = 'edit-um_directory'; - $um_pages[] = 'ultimate-member_page_ultimatemember-extensions'; - - if ( isset( $current_screen->id ) && in_array( $current_screen->id, $um_pages ) ) { - // Change the footer text - if ( ! get_option( 'um_admin_footer_text_rated' ) ) { - - $footer_text = sprintf( __( 'If you like Ultimate Member please consider leaving a %s★★★★★%s review. It will help us to grow the plugin and make it more popular. Thank you.', 'ultimate-member' ), '', '' ); - - $footer_text .= ""; - } - } - - return $footer_text; - } - - /** - * When user clicks the review link in backend - */ - function ultimatemember_rated() { - update_option('um_admin_footer_text_rated', 1 ); - die(); - } - - - /** - * Manage order of admin menu items - */ - public function menu_order_count() { - global $menu, $submenu; - - if ( ! current_user_can( 'list_users' ) ) - return; - - $count = UM()->user()->get_pending_users_count(); - if ( is_array( $menu ) ) { - foreach ( $menu as $key => $menu_item ) { - if ( 0 === strpos( $menu_item[0], _x( 'Users', 'Admin menu name' ) ) ) { - $menu[ $key ][0] .= ' '.$count.''; - } - } - - } - if ( is_array( $submenu ) ) { - foreach ( $submenu['users.php'] as $key => $menu_item ) { - if ( 0 === strpos( $menu_item[0], _x( 'All Users', 'Admin menu name' ) ) ) { - $submenu['users.php'][ $key ][0] .= ' '.$count.''; - } - } - } - } - - /*** - *** @setup admin menu - ***/ - function primary_admin_menu() { - - $this->pagehook = add_menu_page( __('Ultimate Member', $this->slug), __('Ultimate Member', $this->slug), 'manage_options', $this->slug, array(&$this, 'admin_page'), 'dashicons-admin-users', '42.78578'); - add_action( 'load-' . $this->pagehook, array( &$this, 'on_load_page' ) ); - - add_submenu_page( $this->slug, __('Dashboard', $this->slug), __('Dashboard', $this->slug), 'manage_options', $this->slug, array(&$this, 'admin_page') ); - } - - - /*** - *** @secondary admin menu (after settings) - ***/ - function secondary_menu_items() { - - add_submenu_page( $this->slug, __( 'Forms', 'ultimate-member' ), __( 'Forms', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_form', '' ); - - add_submenu_page( $this->slug, __( 'User Roles', 'ultimate-member' ), __( 'User Roles', 'ultimate-member' ), 'manage_options', 'um_roles', array( &$this, 'um_roles_pages' ) ); - - if ( UM()->options()->get( 'members_page' ) ) { - add_submenu_page( $this->slug, __( 'Member Directories', 'ultimate-member' ), __( 'Member Directories', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_directory', '' ); - } - - /** - * UM hook - * - * @type action - * @title um_extend_admin_menu - * @description Extend UM menu - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_extend_admin_menu', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_extend_admin_menu' ); - } - - - function um_roles_pages() { - - if ( empty( $_GET['tab'] ) ) { - include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php'; - } elseif ( $_GET['tab'] == 'add' || $_GET['tab'] == 'edit' ) { - include_once um_path . 'includes/admin/templates/role/role-edit.php'; - } else { - um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) ); - } - - } - - - /*** - *** @extension menu - ***/ - function extension_menu() { - - add_submenu_page( $this->slug, __('Extensions', $this->slug), '' .__('Extensions', $this->slug) . '', 'manage_options', $this->slug . '-extensions', array(&$this, 'admin_page') ); - - } - - /*** - *** @load metabox stuff - ***/ - function on_load_page() { - wp_enqueue_script('common'); - wp_enqueue_script('wp-lists'); - wp_enqueue_script('postbox'); - - /** custom metaboxes for dashboard defined here **/ - - add_meta_box('um-metaboxes-contentbox-1', __('Users Overview','ultimate-member'), array(&$this, 'users_overview'), $this->pagehook, 'core', 'core'); - - add_meta_box('um-metaboxes-mainbox-1', __('Latest from our blog','ultimate-member'), array(&$this, 'um_news'), $this->pagehook, 'normal', 'core'); - - add_meta_box('um-metaboxes-sidebox-1', __('Purge Temp Files','ultimate-member'), array(&$this, 'purge_temp'), $this->pagehook, 'side', 'core'); - add_meta_box('um-metaboxes-sidebox-2', __('User Cache','ultimate-member'), array(&$this, 'user_cache'), $this->pagehook, 'side', 'core'); - - if ( $this->language_avaialable_not_installed() ) { - add_meta_box('um-metaboxes-sidebox-2', __('Language','ultimate-member'), array(&$this, 'dl_language'), $this->pagehook, 'side', 'core'); - } else if ( $this->language_avaialable_installed() ) { - add_meta_box('um-metaboxes-sidebox-2', __('Language','ultimate-member'), array(&$this, 'up_language'), $this->pagehook, 'side', 'core'); - } else if ( $this->language_not_available() ) { - add_meta_box('um-metaboxes-sidebox-2', __('Language','ultimate-member'), array(&$this, 'ct_language'), $this->pagehook, 'side', 'core'); - } - - } - - function up_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-update.php'; - } - - function dl_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-download.php'; - } - - function ct_language() { - $locale = get_option('WPLANG'); - include_once UM()->admin()->templates_path . 'dashboard/language-contrib.php'; - } - - function um_news() { - include_once UM()->admin()->templates_path . 'dashboard/feed.php'; - } - - function users_overview() { - include_once UM()->admin()->templates_path . 'dashboard/users.php'; - } - - function purge_temp() { - include_once UM()->admin()->templates_path . 'dashboard/purge.php'; - } - - function user_cache() { - include_once UM()->admin()->templates_path . 'dashboard/cache.php'; - } - - /*** - *** @language not available - ***/ - function language_not_available() { - $locale = get_option('WPLANG'); - if ( $locale && !strstr($locale, 'en_') && !isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } - /*** - *** @language available but not installed - ***/ - function language_avaialable_not_installed() { - $locale = get_option('WPLANG'); - if ( $locale && isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } - /*** - *** @language available and installed - ***/ - function language_avaialable_installed() { - $locale = get_option('WPLANG'); - if ( $locale && isset( UM()->available_languages[$locale] ) && file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) - return true; - return false; - } + /** + * Class Admin_Menu + * @package um\admin\core + */ + class Admin_Menu { + + + /** + * @var string + */ + var $pagehook; + + + /** + * Admin_Menu constructor. + */ + function __construct() { + $this->slug = 'ultimatemember'; + + add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 ); + add_action( 'admin_menu', array( &$this, 'secondary_menu_items' ), 1000 ); + add_action( 'admin_menu', array( &$this, 'extension_menu' ), 9999 ); + + add_action( 'admin_head', array( $this, 'menu_order_count' ) ); + + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1000 ); + } - /*** - *** @get a directory size - ***/ - function dir_size( $directory ) { - if ( $directory == 'temp' ) { - $directory = UM()->files()->upload_temp; - $size = 0; - foreach( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory ) ) as $file ) { - $size+=$file->getSize(); - } - return round ( $size / 1048576, 2); - } - return 0; - } + /** + * Change the admin footer text on UM admin pages + * + * @param $footer_text + * + * @return string + */ + public function admin_footer_text( $footer_text ) { + $current_screen = get_current_screen(); + + // Add the dashboard pages + $um_pages[] = 'toplevel_page_ultimatemember'; + $um_pages[] = 'ultimate-member_page_um_options'; + $um_pages[] = 'edit-um_form'; + $um_pages[] = 'edit-um_role'; + $um_pages[] = 'edit-um_directory'; + $um_pages[] = 'ultimate-member_page_ultimatemember-extensions'; + + if ( isset( $current_screen->id ) && in_array( $current_screen->id, $um_pages ) ) { + // Change the footer text + if ( ! get_option( 'um_admin_footer_text_rated' ) ) { + + ob_start(); ?> + + ★★★★★ + + + + + + user()->get_pending_users_count(); + if ( is_array( $menu ) ) { + foreach ( $menu as $key => $menu_item ) { + if ( 0 === strpos( $menu_item[0], _x( 'Users', 'Admin menu name' ) ) ) { + $menu[ $key ][0] .= ' '.$count.''; + } + } + } + + if ( is_array( $submenu ) ) { + foreach ( $submenu['users.php'] as $key => $menu_item ) { + if ( 0 === strpos( $menu_item[0], _x( 'All Users', 'Admin menu name' ) ) ) { + $submenu['users.php'][ $key ][0] .= ' '.$count.''; + } + } + } + } + + + /** + * Setup admin menu + */ + function primary_admin_menu() { + $this->pagehook = add_menu_page( __( 'Ultimate Member', 'ultimate-member' ), __( 'Ultimate Member', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ), 'dashicons-admin-users', '42.78578'); + + add_action( 'load-' . $this->pagehook, array( &$this, 'on_load_page' ) ); + + add_submenu_page( $this->slug, __( 'Dashboard', 'ultimate-member' ), __( 'Dashboard', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ) ); + } + + + /** + * Secondary admin menu (after settings) + */ + function secondary_menu_items() { + add_submenu_page( $this->slug, __( 'Forms', 'ultimate-member' ), __( 'Forms', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_form', '' ); + + add_submenu_page( $this->slug, __( 'User Roles', 'ultimate-member' ), __( 'User Roles', 'ultimate-member' ), 'manage_options', 'um_roles', array( &$this, 'um_roles_pages' ) ); + + if ( UM()->options()->get( 'members_page' ) ) { + add_submenu_page( $this->slug, __( 'Member Directories', 'ultimate-member' ), __( 'Member Directories', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_directory', '' ); + } + + /** + * UM hook + * + * @type action + * @title um_extend_admin_menu + * @description Extend UM menu + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_extend_admin_menu', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_extend_admin_menu' ); + } + + + /** + * Role page menu callback + */ + function um_roles_pages() { + if ( empty( $_GET['tab'] ) ) { + include_once um_path . 'includes/admin/core/list-tables/roles-list-table.php'; + } elseif ( $_GET['tab'] == 'add' || $_GET['tab'] == 'edit' ) { + include_once um_path . 'includes/admin/templates/role/role-edit.php'; + } else { + um_js_redirect( add_query_arg( array( 'page' => 'um_roles' ), get_admin_url( 'admin.php' ) ) ); + } + } + + + /** + * Extension menu + */ + function extension_menu() { + add_submenu_page( $this->slug, __( 'Extensions', 'ultimate-member' ), '' .__( 'Extensions', 'ultimate-member' ) . '', 'manage_options', $this->slug . '-extensions', array( &$this, 'admin_page' ) ); + } + + + /** + * Load metabox stuff + */ + function on_load_page() { + wp_enqueue_script( 'common' ); + wp_enqueue_script( 'wp-lists' ); + wp_enqueue_script( 'postbox' ); + + /** custom metaboxes for dashboard defined here **/ + add_meta_box( 'um-metaboxes-contentbox-1', __( 'Users Overview','ultimate-member' ), array( &$this, 'users_overview' ), $this->pagehook, 'core', 'core' ); + + add_meta_box( 'um-metaboxes-mainbox-1', __( 'Latest from our blog', 'ultimate-member' ), array( &$this, 'um_news' ), $this->pagehook, 'normal', 'core' ); + + add_meta_box( 'um-metaboxes-sidebox-1', __( 'Purge Temp Files', 'ultimate-member' ), array( &$this, 'purge_temp' ), $this->pagehook, 'side', 'core' ); + add_meta_box( 'um-metaboxes-sidebox-2', __( 'User Cache', 'ultimate-member' ), array( &$this, 'user_cache' ), $this->pagehook, 'side', 'core' ); + + if ( $this->language_avaialable_not_installed() ) { + add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'dl_language' ), $this->pagehook, 'side', 'core' ); + } else if ( $this->language_avaialable_installed() ) { + add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'up_language' ), $this->pagehook, 'side', 'core' ); + } else if ( $this->language_not_available() ) { + add_meta_box( 'um-metaboxes-sidebox-2', __( 'Language', 'ultimate-member' ), array( &$this, 'ct_language' ), $this->pagehook, 'side', 'core' ); + } + } + + + /** + * + */ + function up_language() { + $locale = get_option('WPLANG'); + include_once UM()->admin()->templates_path . 'dashboard/language-update.php'; + } + + + /** + * + */ + function dl_language() { + $locale = get_option('WPLANG'); + include_once UM()->admin()->templates_path . 'dashboard/language-download.php'; + } + + + /** + * + */ + function ct_language() { + $locale = get_option('WPLANG'); + include_once UM()->admin()->templates_path . 'dashboard/language-contrib.php'; + } + + + /** + * + */ + function um_news() { + include_once UM()->admin()->templates_path . 'dashboard/feed.php'; + } + + + /** + * + */ + function users_overview() { + include_once UM()->admin()->templates_path . 'dashboard/users.php'; + } + + + /** + * + */ + function purge_temp() { + include_once UM()->admin()->templates_path . 'dashboard/purge.php'; + } + + + /** + * + */ + function user_cache() { + include_once UM()->admin()->templates_path . 'dashboard/cache.php'; + } + + + /** + * Language not available + * + * @return bool + */ + function language_not_available() { + $locale = get_option( 'WPLANG' ); + if ( $locale && !strstr($locale, 'en_') && !isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) + return true; + return false; + } + + + /** + * Language available but not installed + * + * @return bool + */ + function language_avaialable_not_installed() { + $locale = get_option('WPLANG'); + if ( $locale && isset( UM()->available_languages[$locale] ) && !file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) + return true; + return false; + } + + + /** + * Language available and installed + * + * @return bool + */ + function language_avaialable_installed() { + $locale = get_option('WPLANG'); + if ( $locale && isset( UM()->available_languages[$locale] ) && file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) + return true; + return false; + } + + + /** + * Get a directory size + * + * @param $directory + * + * @return float|int + */ + function dir_size( $directory ) { + if ( $directory == 'temp' ) { + $directory = UM()->files()->upload_temp; + $size = 0; + + foreach( new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory ) ) as $file ) { + $size+=$file->getSize(); + } + return round ( $size / 1048576, 2); + } + return 0; + } + + + /** + * Which admin page to show? + */ + function admin_page() { - /*** - *** @which admin page to show? - ***/ - function admin_page() { + $page = $_REQUEST['page']; + if ( $page == 'ultimatemember' && ! isset( $_REQUEST['um-addon'] ) ) { ?> + +
+ +

Ultimate Member

+ + + + + + + +
+ +
- $page = $_REQUEST['page']; - if ( $page == 'ultimatemember' && ! isset( $_REQUEST['um-addon'] ) ) { +
pagehook, 'core', null ); ?>
+
pagehook, 'normal', null ); ?>
+
pagehook, 'side', null ); ?>
+ +
+ +
- ?> - -
- -

Ultimate Member

- - - - - - +
+
+ + + + admin()->templates_path . 'extensions.php'; -
- -
- -
pagehook,'core',null); ?>
-
pagehook,'normal',null); ?>
-
pagehook,'side',null); ?>
+ } -
- -
+ } -
- - - - admin()->templates_path . 'extensions.php'; - - } - - } - - } + } } \ No newline at end of file diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index ccb35a3e..510b0e5f 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -5,2159 +5,2243 @@ namespace um\admin\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin_Metabox' ) ) { - class Admin_Metabox { - private $form_nonce_added = false; - - - function __construct() { - - $this->slug = 'ultimatemember'; - - $this->in_edit = false; - $this->edit_mode_value = null; - - add_action('admin_head', array(&$this, 'admin_head'), 9); - add_action('admin_footer', array(&$this, 'load_modal_content'), 9); - - add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 ); - add_action( 'load-post-new.php', array(&$this, 'add_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' ) ); - } - - /*** - *** @Boolean check if we're viewing UM backend - ***/ - function is_UM_admin() { - 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') ) ) - return true; - return false; - } - - - /*** - *** @Gets the role meta - ***/ - function get_custom_post_meta($id){ - $all_meta = get_post_custom($id); - foreach($all_meta as $k=>$v){ - if (strstr($k, '_um_')){ - $um_meta[$k] = $v; - } - } - if (isset($um_meta)) - return $um_meta; - } - - /*** - *** @Runs on admin head - ***/ - function admin_head(){ - global $post; - if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){ - $this->postmeta = $this->get_custom_post_meta($post->ID); - } - } - - - /*** - *** @Init the metaboxes - ***/ - function add_metabox() { - global $current_screen; - - if ( $current_screen->id == 'um_form' ) { - add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 ); - add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 ); - } - - if ( $current_screen->id == 'um_directory' ) { - add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 ); - add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 ); - } - - //restrict content metabox - $post_types = UM()->options()->get( 'restricted_access_post_metabox' ); - if ( ! empty( $post_types[ $current_screen->id ] ) ) { - - /** - * UM hook - * - * @type filter - * @title um_restrict_content_hide_metabox - * @description Show/Hide Restrict content metabox - * @input_vars - * [{"var":"$show","type":"bool","desc":"Show Metabox"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 ); - * @example - * - */ - $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false ); - - if ( ! $hide_metabox ) { - add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 ); - add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 ); - } - - if ( $current_screen->id == 'attachment' ) { - add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); - add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); - } - } - - - add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 ); - } - - - function save_metabox_custom( $post_id, $post ) { - // validate nonce - if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) || - ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) { - return $post_id; - } - - /** - * UM hook - * - * @type action - * @title um_admin_custom_restrict_content_metaboxes - * @description Save metabox custom with restrict content - * @input_vars - * [{"var":"$post_id","type":"int","desc":"Post ID"}, - * {"var":"$post","type":"array","desc":"Post data"}] - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 ); - * @example - * - */ - do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post ); - } - - - function add_metabox_restrict_content() { - global $current_screen; - - add_meta_box( - 'um-admin-restrict-content', - __( 'UM Content Restriction', 'ultimate-member' ), - array( &$this, 'restrict_content_cb' ), - $current_screen->id, - 'normal', - 'default' - ); - - /** - * UM hook - * - * @type action - * @title um_admin_custom_restrict_content_metaboxes - * @description Add restrict content custom metabox - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_admin_custom_restrict_content_metaboxes' ); - } - - - /** - * Content restriction metabox - * - * @param $object - * @param $box - */ - function restrict_content_cb( $object, $box ) { - include_once UM()->admin()->templates_path . 'access/restrict_content.php'; - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' ); - } - - - /*** - *** @Init the metaboxes - ***/ - function add_taxonomy_metabox() { - //restrict content metabox - $all_taxonomies = get_taxonomies( array( 'public' => true ) ); - $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); - $exclude_taxonomies = UM()->excluded_taxonomies(); - - foreach ( $all_taxonomies as $key => $taxonomy ) { - if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) ) - continue; - - add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) ); - add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) ); - add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); - add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); - } - } - - - function save_metabox_restrict_content( $post_id, $post ) { - // validate nonce - if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) - return $post_id; - - // validate user - $post_type = get_post_type_object( $post->post_type ); - if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) - return $post_id; - - if ( ! empty( $_POST['um_content_restriction'] ) ) - update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); - else - delete_post_meta( $post_id, 'um_content_restriction' ); - - return $post_id; - } - - - function save_attachment_metabox_restrict_content( $post_id ) { - // validate nonce - if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) - return $post_id; - - $post = get_post( $post_id ); - - // validate user - $post_type = get_post_type_object( $post->post_type ); - if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) - return $post_id; - - if ( ! empty( $_POST['um_content_restriction'] ) ) - update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); - else - delete_post_meta( $post_id, 'um_content_restriction' ); - - return $post_id; - } - - - function um_category_access_fields_create() { - $data = array(); - - /** - * UM hook - * - * @type filter - * @title um_admin_category_access_settings_fields - * @description Settings fields for terms - * @input_vars - * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, - * {"var":"$data","type":"array","desc":"Settings Data"}, - * {"var":"$screen","type":"string","desc":"Category Screen"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); - * @example - * 'my-field-key', - * 'type' => 'my-field-type', - * 'label' => __( 'My field Label', 'ultimate-member' ), - * 'description' => __( 'My Field Description', 'ultimate-member' ), - * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, - * ); - * return $access_settings_fields; - * } - * ?> - */ - $fields = apply_filters( 'um_admin_category_access_settings_fields', array( - array( - 'id' => '_um_custom_access_settings', - 'type' => 'checkbox', - 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, - ), - array( - 'id' => '_um_accessible', - 'type' => 'select', - 'label' => __( 'Who can access this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, - 'options' => array( - '0' => __( 'Everyone', 'ultimate-member' ), - '1' => __( 'Logged out users', 'ultimate-member' ), - '2' => __( 'Logged in users', 'ultimate-member' ), - ), - 'conditional' => array( '_um_custom_access_settings', '=', '1' ) - ), - array( - 'id' => '_um_access_roles', - 'type' => 'multi_checkbox', - 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), - 'columns' => 3, - 'conditional' => array( '_um_accessible', '=', '2' ) - ), - array( - 'id' => '_um_noaccess_action', - 'type' => 'select', - 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), - 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, - 'options' => array( - '0' => __( 'Show access restricted message', 'ultimate-member' ), - '1' => __( 'Redirect user', 'ultimate-member' ), - ), - 'conditional' => array( '_um_accessible', '!=', '0' ) - ), - array( - 'id' => '_um_restrict_by_custom_message', - 'type' => 'select', - 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), - 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', - 'options' => array( - '0' => __( 'Global default message (default)', 'ultimate-member' ), - '1' => __( 'Custom message', 'ultimate-member' ), - ), - 'conditional' => array( '_um_noaccess_action', '=', '0' ) - ), - array( - 'id' => '_um_restrict_custom_message', - 'type' => 'wp_editor', - 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), - 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', - 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) - ), - array( - 'id' => '_um_access_redirect', - 'type' => 'select', - 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), - 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', - 'conditional' => array( '_um_noaccess_action', '=', '1' ), - 'options' => array( - '0' => __( 'Login page', 'ultimate-member' ), - '1' => __( 'Custom URL', 'ultimate-member' ), - ), - ), - array( - 'id' => '_um_access_redirect_url', - 'type' => 'text', - 'label' => __( 'Redirect URL', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', - 'conditional' => array( '_um_access_redirect', '=', '1' ) - ), - array( - 'id' => '_um_access_hide_from_queries', - 'type' => 'checkbox', - 'label' => __( 'Hide from queries', 'ultimate-member' ), - 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', - 'conditional' => array( '_um_accessible', '!=', '0' ) - ) - ), $data, 'create' ); - - UM()->admin_forms( array( - 'class' => 'um-restrict-content um-third-column', - 'prefix_id' => 'um_content_restriction', - 'without_wrapper' => true, - 'div_line' => true, - 'fields' => $fields - ) )->render_form(); - - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); - } - - - function um_category_access_fields_edit( $term ) { - $termID = $term->term_id; - - $data = get_term_meta( $termID, 'um_content_restriction', true ); - - $_um_access_roles_value = array(); - if ( ! empty( $data['_um_access_roles'] ) ) { - foreach ( $data['_um_access_roles'] as $key => $value ) { - if ( $value ) - $_um_access_roles_value[] = $key; - } - } - - /** - * UM hook - * - * @type filter - * @title um_admin_category_access_settings_fields - * @description Settings fields for terms - * @input_vars - * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, - * {"var":"$data","type":"array","desc":"Settings Data"}, - * {"var":"$screen","type":"string","desc":"Category Screen"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); - * @example - * 'my-field-key', - * 'type' => 'my-field-type', - * 'label' => __( 'My field Label', 'ultimate-member' ), - * 'description' => __( 'My Field Description', 'ultimate-member' ), - * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, - * ); - * return $access_settings_fields; - * } - * ?> - */ - $fields = apply_filters( 'um_admin_category_access_settings_fields', array( - array( - 'id' => '_um_custom_access_settings', - 'type' => 'checkbox', - 'class' => 'form-field', - 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, - ), - array( - 'id' => '_um_accessible', - 'type' => 'select', - 'class' => 'form-field', - 'label' => __( 'Who can access this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, - 'options' => array( - '0' => __( 'Everyone', 'ultimate-member' ), - '1' => __( 'Logged out users', 'ultimate-member' ), - '2' => __( 'Logged in users', 'ultimate-member' ), - ), - 'conditional' => array( '_um_custom_access_settings', '=', '1' ) - ), - array( - 'id' => '_um_access_roles', - 'type' => 'multi_checkbox', - 'class' => 'form-field', - 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), - 'value' => $_um_access_roles_value, - 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), - 'columns' => 3, - 'conditional' => array( '_um_accessible', '=', '2' ) - ), - array( - 'id' => '_um_noaccess_action', - 'type' => 'select', - 'class' => 'form-field', - 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), - 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, - 'options' => array( - '0' => __( 'Show access restricted message', 'ultimate-member' ), - '1' => __( 'Redirect user', 'ultimate-member' ), - ), - 'conditional' => array( '_um_accessible', '!=', '0' ) - ), - array( - 'id' => '_um_restrict_by_custom_message', - 'type' => 'select', - 'class' => 'form-field', - 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), - 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', - 'options' => array( - '0' => __( 'Global default message (default)', 'ultimate-member' ), - '1' => __( 'Custom message', 'ultimate-member' ), - ), - 'conditional' => array( '_um_noaccess_action', '=', '0' ) - ), - array( - 'id' => '_um_restrict_custom_message', - 'type' => 'wp_editor', - 'class' => 'form-field', - 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), - 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', - 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) - ), - array( - 'id' => '_um_access_redirect', - 'type' => 'select', - 'class' => 'form-field', - 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), - 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', - 'conditional' => array( '_um_noaccess_action', '=', '1' ), - 'options' => array( - '0' => __( 'Login page', 'ultimate-member' ), - '1' => __( 'Custom URL', 'ultimate-member' ), - ), - ), - array( - 'id' => '_um_access_redirect_url', - 'type' => 'text', - 'class' => 'form-field', - 'label' => __( 'Redirect URL', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', - 'conditional' => array( '_um_access_redirect', '=', '1' ) - ), - array( - 'id' => '_um_access_hide_from_queries', - 'type' => 'checkbox', - 'class' => 'form-field', - 'label' => __( 'Hide from queries', 'ultimate-member' ), - 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), - 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', - 'conditional' => array( '_um_accessible', '!=', '0' ) - ) - ), $data, 'edit' ); - - UM()->admin_forms( array( - 'class' => 'um-restrict-content um-third-column', - 'prefix_id' => 'um_content_restriction', - 'without_wrapper' => true, - 'fields' => $fields - ) )->render_form(); - - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); - } - - - function um_category_access_fields_save( $termID ) { - - // validate nonce - if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) - return $termID; - - // validate user - $term = get_term( $termID ); - $taxonomy = get_taxonomy( $term->taxonomy ); - - if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) - return $termID; - - if ( ! empty( $_REQUEST['um_content_restriction'] ) ) - update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] ); - else - delete_term_meta( $termID, 'um_content_restriction' ); - - return $termID; - } - - - /*** - *** @load a directory metabox - ***/ - function load_metabox_directory( $object, $box ) { - $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); - include_once UM()->admin()->templates_path . 'directory/'. $box['id'] . '.php'; - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' ); - } - - - /*** - *** @load a role metabox - ***/ - function load_metabox_role( $object, $box ) { - global $post; - - $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); - - if ( $box['id'] == 'builder' ) { - UM()->builder()->form_id = get_the_ID(); - } - - preg_match('#\{.*?\}#s', $box['id'], $matches); - - if ( isset($matches[0]) ){ - $path = $matches[0]; - $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); - } else { - $path = um_path; - } - - $path = str_replace('{','', $path ); - $path = str_replace('}','', $path ); - - include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php'; - //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' ); - } - - - /*** - *** @load a form metabox - ***/ - function load_metabox_form( $object, $box ) { - global $post; - - $box['id'] = str_replace( 'um-admin-form-','', $box['id'] ); - - if ( $box['id'] == 'builder' ) { - UM()->builder()->form_id = get_the_ID(); - } - - preg_match('#\{.*?\}#s', $box['id'], $matches); - - if ( isset( $matches[0] ) ) { - $path = $matches[0]; - $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); - } else { - $path = um_path; - } - - $path = str_replace('{','', $path ); - $path = str_replace('}','', $path ); - - include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php'; - - if ( ! $this->form_nonce_added ) { - $this->form_nonce_added = true; - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' ); - } - } - - - /*** - *** @load a form metabox - ***/ - function load_metabox_custom( $object, $box ) { - global $post; - - $box['id'] = str_replace('um-admin-custom-','', $box['id']); - - preg_match('#\{.*?\}#s', $box['id'], $matches); - - if ( isset($matches[0]) ){ - $path = $matches[0]; - $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); - } else { - $path = um_path; - } - - $path = str_replace('{','', $path ); - $path = str_replace('}','', $path ); - - include_once $path . 'includes/admin/templates/'. $box['id'] . '.php'; - wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' ); - } - - /*** - *** @add directory metabox - ***/ - function add_metabox_directory() { - - add_meta_box('um-admin-form-general', __('General Options'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); - add_meta_box('um-admin-form-profile', __('Profile Card'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); - add_meta_box('um-admin-form-search', __('Search Options'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); - add_meta_box('um-admin-form-pagination', __('Results & Pagination'), array(&$this, 'load_metabox_directory'), 'um_directory', 'normal', 'default'); - - add_meta_box('um-admin-form-shortcode', __('Shortcode'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); - - add_meta_box('um-admin-form-appearance', __('Styling: General'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); - - //add_meta_box('um-admin-form-profile_card', __('Styling: Profile Card'), array(&$this, 'load_metabox_directory'), 'um_directory', 'side', 'default'); - - } - - /*** - *** @add role metabox - ***/ - function add_metabox_role() { - $callback = array( &$this, 'load_metabox_role' ); - - $roles_metaboxes = array( - array( - 'id' => 'um-admin-form-admin-permissions', - 'title' => __( 'Administrative Permissions', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-general', - 'title' => __( 'General Permissions', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-profile', - 'title' => __( 'Profile Access', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ) - ); - - 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' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-login', - 'title' => __( 'Login Options', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-logout', - 'title' => __( 'Logout Options', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-delete', - 'title' => __( 'Delete Options', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ), - array( - 'id' => 'um-admin-form-publish', - 'title' => __( 'Publish', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'side', - 'priority' => 'default' - ) - ) ); - - /** - * UM hook - * - * @type filter - * @title um_admin_role_metaboxes - * @description Extend metaboxes at Add/Edit User Role - * @input_vars - * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 ); - * @example - * 'um-admin-form-your-custom', - * 'title' => __( 'My Roles Metabox', 'ultimate-member' ), - * 'callback' => 'my-metabox-callback', - * 'screen' => 'um_role_meta', - * 'context' => 'side', - * 'priority' => 'default' - * ); - * - * return $roles_metaboxes; - * } - * ?> - */ - $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); - - $wp_caps_metabox = false; - if ( ! empty( $_GET['id'] ) ) { - $data = get_option( "um_role_{$_GET['id']}_meta" ); - if ( ! empty( $data['_um_is_custom'] ) ) - $wp_caps_metabox = true; - } - if ( 'add' == $_GET['tab'] || $wp_caps_metabox ) { - $roles_metaboxes[] = array( - 'id' => 'um-admin-form-wp-capabilities', - 'title' => __( 'WP Capabilities', 'ultimate-member' ), - 'callback' => $callback, - 'screen' => 'um_role_meta', - 'context' => 'normal', - 'priority' => 'default' - ); - } - - - foreach ( $roles_metaboxes as $metabox ) { - add_meta_box( - $metabox['id'], - $metabox['title'], - $metabox['callback'], - $metabox['screen'], - $metabox['context'], - $metabox['priority'] - ); - } - } - - - /*** - *** @add form metabox - ***/ - function add_metabox_form() { - - add_meta_box( 'um-admin-form-mode', __( 'Select Form Type' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); - add_meta_box( 'um-admin-form-builder', __( 'Form Builder' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); - add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); - - add_meta_box('um-admin-form-register_customize', __( 'Customize this form' ), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); - - /** - * UM hook - * - * @type action - * @title um_admin_custom_register_metaboxes - * @description Add custom metaboxes for register form - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_admin_custom_register_metaboxes' ); - - add_meta_box('um-admin-form-profile_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); - add_meta_box('um-admin-form-profile_settings', __('User Meta'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); - - /** - * UM hook - * - * @type action - * @title um_admin_custom_profile_metaboxes - * @description Add custom metaboxes for profile form - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_admin_custom_profile_metaboxes' ); - - add_meta_box('um-admin-form-login_customize', __('Customize this form'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); - add_meta_box('um-admin-form-login_settings', __('Options'), array(&$this, 'load_metabox_form'), 'um_form', 'side', 'default'); - - /** - * UM hook - * - * @type action - * @title um_admin_custom_login_metaboxes - * @description Add custom metaboxes for login form - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_admin_custom_login_metaboxes' ); - } - - /*** - *** @save directory metabox - ***/ - function save_metabox_directory( $post_id, $post ) { - global $wpdb; - - // validate nonce - if ( !isset( $_POST['um_admin_save_metabox_directory_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) return $post_id; - - // validate post type - if ( $post->post_type != 'um_directory' ) return $post_id; - - // validate user - $post_type = get_post_type_object( $post->post_type ); - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; - - $where = array( 'ID' => $post_id ); - - if ( empty( $_POST['post_title'] ) ) - $_POST['post_title'] = 'Directory #'.$post_id; - - $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); - - // save - delete_post_meta( $post_id, '_um_roles' ); - delete_post_meta( $post_id, '_um_tagline_fields' ); - delete_post_meta( $post_id, '_um_reveal_fields' ); - delete_post_meta( $post_id, '_um_search_fields' ); - delete_post_meta( $post_id, '_um_roles_can_search' ); - delete_post_meta( $post_id, '_um_show_these_users' ); - - //save metadata - foreach ( $_POST['um_metadata'] as $k => $v ) { - if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) { - $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY ); - } - if ( strstr( $k, '_um_' ) ) { - update_post_meta( $post_id, $k, $v ); - } - } - - } - - - /*** - *** @save form metabox - ***/ - function save_metabox_form( $post_id, $post ) { - global $wpdb; - - // validate nonce - if ( !isset( $_POST['um_admin_save_metabox_form_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) return $post_id; - - // validate post type - if ( $post->post_type != 'um_form' ) return $post_id; - - // validate user - $post_type = get_post_type_object( $post->post_type ); - if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; - - $where = array( 'ID' => $post_id ); - if ( empty( $_POST['post_title'] ) ) $_POST['post_title'] = 'Form #' . $post_id; - $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); - - // save - delete_post_meta( $post_id, '_um_profile_metafields' ); - foreach ( $_POST['form'] as $k => $v ) { - if ( strstr( $k, '_um_' ) ){ - update_post_meta( $post_id, $k, $v); - } - } - - } - - /*** - *** @Load modal content - ***/ - function load_modal_content() { - - $screen = get_current_screen(); - if ( $this->is_UM_admin() ) { - foreach ( glob( um_path . 'includes/admin/templates/modal/*.php' ) as $modal_content ) { - include_once $modal_content; - } - } - - // needed on forms only - if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) { - - $settings['textarea_rows'] = 8; - - echo ''; - - echo ''; - - $this->is_loaded = true; - } - - } - /*** - *** @Show field input for edit - ***/ - function field_input( $attribute, $form_id = null, $field_args = array() ) { - if ( $this->in_edit == true ) { // we're editing a field - $real_attr = substr( $attribute, 1 ); - $this->edit_mode_value = (isset( $this->edit_array[ $real_attr ] ) ) ? $this->edit_array[ $real_attr ] : null; - } + /** + * Class Admin_Metabox + * @package um\admin\core + */ + class Admin_Metabox { + + + /** + * @var bool + */ + private $form_nonce_added = false; + + + /** + * Admin_Metabox constructor. + */ + function __construct() { + + $this->slug = 'ultimatemember'; + + $this->in_edit = false; + $this->edit_mode_value = null; + + add_action('admin_head', array(&$this, 'admin_head'), 9); + add_action('admin_footer', array(&$this, 'load_modal_content'), 9); + + add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 ); + add_action( 'load-post-new.php', array(&$this, 'add_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' ) ); + } + + + /** + * Boolean check if we're viewing UM backend + * + * @return bool + */ + function is_UM_admin() { + 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') ) ) + return true; + return false; + } + + + /** + * Gets the role meta + * + * @param $id + * + * @return mixed + */ + function get_custom_post_meta( $id ) { + $all_meta = get_post_custom( $id ); + foreach ( $all_meta as $k => $v ) { + if ( strstr( $k, '_um_' ) ) { + $um_meta[ $k ] = $v; + } + } + if ( isset( $um_meta ) ) { + return $um_meta; + } + + return false; + } + + + /** + * Runs on admin head + */ + function admin_head(){ + global $post; + if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){ + $this->postmeta = $this->get_custom_post_meta($post->ID); + } + } + + + /** + * Init the metaboxes + */ + function add_metabox() { + global $current_screen; + + if ( $current_screen->id == 'um_form' ) { + add_action( 'add_meta_boxes', array(&$this, 'add_metabox_form'), 1 ); + add_action( 'save_post', array(&$this, 'save_metabox_form'), 10, 2 ); + } + + if ( $current_screen->id == 'um_directory' ) { + add_action( 'add_meta_boxes', array(&$this, 'add_metabox_directory'), 1 ); + add_action( 'save_post', array(&$this, 'save_metabox_directory'), 10, 2 ); + } + + //restrict content metabox + $post_types = UM()->options()->get( 'restricted_access_post_metabox' ); + if ( ! empty( $post_types[ $current_screen->id ] ) ) { + + /** + * UM hook + * + * @type filter + * @title um_restrict_content_hide_metabox + * @description Show/Hide Restrict content metabox + * @input_vars + * [{"var":"$show","type":"bool","desc":"Show Metabox"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_restrict_content_hide_metabox', 'function_name', 10, 1 ); + * @example + * + */ + $hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false ); + + if ( ! $hide_metabox ) { + add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 ); + add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 ); + } + + if ( $current_screen->id == 'attachment' ) { + add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); + add_action( 'edit_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 ); + } + } + + + add_action( 'save_post', array( &$this, 'save_metabox_custom' ), 10, 2 ); + } + + + /** + * @param $post_id + * @param $post + * + * @return mixed + */ + function save_metabox_custom( $post_id, $post ) { + // validate nonce + if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) || + ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) { + return $post_id; + } + + /** + * UM hook + * + * @type action + * @title um_admin_custom_restrict_content_metaboxes + * @description Save metabox custom with restrict content + * @input_vars + * [{"var":"$post_id","type":"int","desc":"Post ID"}, + * {"var":"$post","type":"array","desc":"Post data"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10, 2 ); + * @example + * + */ + do_action( 'um_admin_custom_restrict_content_metaboxes', $post_id, $post ); + } + + + /** + * + */ + function add_metabox_restrict_content() { + global $current_screen; + + add_meta_box( + 'um-admin-restrict-content', + __( 'UM Content Restriction', 'ultimate-member' ), + array( &$this, 'restrict_content_cb' ), + $current_screen->id, + 'normal', + 'default' + ); + + /** + * UM hook + * + * @type action + * @title um_admin_custom_restrict_content_metaboxes + * @description Add restrict content custom metabox + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_custom_restrict_content_metaboxes', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_admin_custom_restrict_content_metaboxes' ); + } + + + /** + * Content restriction metabox + * + * @param $object + * @param $box + */ + function restrict_content_cb( $object, $box ) { + include_once UM()->admin()->templates_path . 'access/restrict_content.php'; + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_restrict_content_nonce' ); + } + + + /** + * Init the metaboxes + */ + function add_taxonomy_metabox() { + //restrict content metabox + $all_taxonomies = get_taxonomies( array( 'public' => true ) ); + $tax_types = UM()->options()->get( 'restricted_access_taxonomy_metabox' ); + $exclude_taxonomies = UM()->excluded_taxonomies(); + + foreach ( $all_taxonomies as $key => $taxonomy ) { + if ( in_array( $key, $exclude_taxonomies ) || empty( $tax_types[$key] ) ) + continue; + + add_action( $taxonomy . '_add_form_fields', array( &$this, 'um_category_access_fields_create' ) ); + add_action( $taxonomy . '_edit_form_fields', array( &$this, 'um_category_access_fields_edit' ) ); + add_action( 'create_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); + add_action( 'edited_' . $taxonomy, array( &$this, 'um_category_access_fields_save' ) ); + } + } + + + /** + * @param $post_id + * @param $post + * + * @return mixed + */ + function save_metabox_restrict_content( $post_id, $post ) { + // validate nonce + if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) { + return $post_id; + } + + // validate user + $post_type = get_post_type_object( $post->post_type ); + if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) { + return $post_id; + } + + if ( ! empty( $_POST['um_content_restriction'] ) ) { + update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); + } else { + delete_post_meta( $post_id, 'um_content_restriction' ); + } + + return $post_id; + } + + + /** + * @param $post_id + * + * @return mixed + */ + function save_attachment_metabox_restrict_content( $post_id ) { + // validate nonce + if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) + return $post_id; + + $post = get_post( $post_id ); + + // validate user + $post_type = get_post_type_object( $post->post_type ); + if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) { + return $post_id; + } + + if ( ! empty( $_POST['um_content_restriction'] ) ) { + update_post_meta( $post_id, 'um_content_restriction', $_POST['um_content_restriction'] ); + } else { + delete_post_meta( $post_id, 'um_content_restriction' ); + } + + return $post_id; + } + + + /** + * + */ + function um_category_access_fields_create() { + $data = array(); + + /** + * UM hook + * + * @type filter + * @title um_admin_category_access_settings_fields + * @description Settings fields for terms + * @input_vars + * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, + * {"var":"$data","type":"array","desc":"Settings Data"}, + * {"var":"$screen","type":"string","desc":"Category Screen"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); + * @example + * 'my-field-key', + * 'type' => 'my-field-type', + * 'label' => __( 'My field Label', 'ultimate-member' ), + * 'description' => __( 'My Field Description', 'ultimate-member' ), + * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + * ); + * return $access_settings_fields; + * } + * ?> + */ + $fields = apply_filters( 'um_admin_category_access_settings_fields', array( + array( + 'id' => '_um_custom_access_settings', + 'type' => 'checkbox', + 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + ), + array( + 'id' => '_um_accessible', + 'type' => 'select', + 'label' => __( 'Who can access this content?', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, + 'options' => array( + '0' => __( 'Everyone', 'ultimate-member' ), + '1' => __( 'Logged out users', 'ultimate-member' ), + '2' => __( 'Logged in users', 'ultimate-member' ), + ), + 'conditional' => array( '_um_custom_access_settings', '=', '1' ) + ), + array( + 'id' => '_um_access_roles', + 'type' => 'multi_checkbox', + 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), + 'columns' => 3, + 'conditional' => array( '_um_accessible', '=', '2' ) + ), + array( + 'id' => '_um_noaccess_action', + 'type' => 'select', + 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), + 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, + 'options' => array( + '0' => __( 'Show access restricted message', 'ultimate-member' ), + '1' => __( 'Redirect user', 'ultimate-member' ), + ), + 'conditional' => array( '_um_accessible', '!=', '0' ) + ), + array( + 'id' => '_um_restrict_by_custom_message', + 'type' => 'select', + 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), + 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', + 'options' => array( + '0' => __( 'Global default message (default)', 'ultimate-member' ), + '1' => __( 'Custom message', 'ultimate-member' ), + ), + 'conditional' => array( '_um_noaccess_action', '=', '0' ) + ), + array( + 'id' => '_um_restrict_custom_message', + 'type' => 'wp_editor', + 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), + 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', + 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) + ), + array( + 'id' => '_um_access_redirect', + 'type' => 'select', + 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), + 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', + 'conditional' => array( '_um_noaccess_action', '=', '1' ), + 'options' => array( + '0' => __( 'Login page', 'ultimate-member' ), + '1' => __( 'Custom URL', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_access_redirect_url', + 'type' => 'text', + 'label' => __( 'Redirect URL', 'ultimate-member' ), + 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', + 'conditional' => array( '_um_access_redirect', '=', '1' ) + ), + array( + 'id' => '_um_access_hide_from_queries', + 'type' => 'checkbox', + 'label' => __( 'Hide from queries', 'ultimate-member' ), + 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', + 'conditional' => array( '_um_accessible', '!=', '0' ) + ) + ), $data, 'create' ); + + UM()->admin_forms( array( + 'class' => 'um-restrict-content um-third-column', + 'prefix_id' => 'um_content_restriction', + 'without_wrapper' => true, + 'div_line' => true, + 'fields' => $fields + ) )->render_form(); + + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); + } + + + /** + * @param $term + */ + function um_category_access_fields_edit( $term ) { + $termID = $term->term_id; + + $data = get_term_meta( $termID, 'um_content_restriction', true ); + + $_um_access_roles_value = array(); + if ( ! empty( $data['_um_access_roles'] ) ) { + foreach ( $data['_um_access_roles'] as $key => $value ) { + if ( $value ) + $_um_access_roles_value[] = $key; + } + } + + /** + * UM hook + * + * @type filter + * @title um_admin_category_access_settings_fields + * @description Settings fields for terms + * @input_vars + * [{"var":"$access_settings_fields","type":"array","desc":"Settings Fields"}, + * {"var":"$data","type":"array","desc":"Settings Data"}, + * {"var":"$screen","type":"string","desc":"Category Screen"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_category_access_settings_fields', 'function_name', 10, 3 ); + * @example + * 'my-field-key', + * 'type' => 'my-field-type', + * 'label' => __( 'My field Label', 'ultimate-member' ), + * 'description' => __( 'My Field Description', 'ultimate-member' ), + * 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + * ); + * return $access_settings_fields; + * } + * ?> + */ + $fields = apply_filters( 'um_admin_category_access_settings_fields', array( + array( + 'id' => '_um_custom_access_settings', + 'type' => 'checkbox', + 'class' => 'form-field', + 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, + ), + array( + 'id' => '_um_accessible', + 'type' => 'select', + 'class' => 'form-field', + 'label' => __( 'Who can access this content?', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, + 'options' => array( + '0' => __( 'Everyone', 'ultimate-member' ), + '1' => __( 'Logged out users', 'ultimate-member' ), + '2' => __( 'Logged in users', 'ultimate-member' ), + ), + 'conditional' => array( '_um_custom_access_settings', '=', '1' ) + ), + array( + 'id' => '_um_access_roles', + 'type' => 'multi_checkbox', + 'class' => 'form-field', + 'label' => __( 'Select which roles can access this content', 'ultimate-member' ), + 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'value' => $_um_access_roles_value, + 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), + 'columns' => 3, + 'conditional' => array( '_um_accessible', '=', '2' ) + ), + array( + 'id' => '_um_noaccess_action', + 'type' => 'select', + 'class' => 'form-field', + 'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ), + 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0, + 'options' => array( + '0' => __( 'Show access restricted message', 'ultimate-member' ), + '1' => __( 'Redirect user', 'ultimate-member' ), + ), + 'conditional' => array( '_um_accessible', '!=', '0' ) + ), + array( + 'id' => '_um_restrict_by_custom_message', + 'type' => 'select', + 'class' => 'form-field', + 'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ), + 'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0', + 'options' => array( + '0' => __( 'Global default message (default)', 'ultimate-member' ), + '1' => __( 'Custom message', 'ultimate-member' ), + ), + 'conditional' => array( '_um_noaccess_action', '=', '0' ) + ), + array( + 'id' => '_um_restrict_custom_message', + 'type' => 'wp_editor', + 'class' => 'form-field', + 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), + 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '', + 'conditional' => array( '_um_restrict_by_custom_message', '=', '1' ) + ), + array( + 'id' => '_um_access_redirect', + 'type' => 'select', + 'class' => 'form-field', + 'label' => __( 'Where should users be redirected to?', 'ultimate-member' ), + 'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0', + 'conditional' => array( '_um_noaccess_action', '=', '1' ), + 'options' => array( + '0' => __( 'Login page', 'ultimate-member' ), + '1' => __( 'Custom URL', 'ultimate-member' ), + ), + ), + array( + 'id' => '_um_access_redirect_url', + 'type' => 'text', + 'class' => 'form-field', + 'label' => __( 'Redirect URL', 'ultimate-member' ), + 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', + 'conditional' => array( '_um_access_redirect', '=', '1' ) + ), + array( + 'id' => '_um_access_hide_from_queries', + 'type' => 'checkbox', + 'class' => 'form-field', + 'label' => __( 'Hide from queries', 'ultimate-member' ), + 'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ), + 'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '', + 'conditional' => array( '_um_accessible', '!=', '0' ) + ) + ), $data, 'edit' ); + + UM()->admin_forms( array( + 'class' => 'um-restrict-content um-third-column', + 'prefix_id' => 'um_content_restriction', + 'without_wrapper' => true, + 'fields' => $fields + ) )->render_form(); + + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' ); + } + + + /** + * @param $termID + * + * @return mixed + */ + function um_category_access_fields_save( $termID ) { + + // validate nonce + if ( ! isset( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'] ) || ! wp_verify_nonce( $_REQUEST['um_admin_save_taxonomy_restrict_content_nonce'], basename( __FILE__ ) ) ) + return $termID; + + // validate user + $term = get_term( $termID ); + $taxonomy = get_taxonomy( $term->taxonomy ); + + if ( ! current_user_can( $taxonomy->cap->edit_terms, $termID ) ) + return $termID; + + if ( ! empty( $_REQUEST['um_content_restriction'] ) ) { + update_term_meta( $termID, 'um_content_restriction', $_REQUEST['um_content_restriction'] ); + } else { + delete_term_meta( $termID, 'um_content_restriction' ); + } + + return $termID; + } + + + /** + * Load a directory metabox + * + * @param $object + * @param $box + */ + function load_metabox_directory( $object, $box ) { + $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); + include_once UM()->admin()->templates_path . 'directory/'. $box['id'] . '.php'; + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_directory_nonce' ); + } + + + /** + * Load a role metabox + * + * @param $object + * @param $box + */ + function load_metabox_role( $object, $box ) { + global $post; + + $box['id'] = str_replace( 'um-admin-form-', '', $box['id'] ); + + if ( $box['id'] == 'builder' ) { + UM()->builder()->form_id = get_the_ID(); + } + + preg_match('#\{.*?\}#s', $box['id'], $matches); + + if ( isset($matches[0]) ){ + $path = $matches[0]; + $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); + } else { + $path = um_path; + } + + $path = str_replace('{','', $path ); + $path = str_replace('}','', $path ); + + include_once $path . 'includes/admin/templates/role/'. $box['id'] . '.php'; + //wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_role_nonce' ); + } + + + /** + * Load a form metabox + * + * @param $object + * @param $box + */ + function load_metabox_form( $object, $box ) { + global $post; + + $box['id'] = str_replace( 'um-admin-form-','', $box['id'] ); + + if ( $box['id'] == 'builder' ) { + UM()->builder()->form_id = get_the_ID(); + } + + preg_match('#\{.*?\}#s', $box['id'], $matches); + + if ( isset( $matches[0] ) ) { + $path = $matches[0]; + $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); + } else { + $path = um_path; + } + + $path = str_replace('{','', $path ); + $path = str_replace('}','', $path ); + + include_once $path . 'includes/admin/templates/form/'. $box['id'] . '.php'; + + if ( ! $this->form_nonce_added ) { + $this->form_nonce_added = true; + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_form_nonce' ); + } + } + + + /** + * Load admin custom metabox + * + * @param $object + * @param $box + */ + function load_metabox_custom( $object, $box ) { + global $post; + + $box['id'] = str_replace('um-admin-custom-','', $box['id']); + + preg_match('#\{.*?\}#s', $box['id'], $matches); + + if ( isset($matches[0]) ){ + $path = $matches[0]; + $box['id'] = preg_replace('~(\\{[^}]+\\})~','', $box['id'] ); + } else { + $path = um_path; + } + + $path = str_replace('{','', $path ); + $path = str_replace('}','', $path ); + + include_once $path . 'includes/admin/templates/'. $box['id'] . '.php'; + wp_nonce_field( basename( __FILE__ ), 'um_admin_save_metabox_custom_nonce' ); + } + + + /** + * Add directory metabox + */ + function add_metabox_directory() { + add_meta_box( 'um-admin-form-general', __( 'General Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); + add_meta_box( 'um-admin-form-profile', __( 'Profile Card', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); + add_meta_box( 'um-admin-form-search', __( 'Search Options', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); + add_meta_box( 'um-admin-form-pagination', __( 'Results & Pagination', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'normal', 'default' ); + add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_directory' ), 'um_directory', 'side', 'default' ); + add_meta_box( 'um-admin-form-appearance', __( 'Styling: General', 'ultimate-member' ), array( &$this, 'load_metabox_directory'), 'um_directory', 'side', 'default' ); + } + + + /** + * Add role metabox + */ + function add_metabox_role() { + $callback = array( &$this, 'load_metabox_role' ); + + $roles_metaboxes = array( + array( + 'id' => 'um-admin-form-admin-permissions', + 'title' => __( 'Administrative Permissions', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-general', + 'title' => __( 'General Permissions', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-profile', + 'title' => __( 'Profile Access', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ) + ); + + 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' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-login', + 'title' => __( 'Login Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-logout', + 'title' => __( 'Logout Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-delete', + 'title' => __( 'Delete Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-publish', + 'title' => __( 'Publish', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'side', + 'priority' => 'default' + ) + ) ); + + /** + * UM hook + * + * @type filter + * @title um_admin_role_metaboxes + * @description Extend metaboxes at Add/Edit User Role + * @input_vars + * [{"var":"$roles_metaboxes","type":"array","desc":"Metaboxes at Add/Edit UM Role"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_role_metaboxes', 'function_name', 10, 1 ); + * @example + * 'um-admin-form-your-custom', + * 'title' => __( 'My Roles Metabox', 'ultimate-member' ), + * 'callback' => 'my-metabox-callback', + * 'screen' => 'um_role_meta', + * 'context' => 'side', + * 'priority' => 'default' + * ); + * + * return $roles_metaboxes; + * } + * ?> + */ + $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); + + $wp_caps_metabox = false; + if ( ! empty( $_GET['id'] ) ) { + $data = get_option( "um_role_{$_GET['id']}_meta" ); + if ( ! empty( $data['_um_is_custom'] ) ) + $wp_caps_metabox = true; + } + if ( 'add' == $_GET['tab'] || $wp_caps_metabox ) { + $roles_metaboxes[] = array( + 'id' => 'um-admin-form-wp-capabilities', + 'title' => __( 'WP Capabilities', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ); + } + + + foreach ( $roles_metaboxes as $metabox ) { + add_meta_box( + $metabox['id'], + $metabox['title'], + $metabox['callback'], + $metabox['screen'], + $metabox['context'], + $metabox['priority'] + ); + } + } + + + /** + * Add form metabox + */ + function add_metabox_form() { + + add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); + add_meta_box( 'um-admin-form-builder', __( 'Form Builder', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' ); + add_meta_box( 'um-admin-form-shortcode', __( 'Shortcode', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + + add_meta_box( 'um-admin-form-register_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + + /** + * UM hook + * + * @type action + * @title um_admin_custom_register_metaboxes + * @description Add custom metaboxes for register form + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_custom_register_metaboxes', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_admin_custom_register_metaboxes' ); + + add_meta_box( 'um-admin-form-profile_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + add_meta_box( 'um-admin-form-profile_settings', __( 'User Meta', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + + /** + * UM hook + * + * @type action + * @title um_admin_custom_profile_metaboxes + * @description Add custom metaboxes for profile form + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_custom_profile_metaboxes', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_admin_custom_profile_metaboxes' ); + + add_meta_box( 'um-admin-form-login_customize', __( 'Customize this form', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + add_meta_box( 'um-admin-form-login_settings', __( 'Options', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'side', 'default' ); + + /** + * UM hook + * + * @type action + * @title um_admin_custom_login_metaboxes + * @description Add custom metaboxes for login form + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_custom_login_metaboxes', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_admin_custom_login_metaboxes' ); + } + + + /** + * Save directory metabox + * + * @param $post_id + * @param $post + * + * @return mixed + */ + function save_metabox_directory( $post_id, $post ) { + global $wpdb; + + // validate nonce + if ( !isset( $_POST['um_admin_save_metabox_directory_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_directory_nonce'], basename( __FILE__ ) ) ) return $post_id; + + // validate post type + if ( $post->post_type != 'um_directory' ) return $post_id; + + // validate user + $post_type = get_post_type_object( $post->post_type ); + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; + + $where = array( 'ID' => $post_id ); + + if ( empty( $_POST['post_title'] ) ) + $_POST['post_title'] = 'Directory #'.$post_id; + + $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); + + // save + delete_post_meta( $post_id, '_um_roles' ); + delete_post_meta( $post_id, '_um_tagline_fields' ); + delete_post_meta( $post_id, '_um_reveal_fields' ); + delete_post_meta( $post_id, '_um_search_fields' ); + delete_post_meta( $post_id, '_um_roles_can_search' ); + delete_post_meta( $post_id, '_um_show_these_users' ); + + //save metadata + foreach ( $_POST['um_metadata'] as $k => $v ) { + if ( $k == '_um_show_these_users' && trim( $_POST['um_metadata'][ $k ] ) ) { + $v = preg_split( '/[\r\n]+/', $v, -1, PREG_SPLIT_NO_EMPTY ); + } + if ( strstr( $k, '_um_' ) ) { + update_post_meta( $post_id, $k, $v ); + } + } + } + + + /** + * Save form metabox + * + * @param $post_id + * @param $post + * + * @return mixed + */ + function save_metabox_form( $post_id, $post ) { + global $wpdb; + + // validate nonce + if ( !isset( $_POST['um_admin_save_metabox_form_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) return $post_id; + + // validate post type + if ( $post->post_type != 'um_form' ) return $post_id; + + // validate user + $post_type = get_post_type_object( $post->post_type ); + if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id; + + $where = array( 'ID' => $post_id ); + if ( empty( $_POST['post_title'] ) ) $_POST['post_title'] = 'Form #' . $post_id; + $wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'] ), $where ); + + // save + delete_post_meta( $post_id, '_um_profile_metafields' ); + foreach ( $_POST['form'] as $k => $v ) { + if ( strstr( $k, '_um_' ) ){ + update_post_meta( $post_id, $k, $v); + } + } + + } + + + /** + * Load modal content + */ + function load_modal_content() { + + $screen = get_current_screen(); + if ( $this->is_UM_admin() ) { + foreach ( glob( um_path . 'includes/admin/templates/modal/*.php' ) as $modal_content ) { + include_once $modal_content; + } + } + + // needed on forms only + if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) { + $settings['textarea_rows'] = 8; + + echo ''; + + echo ''; + + $this->is_loaded = true; + } + } + + + /** + * Show field input for edit at modal field + * + * @param $attribute + * @param null $form_id + * @param array $field_args + */ + function field_input( $attribute, $form_id = null, $field_args = array() ) { + + if ( $this->in_edit == true ) { // we're editing a field + $real_attr = substr( $attribute, 1 ); + $this->edit_mode_value = (isset( $this->edit_array[ $real_attr ] ) ) ? $this->edit_array[ $real_attr ] : null; + } + + switch ( $attribute ) { + + default: + + /** + * UM hook + * + * @type action + * @title um_admin_field_edit_hook{$attribute} + * @description Integration for 3-d party fields at wp-admin + * @input_vars + * [{"var":"$edit_mode_value","type":"string","desc":"Post ID"}] + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_field_edit_hook{$attribute}', 'function_name', 10, 1 ); + * @example + * + */ + do_action( "um_admin_field_edit_hook{$attribute}", $this->edit_mode_value ); + + break; + + case '_visibility': + ?> - switch ( $attribute ) { +

+ +

+ + + +

+ + +    +

+ + + +

+ +

+ + + +

+ - - - - -

+ - - case '_conditional_action': - case '_conditional_action1': - case '_conditional_action2': - case '_conditional_action3': - case '_conditional_action4': - ?> + +

-

- +

- + + case '_validate': + ?> - +

+ - - - - query()->get_attr( 'custom_fields', $form_id ); - - foreach ( $fields as $key => $array ) { - if ( isset( $array['title'] ) && - ( ! isset( $this->edit_array['metakey'] ) || $key != $this->edit_array['metakey'] ) ) { ?> - - - - - - -

- - - -

- +

- + -

+ case '_custom_validate': + ?> - + +

- case '_conditional_value': - case '_conditional_value1': - case '_conditional_value2': - case '_conditional_value3': - case '_conditional_value4': - ?> + - -

+ case '_icon': - set_field_type == 'row' ) { + $back = 'UM_edit_row'; - case '_validate': - ?> + ?> -

- -

+ - edit_mode_value ) { ?> + + + + - case '_custom_validate': - ?> +

-

- -

+ in_edit ) { + $back = 'UM_edit_field'; + } else { + $back = 'UM_add_field'; + } - case '_icon': + ?> - if ( $this->set_field_type == 'row' ) { - $back = 'UM_edit_row'; +
- ?> +

-

+ Choose Icon - Choose Icon + edit_mode_value ) { ?>No Icon - edit_mode_value ) { ?>No Icon + - + edit_mode_value ) { ?> + + + + - edit_mode_value ) { ?> - - - - +

-

+
- in_edit ) { - $back = 'UM_edit_field'; - } else { - $back = 'UM_add_field'; - } + } - ?> + break; -
+ case '_css_class': + ?> -

+

+ +

- Choose Icon + edit_mode_value ) { ?>No Icon + case '_width': + ?> - +

+ +

- edit_mode_value ) { ?> - - - - + + case '_divider_text': + ?> -
+

+ +

- - break; +

+ +

- case '_css_class': - ?> + - -

+ case '_margin': + ?> - + +

- case '_width': - ?> + - -

+ case '_border': + ?> - + +

- case '_divider_text': - ?> + - -

+ case '_borderstyle': + ?> - + +

- case '_padding': - ?> + - -

+ case '_borderradius': + ?> - + +

- case '_margin': - ?> + - -

+ case '_bordercolor': + ?> - + +

- case '_border': - ?> + - -

+ case '_heading': + ?> - + edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" /> +

- case '_borderstyle': - ?> + - -

+ case '_heading_text': + ?> - + +

- case '_borderradius': - ?> + - -

+ case '_background': + ?> - + +

- case '_bordercolor': - ?> + - -

+ case '_heading_background_color': + ?> - + +

- case '_heading': - ?> + - edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_heading_text" data-cond1-hide="xxx" /> -

+ case '_heading_text_color': + ?> - + +

- case '_heading_text': - ?> + - -

+ case '_text_color': + ?> - + +

- case '_background': - ?> + - -

+ case '_icon_color': + ?> - + +

- case '_heading_background_color': - ?> + - -

+ case '_color': + ?> - + +

- case '_heading_text_color': - ?> + - -

+ case '_url_text': + ?> - + +

- case '_text_color': - ?> + - -

+ case '_url_target': + ?> - + +

- case '_icon_color': - ?> + - -

+ case '_url_rel': + ?> - + +

- case '_color': - ?> + - -

+ case '_force_good_pass': + ?> - + edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> +

- case '_url_text': - ?> + - -

+ case '_force_confirm_pass': + ?> - + edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> +

- case '_url_target': - ?> + - -

+ case '_style': + ?> - + +

- case '_url_rel': - ?> + - -

+ case '_intervals': - - case '_force_good_pass': - ?> +

+ +

-

- edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> -

+ + case '_format': -

- edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> -

+ if ( $this->set_field_type == 'date' ) { + ?> - + +

- case '_style': - ?> + -

- -

+

+ +

- - ?> +

+ +

-

- -

+ edit_mode_value ) && is_array( $this->edit_mode_value ) ) { + $values = $this->edit_mode_value; + } else { + $values = array(''); + } + ?> - case '_format': +

+ +

- if ( $this->set_field_type == 'date' ) { - ?> + - -

+ case '_years': + ?> - +

+ +

-

- -

+ - case '_pretty_format': - ?> +

+ +

-

- -

+ - case '_disabled_weekdays': +

+ +

- if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) { - $values = $this->edit_mode_value; - } else { - $values = array(''); - } - ?> + - -

+ case '_range_end': + ?> - + +

- case '_years': - ?> + - -

+ case '_range': + ?> - + +

- case '_years_x': - ?> + - -

+ case '_content': - set_field_type == 'shortcode' ) { - case '_range_start': - ?> + ?> -

- -

+

+ +

- + } else { -

- -

+ ?> - - case '_range': - ?> +
-

- -

+ set_field_type == 'shortcode' ) { + case '_crop': + ?> - ?> +

+ +

-

- -

+ set_field_type == 'image' ) { - ?> + if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) { + $values = $this->edit_mode_value; + } else { + $values = array('png','jpeg','jpg','gif'); + } + ?> -
+

+ +

-
+ edit_mode_value ) && is_array( $this->edit_mode_value ) ) { + $values = $this->edit_mode_value; + } else { + $values = array('pdf','txt'); + } - break; + ?> - case '_crop': - ?> +

+ +

-

- -

+ set_field_type == 'image' ) { + case '_upload_text': - if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) { - $values = $this->edit_mode_value; - } else { - $values = array('png','jpeg','jpg','gif'); - } - ?> + if ( $this->set_field_type == 'image' ) $value = 'Drag & Drop Photo'; + if ( $this->set_field_type == 'file' ) $value = 'Drag & Drop File'; -

- -

+ ?> - + +

- } else { + edit_mode_value ) && is_array( $this->edit_mode_value ) ) { - $values = $this->edit_mode_value; - } else { - $values = array('pdf','txt'); - } + case '_upload_help_text': + ?> - ?> +

+ +

-

- -

+ - } +

+ +

- break; + - if ( $this->set_field_type == 'image' ) $value = 'Drag & Drop Photo'; - if ( $this->set_field_type == 'file' ) $value = 'Drag & Drop File'; +

+ +

- ?> + - -

+ case '_height': + ?> - + +

- case '_upload_help_text': - ?> + - -

+ case '_spacing': + ?> - + +

- case '_button_text': - ?> + - -

+ case '_is_multi': + ?> - + edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" /> +

- case '_max_size': - ?> + - -

+ case '_max_selections': + ?> - + +

- case '_height': - ?> + - -

+ case '_min_selections': + ?> - + +

- case '_spacing': - ?> + - -

+ case '_max_entries': + ?> - + +

- case '_is_multi': - ?> + - edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> class="um-adm-conditional" data-cond1="1" data-cond1-show="_max_selections" data-cond1-hide="xxx" /> -

+ case '_max_words': + ?> - + +

- case '_max_selections': - ?> + - -

+ case '_min': + ?> - + +

- case '_min_selections': - ?> + - -

+ case '_max': + ?> - + +

- case '_max_entries': - ?> + - -

+ case '_min_chars': + ?> - + +

- case '_max_words': - ?> + - -

+ case '_max_chars': + ?> - + +

- case '_min': - ?> + - -

+ case '_html': + ?> - + edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> +

- case '_max': - ?> + - -

+ case '_options': - edit_mode_value ) && is_array( $this->edit_mode_value ) ) { + $values = implode("\n", $this->edit_mode_value); + } else if ( $this->edit_mode_value ) { + $values = $this->edit_mode_value; + } else { + $values = ''; + } - case '_min_chars': - ?> + ?> -

- -

+

+ +

- + case '_title': + ?> -

- -

+

+ +

- + case '_id': -

- edit_mode_value ) ? $this->edit_mode_value : 0 ) ?> /> -

+ ?> - + +

- case '_options': + edit_mode_value ) && is_array( $this->edit_mode_value ) ) { - $values = implode("\n", $this->edit_mode_value); - } else if ( $this->edit_mode_value ) { - $values = $this->edit_mode_value; - } else { - $values = ''; - } + break; - ?> + case '_metakey': -

- -

+ if ( $this->in_edit ) { - - case '_title': - ?> +

+ +

-

- -

+ - + +

- case '_id': + + } -

- -

+ break; - - break; +

+ +

- case '_metakey': + in_edit ) { + case '_default': + ?> - ?> + set_field_type == 'textarea' ) { ?> -

- -

+

+ +

- + set_field_type == 'rating' ) { ?> -

- -

+

+ +

- - } +

+ +

- break; + - case '_help': - ?> + - -

+ case '_label': + ?> - + +

- case '_default': - ?> + set_field_type == 'textarea' ) { ?> + case '_placeholder': + ?> -

- -

+

+ +

- set_field_type == 'rating' ) { ?> + - -

+ case '_public': + ?> - +

+ +

-

- -

+ + case '_roles': - edit_mode_value ) && is_array( $this->edit_mode_value ) ) { + $values = $this->edit_mode_value; + } else { + $values = array(''); + } - case '_label': - ?> + ?> -

- -

+

+ -

+ - +

- case '_public': - ?> + - -

+ case '_required': - set_field_type == 'password' ) + $def_required = 1; + else + $def_required = 0; - case '_roles': + ?> - if ( isset( $this->edit_mode_value ) && is_array( $this->edit_mode_value ) ) { - $values = $this->edit_mode_value; - } else { - $values = array(''); - } +
- ?> +

+ edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> /> +

-

- -

+

+ + edit_mode_value || $this->edit_mode_value ) ?> /> +

- - case '_required': + set_field_type == 'password' ) - $def_required = 1; - else - $def_required = 0; + case '_number': + ?> - ?> +

+ +

-
+ - edit_mode_value ) ? $this->edit_mode_value : $def_required ) ?> /> -

+ case '_custom_dropdown_options_source': + ?> -
+

+ +

- -
+ case '_parent_dropdown_relationship': + ?> -

- - edit_mode_value || $this->edit_mode_value ) ?> /> -

+

+ +

- -

- -

+ } - - -

- -

- - - -

- -

- - files()->upload_basedir; + $path = str_replace( '/uploads/ultimatemember', '', $path ); + $path = $path . '/languages/plugins/'; + $path = str_replace( '//', '/', $path ); - /*** - *** @to store plugin languages - ***/ - function create_languages_folder() { - - $path = UM()->files()->upload_basedir; - $path = str_replace('/uploads/ultimatemember','',$path); - $path = $path . '/languages/plugins/'; - $path = str_replace('//','/',$path); - - if ( !file_exists( $path ) ) { - $old = umask(0); - @mkdir( $path, 0777, true); - umask($old); - } - - } + if ( ! file_exists( $path ) ) { + $old = umask(0); + @mkdir( $path, 0777, true ); + umask( $old ); + } + } /** * Show main notices */ - function main_notices() { + function main_notices() { - if ( ! defined( 'DOING_AJAX' ) ) { + if ( ! defined( 'DOING_AJAX' ) ) { - $hide_exif_notice = get_option( 'um_hide_exif_notice' ); + $hide_exif_notice = get_option( 'um_hide_exif_notice' ); - if ( !extension_loaded('exif') && !$hide_exif_notice ) { + if ( !extension_loaded('exif') && !$hide_exif_notice ) { - echo '

'; + echo '

'; - echo sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. Hide this notice', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ); + echo sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. Hide this notice', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ); - echo '

'; + echo '

'; - } + } - // Regarding page setup - $pages = UM()->config()->permalinks; - if ( $pages && is_array( $pages ) ) { + // Regarding page setup + $pages = UM()->config()->permalinks; + if ( $pages && is_array( $pages ) ) { - $err = false; + $err = false; - foreach( $pages as $slug => $page_id ) { + foreach( $pages as $slug => $page_id ) { - $page = get_post( $page_id ); + $page = get_post( $page_id ); - if ( !isset( $page->ID ) && in_array( $slug, array( 'user','account','members','register','login','logout','password-reset' ) ) ) { - $err = true; - } + if ( !isset( $page->ID ) && in_array( $slug, array( 'user','account','members','register','login','logout','password-reset' ) ) ) { + $err = true; + } - } + } - if ( $err ) { - echo '

' . __('One or more of your Ultimate Member pages are not correctly setup. Please visit Ultimate Member > Settings to re-assign your missing pages.','ultimate-member') . '

'; - } + if ( $err ) { + echo '

' . __('One or more of your Ultimate Member pages are not correctly setup. Please visit Ultimate Member > Settings to re-assign your missing pages.','ultimate-member') . '

'; + } - if ( isset( $pages['user'] ) ) { - $test = get_post( $pages['user'] ); - if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { - echo '

' . __('Ultimate Member Setup Error: User page can not be a child page.','ultimate-member') . '

'; - } - } + if ( isset( $pages['user'] ) ) { + $test = get_post( $pages['user'] ); + if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { + echo '

' . __('Ultimate Member Setup Error: User page can not be a child page.','ultimate-member') . '

'; + } + } - if ( isset( $pages['account'] ) ) { - $test = get_post( $pages['account'] ); - if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { - echo '

' . __('Ultimate Member Setup Error: Account page can not be a child page.','ultimate-member') . '

'; - } - } + if ( isset( $pages['account'] ) ) { + $test = get_post( $pages['account'] ); + if ( isset( $test->post_parent ) && $test->post_parent > 0 ) { + echo '

' . __('Ultimate Member Setup Error: Account page can not be a child page.','ultimate-member') . '

'; + } + } - } + } - /** - * UM hook - * - * @type action - * @title um_admin_after_main_notices - * @description Insert some content after main admin notices - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_admin_after_main_notices', 'function_name', 10 ); - * @example - * - */ - do_action( 'um_admin_after_main_notices' ); - } + /** + * UM hook + * + * @type action + * @title um_admin_after_main_notices + * @description Insert some content after main admin notices + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_admin_after_main_notices', 'function_name', 10 ); + * @example + * + */ + do_action( 'um_admin_after_main_notices' ); + } - } + } - /*** - *** @localization notice - ***/ - function localize_note() { - $locale = get_option('WPLANG'); - if ( !$locale ) return; - if ( strstr( $locale, 'en_' ) ) return; // really, english! - if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) return; + /** + * Localization notice + */ + function localize_note() { + $locale = get_option( 'WPLANG' ); + if ( ! $locale || strstr( $locale, 'en_' ) ) { + return; + } + if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) { + return; + } - if ( isset( UM()->available_languages[ $locale ] ) ) { + $hide_locale_notice = get_option( 'um_hide_locale_notice' ); + if ( $hide_locale_notice ) { + return; + } - $download_uri = add_query_arg('um_adm_action', 'um_language_downloader'); + if ( isset( UM()->available_languages[ $locale ] ) ) { - $hide_locale_notice = get_option('um_hide_locale_notice'); - if ( !$hide_locale_notice ) { - echo '

'; + $download_uri = add_query_arg( 'um_adm_action', 'um_language_downloader' ); - echo sprintf(__('Your site language is %1$s. Good news! Ultimate Member is already available in %2$s language. Download the translation files and start using the plugin in your language now. Hide this notice','ultimate-member'), $locale, UM()->available_languages[$locale], $download_uri, add_query_arg('um_adm_action', 'um_hide_locale_notice') ); + echo '

'; - echo '

'; - } + echo sprintf(__('Your site language is %1$s. Good news! Ultimate Member is already available in %2$s language. Download the translation files and start using the plugin in your language now. Hide this notice','ultimate-member'), $locale, UM()->available_languages[$locale], $download_uri, add_query_arg('um_adm_action', 'um_hide_locale_notice') ); + + echo '

'; - } else { + } else { - $hide_locale_notice = get_option('um_hide_locale_notice'); - if ( !$hide_locale_notice ) { - echo '

'; + echo '

'; - echo sprintf(__('Ultimate Member has not yet been translated to your langeuage: %1$s. If you have translated the plugin you need put these files ultimatemember-%1$s.po and ultimatemember-%1$s.mo in /wp-content/languages/plugins/ for the plugin to be translated in your language. Hide this notice','ultimate-member'), $locale, add_query_arg('um_adm_action', 'um_hide_locale_notice') ); + echo sprintf(__('Ultimate Member has not yet been translated to your langeuage: %1$s. If you have translated the plugin you need put these files ultimatemember-%1$s.po and ultimatemember-%1$s.mo in /wp-content/languages/plugins/ for the plugin to be translated in your language. Hide this notice','ultimate-member'), $locale, add_query_arg('um_adm_action', 'um_hide_locale_notice') ); - echo '

'; + echo '

'; - } + } - } + } - } - /*** - *** @updating users - ***/ - function show_update_messages(){ + /** + * Updating users + */ + function show_update_messages() { - if ( !isset($_REQUEST['update']) ) return; + if ( ! isset( $_REQUEST['update'] ) ) { + return; + } - $update = $_REQUEST['update']; - switch($update) { + $update = $_REQUEST['update']; + switch( $update ) { - case 'confirm_delete': - $confirm_uri = admin_url('users.php?' . http_build_query(array( - 'um_adm_action' => 'delete_users', - 'user' => array_map('intval', (array) $_REQUEST['user']), - 'confirm' => 1 - ))); - $users = ''; + case 'confirm_delete': + $confirm_uri = admin_url( 'users.php?' . http_build_query( array( + 'um_adm_action' => 'delete_users', + 'user' => array_map( 'intval', (array) $_REQUEST['user'] ), + 'confirm' => 1 + ) ) ); + $users = ''; - if( isset( $_REQUEST['user'] ) ){ - foreach( $_REQUEST['user'] as $user_id ) { - $user = get_userdata( $user_id ); - $users .= '#' . $user_id . ': ' . $user->user_login . '
'; - } - } + if ( isset( $_REQUEST['user'] ) ){ + foreach ( $_REQUEST['user'] as $user_id ) { + $user = get_userdata( $user_id ); + $users .= '#' . $user_id . ': ' . $user->user_login . '
'; + } + } - $ignore = admin_url('users.php'); + $ignore = admin_url('users.php'); - $messages[0]['err_content'] = sprintf(__('Are you sure you want to delete the selected user(s)? The following users will be deleted:

%s

This cannot be undone!','ultimate-member'), $users); - $messages[0]['err_content'] .= '

' . __('Remove','ultimate-member') . '  ' . __('Undo','ultimate-member') . '

'; + $messages[0]['err_content'] = sprintf( __( 'Are you sure you want to delete the selected user(s)? The following users will be deleted:

%s

This cannot be undone!','ultimate-member'), $users); + $messages[0]['err_content'] .= '

' . __( 'Remove', 'ultimate-member' ) . '  ' . __('Undo','ultimate-member') . '

'; - break; + break; - case 'language_updated': - $messages[0]['content'] = __('Your translation files have been updated successfully.','ultimate-member'); - break; + case 'language_updated': + $messages[0]['content'] = __( 'Your translation files have been updated successfully.', 'ultimate-member' ); + break; - case 'purged_temp': - $messages[0]['content'] = __('Your temp uploads directory is now clean.','ultimate-member'); - break; + case 'purged_temp': + $messages[0]['content'] = __( 'Your temp uploads directory is now clean.', 'ultimate-member' ); + break; - case 'cleared_cache': - $messages[0]['content'] = __('Your user cache is now removed.','ultimate-member'); - break; + case 'cleared_cache': + $messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' ); + break; - case 'form_duplicated': - $messages[0]['content'] = __('The form has been duplicated successfully.','ultimate-member'); - break; + case 'form_duplicated': + $messages[0]['content'] = __( 'The form has been duplicated successfully.', 'ultimate-member' ); + break; - case 'user_updated': - $messages[0]['content'] = __('User has been updated.','ultimate-member'); - break; + case 'user_updated': + $messages[0]['content'] = __( 'User has been updated.', 'ultimate-member' ); + break; - case 'users_updated': - $messages[0]['content'] = __('Users have been updated.','ultimate-member'); - break; + case 'users_updated': + $messages[0]['content'] = __( 'Users have been updated.', 'ultimate-member' ); + break; - case 'users_role_updated': - $messages[0]['content'] = __('Changed roles.','ultimate-member'); - break; + case 'users_role_updated': + $messages[0]['content'] = __( 'Changed roles.', 'ultimate-member' ); + break; - case 'err_users_updated': - $messages[0]['err_content'] = __('Super administrators cannot be modified.','ultimate-member'); - $messages[1]['content'] = __('Other users have been updated.','ultimate-member'); + case 'err_users_updated': + $messages[0]['err_content'] = __( 'Super administrators cannot be modified.', 'ultimate-member' ); + $messages[1]['content'] = __( 'Other users have been updated.', 'ultimate-member' ); - } + } - if ( !empty( $messages ) ) { - foreach( $messages as $message ) { - if ( isset($message['err_content'])) { - echo '

' . $message['err_content'] . '

'; - } else { - echo '

' . $message['content'] . '

'; - } - } - } + if ( ! empty( $messages ) ) { + foreach ( $messages as $message ) { + if ( isset( $message['err_content'] ) ) { + echo '

' . $message['err_content'] . '

'; + } else { + echo '

' . $message['content'] . '

'; + } + } + } - } + } - } + } } \ No newline at end of file diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 21012bc7..8d143a56 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -5,1197 +5,1238 @@ namespace um\admin\core; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'Admin_Settings' ) ) { - class Admin_Settings { - - var $settings_structure; - var $previous_licenses; - var $need_change_permalinks; - - function __construct() { - //init settings structure - add_action( 'admin_init', array( &$this, 'init_variables' ), 9 ); - - //admin menu - add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 ); - - //settings structure handlers - add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) ); - add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 ); - - //enqueue wp_media for profiles tab - add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) ); - - //custom content for licenses tab - add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 ); - - add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 ); - add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 ); + /** + * Class Admin_Settings + * @package um\admin\core + */ + class Admin_Settings { - //save handlers - add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 ); - - //save pages options - add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) ); - add_action( 'um_settings_save', array( $this, 'on_settings_save' ) ); + /** + * @var + */ + var $settings_structure; - add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) ); + /** + * @var + */ + var $previous_licenses; - //save licenses options - add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) ); - add_action( 'um_settings_save', array( $this, 'licenses_save' ) ); - - 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' ) ); - - } + /** + * @var + */ + var $need_change_permalinks; - function init_variables() { - $general_pages_fields = array( - array( - 'id' => 'pages_settings', - 'type' => 'hidden', - 'default' => true, - 'is_option' => false - ) - ); + /** + * Admin_Settings constructor. + */ + function __construct() { + //init settings structure + add_action( 'admin_init', array( &$this, 'init_variables' ), 9 ); - $core_pages = UM()->config()->core_pages; + //admin menu + add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 ); - foreach ( $core_pages as $page_s => $page ) { - $have_pages = UM()->query()->wp_pages(); - $page_id = UM()->options()->get_core_page_id( $page_s ); + //settings structure handlers + add_action( 'um_settings_page_before_email__content', array( $this, 'settings_before_email_tab' ) ); + add_filter( 'um_settings_section_email__content', array( $this, 'settings_email_tab' ), 10, 1 ); - $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; + //enqueue wp_media for profiles tab + add_action( 'um_settings_page_appearance__before_section', array( $this, 'settings_appearance_profile_tab' ) ); - if ( 'reached_maximum_limit' == $have_pages ) { - $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'text', - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'placeholder' => __('Add page ID','ultimate-member'), - 'compiler' => true, - 'size' => 'small' - ); - } else { - $general_pages_fields[] = array( - 'id' => $page_id, - 'type' => 'select', - 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), - 'options' => UM()->query()->wp_pages(), - 'placeholder' => __('Choose a page...','ultimate-member'), - 'compiler' => true, - 'size' => 'small' - ); - } - } + //custom content for licenses tab + add_filter( 'um_settings_section_licenses__content', array( $this, 'settings_licenses_tab' ), 10, 2 ); + + add_filter( 'um_settings_section_install_info__content', array( $this, 'settings_install_info_tab' ), 10, 2 ); + + + add_filter( 'um_settings_structure', array( $this, 'sorting_licenses_options' ), 9999, 1 ); + + + //save handlers + add_action( 'admin_init', array( $this, 'save_settings_handler' ), 10 ); + + //save pages options + add_action( 'um_settings_before_save', array( $this, 'check_permalinks_changes' ) ); + add_action( 'um_settings_save', array( $this, 'on_settings_save' ) ); + + + add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) ); + + + //save licenses options + add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) ); + add_action( 'um_settings_save', array( $this, 'licenses_save' ) ); + + 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' ) ); + + } + + + /** + * + */ + function init_variables() { + $general_pages_fields = array( + array( + 'id' => 'pages_settings', + 'type' => 'hidden', + 'default' => true, + 'is_option' => false + ) + ); + + $core_pages = UM()->config()->core_pages; + + foreach ( $core_pages as $page_s => $page ) { + $have_pages = UM()->query()->wp_pages(); + $page_id = UM()->options()->get_core_page_id( $page_s ); + + $page_title = ! empty( $page['title'] ) ? $page['title'] : ''; + + if ( 'reached_maximum_limit' == $have_pages ) { + $general_pages_fields[] = array( + 'id' => $page_id, + 'type' => 'text', + 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), + 'placeholder' => __('Add page ID','ultimate-member'), + 'compiler' => true, + 'size' => 'small' + ); + } else { + $general_pages_fields[] = array( + 'id' => $page_id, + 'type' => 'select', + 'label' => sprintf( __( '%s page', 'ultimate-member' ), $page_title ), + 'options' => UM()->query()->wp_pages(), + 'placeholder' => __('Choose a page...','ultimate-member'), + 'compiler' => true, + 'size' => 'small' + ); + } + } - $appearances_profile_menu_fields = array( - array( - 'id' => 'profile_menu', - 'type' => 'checkbox', - 'label' => __('Enable profile menu','ultimate-member'), - ) - ); + $appearances_profile_menu_fields = array( + array( + 'id' => 'profile_menu', + 'type' => 'checkbox', + 'label' => __('Enable profile menu','ultimate-member'), + ) + ); - $tabs = UM()->profile()->tabs_primary(); + $tabs = UM()->profile()->tabs_primary(); - foreach( $tabs as $id => $tab ) { + foreach( $tabs as $id => $tab ) { - $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array( - array( - 'id' => 'profile_tab_' . $id, - 'type' => 'checkbox', - 'label' => sprintf(__('%s Tab','ultimate-member'), $tab ), - 'conditional' => array( 'profile_menu', '=', 1 ), - ), - array( - 'id' => 'profile_tab_' . $id . '_privacy', - 'type' => 'select', - 'label' => sprintf( __( 'Who can see %s Tab?','ultimate-member' ), $tab ), - 'tooltip' => __( 'Select which users can view this tab.','ultimate-member' ), - 'options' => UM()->profile()->tabs_privacy(), - 'conditional' => array( 'profile_tab_' . $id, '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_tab_' . $id . '_roles', - 'type' => 'select', - 'multi' => true, - 'label' => __( 'Allowed roles','ultimate-member' ), - 'tooltip' => __( 'Select the the user roles allowed to view this tab.','ultimate-member' ), - 'options' => UM()->roles()->get_roles(), - 'placeholder' => __( 'Choose user roles...','ultimate-member' ), - 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', 4 ), - 'size' => 'small' - ) - ) ); - } + $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array( + array( + 'id' => 'profile_tab_' . $id, + 'type' => 'checkbox', + 'label' => sprintf(__('%s Tab','ultimate-member'), $tab ), + 'conditional' => array( 'profile_menu', '=', 1 ), + ), + array( + 'id' => 'profile_tab_' . $id . '_privacy', + 'type' => 'select', + 'label' => sprintf( __( 'Who can see %s Tab?','ultimate-member' ), $tab ), + 'tooltip' => __( 'Select which users can view this tab.','ultimate-member' ), + 'options' => UM()->profile()->tabs_privacy(), + 'conditional' => array( 'profile_tab_' . $id, '=', 1 ), + 'size' => 'small' + ), + array( + 'id' => 'profile_tab_' . $id . '_roles', + 'type' => 'select', + 'multi' => true, + 'label' => __( 'Allowed roles','ultimate-member' ), + 'tooltip' => __( 'Select the the user roles allowed to view this tab.','ultimate-member' ), + 'options' => UM()->roles()->get_roles(), + 'placeholder' => __( 'Choose user roles...','ultimate-member' ), + 'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', 4 ), + 'size' => 'small' + ) + ) ); + } - $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(), - 'conditional' => array( 'profile_menu', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_menu_icons', - 'type' => 'checkbox', - 'label' => __('Enable menu icons in desktop view','ultimate-member'), - 'conditional' => array( 'profile_menu', '=', 1 ), - ) - ) ); + $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(), + 'conditional' => array( 'profile_menu', '=', 1 ), + 'size' => 'small' + ), + array( + 'id' => 'profile_menu_icons', + 'type' => 'checkbox', + 'label' => __('Enable menu icons in desktop view','ultimate-member'), + 'conditional' => array( 'profile_menu', '=', 1 ), + ) + ) ); - $all_post_types = get_post_types( array( 'public' => true ) ); + $all_post_types = get_post_types( array( 'public' => true ) ); - $all_taxonomies = get_taxonomies( array( 'public' => true ) ); - $exclude_taxonomies = UM()->excluded_taxonomies(); + $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_taxonomies as $key => $taxonomy ) { + if( in_array( $key , $exclude_taxonomies ) ) + unset( $all_taxonomies[$key] ); + } - $restricted_access_post_metabox_value = array(); - if ( $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' ) ) { - foreach ( $restricted_access_post_metabox as $key => $value ) { - if ( $value ) - $restricted_access_post_metabox_value[] = $key; - } - } + $restricted_access_post_metabox_value = array(); + if ( $restricted_access_post_metabox = UM()->options()->get( 'restricted_access_post_metabox' ) ) { + foreach ( $restricted_access_post_metabox as $key => $value ) { + if ( $value ) + $restricted_access_post_metabox_value[] = $key; + } + } - $restricted_access_taxonomy_metabox_value = array(); - if ( $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ) ) { - foreach ( $restricted_access_taxonomy_metabox as $key => $value ) { - if ( $value ) - $restricted_access_taxonomy_metabox_value[] = $key; - } - } + $restricted_access_taxonomy_metabox_value = array(); + if ( $restricted_access_taxonomy_metabox = UM()->options()->get( 'restricted_access_taxonomy_metabox' ) ) { + foreach ( $restricted_access_taxonomy_metabox as $key => $value ) { + if ( $value ) + $restricted_access_taxonomy_metabox_value[] = $key; + } + } - /** - * UM hook - * - * @type filter - * @title um_settings_structure - * @description Extend UM Settings - * @input_vars - * [{"var":"$settings","type":"array","desc":"UM Settings"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 ); - * @example - * - */ - $this->settings_structure = apply_filters( 'um_settings_structure', array( - '' => array( - 'title' => __( 'General', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Pages', 'ultimate-member' ), - 'fields' => $general_pages_fields - ), - 'users' => array( - 'title' => __( 'Users', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'permalink_base', - 'type' => 'select', - 'size' => 'small', - 'label' => __( 'Profile Permalink Base','ultimate-member' ), - 'tooltip' => __( 'Here you can control the permalink structure of the user profile URL globally e.g. ' . trailingslashit( um_get_core_page('user') ) . 'username/','ultimate-member' ), - 'options' => array( - 'user_login' => __('Username','ultimate-member'), - 'name' => __('First and Last Name with \'.\'','ultimate-member'), - 'name_dash' => __('First and Last Name with \'-\'','ultimate-member'), - 'name_plus' => __('First and Last Name with \'+\'','ultimate-member'), - 'user_id' => __('User ID','ultimate-member'), - ), - 'placeholder' => __('Select...','ultimate-member'), - ), - array( - 'id' => 'display_name', - 'type' => 'select', - 'size' => 'medium', - 'label' => __( 'User Display Name','ultimate-member' ), - 'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists','ultimate-member' ), - 'options' => array( - 'default' => __('Default WP Display Name','ultimate-member'), - 'nickname' => __('Nickname','ultimate-member'), - 'username' => __('Username','ultimate-member'), - 'full_name' => __('First name & last name','ultimate-member'), - 'sur_name' => __('Last name & first name','ultimate-member'), - 'initial_name' => __('First name & first initial of last name','ultimate-member'), - 'initial_name_f' => __('First initial of first name & last name','ultimate-member'), - 'first_name' => __('First name only','ultimate-member'), - 'field' => __('Custom field(s)','ultimate-member'), - ), - 'placeholder' => __('Select...'), - ), - array( - 'id' => 'display_name_field', - 'type' => 'text', - 'label' => __( 'Display Name Custom Field(s)','ultimate-member' ), - 'tooltip' => __('Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site','ultimate-member'), - 'conditional' => array( 'display_name', '=', 'field' ), - ), - array( - 'id' => 'author_redirect', - 'type' => 'checkbox', - 'label' => __( 'Automatically redirect author page to their profile?','ultimate-member'), - 'tooltip' => __('If enabled, author pages will automatically redirect to the user\'s profile page','ultimate-member'), - ), - array( - 'id' => 'members_page', - 'type' => 'checkbox', - 'label' => __( 'Enable Members Directory','ultimate-member' ), - 'tooltip' => __('Control whether to enable or disable member directories on this site','ultimate-member'), - ), - array( - 'id' => 'use_gravatars', - 'type' => 'checkbox', - 'label' => __( 'Use Gravatars?','ultimate-member' ), - 'tooltip' => __('Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)','ultimate-member'), - ), - array( - 'id' => 'use_um_gravatar_default_builtin_image', - 'type' => 'select', - 'label' => __( 'Use Gravatar builtin image','ultimate-member' ), - 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults','ultimate-member' ), - 'options' => array( - 'default' => __('Default','ultimate-member'), - '404' => __('404 ( File Not Found response )','ultimate-member'), - 'mm' => __('Mystery Man','ultimate-member'), - 'identicon' => __('Identicon','ultimate-member'), - 'monsterid' => __('Monsterid','ultimate-member'), - 'wavatar' => __('Wavatar','ultimate-member'), - 'retro' => __('Retro','ultimate-member'), - 'blank' => __('Blank ( a transparent PNG image )','ultimate-member'), - ), - 'conditional' => array( 'use_gravatars', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'use_um_gravatar_default_image', - 'type' => 'checkbox', - 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar','ultimate-member' ), - 'tooltip' => __('Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)','ultimate-member'), - 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), - ), - array( - 'id' => 'reset_require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password? (when user resets password only)','ultimate-member' ), - 'tooltip' => __('Enable or disable a strong password rules on password reset and change procedure','ultimate-member'), - ) - ) - ), - 'account' => array( - 'title' => __( 'Account', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'account_tab_password', - 'type' => 'checkbox', - 'label' => __( 'Password Account Tab','ultimate-member' ), - 'tooltip' => 'Enable/disable the Password account tab in account page', - ), - array( - 'id' => 'account_tab_privacy', - 'type' => 'checkbox', - 'label' => __( 'Privacy Account Tab','ultimate-member' ), - 'tooltip' => __('Enable/disable the Privacy account tab in account page','ultimate-member'), - ), - array( - 'id' => 'account_tab_notifications', - 'type' => 'checkbox', - 'label' => __( 'Notifications Account Tab','ultimate-member' ), - 'tooltip' => __('Enable/disable the Notifications account tab in account page','ultimate-member'), - ), - array( - 'id' => 'account_tab_delete', - 'type' => 'checkbox', - 'label' => __( 'Delete Account Tab','ultimate-member' ), - 'tooltip' => __('Enable/disable the Delete account tab in account page','ultimate-member'), - ), - array( - 'id' => 'delete_account_text', - 'type' => 'textarea', // bug with wp 4.4? should be editor - 'label' => __( 'Account Deletion Custom Text','ultimate-member' ), - 'tooltip' => __('This is custom text that will be displayed to users before they delete their accounts from your site','ultimate-member'), - 'args' => array( - 'textarea_rows' => 6 - ), - ), - array( - 'id' => 'account_name', - 'type' => 'checkbox', - 'label' => __( 'Add a First & Last Name fields','ultimate-member' ), - 'tooltip' => __('Whether to enable these fields on the user account page by default or hide them.','ultimate-member'), - ), - array( - 'id' => 'account_name_disable', - 'type' => 'checkbox', - 'label' => __( 'Disable First & Last Name fields','ultimate-member' ), - 'tooltip' => __('Whether to allow users changing their first and last name in account page.','ultimate-member'), - 'conditional' => array( 'account_name', '=', '1' ), - ), - array( - 'id' => 'account_name_require', - 'type' => 'checkbox', - 'label' => __( 'Require First & Last Name','ultimate-member' ), - 'tooltip' => __('Require first and last name?','ultimate-member'), - 'conditional' => array( 'account_name', '=', '1' ), - ), - array( - 'id' => 'account_email', - 'type' => 'checkbox', - 'label' => __( 'Allow users to change e-mail','ultimate-member' ), - 'tooltip' => __('Whether to allow users changing their email in account page.','ultimate-member'), - ), - array( - 'id' => 'account_hide_in_directory', - 'type' => 'checkbox', - 'label' => __( 'Allow users to hide their profiles from directory','ultimate-member' ), - 'tooltip' => __('Whether to allow users changing their profile visibility from member directory in account page.','ultimate-member'), - ), - array( - 'id' => 'account_require_strongpass', - 'type' => 'checkbox', - 'label' => __( 'Require a strong password?','ultimate-member' ), - 'tooltip' => __('Enable or disable a strong password rules on account page / change password tab','ultimate-member'), - ) - ) - ), - 'uploads' => array( - 'title' => __( 'Uploads', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'profile_photo_max_size', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ), - 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ), - ), + /** + * UM hook + * + * @type filter + * @title um_settings_structure + * @description Extend UM Settings + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Settings"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_structure', 'function_name', 10, 1 ); + * @example + * + */ + $this->settings_structure = apply_filters( 'um_settings_structure', array( + '' => array( + 'title' => __( 'General', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Pages', 'ultimate-member' ), + 'fields' => $general_pages_fields + ), + 'users' => array( + 'title' => __( 'Users', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'permalink_base', + 'type' => 'select', + 'size' => 'small', + 'label' => __( 'Profile Permalink Base','ultimate-member' ), + 'tooltip' => __( 'Here you can control the permalink structure of the user profile URL globally e.g. ' . trailingslashit( um_get_core_page('user') ) . 'username/','ultimate-member' ), + 'options' => array( + 'user_login' => __('Username','ultimate-member'), + 'name' => __('First and Last Name with \'.\'','ultimate-member'), + 'name_dash' => __('First and Last Name with \'-\'','ultimate-member'), + 'name_plus' => __('First and Last Name with \'+\'','ultimate-member'), + 'user_id' => __('User ID','ultimate-member'), + ), + 'placeholder' => __('Select...','ultimate-member'), + ), + array( + 'id' => 'display_name', + 'type' => 'select', + 'size' => 'medium', + 'label' => __( 'User Display Name','ultimate-member' ), + 'tooltip' => __( 'This is the name that will be displayed for users on the front end of your site. Default setting uses first/last name as display name if it exists','ultimate-member' ), + 'options' => array( + 'default' => __('Default WP Display Name','ultimate-member'), + 'nickname' => __('Nickname','ultimate-member'), + 'username' => __('Username','ultimate-member'), + 'full_name' => __('First name & last name','ultimate-member'), + 'sur_name' => __('Last name & first name','ultimate-member'), + 'initial_name' => __('First name & first initial of last name','ultimate-member'), + 'initial_name_f' => __('First initial of first name & last name','ultimate-member'), + 'first_name' => __('First name only','ultimate-member'), + 'field' => __('Custom field(s)','ultimate-member'), + ), + 'placeholder' => __('Select...'), + ), + array( + 'id' => 'display_name_field', + 'type' => 'text', + 'label' => __( 'Display Name Custom Field(s)','ultimate-member' ), + 'tooltip' => __('Specify the custom field meta key or custom fields seperated by comma that you want to use to display users name on the frontend of your site','ultimate-member'), + 'conditional' => array( 'display_name', '=', 'field' ), + ), + array( + 'id' => 'author_redirect', + 'type' => 'checkbox', + 'label' => __( 'Automatically redirect author page to their profile?','ultimate-member'), + 'tooltip' => __('If enabled, author pages will automatically redirect to the user\'s profile page','ultimate-member'), + ), + array( + 'id' => 'members_page', + 'type' => 'checkbox', + 'label' => __( 'Enable Members Directory','ultimate-member' ), + 'tooltip' => __('Control whether to enable or disable member directories on this site','ultimate-member'), + ), + array( + 'id' => 'use_gravatars', + 'type' => 'checkbox', + 'label' => __( 'Use Gravatars?','ultimate-member' ), + 'tooltip' => __('Do you want to use gravatars instead of the default plugin profile photo (If the user did not upload a custom profile photo / avatar)','ultimate-member'), + ), + array( + 'id' => 'use_um_gravatar_default_builtin_image', + 'type' => 'select', + 'label' => __( 'Use Gravatar builtin image','ultimate-member' ), + 'tooltip' => __( 'Gravatar has a number of built in options which you can also use as defaults','ultimate-member' ), + 'options' => array( + 'default' => __('Default','ultimate-member'), + '404' => __('404 ( File Not Found response )','ultimate-member'), + 'mm' => __('Mystery Man','ultimate-member'), + 'identicon' => __('Identicon','ultimate-member'), + 'monsterid' => __('Monsterid','ultimate-member'), + 'wavatar' => __('Wavatar','ultimate-member'), + 'retro' => __('Retro','ultimate-member'), + 'blank' => __('Blank ( a transparent PNG image )','ultimate-member'), + ), + 'conditional' => array( 'use_gravatars', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'use_um_gravatar_default_image', + 'type' => 'checkbox', + 'label' => __( 'Use Default plugin avatar as Gravatar\'s Default avatar','ultimate-member' ), + 'tooltip' => __('Do you want to use the plugin default avatar instead of the gravatar default photo (If the user did not upload a custom profile photo / avatar)','ultimate-member'), + 'conditional' => array( 'use_um_gravatar_default_builtin_image', '=', 'default' ), + ), + array( + 'id' => 'reset_require_strongpass', + 'type' => 'checkbox', + 'label' => __( 'Require a strong password? (when user resets password only)','ultimate-member' ), + 'tooltip' => __('Enable or disable a strong password rules on password reset and change procedure','ultimate-member'), + ) + ) + ), + 'account' => array( + 'title' => __( 'Account', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'account_tab_password', + 'type' => 'checkbox', + 'label' => __( 'Password Account Tab','ultimate-member' ), + 'tooltip' => 'Enable/disable the Password account tab in account page', + ), + array( + 'id' => 'account_tab_privacy', + 'type' => 'checkbox', + 'label' => __( 'Privacy Account Tab','ultimate-member' ), + 'tooltip' => __('Enable/disable the Privacy account tab in account page','ultimate-member'), + ), + array( + 'id' => 'account_tab_notifications', + 'type' => 'checkbox', + 'label' => __( 'Notifications Account Tab','ultimate-member' ), + 'tooltip' => __('Enable/disable the Notifications account tab in account page','ultimate-member'), + ), + array( + 'id' => 'account_tab_delete', + 'type' => 'checkbox', + 'label' => __( 'Delete Account Tab','ultimate-member' ), + 'tooltip' => __('Enable/disable the Delete account tab in account page','ultimate-member'), + ), + array( + 'id' => 'delete_account_text', + 'type' => 'textarea', // bug with wp 4.4? should be editor + 'label' => __( 'Account Deletion Custom Text','ultimate-member' ), + 'tooltip' => __('This is custom text that will be displayed to users before they delete their accounts from your site','ultimate-member'), + 'args' => array( + 'textarea_rows' => 6 + ), + ), + array( + 'id' => 'account_name', + 'type' => 'checkbox', + 'label' => __( 'Add a First & Last Name fields','ultimate-member' ), + 'tooltip' => __('Whether to enable these fields on the user account page by default or hide them.','ultimate-member'), + ), + array( + 'id' => 'account_name_disable', + 'type' => 'checkbox', + 'label' => __( 'Disable First & Last Name fields','ultimate-member' ), + 'tooltip' => __('Whether to allow users changing their first and last name in account page.','ultimate-member'), + 'conditional' => array( 'account_name', '=', '1' ), + ), + array( + 'id' => 'account_name_require', + 'type' => 'checkbox', + 'label' => __( 'Require First & Last Name','ultimate-member' ), + 'tooltip' => __('Require first and last name?','ultimate-member'), + 'conditional' => array( 'account_name', '=', '1' ), + ), + array( + 'id' => 'account_email', + 'type' => 'checkbox', + 'label' => __( 'Allow users to change e-mail','ultimate-member' ), + 'tooltip' => __('Whether to allow users changing their email in account page.','ultimate-member'), + ), + array( + 'id' => 'account_hide_in_directory', + 'type' => 'checkbox', + 'label' => __( 'Allow users to hide their profiles from directory','ultimate-member' ), + 'tooltip' => __('Whether to allow users changing their profile visibility from member directory in account page.','ultimate-member'), + ), + array( + 'id' => 'account_require_strongpass', + 'type' => 'checkbox', + 'label' => __( 'Require a strong password?','ultimate-member' ), + 'tooltip' => __('Enable or disable a strong password rules on account page / change password tab','ultimate-member'), + ) + ) + ), + 'uploads' => array( + 'title' => __( 'Uploads', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'profile_photo_max_size', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Profile Photo Maximum File Size (bytes)', 'ultimate-member' ), + 'tooltip' => __( 'Sets a maximum size for the uploaded photo', 'ultimate-member' ), + ), - array( - 'id' => 'cover_photo_max_size', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ), - 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ), - ), - array( - 'id' => 'photo_thumb_sizes', - 'type' => 'multi_text', - 'size' => 'small', - 'label' => __( 'Profile Photo Thumbnail Sizes (px)','ultimate-member' ), - 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.','ultimate-member' ), - 'validate' => 'numeric', - 'add_text' => __('Add New Size','ultimate-member'), - 'show_default_number' => 1, - ), - array( - 'id' => 'cover_thumb_sizes', - 'type' => 'multi_text', - 'size' => 'small', - 'label' => __( 'Cover Photo Thumbnail Sizes (px)','ultimate-member' ), - 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.','ultimate-member' ), - 'validate' => 'numeric', - 'add_text' => __('Add New Size','ultimate-member'), - 'show_default_number' => 1, - ), + array( + 'id' => 'cover_photo_max_size', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Cover Photo Maximum File Size (bytes)', 'ultimate-member' ), + 'tooltip' => __( 'Sets a maximum size for the uploaded cover', 'ultimate-member' ), + ), + array( + 'id' => 'photo_thumb_sizes', + 'type' => 'multi_text', + 'size' => 'small', + 'label' => __( 'Profile Photo Thumbnail Sizes (px)','ultimate-member' ), + 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each profile photo upload.','ultimate-member' ), + 'validate' => 'numeric', + 'add_text' => __('Add New Size','ultimate-member'), + 'show_default_number' => 1, + ), + array( + 'id' => 'cover_thumb_sizes', + 'type' => 'multi_text', + 'size' => 'small', + 'label' => __( 'Cover Photo Thumbnail Sizes (px)','ultimate-member' ), + 'tooltip' => __( 'Here you can define which thumbnail sizes will be created for each cover photo upload.','ultimate-member' ), + 'validate' => 'numeric', + 'add_text' => __('Add New Size','ultimate-member'), + 'show_default_number' => 1, + ), - array( - 'id' => 'image_compression', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Image Quality','ultimate-member'), - 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ), - ), + array( + 'id' => 'image_compression', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Image Quality','ultimate-member'), + 'tooltip' => __( 'Quality is used to determine quality of image uploads, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default range is 60.', 'ultimate-member' ), + ), - array( - 'id' => 'image_max_width', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ), - ), + array( + 'id' => 'image_max_width', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Image Upload Maximum Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'Any image upload above this width will be resized to this limit automatically.', 'ultimate-member' ), + ), - array( - 'id' => 'cover_min_width', - 'type' => 'text', - 'size' => 'small', - 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ), - 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ), - ), - ) - ) - ) - ), - 'access' => array( - 'title' => __( 'Access', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Restriction Content', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'accessible', - 'type' => 'select', - 'label' => __( 'Global Site Access','ultimate-member' ), - 'tooltip' => __('Globally control the access of your site, you can have seperate restrict options per post/page by editing the desired item.','ultimate-member'), - 'options' => array( - 0 => 'Site accessible to Everyone', - 2 => 'Site accessible to Logged In Users' - ), - 'size' => 'medium' - ), - array( - 'id' => 'access_redirect', - 'type' => 'text', - 'label' => __( 'Custom Redirect URL','ultimate-member' ), - 'tooltip' => __('A logged out user will be redirected to this url If he is not permitted to access the site','ultimate-member'), - 'conditional' => array( 'accessible', '=', 2 ), - ), - array( - 'id' => 'access_exclude_uris', - 'type' => 'multi_text', - 'label' => __( 'Exclude the following URLs','ultimate-member' ), - 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone','ultimate-member' ), - 'add_text' => __('Add New URL','ultimate-member'), - 'conditional' => array( 'accessible', '=', 2 ), - 'show_default_number' => 1, - ), - array( - 'id' => 'home_page_accessible', - 'type' => 'checkbox', - 'label' => __( 'Allow Homepage to be accessible','ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), - ), - array( - 'id' => 'category_page_accessible', - 'type' => 'checkbox', - 'label' => __( 'Allow Category pages to be accessible','ultimate-member' ), - 'conditional' => array( 'accessible', '=', 2 ), - ), - array( - 'id' => 'restricted_access_message', - 'type' => 'wp_editor', - 'label' => __( 'Restricted Access Message','ultimate-member' ), - 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content','ultimate-member' ), - ), - array( - 'id' => 'restricted_access_post_metabox', - 'type' => 'hidden', - 'value' => '', - ), - array( - 'id' => 'restricted_access_taxonomy_metabox', - 'type' => 'hidden', - 'value' => '', - ), - array( - 'id' => 'restricted_access_post_metabox', - 'type' => 'multi_checkbox', - 'label' => __( 'Restricted Access to Posts','ultimate-member' ), - 'tooltip' => __( 'Restriction content of the current Posts','ultimate-member' ), - 'options' => $all_post_types, - 'columns' => 3, - 'value' => $restricted_access_post_metabox_value, - 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ), - ), - array( - 'id' => 'restricted_access_taxonomy_metabox', - 'type' => 'multi_checkbox', - 'label' => __( 'Restricted Access to Taxonomies','ultimate-member' ), - 'tooltip' => __( 'Restriction content of the current Taxonomies','ultimate-member' ), - 'options' => $all_taxonomies, - 'columns' => 3, - 'value' => $restricted_access_taxonomy_metabox_value, - 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ), - ), - ) - ), - 'other' => array( - 'title' => __( 'Other', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'enable_reset_password_limit', - 'type' => 'checkbox', - 'label' => __( 'Enable the Reset Password Limit?','ultimate-member' ), - ), - array( - 'id' => 'reset_password_limit_number', - 'type' => 'text', - 'label' => __( 'Reset Password Limit','ultimate-member' ), - 'tooltip' => __('Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.','ultimate-member'), - 'validate' => 'numeric', - 'conditional' => array('enable_reset_password_limit','=',1), - 'size' => 'um-small-field', - ), - array( - 'id' => 'blocked_emails', - 'type' => 'textarea', - 'label' => __( 'Blocked Email Addresses','ultimate-member' ), - 'tooltip' => __('This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com','ultimate-member'), - ), - array( - 'id' => 'blocked_words', - 'type' => 'textarea', - 'label' => __( 'Blacklist Words','ultimate-member' ), - 'tooltip' => __('This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username','ultimate-member'), - ) - ) - ), - ) - ), - 'email' => array( - 'title' => __( 'Email', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'admin_email', - 'type' => 'text', - 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), - ), - array( - 'id' => 'mail_from', - 'type' => 'text', - 'label' => __( 'Mail appears from','ultimate-member' ), - 'tooltip' => __( 'e.g. Site Name','ultimate-member' ), - ), - array( - 'id' => 'mail_from_addr', - 'type' => 'text', - 'label' => __( 'Mail appears from address','ultimate-member' ), - 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), - ), - array( - 'id' => 'email_html', - 'type' => 'checkbox', - 'label' => __( 'Use HTML for E-mails?','ultimate-member' ), - 'tooltip' => __('If you enable HTML for e-mails, you can customize the HTML e-mail templates found in templates/email folder.','ultimate-member'), - ) - ) - ), - 'appearance' => array( - 'title' => __( 'Appearance', 'ultimate-member' ), - 'sections' => array( - '' => array( - 'title' => __( 'Profile', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'profile_template', - 'type' => 'select', - 'label' => __( 'Profile Default Template','ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output profile','ultimate-member' ), - 'default' => um_get_metadefault('profile_template'), - 'options' => UM()->shortcodes()->get_templates( 'profile' ), - 'size' => 'small' - ), - array( - 'id' => 'profile_max_width', - 'type' => 'text', - 'label' => __( 'Profile Maximum Width','ultimate-member' ), - 'default' => um_get_metadefault('profile_max_width'), - 'tooltip' => 'The maximum width this shortcode can take from the page width', - 'size' => 'small' - ), + array( + 'id' => 'cover_min_width', + 'type' => 'text', + 'size' => 'small', + 'label' => __( 'Cover Photo Minimum Width (px)', 'ultimate-member' ), + 'tooltip' => __( 'This will be the minimum width for cover photo uploads', 'ultimate-member' ), + ), + ) + ) + ) + ), + 'access' => array( + 'title' => __( 'Access', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Restriction Content', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'accessible', + 'type' => 'select', + 'label' => __( 'Global Site Access','ultimate-member' ), + 'tooltip' => __('Globally control the access of your site, you can have seperate restrict options per post/page by editing the desired item.','ultimate-member'), + 'options' => array( + 0 => 'Site accessible to Everyone', + 2 => 'Site accessible to Logged In Users' + ), + 'size' => 'medium' + ), + array( + 'id' => 'access_redirect', + 'type' => 'text', + 'label' => __( 'Custom Redirect URL','ultimate-member' ), + 'tooltip' => __('A logged out user will be redirected to this url If he is not permitted to access the site','ultimate-member'), + 'conditional' => array( 'accessible', '=', 2 ), + ), + array( + 'id' => 'access_exclude_uris', + 'type' => 'multi_text', + 'label' => __( 'Exclude the following URLs','ultimate-member' ), + 'tooltip' => __( 'Here you can exclude URLs beside the redirect URI to be accessible to everyone','ultimate-member' ), + 'add_text' => __('Add New URL','ultimate-member'), + 'conditional' => array( 'accessible', '=', 2 ), + 'show_default_number' => 1, + ), + array( + 'id' => 'home_page_accessible', + 'type' => 'checkbox', + 'label' => __( 'Allow Homepage to be accessible','ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), + ), + array( + 'id' => 'category_page_accessible', + 'type' => 'checkbox', + 'label' => __( 'Allow Category pages to be accessible','ultimate-member' ), + 'conditional' => array( 'accessible', '=', 2 ), + ), + array( + 'id' => 'restricted_access_message', + 'type' => 'wp_editor', + 'label' => __( 'Restricted Access Message','ultimate-member' ), + 'tooltip' => __( 'This is the message shown to users that do not have permission to view the content','ultimate-member' ), + ), + array( + 'id' => 'restricted_access_post_metabox', + 'type' => 'hidden', + 'value' => '', + ), + array( + 'id' => 'restricted_access_taxonomy_metabox', + 'type' => 'hidden', + 'value' => '', + ), + array( + 'id' => 'restricted_access_post_metabox', + 'type' => 'multi_checkbox', + 'label' => __( 'Restricted Access to Posts','ultimate-member' ), + 'tooltip' => __( 'Restriction content of the current Posts','ultimate-member' ), + 'options' => $all_post_types, + 'columns' => 3, + 'value' => $restricted_access_post_metabox_value, + 'default' => UM()->options()->get_default( 'restricted_access_post_metabox' ), + ), + array( + 'id' => 'restricted_access_taxonomy_metabox', + 'type' => 'multi_checkbox', + 'label' => __( 'Restricted Access to Taxonomies','ultimate-member' ), + 'tooltip' => __( 'Restriction content of the current Taxonomies','ultimate-member' ), + 'options' => $all_taxonomies, + 'columns' => 3, + 'value' => $restricted_access_taxonomy_metabox_value, + 'default' => UM()->options()->get_default( 'restricted_access_taxonomy_metabox' ), + ), + ) + ), + 'other' => array( + 'title' => __( 'Other', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'enable_reset_password_limit', + 'type' => 'checkbox', + 'label' => __( 'Enable the Reset Password Limit?','ultimate-member' ), + ), + array( + 'id' => 'reset_password_limit_number', + 'type' => 'text', + 'label' => __( 'Reset Password Limit','ultimate-member' ), + 'tooltip' => __('Set the maximum reset password limit. If reached the maximum limit, user will be locked from using this.','ultimate-member'), + 'validate' => 'numeric', + 'conditional' => array('enable_reset_password_limit','=',1), + 'size' => 'um-small-field', + ), + array( + 'id' => 'blocked_emails', + 'type' => 'textarea', + 'label' => __( 'Blocked Email Addresses','ultimate-member' ), + 'tooltip' => __('This will block the specified e-mail addresses from being able to sign up or sign in to your site. To block an entire domain, use something like *@domain.com','ultimate-member'), + ), + array( + 'id' => 'blocked_words', + 'type' => 'textarea', + 'label' => __( 'Blacklist Words','ultimate-member' ), + 'tooltip' => __('This option lets you specify blacklist of words to prevent anyone from signing up with such a word as their username','ultimate-member'), + ) + ) + ), + ) + ), + 'email' => array( + 'title' => __( 'Email', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'admin_email', + 'type' => 'text', + 'label' => __( 'Admin E-mail Address', 'ultimate-member' ), + 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), + ), + array( + 'id' => 'mail_from', + 'type' => 'text', + 'label' => __( 'Mail appears from','ultimate-member' ), + 'tooltip' => __( 'e.g. Site Name','ultimate-member' ), + ), + array( + 'id' => 'mail_from_addr', + 'type' => 'text', + 'label' => __( 'Mail appears from address','ultimate-member' ), + 'tooltip' => __( 'e.g. admin@companyname.com','ultimate-member' ), + ), + array( + 'id' => 'email_html', + 'type' => 'checkbox', + 'label' => __( 'Use HTML for E-mails?','ultimate-member' ), + 'tooltip' => __('If you enable HTML for e-mails, you can customize the HTML e-mail templates found in templates/email folder.','ultimate-member'), + ) + ) + ), + 'appearance' => array( + 'title' => __( 'Appearance', 'ultimate-member' ), + 'sections' => array( + '' => array( + 'title' => __( 'Profile', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'profile_template', + 'type' => 'select', + 'label' => __( 'Profile Default Template','ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output profile','ultimate-member' ), + 'default' => um_get_metadefault('profile_template'), + 'options' => UM()->shortcodes()->get_templates( 'profile' ), + 'size' => 'small' + ), + array( + 'id' => 'profile_max_width', + 'type' => 'text', + 'label' => __( 'Profile Maximum Width','ultimate-member' ), + 'default' => um_get_metadefault('profile_max_width'), + 'tooltip' => 'The maximum width this shortcode can take from the page width', + 'size' => 'small' + ), - array( - 'id' => 'profile_area_max_width', - 'type' => 'text', - 'label' => __( 'Profile Area Maximum Width','ultimate-member' ), - 'default' => um_get_metadefault('profile_area_max_width'), - 'tooltip' => __('The maximum width of the profile area inside profile (below profile header)','ultimate-member'), - 'size' => 'small' - ), - array( - 'id' => 'profile_icons', - 'type' => 'select', - 'label' => __( 'Profile Field Icons' ), - 'tooltip' => __( 'This is applicable for edit mode only','ultimate-member' ), - 'default' => um_get_metadefault('profile_icons'), - 'options' => array( - 'field' => __('Show inside text field','ultimate-member'), - 'label' => __('Show with label','ultimate-member'), - 'off' => __('Turn off','ultimate-member'), - ), - 'size' => 'small' - ), - array( - 'id' => 'profile_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Profile Primary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('profile_primary_btn_word'), - 'tooltip' => __('The text that is used for updating profile button','ultimate-member'), - 'size' => 'medium' - ), - array( - 'id' => 'profile_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Profile Secondary Button','ultimate-member' ), - 'default' => um_get_metadefault('profile_secondary_btn'), - 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), - ), - array( - 'id' => 'profile_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Profile Secondary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('profile_secondary_btn_word'), - 'tooltip' => __('The text that is used for cancelling update profile button','ultimate-member'), - 'conditional' => array( 'profile_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'default_avatar', - 'type' => 'media', - 'label' => __('Default Profile Photo', 'ultimate-member'), - 'tooltip' => __('You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member'), - 'upload_frame_title'=> __('Select Default Profile Photo', 'ultimate-member'), - 'default' => array( - 'url' => um_url . 'assets/img/default_avatar.jpg', - ), - ), - array( - 'id' => 'default_cover', - 'type' => 'media', - 'url' => true, - 'preview' => false, - 'label' => __('Default Cover Photo', 'ultimate-member'), - 'tooltip' => __('You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member'), - 'upload_frame_title'=> __('Select Default Cover Photo', 'ultimate-member'), - ), - array( - 'id' => 'profile_photosize', - 'type' => 'text', - 'label' => __( 'Profile Photo Size','ultimate-member' ), - 'default' => um_get_metadefault('profile_photosize'), - 'tooltip' => __('The global default of profile photo size. This can be overridden by individual form settings','ultimate-member'), - 'size' => 'small' - ), - array( - 'id' => 'profile_cover_enabled', - 'type' => 'checkbox', - 'label' => __( 'Profile Cover Photos','ultimate-member' ), - 'default' => 1, - 'tooltip' => __('Switch on/off the profile cover photos','ultimate-member'), - ), - array( - 'id' => 'profile_cover_ratio', - 'type' => 'select', - 'label' => __( 'Profile Cover Ratio','ultimate-member' ), - 'tooltip' => __( 'Choose global ratio for cover photos of profiles','ultimate-member' ), - 'default' => um_get_metadefault('profile_cover_ratio'), - 'options' => array( - '1.6:1' => '1.6:1', - '2.7:1' => '2.7:1', - '2.2:1' => '2.2:1', - '3.2:1' => '3.2:1', - ), - 'conditional' => array( 'profile_cover_enabled', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_show_metaicon', - 'type' => 'checkbox', - 'label' => __( 'Profile Header Meta Text Icon','ultimate-member' ), - 'default' => 0, - 'tooltip' => __('Display field icons for related user meta fields in header or not','ultimate-member'), - ), - array( - 'id' => 'profile_show_name', - 'type' => 'checkbox', - 'label' => __( 'Show display name in profile header','ultimate-member' ), - 'default' => um_get_metadefault('profile_show_name'), - 'tooltip' => __('Switch on/off the user name on profile header','ultimate-member'), - ), - array( - 'id' => 'profile_show_social_links', - 'type' => 'checkbox', - 'label' => __( 'Show social links in profile header','ultimate-member' ), - 'default' => um_get_metadefault('profile_show_social_links'), - 'tooltip' => __('Switch on/off the social links on profile header','ultimate-member'), - ), - array( - 'id' => 'profile_show_bio', - 'type' => 'checkbox', - 'label' => __( 'Show user description in header','ultimate-member' ), - 'default' => um_get_metadefault('profile_show_bio'), - 'tooltip' => __('Switch on/off the user description on profile header','ultimate-member'), - ), - array( - 'id' => 'profile_show_html_bio', - 'type' => 'checkbox', - 'label' => __( 'Enable html support for user description','ultimate-member' ), - 'default' => um_get_metadefault('profile_show_html_bio'), - 'tooltip' => __('Switch on/off to enable/disable support for html tags on user description.','ultimate-member'), - ), - array( - 'id' => 'profile_bio_maxchars', - 'type' => 'text', - 'label' => __( 'User description maximum chars','ultimate-member' ), - 'default' => um_get_metadefault('profile_bio_maxchars'), - 'tooltip' => __('Maximum number of characters to allow in user description field in header.','ultimate-member'), - 'conditional' => array( 'profile_show_bio', '=', 1 ), - 'size' => 'small' - ), - array( - 'id' => 'profile_header_menu', - 'type' => 'select', - 'label' => __( 'Profile Header Menu Position','ultimate-member' ), - 'default' => um_get_metadefault('profile_header_menu'), - 'tooltip' => __('For incompatible themes, please make the menu open from left instead of bottom by default.','ultimate-member'), - 'options' => array( - 'bc' => 'Bottom of Icon', - 'lc' => 'Left of Icon', - ), - 'size' => 'small' - ), - array( - 'id' => 'profile_empty_text', - 'type' => 'checkbox', - 'label' => __( 'Show a custom message if profile is empty','ultimate-member' ), - 'default' => um_get_metadefault('profile_empty_text'), - 'tooltip' => __('Switch on/off the custom message that appears when the profile is empty','ultimate-member'), - ), - array( - 'id' => 'profile_empty_text_emo', - 'type' => 'checkbox', - 'label' => __( 'Show the emoticon','ultimate-member' ), - 'default' => um_get_metadefault('profile_empty_text_emo'), - 'tooltip' => __('Switch on/off the emoticon (sad face) that appears above the message','ultimate-member'), - 'conditional' => array( 'profile_empty_text', '=', 1 ), - ) - ) - ), - 'profile_menu' => array( - 'title' => __( 'Profile Menu', 'ultimate-member' ), - 'fields' => $appearances_profile_menu_fields - ), - 'registration_form' => array( - 'title' => __( 'Registration Form', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'register_template', - 'type' => 'select', - 'label' => __( 'Registration Default Template','ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output registration' ), - 'default' => um_get_metadefault('register_template'), - 'options' => UM()->shortcodes()->get_templates( 'register' ), - 'size' => 'small' - ), - array( - 'id' => 'register_max_width', - 'type' => 'text', - 'label' => __( 'Registration Maximum Width','ultimate-member' ), - 'default' => um_get_metadefault('register_max_width'), - 'tooltip' => __('The maximum width this shortcode can take from the page width','ultimate-member'), - 'size' => 'small' - ), - array( - 'id' => 'register_align', - 'type' => 'select', - 'label' => __( 'Registration Shortcode Alignment','ultimate-member' ), - 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here','ultimate-member' ), - 'default' => um_get_metadefault('register_align'), - 'options' => array( - 'center' => __('Centered'), - 'left' => __('Left aligned'), - 'right' => __('Right aligned'), - ), - 'size' => 'small' - ), - array( - 'id' => 'register_icons', - 'type' => 'select', - 'label' => __( 'Registration Field Icons','ultimate-member' ), - 'tooltip' => __( 'This controls the display of field icons in the registration form','ultimate-member' ), - 'default' => um_get_metadefault('register_icons'), - 'options' => array( - 'field' => __('Show inside text field'), - 'label' => __('Show with label'), - 'off' => __('Turn off'), - ), - 'size' => 'small' - ), - array( - 'id' => 'register_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Registration Primary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('register_primary_btn_word'), - 'tooltip' => __('The text that is used for primary button text','ultimate-member'), - 'size' => 'medium' - ), - array( - 'id' => 'register_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Registration Secondary Button','ultimate-member' ), - 'default' => 1, - 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), - ), - array( - 'id' => 'register_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Registration Secondary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('register_secondary_btn_word'), - 'tooltip' => __('The text that is used for the secondary button text','ultimate-member'), - 'conditional' => array( 'register_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'register_secondary_btn_url', - 'type' => 'text', - 'label' => __( 'Registration Secondary Button URL','ultimate-member' ), - 'default' => um_get_metadefault('register_secondary_btn_url'), - 'tooltip' => __('You can replace default link for this button by entering custom URL','ultimate-member'), - 'conditional' => array( 'register_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'register_role', - 'type' => 'select', - 'label' => __( 'Registration Default Role','ultimate-member' ), - 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form','ultimate-member' ), - 'default' => um_get_metadefault('register_role'), - 'options' => UM()->roles()->get_roles( $add_default = 'Default' ), - 'size' => 'small' - ) - ) - ), - 'login_form' => array( - 'title' => __( 'Login Form', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'login_template', - 'type' => 'select', - 'label' => __( 'Login Default Template','ultimate-member' ), - 'tooltip' => __( 'This will be the default template to output login','ultimate-member' ), - 'default' => um_get_metadefault('login_template'), - 'options' => UM()->shortcodes()->get_templates( 'login' ), - 'size' => 'small' - ), - array( - 'id' => 'login_max_width', - 'type' => 'text', - 'label' => __( 'Login Maximum Width','ultimate-member' ), - 'default' => um_get_metadefault('login_max_width'), - 'tooltip' => __('The maximum width this shortcode can take from the page width','ultimate-member'), - 'size' => 'small' - ), - array( - 'id' => 'login_align', - 'type' => 'select', - 'label' => __( 'Login Shortcode Alignment','ultimate-member' ), - 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here','ultimate-member' ), - 'default' => um_get_metadefault('login_align'), - 'options' => array( - 'center' => __('Centered','ultimate-member'), - 'left' => __('Left aligned','ultimate-member'), - 'right' => __('Right aligned','ultimate-member'), - ), - 'size' => 'small' - ), - array( - 'id' => 'login_icons', - 'type' => 'select', - 'label' => __( 'Login Field Icons','ultimate-member' ), - 'tooltip' => __( 'This controls the display of field icons in the login form','ultimate-member' ), - 'default' => um_get_metadefault('login_icons'), - 'options' => array( - 'field' => __('Show inside text field','ultimate-member'), - 'label' => __('Show with label','ultimate-member'), - 'off' => __('Turn off','ultimate-member'), - ), - 'size' => 'small' - ), - array( - 'id' => 'login_primary_btn_word', - 'type' => 'text', - 'label' => __( 'Login Primary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('login_primary_btn_word'), - 'tooltip' => __('The text that is used for primary button text','ultimate-member'), - 'size' => 'medium' - ), - array( - 'id' => 'login_secondary_btn', - 'type' => 'checkbox', - 'label' => __( 'Login Secondary Button','ultimate-member' ), - 'default' => 1, - 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), - ), - array( - 'id' => 'login_secondary_btn_word', - 'type' => 'text', - 'label' => __( 'Login Secondary Button Text','ultimate-member' ), - 'default' => um_get_metadefault('login_secondary_btn_word'), - 'tooltip' => __('The text that is used for the secondary button text','ultimate-member'), - 'conditional' => array( 'login_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'login_secondary_btn_url', - 'type' => 'text', - 'label' => __( 'Login Secondary Button URL','ultimate-member' ), - 'default' => um_get_metadefault('login_secondary_btn_url'), - 'tooltip' => __('You can replace default link for this button by entering custom URL','ultimate-member'), - 'conditional' => array( 'login_secondary_btn', '=', 1 ), - 'size' => 'medium' - ), - array( - 'id' => 'login_forgot_pass_link', - 'type' => 'checkbox', - 'label' => __( 'Login Forgot Password Link','ultimate-member' ), - 'default' => 1, - 'tooltip' => __('Switch on/off the forgot password link in login form','ultimate-member'), - ), - array( - 'id' => 'login_show_rememberme', - 'type' => 'checkbox', - 'label' => __( 'Show "Remember Me"','ultimate-member' ), - 'default' => 1, - 'tooltip' => __('Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.','ultimate-member'), - ) - ) - ) - ) - ), - 'extensions' => array( - 'title' => __( 'Extensions', 'ultimate-member' ) - ), - 'licenses' => array( - 'title' => __( 'Licenses', 'ultimate-member' ), - ), - 'misc' => array( - 'title' => __( 'Misc', 'ultimate-member' ), - 'fields' => array( - array( - 'id' => 'form_asterisk', - 'type' => 'checkbox', - 'label' => __( 'Show an asterisk for required fields','ultimate-member' ), - ), - array( - 'id' => 'profile_title', - 'type' => 'text', - 'label' => __('User Profile Title','ultimate-member'), - 'tooltip' => __('This is the title that is displayed on a specific user profile','ultimate-member'), - 'size' => 'medium' - ), - array( - 'id' => 'profile_desc', - 'type' => 'textarea', - 'label' => __( 'User Profile Dynamic Meta Description','ultimate-member' ), - 'tooltip' => __('This will be used in the meta description that is available for search-engines.','ultimate-member'), - 'args' => array( - 'textarea_rows' => 6 - ) - ), - array( - 'id' => 'menu_item_workaround', - 'type' => 'checkbox', - 'label' => __( 'WP Menu Item Custom Fields Workaround','ultimate-member' ), - 'tooltip' => __( 'Turn on this option if you don\'t see WP Menu Item Restriction options','ultimate-member' ), - ), - array( - 'id' => 'um_allow_tracking', - 'type' => 'checkbox', - 'label' => __( 'Allow Tracking','ultimate-member' ), - ), - array( - 'id' => 'uninstall_on_delete', - 'type' => 'checkbox', - 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), - 'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ), - ) - ) - ), - 'install_info' => array( - 'title' => __( 'Install Info', 'ultimate-member' ), - 'fields' => array( - array( - 'type' => 'install_info', - ), - ) - ), - ) ); + array( + 'id' => 'profile_area_max_width', + 'type' => 'text', + 'label' => __( 'Profile Area Maximum Width','ultimate-member' ), + 'default' => um_get_metadefault('profile_area_max_width'), + 'tooltip' => __('The maximum width of the profile area inside profile (below profile header)','ultimate-member'), + 'size' => 'small' + ), + array( + 'id' => 'profile_icons', + 'type' => 'select', + 'label' => __( 'Profile Field Icons' ), + 'tooltip' => __( 'This is applicable for edit mode only','ultimate-member' ), + 'default' => um_get_metadefault('profile_icons'), + 'options' => array( + 'field' => __('Show inside text field','ultimate-member'), + 'label' => __('Show with label','ultimate-member'), + 'off' => __('Turn off','ultimate-member'), + ), + 'size' => 'small' + ), + array( + 'id' => 'profile_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Profile Primary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('profile_primary_btn_word'), + 'tooltip' => __('The text that is used for updating profile button','ultimate-member'), + 'size' => 'medium' + ), + array( + 'id' => 'profile_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Profile Secondary Button','ultimate-member' ), + 'default' => um_get_metadefault('profile_secondary_btn'), + 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), + ), + array( + 'id' => 'profile_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Profile Secondary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('profile_secondary_btn_word'), + 'tooltip' => __('The text that is used for cancelling update profile button','ultimate-member'), + 'conditional' => array( 'profile_secondary_btn', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'default_avatar', + 'type' => 'media', + 'label' => __('Default Profile Photo', 'ultimate-member'), + 'tooltip' => __('You can change the default profile picture globally here. Please make sure that the photo is 300x300px.', 'ultimate-member'), + 'upload_frame_title'=> __('Select Default Profile Photo', 'ultimate-member'), + 'default' => array( + 'url' => um_url . 'assets/img/default_avatar.jpg', + ), + ), + array( + 'id' => 'default_cover', + 'type' => 'media', + 'url' => true, + 'preview' => false, + 'label' => __('Default Cover Photo', 'ultimate-member'), + 'tooltip' => __('You can change the default cover photo globally here. Please make sure that the default cover is large enough and respects the ratio you are using for cover photos.', 'ultimate-member'), + 'upload_frame_title'=> __('Select Default Cover Photo', 'ultimate-member'), + ), + array( + 'id' => 'profile_photosize', + 'type' => 'text', + 'label' => __( 'Profile Photo Size','ultimate-member' ), + 'default' => um_get_metadefault('profile_photosize'), + 'tooltip' => __('The global default of profile photo size. This can be overridden by individual form settings','ultimate-member'), + 'size' => 'small' + ), + array( + 'id' => 'profile_cover_enabled', + 'type' => 'checkbox', + 'label' => __( 'Profile Cover Photos','ultimate-member' ), + 'default' => 1, + 'tooltip' => __('Switch on/off the profile cover photos','ultimate-member'), + ), + array( + 'id' => 'profile_cover_ratio', + 'type' => 'select', + 'label' => __( 'Profile Cover Ratio','ultimate-member' ), + 'tooltip' => __( 'Choose global ratio for cover photos of profiles','ultimate-member' ), + 'default' => um_get_metadefault('profile_cover_ratio'), + 'options' => array( + '1.6:1' => '1.6:1', + '2.7:1' => '2.7:1', + '2.2:1' => '2.2:1', + '3.2:1' => '3.2:1', + ), + 'conditional' => array( 'profile_cover_enabled', '=', 1 ), + 'size' => 'small' + ), + array( + 'id' => 'profile_show_metaicon', + 'type' => 'checkbox', + 'label' => __( 'Profile Header Meta Text Icon','ultimate-member' ), + 'default' => 0, + 'tooltip' => __('Display field icons for related user meta fields in header or not','ultimate-member'), + ), + array( + 'id' => 'profile_show_name', + 'type' => 'checkbox', + 'label' => __( 'Show display name in profile header','ultimate-member' ), + 'default' => um_get_metadefault('profile_show_name'), + 'tooltip' => __('Switch on/off the user name on profile header','ultimate-member'), + ), + array( + 'id' => 'profile_show_social_links', + 'type' => 'checkbox', + 'label' => __( 'Show social links in profile header','ultimate-member' ), + 'default' => um_get_metadefault('profile_show_social_links'), + 'tooltip' => __('Switch on/off the social links on profile header','ultimate-member'), + ), + array( + 'id' => 'profile_show_bio', + 'type' => 'checkbox', + 'label' => __( 'Show user description in header','ultimate-member' ), + 'default' => um_get_metadefault('profile_show_bio'), + 'tooltip' => __('Switch on/off the user description on profile header','ultimate-member'), + ), + array( + 'id' => 'profile_show_html_bio', + 'type' => 'checkbox', + 'label' => __( 'Enable html support for user description','ultimate-member' ), + 'default' => um_get_metadefault('profile_show_html_bio'), + 'tooltip' => __('Switch on/off to enable/disable support for html tags on user description.','ultimate-member'), + ), + array( + 'id' => 'profile_bio_maxchars', + 'type' => 'text', + 'label' => __( 'User description maximum chars','ultimate-member' ), + 'default' => um_get_metadefault('profile_bio_maxchars'), + 'tooltip' => __('Maximum number of characters to allow in user description field in header.','ultimate-member'), + 'conditional' => array( 'profile_show_bio', '=', 1 ), + 'size' => 'small' + ), + array( + 'id' => 'profile_header_menu', + 'type' => 'select', + 'label' => __( 'Profile Header Menu Position','ultimate-member' ), + 'default' => um_get_metadefault('profile_header_menu'), + 'tooltip' => __('For incompatible themes, please make the menu open from left instead of bottom by default.','ultimate-member'), + 'options' => array( + 'bc' => 'Bottom of Icon', + 'lc' => 'Left of Icon', + ), + 'size' => 'small' + ), + array( + 'id' => 'profile_empty_text', + 'type' => 'checkbox', + 'label' => __( 'Show a custom message if profile is empty','ultimate-member' ), + 'default' => um_get_metadefault('profile_empty_text'), + 'tooltip' => __('Switch on/off the custom message that appears when the profile is empty','ultimate-member'), + ), + array( + 'id' => 'profile_empty_text_emo', + 'type' => 'checkbox', + 'label' => __( 'Show the emoticon','ultimate-member' ), + 'default' => um_get_metadefault('profile_empty_text_emo'), + 'tooltip' => __('Switch on/off the emoticon (sad face) that appears above the message','ultimate-member'), + 'conditional' => array( 'profile_empty_text', '=', 1 ), + ) + ) + ), + 'profile_menu' => array( + 'title' => __( 'Profile Menu', 'ultimate-member' ), + 'fields' => $appearances_profile_menu_fields + ), + 'registration_form' => array( + 'title' => __( 'Registration Form', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'register_template', + 'type' => 'select', + 'label' => __( 'Registration Default Template','ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output registration' ), + 'default' => um_get_metadefault('register_template'), + 'options' => UM()->shortcodes()->get_templates( 'register' ), + 'size' => 'small' + ), + array( + 'id' => 'register_max_width', + 'type' => 'text', + 'label' => __( 'Registration Maximum Width','ultimate-member' ), + 'default' => um_get_metadefault('register_max_width'), + 'tooltip' => __('The maximum width this shortcode can take from the page width','ultimate-member'), + 'size' => 'small' + ), + array( + 'id' => 'register_align', + 'type' => 'select', + 'label' => __( 'Registration Shortcode Alignment','ultimate-member' ), + 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here','ultimate-member' ), + 'default' => um_get_metadefault('register_align'), + 'options' => array( + 'center' => __('Centered'), + 'left' => __('Left aligned'), + 'right' => __('Right aligned'), + ), + 'size' => 'small' + ), + array( + 'id' => 'register_icons', + 'type' => 'select', + 'label' => __( 'Registration Field Icons','ultimate-member' ), + 'tooltip' => __( 'This controls the display of field icons in the registration form','ultimate-member' ), + 'default' => um_get_metadefault('register_icons'), + 'options' => array( + 'field' => __('Show inside text field'), + 'label' => __('Show with label'), + 'off' => __('Turn off'), + ), + 'size' => 'small' + ), + array( + 'id' => 'register_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Registration Primary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('register_primary_btn_word'), + 'tooltip' => __('The text that is used for primary button text','ultimate-member'), + 'size' => 'medium' + ), + array( + 'id' => 'register_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Registration Secondary Button','ultimate-member' ), + 'default' => 1, + 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), + ), + array( + 'id' => 'register_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Registration Secondary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('register_secondary_btn_word'), + 'tooltip' => __('The text that is used for the secondary button text','ultimate-member'), + 'conditional' => array( 'register_secondary_btn', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'register_secondary_btn_url', + 'type' => 'text', + 'label' => __( 'Registration Secondary Button URL','ultimate-member' ), + 'default' => um_get_metadefault('register_secondary_btn_url'), + 'tooltip' => __('You can replace default link for this button by entering custom URL','ultimate-member'), + 'conditional' => array( 'register_secondary_btn', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'register_role', + 'type' => 'select', + 'label' => __( 'Registration Default Role','ultimate-member' ), + 'tooltip' => __( 'This will be the default role assigned to users registering thru registration form','ultimate-member' ), + 'default' => um_get_metadefault('register_role'), + 'options' => UM()->roles()->get_roles( $add_default = 'Default' ), + 'size' => 'small' + ) + ) + ), + 'login_form' => array( + 'title' => __( 'Login Form', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'login_template', + 'type' => 'select', + 'label' => __( 'Login Default Template','ultimate-member' ), + 'tooltip' => __( 'This will be the default template to output login','ultimate-member' ), + 'default' => um_get_metadefault('login_template'), + 'options' => UM()->shortcodes()->get_templates( 'login' ), + 'size' => 'small' + ), + array( + 'id' => 'login_max_width', + 'type' => 'text', + 'label' => __( 'Login Maximum Width','ultimate-member' ), + 'default' => um_get_metadefault('login_max_width'), + 'tooltip' => __('The maximum width this shortcode can take from the page width','ultimate-member'), + 'size' => 'small' + ), + array( + 'id' => 'login_align', + 'type' => 'select', + 'label' => __( 'Login Shortcode Alignment','ultimate-member' ), + 'tooltip' => __( 'The shortcode is centered by default unless you specify otherwise here','ultimate-member' ), + 'default' => um_get_metadefault('login_align'), + 'options' => array( + 'center' => __('Centered','ultimate-member'), + 'left' => __('Left aligned','ultimate-member'), + 'right' => __('Right aligned','ultimate-member'), + ), + 'size' => 'small' + ), + array( + 'id' => 'login_icons', + 'type' => 'select', + 'label' => __( 'Login Field Icons','ultimate-member' ), + 'tooltip' => __( 'This controls the display of field icons in the login form','ultimate-member' ), + 'default' => um_get_metadefault('login_icons'), + 'options' => array( + 'field' => __('Show inside text field','ultimate-member'), + 'label' => __('Show with label','ultimate-member'), + 'off' => __('Turn off','ultimate-member'), + ), + 'size' => 'small' + ), + array( + 'id' => 'login_primary_btn_word', + 'type' => 'text', + 'label' => __( 'Login Primary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('login_primary_btn_word'), + 'tooltip' => __('The text that is used for primary button text','ultimate-member'), + 'size' => 'medium' + ), + array( + 'id' => 'login_secondary_btn', + 'type' => 'checkbox', + 'label' => __( 'Login Secondary Button','ultimate-member' ), + 'default' => 1, + 'tooltip' => __('Switch on/off the secondary button display in the form','ultimate-member'), + ), + array( + 'id' => 'login_secondary_btn_word', + 'type' => 'text', + 'label' => __( 'Login Secondary Button Text','ultimate-member' ), + 'default' => um_get_metadefault('login_secondary_btn_word'), + 'tooltip' => __('The text that is used for the secondary button text','ultimate-member'), + 'conditional' => array( 'login_secondary_btn', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'login_secondary_btn_url', + 'type' => 'text', + 'label' => __( 'Login Secondary Button URL','ultimate-member' ), + 'default' => um_get_metadefault('login_secondary_btn_url'), + 'tooltip' => __('You can replace default link for this button by entering custom URL','ultimate-member'), + 'conditional' => array( 'login_secondary_btn', '=', 1 ), + 'size' => 'medium' + ), + array( + 'id' => 'login_forgot_pass_link', + 'type' => 'checkbox', + 'label' => __( 'Login Forgot Password Link','ultimate-member' ), + 'default' => 1, + 'tooltip' => __('Switch on/off the forgot password link in login form','ultimate-member'), + ), + array( + 'id' => 'login_show_rememberme', + 'type' => 'checkbox', + 'label' => __( 'Show "Remember Me"','ultimate-member' ), + 'default' => 1, + 'tooltip' => __('Allow users to choose If they want to stay signed in even after closing the browser. If you do not show this option, the default will be to not remember login session.','ultimate-member'), + ) + ) + ) + ) + ), + 'extensions' => array( + 'title' => __( 'Extensions', 'ultimate-member' ) + ), + 'licenses' => array( + 'title' => __( 'Licenses', 'ultimate-member' ), + ), + 'misc' => array( + 'title' => __( 'Misc', 'ultimate-member' ), + 'fields' => array( + array( + 'id' => 'form_asterisk', + 'type' => 'checkbox', + 'label' => __( 'Show an asterisk for required fields','ultimate-member' ), + ), + array( + 'id' => 'profile_title', + 'type' => 'text', + 'label' => __('User Profile Title','ultimate-member'), + 'tooltip' => __('This is the title that is displayed on a specific user profile','ultimate-member'), + 'size' => 'medium' + ), + array( + 'id' => 'profile_desc', + 'type' => 'textarea', + 'label' => __( 'User Profile Dynamic Meta Description','ultimate-member' ), + 'tooltip' => __('This will be used in the meta description that is available for search-engines.','ultimate-member'), + 'args' => array( + 'textarea_rows' => 6 + ) + ), + array( + 'id' => 'menu_item_workaround', + 'type' => 'checkbox', + 'label' => __( 'WP Menu Item Custom Fields Workaround','ultimate-member' ), + 'tooltip' => __( 'Turn on this option if you don\'t see WP Menu Item Restriction options','ultimate-member' ), + ), + array( + 'id' => 'um_allow_tracking', + 'type' => 'checkbox', + 'label' => __( 'Allow Tracking','ultimate-member' ), + ), + array( + 'id' => 'uninstall_on_delete', + 'type' => 'checkbox', + 'label' => __( 'Remove Data on Uninstall?', 'ultimate-member' ), + 'tooltip' => __( 'Check this box if you would like Ultimate Member to completely remove all of its data when the plugin/extensions are deleted.', 'ultimate-member' ), + ) + ) + ), + 'install_info' => array( + 'title' => __( 'Install Info', 'ultimate-member' ), + 'fields' => array( + array( + 'type' => 'install_info', + ), + ) + ), + ) ); - } + } - function sorting_licenses_options( $settings ) { - //sorting licenses - if ( empty( $settings['licenses']['fields'] ) ) - return $settings; - $licenses = $settings['licenses']['fields']; - @uasort( $licenses, create_function( '$a,$b', 'return strnatcasecmp($a["label"],$b["label"]);' ) ); - $settings['licenses']['fields'] = $licenses; + /** + * @param $settings + * + * @return mixed + */ + function sorting_licenses_options( $settings ) { + //sorting licenses + if ( empty( $settings['licenses']['fields'] ) ) + return $settings; + $licenses = $settings['licenses']['fields']; + @uasort( $licenses, create_function( '$a,$b', 'return strnatcasecmp($a["label"],$b["label"]);' ) ); + $settings['licenses']['fields'] = $licenses; - //sorting extensions - if ( empty( $settings['extensions']['sections'] ) ) - return $settings; + //sorting extensions + if ( empty( $settings['extensions']['sections'] ) ) + return $settings; - $extensions = $settings['extensions']['sections']; - @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); + $extensions = $settings['extensions']['sections']; + @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); - $keys = array_keys( $extensions ); - if ( $keys[0] != "" ) { - $new_key = strtolower( str_replace( " ", "_", $extensions[""]['title'] ) ); - $temp = $extensions[""]; - $extensions[$new_key] = $temp; - $extensions[""] = $extensions[$keys[0]]; - unset( $extensions[$keys[0]] ); - @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); - } + $keys = array_keys( $extensions ); + if ( $keys[0] != "" ) { + $new_key = strtolower( str_replace( " ", "_", $extensions[""]['title'] ) ); + $temp = $extensions[""]; + $extensions[$new_key] = $temp; + $extensions[""] = $extensions[$keys[0]]; + unset( $extensions[$keys[0]] ); + @uasort( $extensions, create_function( '$a,$b', 'return strnatcasecmp($a["title"],$b["title"]);' ) ); + } - $settings['extensions']['sections'] = $extensions; + $settings['extensions']['sections'] = $extensions; - return $settings; - } + return $settings; + } - function get_section_fields( $tab, $section ) { + /** + * @param $tab + * @param $section + * + * @return array + */ + function get_section_fields( $tab, $section ) { - if ( empty( $this->settings_structure[$tab] ) ) - return array(); + if ( empty( $this->settings_structure[$tab] ) ) + return array(); - if ( ! empty( $this->settings_structure[$tab]['sections'][$section]['fields'] ) ) { - return $this->settings_structure[$tab]['sections'][$section]['fields']; - } elseif ( ! empty( $this->settings_structure[$tab]['fields'] ) ) { - return $this->settings_structure[$tab]['fields']; - } + if ( ! empty( $this->settings_structure[$tab]['sections'][$section]['fields'] ) ) { + return $this->settings_structure[$tab]['sections'][$section]['fields']; + } elseif ( ! empty( $this->settings_structure[$tab]['fields'] ) ) { + return $this->settings_structure[$tab]['fields']; + } - return array(); - } + return array(); + } - /*** - *** @setup admin menu - ***/ - function primary_admin_menu() { + /** + * Setup admin menu + */ + function primary_admin_menu() { add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) ); } - function settings_page() { - $current_tab = empty( $_GET['tab'] ) ? '' : urldecode( $_GET['tab'] ); - $current_subtab = empty( $_GET['section'] ) ? '' : urldecode( $_GET['section'] ); + /** + * Settings page callback + */ + function settings_page() { + $current_tab = empty( $_GET['tab'] ) ? '' : urldecode( $_GET['tab'] ); + $current_subtab = empty( $_GET['section'] ) ? '' : urldecode( $_GET['section'] ); - $settings_struct = $this->settings_structure[$current_tab]; + $settings_struct = $this->settings_structure[$current_tab]; - //remove not option hidden fields - if ( ! empty( $settings_struct['fields'] ) ) { - foreach ( $settings_struct['fields'] as $field_key=>$field_options ) { + //remove not option hidden fields + if ( ! empty( $settings_struct['fields'] ) ) { + foreach ( $settings_struct['fields'] as $field_key=>$field_options ) { - if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) - unset( $settings_struct['fields'][$field_key] ); + if ( isset( $field_options['is_option'] ) && $field_options['is_option'] === false ) + unset( $settings_struct['fields'][$field_key] ); - } - } + } + } - if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) - um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) ); + if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) ) + um_js_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) ); - if ( ! empty( $settings_struct['sections'] ) ) { - if ( empty( $settings_struct['sections'][$current_subtab] ) ) - um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) ); - } + if ( ! empty( $settings_struct['sections'] ) ) { + if ( empty( $settings_struct['sections'][$current_subtab] ) ) + um_js_redirect( add_query_arg( array( 'page' => 'um_options', 'tab' => $current_tab ), admin_url( 'admin.php' ) ) ); + } - echo '

' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '

'; + echo '

' . __( 'Ultimate Member - Settings', 'ultimate-member' ) . '

'; - echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab ); + echo $this->generate_tabs_menu() . $this->generate_subtabs_menu( $current_tab ); - /** - * UM hook - * - * @type action - * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content - * @description Show some content before settings page content - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 ); - * @example - * - */ - do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" ); + /** + * UM hook + * + * @type action + * @title um_settings_page_before_{$current_tab}_{$current_subtab}_content + * @description Show some content before settings page content + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_settings_page_before_{$current_tab}_{$current_subtab}_content', 'function_name', 10 ); + * @example + * + */ + do_action( "um_settings_page_before_" . $current_tab . "_" . $current_subtab . "_content" ); - if ( 'licenses' == $current_tab || 'install_info' == $current_tab ) { + if ( 'licenses' == $current_tab || 'install_info' == $current_tab ) { - /** - * UM hook - * - * @type action - * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section - * @description Show some content before section content at settings page - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 ); - * @example - * - */ - do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); + /** + * UM hook + * + * @type action + * @title um_settings_page_{$current_tab}_{$current_subtab}_before_section + * @description Show some content before section content at settings page + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_settings_page_{$current_tab}_{$current_subtab}_before_section', 'function_name', 10 ); + * @example + * + */ + do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); - $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); - /** - * UM hook - * - * @type filter - * @title um_settings_section_{$current_tab}_{$current_subtab}_content - * @description Render settings section - * @input_vars - * [{"var":"$content","type":"string","desc":"Section content"}, - * {"var":"$section_fields","type":"array","desc":"Section Fields"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); - * @example - * - */ - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), - $section_fields - ); + /** + * UM hook + * + * @type filter + * @title um_settings_section_{$current_tab}_{$current_subtab}_content + * @description Render settings section + * @input_vars + * [{"var":"$content","type":"string","desc":"Section content"}, + * {"var":"$section_fields","type":"array","desc":"Section Fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); + * @example + * + */ + echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', + $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $section_fields + ); - } else { ?> + } else { ?> - -
- + + - - */ - do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); + + */ + do_action( "um_settings_page_" . $current_tab . "_" . $current_subtab . "_before_section" ); - $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); + $section_fields = $this->get_section_fields( $current_tab, $current_subtab ); - /** - * UM hook - * - * @type filter - * @title um_settings_section_{$current_tab}_{$current_subtab}_content - * @description Render settings section - * @input_vars - * [{"var":"$content","type":"string","desc":"Section content"}, - * {"var":"$section_fields","type":"array","desc":"Section Fields"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); - * @example - * - */ - echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', - $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), - $section_fields - ); - ?> + /** + * UM hook + * + * @type filter + * @title um_settings_section_{$current_tab}_{$current_subtab}_content + * @description Render settings section + * @input_vars + * [{"var":"$content","type":"string","desc":"Section content"}, + * {"var":"$section_fields","type":"array","desc":"Section Fields"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_settings_section_{$current_tab}_{$current_subtab}_content', 'function_name', 10, 2 ); + * @example + * + */ + echo apply_filters( 'um_settings_section_' . $current_tab . '_' . $current_subtab . '_content', + $this->render_settings_section( $section_fields, $current_tab, $current_subtab ), + $section_fields + ); + ?> -

- -

-
+

+ +

+ - ';*/ - } + /*echo '
';*/ + } - /** - * Generate pages tabs - * - * @param string $page - * @return string - */ - function generate_tabs_menu( $page = 'settings' ) { + /** + * Generate pages tabs + * + * @param string $page + * @return string + */ + function generate_tabs_menu( $page = 'settings' ) { - $tabs = ''; - } + return $tabs . ''; + } + /** + * @param string $tab + * + * @return string + */ + function generate_subtabs_menu( $tab = '' ) { + if ( empty( $this->settings_structure[$tab]['sections'] ) ) + return ''; - function generate_subtabs_menu( $tab = '' ) { - if ( empty( $this->settings_structure[$tab]['sections'] ) ) - return ''; + $menu_subtabs = array(); + foreach ( $this->settings_structure[$tab]['sections'] as $slug => $subtab ) { + $menu_subtabs[$slug] = $subtab['title']; + } - $menu_subtabs = array(); - foreach ( $this->settings_structure[$tab]['sections'] as $slug => $subtab ) { - $menu_subtabs[$slug] = $subtab['title']; - } + $subtabs = '
    '; - $subtabs = '
      '; + $current_tab = empty( $_GET['tab'] ) ? '' : urldecode( $_GET['tab'] ); + $current_subtab = empty( $_GET['section'] ) ? '' : urldecode( $_GET['section'] ); + foreach ( $menu_subtabs as $name => $label ) { + $active = ( $current_subtab == $name ) ? 'current' : ''; + $subtabs .= '' + . $label . + ' | '; + } - $current_tab = empty( $_GET['tab'] ) ? '' : urldecode( $_GET['tab'] ); - $current_subtab = empty( $_GET['section'] ) ? '' : urldecode( $_GET['section'] ); - foreach ( $menu_subtabs as $name => $label ) { - $active = ( $current_subtab == $name ) ? 'current' : ''; - $subtabs .= '' - . $label . - ' | '; - } - - return substr( $subtabs, 0, -3 ) . '
    '; - } + return substr( $subtabs, 0, -3 ) . '
'; + } - /** - * Handler for settings forms - * when "Save Settings" button click - * - */ - function save_settings_handler() { - if ( isset( $_POST['um-settings-action'] ) && 'save' == $_POST['um-settings-action'] && ! empty( $_POST['um_options'] ) ) { - /** - * UM hook - * - * @type action - * @title um_settings_before_save - * @description Before settings save action - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_settings_before_save', 'function_name', 10 ); - * @example - * - */ - do_action( "um_settings_before_save" ); + /** + * Handler for settings forms + * when "Save Settings" button click + * + */ + function save_settings_handler() { + if ( isset( $_POST['um-settings-action'] ) && 'save' == $_POST['um-settings-action'] && ! empty( $_POST['um_options'] ) ) { + /** + * UM hook + * + * @type action + * @title um_settings_before_save + * @description Before settings save action + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_settings_before_save', 'function_name', 10 ); + * @example + * + */ + do_action( "um_settings_before_save" ); - /** - * UM hook - * - * @type filter - * @title um_change_settings_before_save - * @description Change settings before save - * @input_vars - * [{"var":"$settings","type":"array","desc":"UM Settings on save"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 ); - * @example - * - */ - $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] ); + /** + * UM hook + * + * @type filter + * @title um_change_settings_before_save + * @description Change settings before save + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Settings on save"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_change_settings_before_save', 'function_name', 10, 1 ); + * @example + * + */ + $settings = apply_filters( 'um_change_settings_before_save', $_POST['um_options'] ); - foreach ( $settings as $key => $value ) { - UM()->options()->update( $key, $value ); - } + foreach ( $settings as $key => $value ) { + UM()->options()->update( $key, $value ); + } - /** - * UM hook - * - * @type action - * @title um_settings_save - * @description After settings save action - * @change_log - * ["Since: 2.0"] - * @usage add_action( 'um_settings_save', 'function_name', 10 ); - * @example - * - */ - do_action( "um_settings_save" ); + /** + * UM hook + * + * @type action + * @title um_settings_save + * @description After settings save action + * @change_log + * ["Since: 2.0"] + * @usage add_action( 'um_settings_save', 'function_name', 10 ); + * @example + * + */ + do_action( "um_settings_save" ); - //redirect after save settings - $arg = array( - 'page' => 'um_options', - ); + //redirect after save settings + $arg = array( + 'page' => 'um_options', + ); - if ( ! empty( $_GET['tab'] ) ) - $arg['tab'] = $_GET['tab']; + if ( ! empty( $_GET['tab'] ) ) + $arg['tab'] = $_GET['tab']; - if ( ! empty( $_GET['section'] ) ) - $arg['section'] = $_GET['section']; + if ( ! empty( $_GET['section'] ) ) + $arg['section'] = $_GET['section']; - um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) ); - } - } + um_js_redirect( add_query_arg( $arg, admin_url( 'admin.php' ) ) ); + } + } - /** - * Remove empty values from multi text fields - * - * @param $settings - * @return array - */ - function remove_empty_values( $settings ) { - $tab = ''; - if ( ! empty( $_GET['tab'] ) ) - $tab = $_GET['tab']; + /** + * Remove empty values from multi text fields + * + * @param $settings + * @return array + */ + function remove_empty_values( $settings ) { + $tab = ''; + if ( ! empty( $_GET['tab'] ) ) + $tab = $_GET['tab']; - $section = ''; - if ( ! empty( $_GET['section'] ) ) - $section = $_GET['section']; + $section = ''; + if ( ! empty( $_GET['section'] ) ) + $section = $_GET['section']; - if ( isset( $this->settings_structure[$tab]['sections'][$section]['fields'] ) ) - $fields = $this->settings_structure[$tab]['sections'][$section]['fields']; - else - $fields = $this->settings_structure[$tab]['fields']; + if ( isset( $this->settings_structure[$tab]['sections'][$section]['fields'] ) ) + $fields = $this->settings_structure[$tab]['sections'][$section]['fields']; + else + $fields = $this->settings_structure[$tab]['fields']; - if ( empty( $fields ) ) - return $settings; + if ( empty( $fields ) ) + return $settings; - $filtered_settings = array(); - foreach ( $settings as $key=>$value ) { + $filtered_settings = array(); + foreach ( $settings as $key=>$value ) { - $filtered_settings[$key] = $value; + $filtered_settings[$key] = $value; - foreach( $fields as $field ) { - if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) { - $filtered_settings[$key] = array_filter( $settings[$key] ); - } - } - } + foreach( $fields as $field ) { + if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) { + $filtered_settings[$key] = array_filter( $settings[$key] ); + } + } + } - return $filtered_settings; - } + return $filtered_settings; + } - function check_permalinks_changes() { - if ( ! empty( $_POST['um_options']['permalink_base'] ) ) { - if ( UM()->options()->get( 'permalink_base' ) != $_POST['um_options']['permalink_base'] ) { - $this->need_change_permalinks = true; - } - } - } + /** + * + */ + function check_permalinks_changes() { + if ( ! empty( $_POST['um_options']['permalink_base'] ) ) { + if ( UM()->options()->get( 'permalink_base' ) != $_POST['um_options']['permalink_base'] ) { + $this->need_change_permalinks = true; + } + } + } - function on_settings_save() { - if ( ! empty( $_POST['um_options'] ) ) { - if ( ! empty( $_POST['um_options']['pages_settings'] ) ) { - $post_ids = new \WP_Query( array( - 'post_type' => 'page', - 'meta_query' => array( - array( - 'key' => '_um_core', - 'compare' => 'EXISTS' - ) - ), - 'posts_per_page' => -1, - 'fields' => 'ids' - ) ); + /** + * + */ + function on_settings_save() { + if ( ! empty( $_POST['um_options'] ) ) { + if ( ! empty( $_POST['um_options']['pages_settings'] ) ) { + $post_ids = new \WP_Query( array( + 'post_type' => 'page', + 'meta_query' => array( + array( + 'key' => '_um_core', + 'compare' => 'EXISTS' + ) + ), + 'posts_per_page' => -1, + 'fields' => 'ids' + ) ); - $post_ids = $post_ids->get_posts(); + $post_ids = $post_ids->get_posts(); - if ( ! empty( $post_ids ) ) { - foreach ( $post_ids as $post_id ) { - delete_post_meta( $post_id, '_um_core' ); - } - } + if ( ! empty( $post_ids ) ) { + foreach ( $post_ids as $post_id ) { + delete_post_meta( $post_id, '_um_core' ); + } + } - foreach ( $_POST['um_options'] as $option_slug => $post_id ) { - $slug = str_replace( 'core_', '', $option_slug ); - update_post_meta( $post_id, '_um_core', $slug ); - } - } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) { - if ( ! empty( $this->need_change_permalinks ) ) { - $users = get_users( array( + foreach ( $_POST['um_options'] as $option_slug => $post_id ) { + $slug = str_replace( 'core_', '', $option_slug ); + update_post_meta( $post_id, '_um_core', $slug ); + } + } elseif ( ! empty( $_POST['um_options']['permalink_base'] ) ) { + if ( ! empty( $this->need_change_permalinks ) ) { + $users = get_users( array( 'fields' => 'ids', - ) ); - if ( ! empty( $users ) ) { - foreach ( $users as $user_id ) { - UM()->user()->generate_profile_slug( $user_id ); - } - } - } - } - } - } + ) ); + if ( ! empty( $users ) ) { + foreach ( $users as $user_id ) { + UM()->user()->generate_profile_slug( $user_id ); + } + } + } + } + } + } - function before_licenses_save() { - if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) - return; + /** + * + */ + function before_licenses_save() { + if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) + return; - foreach ( $_POST['um_options'] as $key => $value ) { - $this->previous_licenses[$key] = UM()->options()->get( $key ); - } - } + foreach ( $_POST['um_options'] as $key => $value ) { + $this->previous_licenses[$key] = UM()->options()->get( $key ); + } + } - function licenses_save() { - if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) - return; + /** + * + */ + function licenses_save() { + if ( empty( $_POST['um_options'] ) || empty( $_POST['licenses_settings'] ) ) + return; - foreach ( $_POST['um_options'] as $key => $value ) { - $edd_action = ''; - $license_key = ''; - if ( empty( $this->previous_licenses[$key] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[$key] ) && ! empty( $value ) && $this->previous_licenses[$key] != $value ) ) { - $edd_action = 'activate_license'; - $license_key = $value; - } elseif ( ! empty( $this->previous_licenses[$key] ) && empty( $value ) ) { - $edd_action = 'deactivate_license'; - $license_key = $this->previous_licenses[$key]; - } elseif ( ! empty( $this->previous_licenses[$key] ) && ! empty( $value ) ) { - $edd_action = 'check_license'; - $license_key = $value; - } + foreach ( $_POST['um_options'] as $key => $value ) { + $edd_action = ''; + $license_key = ''; + if ( empty( $this->previous_licenses[$key] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[$key] ) && ! empty( $value ) && $this->previous_licenses[$key] != $value ) ) { + $edd_action = 'activate_license'; + $license_key = $value; + } elseif ( ! empty( $this->previous_licenses[$key] ) && empty( $value ) ) { + $edd_action = 'deactivate_license'; + $license_key = $this->previous_licenses[$key]; + } elseif ( ! empty( $this->previous_licenses[$key] ) && ! empty( $value ) ) { + $edd_action = 'check_license'; + $license_key = $value; + } - if ( empty( $edd_action ) ) - continue; + if ( empty( $edd_action ) ) + continue; - $item_name = false; - $version = false; - $author = false; - foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) { - if ( $field_data['id'] == $key ) { - $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false; - $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false; - $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false; - } - } + $item_name = false; + $version = false; + $author = false; + foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) { + if ( $field_data['id'] == $key ) { + $item_name = ! empty( $field_data['item_name'] ) ? $field_data['item_name'] : false; + $version = ! empty( $field_data['version'] ) ? $field_data['version'] : false; + $author = ! empty( $field_data['author'] ) ? $field_data['author'] : false; + } + } - $api_params = array( - 'edd_action' => $edd_action, - 'license' => $license_key, - 'item_name' => $item_name, - 'version' => $version, - 'author' => $author, - 'url' => home_url(), - ); + $api_params = array( + 'edd_action' => $edd_action, + 'license' => $license_key, + 'item_name' => $item_name, + 'version' => $version, + 'author' => $author, + 'url' => home_url(), + ); - $request = wp_remote_post( - 'https://ultimatemember.com/', - array( - 'timeout' => 15, - 'sslverify' => false, - 'body' => $api_params - ) - ); + $request = wp_remote_post( + 'https://ultimatemember.com/', + array( + 'timeout' => 15, + 'sslverify' => false, + 'body' => $api_params + ) + ); - if ( ! is_wp_error( $request ) ) - $request = json_decode( wp_remote_retrieve_body( $request ) ); + if ( ! is_wp_error( $request ) ) + $request = json_decode( wp_remote_retrieve_body( $request ) ); - $request = ( $request ) ? maybe_unserialize( $request ) : false; + $request = ( $request ) ? maybe_unserialize( $request ) : false; - if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) - update_option( "{$key}_edd_answer", $request ); - else - delete_option( "{$key}_edd_answer" ); + if ( $edd_action == 'activate_license' || $edd_action == 'check_license' ) + update_option( "{$key}_edd_answer", $request ); + else + delete_option( "{$key}_edd_answer" ); - } - } + } + } - function check_wrong_licenses() { - $invalid_license = 0; - $arr_inactive_license_keys = array(); + /** + * + */ + function check_wrong_licenses() { + $invalid_license = 0; + $arr_inactive_license_keys = array(); - if ( empty( $this->settings_structure['licenses']['fields'] ) ) - return; + 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" ); + 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 ) && 'valid' == $license->license ) || 'valid' == $license ) + continue; - if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ){ - $arr_inactive_license_keys[ ] = $license->item_name; - } + if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ){ + $arr_inactive_license_keys[ ] = $license->item_name; + } - $invalid_license++; + $invalid_license++; - } - - if ( ! empty( $arr_inactive_license_keys ) ) { ?> - -
-

- www.UltimateMember.com.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) ; ?> -

-
- - - -
-

- Licenses page to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) ?> -

-
- - config()->email_notifications; - - if ( empty( $email_key ) || empty( $emails[$email_key] ) ) - include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php'; - } - - - function settings_email_tab( $section ) { - $email_key = empty( $_GET['email'] ) ? '' : urldecode( $_GET['email'] ); - $emails = UM()->config()->email_notifications; - - if ( empty( $email_key ) || empty( $emails[$email_key] ) ) - return $section; - - $in_theme = UM()->mail()->template_in_theme( $email_key ); - - /** - * UM hook - * - * @type filter - * @title um_admin_settings_email_section_fields - * @description Extend UM Email Settings - * @input_vars - * [{"var":"$settings","type":"array","desc":"UM Email Settings"}, - * {"var":"$email_key","type":"string","desc":"Email Key"}] - * @change_log - * ["Since: 2.0"] - * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 ); - * @example - * - */ - $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array( - array( - 'id' => 'um_email_template', - 'type' => 'hidden', - 'value' => $email_key, - ), - array( - 'id' => $email_key . '_on', - 'type' => 'checkbox', - 'label' => $emails[$email_key]['title'], - 'tooltip' => $emails[$email_key]['description'], - ), - array( - 'id' => $email_key . '_sub', - 'type' => 'text', - 'label' => __( 'Subject Line','ultimate-member' ), - 'conditional' => array( $email_key . '_on', '=', 1 ), - 'tooltip' => __('This is the subject line of the e-mail','ultimate-member'), - ), - array( - 'id' => $email_key, - 'type' => 'email_template', - 'label' => __( 'Message Body','ultimate-member' ), - 'conditional' => array( $email_key . '_on', '=', 1 ), - 'tooltip' => __('This is the content of the e-mail','ultimate-member'), - 'value' => UM()->mail()->get_email_template( $email_key ), - 'in_theme' => $in_theme - ), - ), $email_key ); + } + + if ( ! empty( $arr_inactive_license_keys ) ) { ?> + +
+

+ www.UltimateMember.com.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) ; ?> +

+
+ + + +
+

+ Licenses page to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) ?> +

+
+ + config()->email_notifications; + + if ( empty( $email_key ) || empty( $emails[$email_key] ) ) + include_once um_path . 'includes/admin/core/list-tables/emails-list-table.php'; + } + + + /** + * @param $section + * + * @return string + */ + function settings_email_tab( $section ) { + $email_key = empty( $_GET['email'] ) ? '' : urldecode( $_GET['email'] ); + $emails = UM()->config()->email_notifications; + + if ( empty( $email_key ) || empty( $emails[$email_key] ) ) + return $section; + + $in_theme = UM()->mail()->template_in_theme( $email_key ); + + /** + * UM hook + * + * @type filter + * @title um_admin_settings_email_section_fields + * @description Extend UM Email Settings + * @input_vars + * [{"var":"$settings","type":"array","desc":"UM Email Settings"}, + * {"var":"$email_key","type":"string","desc":"Email Key"}] + * @change_log + * ["Since: 2.0"] + * @usage add_filter( 'um_admin_settings_email_section_fields', 'function_name', 10, 2 ); + * @example + * + */ + $section_fields = apply_filters( 'um_admin_settings_email_section_fields', array( + array( + 'id' => 'um_email_template', + 'type' => 'hidden', + 'value' => $email_key, + ), + array( + 'id' => $email_key . '_on', + 'type' => 'checkbox', + 'label' => $emails[$email_key]['title'], + 'tooltip' => $emails[$email_key]['description'], + ), + array( + 'id' => $email_key . '_sub', + 'type' => 'text', + 'label' => __( 'Subject Line','ultimate-member' ), + 'conditional' => array( $email_key . '_on', '=', 1 ), + 'tooltip' => __('This is the subject line of the e-mail','ultimate-member'), + ), + array( + 'id' => $email_key, + 'type' => 'email_template', + 'label' => __( 'Message Body','ultimate-member' ), + 'conditional' => array( $email_key . '_on', '=', 1 ), + 'tooltip' => __('This is the content of the e-mail','ultimate-member'), + 'value' => UM()->mail()->get_email_template( $email_key ), + 'in_theme' => $in_theme + ), + ), $email_key ); + + return $this->render_settings_section( $section_fields, 'email', $email_key ); + } + + + /** + * + */ + function settings_appearance_profile_tab() { + wp_enqueue_media(); + } + + + /** + * @param $html + * @param $section_fields + * + * @return string + */ + function settings_licenses_tab( $html, $section_fields ) { + ob_start(); ?> + +
+ + + + options()->get( $field_data['id'] ); + $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' ); + + $license = get_option( "{$field_data['id']}_edd_answer" ); + + if ( is_object( $license ) && ! empty( $value ) ) { + // activate_license 'invalid' on anything other than valid, so if there was an error capture it + if ( false === $license->success ) { + + if ( ! empty( $license->error ) ) { + switch ( $license->error ) { + + case 'expired' : + + $class = 'expired'; + $messages[] = sprintf( + __( 'Your license key expired on %s. Please renew your license key.', 'ultimate-member' ), + date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), + 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' + ); + + $license_status = 'license-' . $class . '-notice'; + + break; + + case 'revoked' : + + $class = 'error'; + $messages[] = sprintf( + __( 'Your license key has been disabled. Please contact support for more information.', 'ultimate-member' ), + 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked' + ); - return $this->render_settings_section( $section_fields, 'email', $email_key ); - } + $license_status = 'license-' . $class . '-notice'; + break; - function settings_appearance_profile_tab() { - wp_enqueue_media(); - } + case 'missing' : + $class = 'error'; + $messages[] = sprintf( + __( 'Invalid license. Please visit your account page and verify it.', 'ultimate-member' ), + 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing' + ); - function settings_licenses_tab( $html, $section_fields ) { - ob_start(); ?> + $license_status = 'license-' . $class . '-notice'; -
- -
- - options()->get( $field_data['id'] ); - $value = isset( $option_value ) && ! empty( $option_value ) ? $option_value : ( isset( $field_data['default'] ) ? $field_data['default'] : '' ); + break; - $license = get_option( "{$field_data['id']}_edd_answer" ); - - if ( is_object( $license ) && ! empty( $value ) ) { - // activate_license 'invalid' on anything other than valid, so if there was an error capture it - if ( false === $license->success ) { + case 'invalid' : + case 'site_inactive' : - if ( ! empty( $license->error ) ) { - switch ( $license->error ) { + $class = 'error'; + $messages[] = sprintf( + __( 'Your %s is not active for this URL. Please visit your account page to manage your license key URLs.', 'ultimate-member' ), + $field_data['item_name'], + 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' + ); - case 'expired' : + $license_status = 'license-' . $class . '-notice'; - $class = 'expired'; - $messages[] = sprintf( - __( 'Your license key expired on %s. Please renew your license key.', 'ultimate-member' ), - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), - 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'item_name_mismatch' : - break; + $class = 'error'; + $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] ); - case 'revoked' : + $license_status = 'license-' . $class . '-notice'; - $class = 'error'; - $messages[] = sprintf( - __( 'Your license key has been disabled. Please contact support for more information.', 'ultimate-member' ), - 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'no_activations_left': - break; + $class = 'error'; + $messages[] = sprintf( __( 'Your license key has reached its activation limit. View possible upgrades now.', 'ultimate-member' ), 'https://ultimatemember.com/account' ); - case 'missing' : + $license_status = 'license-' . $class . '-notice'; - $class = 'error'; - $messages[] = sprintf( - __( 'Invalid license. Please visit your account page and verify it.', 'ultimate-member' ), - 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'license_not_activable': - break; + $class = 'error'; + $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' ); - case 'invalid' : - case 'site_inactive' : + $license_status = 'license-' . $class . '-notice'; + break; - $class = 'error'; - $messages[] = sprintf( - __( 'Your %s is not active for this URL. Please visit your account page to manage your license key URLs.', 'ultimate-member' ), - $field_data['item_name'], - 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' - ); + default : - $license_status = 'license-' . $class . '-notice'; + $class = 'error'; + $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' ); + $messages[] = sprintf( __( 'There was an error with this license key: %s. Please contact our support team.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' ); - break; + $license_status = 'license-' . $class . '-notice'; + break; + } + } else { + $class = 'error'; + $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' ); + $messages[] = sprintf( __( 'There was an error with this license key: %s. Please contact our support team.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' ); - case 'item_name_mismatch' : + $license_status = 'license-' . $class . '-notice'; + } - $class = 'error'; - $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] ); + } else { - $license_status = 'license-' . $class . '-notice'; + switch( $license->license ) { - break; + case 'expired' : - case 'no_activations_left': + $class = 'expired'; + $messages[] = sprintf( + __( 'Your license key expired on %s. Please renew your license key.', 'ultimate-member' ), + date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), + 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' + ); - $class = 'error'; - $messages[] = sprintf( __( 'Your license key has reached its activation limit. View possible upgrades now.', 'ultimate-member' ), 'https://ultimatemember.com/account' ); + $license_status = 'license-' . $class . '-notice'; - $license_status = 'license-' . $class . '-notice'; + break; - break; + case 'revoked' : - case 'license_not_activable': + $class = 'error'; + $messages[] = sprintf( + __( 'Your license key has been disabled. Please contact support for more information.', 'ultimate-member' ), + 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked' + ); - $class = 'error'; - $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' ); + $license_status = 'license-' . $class . '-notice'; - $license_status = 'license-' . $class . '-notice'; - break; + break; - default : + case 'missing' : - $class = 'error'; - $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' ); - $messages[] = sprintf( __( 'There was an error with this license key: %s. Please contact our support team.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' ); + $class = 'error'; + $messages[] = sprintf( + __( 'Invalid license. Please visit your account page and verify it.', 'ultimate-member' ), + 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing' + ); - $license_status = 'license-' . $class . '-notice'; - break; - } - } else { - $class = 'error'; - $error = ! empty( $license->error ) ? $license->error : __( 'unknown_error', 'ultimate-member' ); - $messages[] = sprintf( __( 'There was an error with this license key: %s. Please contact our support team.', 'ultimate-member' ), $error, 'https://ultimatemember.com/support' ); + $license_status = 'license-' . $class . '-notice'; - $license_status = 'license-' . $class . '-notice'; - } + break; - } else { + case 'invalid' : + case 'site_inactive' : - switch( $license->license ) { + $class = 'error'; + $messages[] = sprintf( + __( 'Your %s is not active for this URL. Please visit your account page to manage your license key URLs.', 'ultimate-member' ), + $field_data['item_name'], + 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' + ); - case 'expired' : + $license_status = 'license-' . $class . '-notice'; - $class = 'expired'; - $messages[] = sprintf( - __( 'Your license key expired on %s. Please renew your license key.', 'ultimate-member' ), - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), - 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'item_name_mismatch' : - break; + $class = 'error'; + $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] ); - case 'revoked' : + $license_status = 'license-' . $class . '-notice'; - $class = 'error'; - $messages[] = sprintf( - __( 'Your license key has been disabled. Please contact support for more information.', 'ultimate-member' ), - 'https://ultimatemember.com/support?utm_campaign=admin&utm_source=licenses&utm_medium=revoked' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'no_activations_left': - break; + $class = 'error'; + $messages[] = sprintf( __( 'Your license key has reached its activation limit. View possible upgrades now.', 'ultimate-member' ), 'https://ultimatemember.com/account' ); - case 'missing' : + $license_status = 'license-' . $class . '-notice'; - $class = 'error'; - $messages[] = sprintf( - __( 'Invalid license. Please visit your account page and verify it.', 'ultimate-member' ), - 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=missing' - ); + break; - $license_status = 'license-' . $class . '-notice'; + case 'license_not_activable': - break; + $class = 'error'; + $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' ); - case 'invalid' : - case 'site_inactive' : + $license_status = 'license-' . $class . '-notice'; + break; - $class = 'error'; - $messages[] = sprintf( - __( 'Your %s is not active for this URL. Please visit your account page to manage your license key URLs.', 'ultimate-member' ), - $field_data['item_name'], - 'https://ultimatemember.com/account?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' - ); + case 'valid' : + default: - $license_status = 'license-' . $class . '-notice'; + $class = 'valid'; - break; + $now = current_time( 'timestamp' ); + $expiration = strtotime( $license->expires, current_time( 'timestamp' ) ); - case 'item_name_mismatch' : + if( 'lifetime' === $license->expires ) { - $class = 'error'; - $messages[] = sprintf( __( 'This appears to be an invalid license key for %s.', 'ultimate-member' ), $field_data['item_name'] ); + $messages[] = __( 'License key never expires.', 'ultimate-member' ); - $license_status = 'license-' . $class . '-notice'; + $license_status = 'license-lifetime-notice'; - break; + } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { - case 'no_activations_left': + $messages[] = sprintf( + __( 'Your license key expires soon! It expires on %s. Renew your license key.', 'ultimate-member' ), + date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), + 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew' + ); - $class = 'error'; - $messages[] = sprintf( __( 'Your license key has reached its activation limit. View possible upgrades now.', 'ultimate-member' ), 'https://ultimatemember.com/account' ); + $license_status = 'license-expires-soon-notice'; - $license_status = 'license-' . $class . '-notice'; + } else { - break; + $messages[] = sprintf( + __( 'Your license key expires on %s.', 'ultimate-member' ), + date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) + ); - case 'license_not_activable': + $license_status = 'license-expiration-date-notice'; - $class = 'error'; - $messages[] = __( 'The key you entered belongs to a bundle, please use the product specific license key.', 'ultimate-member' ); + } - $license_status = 'license-' . $class . '-notice'; - break; + break; - case 'valid' : - default: + } - $class = 'valid'; + } - $now = current_time( 'timestamp' ); - $expiration = strtotime( $license->expires, current_time( 'timestamp' ) ); + } else { + $class = 'empty'; - if( 'lifetime' === $license->expires ) { + $messages[] = sprintf( + __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ), + $field_data['item_name'] + ); - $messages[] = __( 'License key never expires.', 'ultimate-member' ); + $license_status = null; - $license_status = 'license-lifetime-notice'; - - } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { - - $messages[] = sprintf( - __( 'Your license key expires soon! It expires on %s. Renew your license key.', 'ultimate-member' ), - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), - 'https://ultimatemember.com/checkout/?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew' - ); - - $license_status = 'license-expires-soon-notice'; - - } else { - - $messages[] = sprintf( - __( 'Your license key expires on %s.', 'ultimate-member' ), - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) - ); - - $license_status = 'license-expiration-date-notice'; - - } - - break; - - } - - } - - } else { - $class = 'empty'; - - $messages[] = sprintf( - __( 'To receive updates, please enter your valid %s license key.', 'ultimate-member' ), - $field_data['item_name'] - ); - - $license_status = null; - - } + } - ?> + ?> - - - + + - - - -
-
- - - - -
- +
+ + + + + +
+ - license ) || 'valid' == $license ) ) { ?> - - - - - - license ) || 'valid' == $license ) ) { ?> + + + + + + -
-

-
- - -
-
- +
+

+
+ + + + + + + +
+ Name . ' ' . $theme_data->Version; + // Get theme info + $theme_data = wp_get_theme(); + $theme = $theme_data->Name . ' ' . $theme_data->Version; - // Identify Hosting Provider - $host = um_get_host(); + // Identify Hosting Provider + $host = um_get_host(); - um_fetch_user( get_current_user_id() ); + um_fetch_user( get_current_user_id() ); - if ( isset( $this->content ) ) { - echo $this->content; - } else { ?> + if ( isset( $this->content ) ) { + echo $this->content; + } else { ?> -

Install Info

+

Install Info

-
-