This commit is contained in:
yura_nalivaiko
2018-04-10 10:48:08 +03:00
90 changed files with 7001 additions and 5368 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -69,7 +69,7 @@ jQuery(document).ready(function() {
return false;
});
jQuery(document).on('click', '.um-finish-upload.file', function(){
jQuery(document).on('click', '.um-finish-upload.file:not(.disabled)', function(){
var key = jQuery(this).attr('data-key');
var preview = jQuery(this).parents('.um-modal-body').find('.um-single-file-preview').html();
@@ -83,7 +83,7 @@ jQuery(document).ready(function() {
jQuery('.um-single-file-preview[data-key='+key+']').parents('.um-field').find('input[type=hidden]').val( jQuery('.um-single-file-preview[data-key='+key+']').parents('.um-field').find('.um-single-fileinfo a').attr('href') );
});
jQuery(document).on('click', '.um-finish-upload.image', function(){
jQuery(document).on('click', '.um-finish-upload.image:not(.disabled)', function(){
var elem = jQuery(this);
var key = jQuery(this).attr('data-key');
+1 -1
View File
@@ -1 +1 @@
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href");return a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:um_scripts.remove_file,type:"post",data:{src:t}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src");return jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:um_scripts.remove_file,type:"post",data:{src:t}}),!1}),jQuery(document).on("click",".um-finish-upload.file",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find("input[type=hidden]").val(jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-single-fileinfo a").attr("href"))}),jQuery(document).on("click",".um-finish-upload.image",function(){var e=jQuery(this),a=jQuery(this).attr("data-key"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),r=t.find("img").attr("src"),i=t.attr("data-coord");if(jQuery(this).parents("#um_upload_single").attr("data-user_id"))var u=jQuery(this).parents("#um_upload_single").attr("data-user_id");else var u=0;i?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:um_scripts.resize_image,type:"POST",data:{src:r,coord:i,user_id:u,key:a},success:function(t){d=new Date,"profile_photo"==a&&jQuery(".um-profile-photo-img img").attr("src",t+"?"+d.getTime()),"cover_photo"==a&&(jQuery(".um-cover-e").empty().html('<img src="'+t+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",t+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find("input[type=hidden]").val(t)}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",r+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find("input[type=hidden]").val(r))}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal");if(jQuery(this).data("modal-size"))var t=jQuery(this).data("modal-size");else var t="normal";jQuery(this).data("modal-copy")?(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),um_new_modal(a,t)):um_new_modal(a,t)})});
jQuery(document).ready(function(){jQuery(document).on("click",".um-popup-overlay",function(){remove_Modal()}),jQuery(document).on("click",'.um-modal-overlay, a[data-action="um_remove_modal"]',function(){um_remove_modal()}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"], .um-modal a',function(e){return e.preventDefault(),!1}),jQuery(document).on("click",".um-modal .um-single-file-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-fileinfo a").attr("href");return a.find(".um-single-file-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:um_scripts.remove_file,type:"post",data:{src:t}}),!1}),jQuery(document).on("click",".um-modal .um-single-image-preview a.cancel",function(e){e.preventDefault();var a=jQuery(this).parents(".um-modal-body"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview img").attr("src");return jQuery("img.cropper-hidden").cropper("destroy"),a.find(".um-single-image-preview img").attr("src",""),a.find(".um-single-image-preview").hide(),a.find(".ajax-upload-dragdrop").show(),a.find(".um-modal-btn.um-finish-upload").addClass("disabled"),um_modal_responsive(),jQuery.ajax({url:um_scripts.remove_file,type:"post",data:{src:t}}),!1}),jQuery(document).on("click",".um-finish-upload.file:not(.disabled)",function(){var e=jQuery(this).attr("data-key"),a=jQuery(this).parents(".um-modal-body").find(".um-single-file-preview").html();um_remove_modal(),jQuery(".um-single-file-preview[data-key="+e+"]").fadeIn().html(a),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-btn-auto-width").html(jQuery(this).attr("data-change")),jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find("input[type=hidden]").val(jQuery(".um-single-file-preview[data-key="+e+"]").parents(".um-field").find(".um-single-fileinfo a").attr("href"))}),jQuery(document).on("click",".um-finish-upload.image:not(.disabled)",function(){var e=jQuery(this),a=jQuery(this).attr("data-key"),t=jQuery(this).parents(".um-modal-body").find(".um-single-image-preview"),r=t.find("img").attr("src"),i=t.attr("data-coord");if(jQuery(this).parents("#um_upload_single").attr("data-user_id"))var u=jQuery(this).parents("#um_upload_single").attr("data-user_id");else var u=0;i?(jQuery(this).html(jQuery(this).attr("data-processing")).addClass("disabled"),jQuery.ajax({url:um_scripts.resize_image,type:"POST",data:{src:r,coord:i,user_id:u,key:a},success:function(t){d=new Date,"profile_photo"==a&&jQuery(".um-profile-photo-img img").attr("src",t+"?"+d.getTime()),"cover_photo"==a&&(jQuery(".um-cover-e").empty().html('<img src="'+t+"?"+d.getTime()+'" alt="" />'),jQuery(".um").hasClass("um-editing")&&jQuery(".um-cover-overlay").show()),jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",t+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find("input[type=hidden]").val(t)}})):(d=new Date,jQuery(".um-single-image-preview[data-key="+a+"]").fadeIn().find("img").attr("src",r+"?"+d.getTime()),um_remove_modal(),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find(".um-btn-auto-width").html(e.attr("data-change")),jQuery(".um-single-image-preview[data-key="+a+"]").parents(".um-field").find("input[type=hidden]").val(r))}),jQuery(document).on("click",'a[data-modal^="um_"], span[data-modal^="um_"]',function(e){var a=jQuery(this).attr("data-modal");if(jQuery(this).data("modal-size"))var t=jQuery(this).data("modal-size");else var t="normal";jQuery(this).data("modal-copy")?(jQuery("#"+a).html(jQuery(this).parents(".um-field").find(".um-modal-hidden-content").html()),jQuery(this).parents(".um-profile-photo").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-profile-photo").attr("data-user_id")),jQuery(this).parents(".um-cover").attr("data-ratio")&&jQuery("#"+a).attr("data-ratio",jQuery(this).parents(".um-cover").attr("data-ratio")),jQuery(this).parents(".um-cover").attr("data-user_id")&&jQuery("#"+a).attr("data-user_id",jQuery(this).parents(".um-cover").attr("data-user_id")),um_new_modal(a,t)):um_new_modal(a,t)})});
+27 -17
View File
@@ -3,6 +3,16 @@
color: #555;
}
.um-admin-notice.upgraded {
border-color: #0085ba !important;
color: #555;
}
.um-admin-notice.error {
border-color: #dc3232 !important;
color: #555;
}
.um-admin-notice a.button-primary {
background-color: #0085ba !important;
border-color: #0085ba !important;
@@ -144,39 +154,39 @@ a.um-delete{ color: #a00; }
/*Tooltip*/
.ui-tooltip.um_tooltip {
padding: 8px;
color: #eeeeee;
background-color: #333;
position: absolute;
z-index: 1000000;
max-width: 300px;
font-size: 12px;
border-radius: 5px;
padding: 8px;
color: #eeeeee !important;
background: #333 !important;
position: absolute;
z-index: 1000000;
max-width: 300px;
font-size: 12px;
border-radius: 5px;
border: none !important;
text-shadow: none !important;
}
.um_tooltip.dashicons,
.um_tooltip.dashicons:before {
height:22px;
height:22px;
}
.um_tooltip.dashicons-editor-help::before {
float: left;
font-size: 20px;
line-height: 20px;
color: #333 !important;
float: left;
font-size: 20px;
line-height: 20px;
color: #333 !important;
}
.um_tooltip {
cursor: pointer;
vertical-align: middle;
cursor: pointer;
vertical-align: middle;
}
.um_tooltip:hover {
opacity: 1;
opacity: 1;
}
.um_tooltip:hover:before {
opacity: 0.8;
opacity: 0.8;
}
+99
View File
@@ -0,0 +1,99 @@
<?php
namespace um\admin;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'um\admin\Admin_Functions' ) ) {
/**
* Class Admin_Functions
* @package um\admin\core
*/
class Admin_Functions {
/**
* Admin_Functions constructor.
*/
function __construct() {
}
/**
* Boolean check if we're viewing UM backend
*
* @return bool
*/
function is_um_screen() {
global $current_screen;
$screen_id = $current_screen->id;
if ( strstr( $screen_id, 'ultimatemember') ||
strstr( $screen_id, 'um_') ||
strstr( $screen_id, 'user' ) ||
strstr( $screen_id, 'profile' ) ||
$screen_id == 'nav-menus' ) {
return true;
}
if ( $this->is_plugin_post_type() ) {
return true;
}
if ( $this->is_restricted_entity() ) {
return true;
}
return false;
}
/**
* Check if current page load UM post type
*
* @return bool
*/
function is_plugin_post_type() {
$cpt = UM()->cpt_list();
if ( isset( $_REQUEST['post_type'] ) ) {
$post_type = $_REQUEST['post_type'];
if ( in_array( $post_type, $cpt ) ) {
return true;
}
} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
$post_type = get_post_type();
if ( in_array( $post_type, $cpt ) ) {
return true;
}
}
return false;
}
/**
* If page now show content with restricted post/taxonomy
*
* @return bool
*/
function is_restricted_entity() {
$restricted_posts = UM()->options()->get( 'restricted_access_post_metabox' );
$restricted_taxonomies = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
global $typenow, $taxnow;
if ( ! empty( $typenow ) && ! empty( $restricted_posts[ $typenow ] ) ) {
return true;
}
if ( ! empty( $taxnow ) && ! empty( $restricted_taxonomies[ $taxnow ] ) ) {
return true;
}
return false;
}
}
}
+280 -37
View File
@@ -4,14 +4,14 @@ namespace um\admin;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin' ) ) {
if ( ! class_exists( 'um\admin\Admin' ) ) {
/**
* Class Admin
* @package um\admin
*/
class Admin {
class Admin extends Admin_Functions {
/**
@@ -24,55 +24,232 @@ if ( ! class_exists( 'Admin' ) ) {
* Admin constructor.
*/
function __construct() {
parent::__construct();
$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 );
$prefix = is_network_admin() ? 'network_admin_' : '';
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
add_action( 'um_admin_do_action__um_language_downloader', array( &$this, 'um_language_downloader' ) );
add_action( 'um_admin_do_action__um_hide_locale_notice', array( &$this, 'um_hide_notice' ) );
add_action( 'um_admin_do_action__um_can_register_notice', array( &$this, 'um_hide_notice' ) );
add_action( 'um_admin_do_action__um_hide_exif_notice', array( &$this, 'um_hide_notice' ) );
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
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' ) );
}
/**
* Check if current page load UM post type
* Clear all users cache
*
*
* @return bool
* @param $action
*/
function is_plugin_post_type() {
if ( isset( $_REQUEST['post_type'] ) ) {
$post_type = $_REQUEST['post_type'];
if ( in_array( $post_type, array( 'um_form','um_directory' ) ) ) {
return true;
}
} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
$post_type = get_post_type();
if ( in_array( $post_type, array( 'um_form', 'um_directory' ) ) ) {
return true;
}
function user_cache( $action ) {
global $wpdb;
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
return false;
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
exit( wp_redirect( $url ) );
}
/**
* Check if plugin is installed with correct folder
* Purge temp uploads dir
* @param $action
*/
function check_wrong_install_folder() {
$invalid_folder = false;
function purge_temp( $action ) {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
$slug_array = explode( '/', um_plugin );
if ( $slug_array[0] != 'ultimate-member' )
$invalid_folder = true;
UM()->files()->remove_dir( UM()->files()->upload_temp );
if ( $invalid_folder ) { ?>
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
exit( wp_redirect( $url ) );
}
<div class="error">
<p>
<?php printf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) ?>
</p>
</div>
<?php }
/**
* Duplicate form
*
* @param $action
*/
function duplicate_form( $action ) {
if ( ! is_admin() || ! current_user_can('manage_options') ) die();
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) die();
$post_id = $_REQUEST['post_id'];
$n = array(
'post_type' => 'um_form',
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
'post_status' => 'publish',
'post_author' => get_current_user_id(),
);
$n_id = wp_insert_post( $n );
$n_fields = get_post_custom( $post_id );
foreach ( $n_fields as $key => $value ) {
if ( $key == '_um_custom_fields' ) {
$the_value = unserialize( $value[0] );
} else {
$the_value = $value[0];
}
update_post_meta( $n_id, $key, $the_value );
}
delete_post_meta($n_id, '_um_core');
$url = admin_url('edit.php?post_type=um_form');
$url = add_query_arg('update','form_duplicated',$url);
exit( wp_redirect( $url ) );
}
/**
* Download a language remotely
*
* @param $action
*/
function um_language_downloader( $action ) {
if ( !is_admin() || !current_user_can('manage_options') ) die();
$locale = get_option('WPLANG');
if ( !$locale ) return;
if ( !isset( UM()->available_languages[$locale] ) ) return;
$path = UM()->files()->upload_basedir;
$path = str_replace('/uploads/ultimatemember','',$path);
$path = $path . '/languages/plugins/';
$path = str_replace('//','/',$path);
$remote = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.po';
$remote2 = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.mo';
$remote_tmp = download_url( $remote, $timeout = 300 );
copy( $remote_tmp, $path . 'ultimatemember-' . $locale . '.po' );
unlink( $remote_tmp );
$remote2_tmp = download_url( $remote2, $timeout = 300 );
copy( $remote2_tmp, $path . 'ultimatemember-' . $locale . '.mo' );
unlink( $remote2_tmp );
$url = remove_query_arg('um_adm_action', UM()->permalinks()->get_current_url() );
$url = add_query_arg('update','language_updated',$url);
exit( wp_redirect($url) );
}
/**
* Action to hide notices in admin
*
* @param $action
*/
function um_hide_notice( $action ) {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
update_option( $action, 1 );
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
}
/**
* Various user actions
*
* @param $action
*/
function user_action( $action ) {
if ( !is_admin() || !current_user_can( 'edit_users' ) ) die();
if ( !isset( $_REQUEST['sub'] ) ) die();
if ( !isset($_REQUEST['user_id']) ) die();
um_fetch_user( $_REQUEST['user_id'] );
$subaction = $_REQUEST['sub'];
/**
* UM hook
*
* @type action
* @title um_admin_user_action_hook
* @description Action on bulk user subaction
* @input_vars
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
* function my_admin_user_action( $subaction ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_hook", $subaction );
/**
* UM hook
*
* @type action
* @title um_admin_user_action_{$subaction}_hook
* @description Action on bulk user subaction
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
* function my_admin_user_action() {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_{$subaction}_hook" );
um_reset_user();
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url('?page=ultimatemember') ) );
exit;
}
/**
* Add any custom links to plugin page
*
* @param array $links
*
* @return array
*/
function plugin_links( $links ) {
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
$links = $more_links + $links;
return $links;
}
@@ -80,12 +257,6 @@ if ( ! class_exists( 'Admin' ) ) {
* Init admin action/filters + request handlers
*/
function admin_init() {
require_once 'core/um-admin-actions-user.php';
require_once 'core/um-admin-actions-modal.php';
require_once 'core/um-admin-actions.php';
require_once 'core/um-admin-filters-fields.php';
if ( is_admin() && current_user_can( 'manage_options' ) && ! empty( $_REQUEST['um_adm_action'] ) ) {
/**
* UM hook
@@ -130,5 +301,77 @@ if ( ! class_exists( 'Admin' ) ) {
}
}
/**
* 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 ) && $this->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;
}
}
}
+256 -1
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Builder' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
/**
@@ -24,7 +24,262 @@ if ( ! class_exists( 'Admin_Builder' ) ) {
* Admin_Builder constructor.
*/
function __construct() {
add_action( 'um_admin_field_modal_header', array( &$this, 'add_message_handlers' ) );
add_action( 'um_admin_field_modal_footer', array( &$this, 'add_conditional_support' ), 10, 4 );
add_filter( 'um_admin_pre_save_field_to_form', array( &$this, 'um_admin_pre_save_field_to_form' ), 1 );
add_filter( 'um_admin_pre_save_fields_hook', array( &$this, 'um_admin_pre_save_fields_hook' ), 1 );
add_filter( 'um_admin_field_update_error_handling', array( &$this, 'um_admin_field_update_error_handling' ), 1, 2 );
}
/**
* Apply a filter to handle errors for field updating in backend
*
* @param $errors
* @param $array
*
* @return mixed
*/
function um_admin_field_update_error_handling( $errors, $array ) {
/**
* @var $field_type
*/
extract( $array );
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
if ( isset( $field_attr['validate'] ) ) {
$validate = $field_attr['validate'];
foreach ( $validate as $post_input => $arr ) {
$mode = $arr['mode'];
switch ( $mode ) {
case 'numeric':
if ( !empty( $array['post'][$post_input] ) && !is_numeric( $array['post'][$post_input] ) ){
$errors[$post_input] = $validate[$post_input]['error'];
}
break;
case 'unique':
if ( !isset( $array['post']['edit_mode'] ) ) {
if ( UM()->builtin()->unique_field_err( $array['post'][$post_input] ) ) {
$errors[$post_input] = UM()->builtin()->unique_field_err( $array['post'][$post_input] );
}
}
break;
case 'required':
if ( $array['post'][$post_input] == '' )
$errors[$post_input] = $validate[$post_input]['error'];
break;
case 'range-start':
if ( UM()->builtin()->date_range_start_err( $array['post'][$post_input] ) && $array['post']['_range'] == 'date_range' )
$errors[$post_input] = UM()->builtin()->date_range_start_err( $array['post'][$post_input] );
break;
case 'range-end':
if ( UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' )
$errors[$post_input] = UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] );
break;
}
}
}
return $errors;
}
/**
* Some fields may require extra fields before saving
*
* @param $array
*
* @return mixed
*/
function um_admin_pre_save_fields_hook( $array ) {
/**
* @var $form_id
* @var $field_type
*/
extract( $array );
/**
* UM hook
*
* @type filter
* @title um_fields_without_metakey
* @description Field Types without meta key
* @input_vars
* [{"var":"$types","type":"array","desc":"Field Types"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
* function my_fields_without_metakey( $types ) {
* // your code here
* return $types;
* }
* ?>
*/
$fields_without_metakey = apply_filters( 'um_fields_without_metakey', array(
'block',
'shortcode',
'spacing',
'divider',
'group'
) );
$fields = UM()->query()->get_attr('custom_fields', $form_id);
$count = 1;
if ( isset( $fields ) && !empty( $fields) ) $count = count($fields)+1;
// set unique meta key
if ( in_array( $field_type, $fields_without_metakey ) && !isset($array['post']['_metakey']) ) {
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
}
// set position
if ( !isset( $array['post']['_position'] ) ) {
$array['post']['_position'] = $count;
}
return $array;
}
/**
* Modify field args just before it is saved into form
*
* @param $array
*
* @return mixed
*/
function um_admin_pre_save_field_to_form( $array ){
unset( $array['conditions'] );
if ( isset($array['conditional_field']) && !empty( $array['conditional_action'] ) && !empty( $array['conditional_operator'] ) ) {
$array['conditional_value'] = ! empty( $array['conditional_value'] ) ? $array['conditional_value'] : '';
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
}
if ( isset($array['conditional_field1']) && !empty( $array['conditional_action1'] ) && !empty( $array['conditional_operator1'] ) ) {
$array['conditional_value1'] = ! empty( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
}
if ( isset($array['conditional_field2']) && !empty( $array['conditional_action2'] ) && !empty( $array['conditional_operator2'] ) ) {
$array['conditional_value2'] = ! empty( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
}
if ( isset($array['conditional_field3']) && !empty( $array['conditional_action3'] ) && !empty( $array['conditional_operator3'] ) ) {
$array['conditional_value3'] = ! empty( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
}
if ( isset($array['conditional_field4']) && !empty( $array['conditional_action4'] ) && !empty( $array['conditional_operator4'] ) ) {
$array['conditional_value4'] = ! empty( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
}
return $array;
}
/**
* Put status handler in modal
*/
function add_message_handlers() {
?>
<div class="um-admin-error-block"></div>
<div class="um-admin-success-block"></div>
<?php
}
/**
* Footer of modal
*
* @param $form_id
* @param $field_args
* @param $in_edit
* @param $edit_array
*/
function add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
$metabox = UM()->metabox();
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
return;
} ?>
<div class="um-admin-btn-toggle">
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
<a href="#"><i class="um-icon-plus"></i><?php _e( 'Manage conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
<?php } else { ?>
<a href="#"><i class="um-icon-plus"></i><?php _e( 'Add conditional fields support' ); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
<?php } ?>
<div class="um-admin-btn-content">
<p class="um-admin-reset-conditions"><a href="#" class="button button-primary"><?php _e( 'Reset all rules', 'ultimate-member' ); ?></a></p>
<div class="um-admin-clear"></div>
<?php if ( isset( $edit_array['conditions'] ) ) {
foreach ( $edit_array['conditions'] as $k => $arr ) {
if ( $k == 0 ) $k = ''; ?>
<div class="um-admin-cur-condition">
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
<?php if ( $k == '' ) { ?>
<p><a href="#" class="um-admin-new-condition button um-admin-tipsy-n" title="Add new condition"><i class="um-icon-plus" style="margin-right:0!important"></i></a></p>
<?php } else { ?>
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
<?php } ?>
<div class="um-admin-clear"></div>
</div>
<?php
}
} else { ?>
<div class="um-admin-cur-condition">
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
<p><a href="#" class="um-admin-new-condition button um-admin-tipsy-n" title="Add new condition"><i class="um-icon-plus" style="margin-right:0!important"></i></a></p>
<div class="um-admin-clear"></div>
</div>
<?php } ?>
</div>
</div>
<?php
}
+19 -1
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Columns' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
/**
@@ -29,6 +29,24 @@ if ( ! class_exists( 'Admin_Columns' ) ) {
// Add a post display state for special UM pages.
add_filter( 'display_post_states', array( &$this, 'add_display_post_states' ), 10, 2 );
add_filter( 'post_row_actions', array( &$this, 'remove_bulk_actions_um_form_inline' ) );
}
/**
* This will remove the "Edit" bulk action, which is actually quick edit.
*
* @param array $actions
*
* @return array;
*/
function remove_bulk_actions_um_form_inline( $actions ) {
if ( UM()->admin()->is_plugin_post_type() ) {
unset( $actions['inline hide-if-no-js'] );
return $actions;
}
return $actions;
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_DragDrop' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_DragDrop' ) ) {
/**
+13 -24
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Enqueue' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
/**
@@ -12,7 +12,17 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
* @package um\admin\core
*/
class Admin_Enqueue {
/**
* @var string
*/
var $js_url;
/**
* @var string
*/
var $css_url;
@@ -355,27 +365,6 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
}
/**
* Boolean check if we're viewing UM backend
*
* @return bool
*/
function is_UM_admin() {
global $current_screen;
$screen_id = $current_screen->id;
if ( strstr( $screen_id, 'ultimatemember' ) || strstr( $screen_id, 'um_' ) || strstr( $screen_id, 'user' ) || strstr( $screen_id, 'profile' ) || $screen_id == 'nav-menus' ) return true;
global $post;
if ( isset( $post->post_type ) ) return true;
global $tax;
if ( isset( $tax->name ) ) return true;
return false;
}
/**
* Adds class to our admin pages
*
@@ -384,7 +373,7 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
* @return string
*/
function admin_body_class( $classes ) {
if ( $this->is_UM_admin() ) {
if ( UM()->admin()->is_um_screen() ) {
return "$classes um-admin";
}
return $classes;
@@ -395,7 +384,7 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
* Enqueue scripts and styles
*/
function admin_enqueue_scripts() {
if ( $this->is_UM_admin() ) {
if ( UM()->admin()->is_um_screen() ) {
/*if ( get_post_type() != 'shop_order' ) {
UM()->enqueue()->wp_enqueue_scripts();
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Forms_Settings' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Forms_Settings' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Forms' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
/**
@@ -1,115 +0,0 @@
<?php
namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Functions' ) ) {
/**
* Class Admin_Functions
* @package um\admin\core
*/
class Admin_Functions {
/**
* 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;
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ use \RecursiveDirectoryIterator;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Menu' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
/**
+71 -8
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Metabox' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
/**
@@ -40,20 +40,83 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
//roles metaboxes
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
add_filter( 'um_builtin_validation_types_continue_loop', array( &$this, 'validation_types_continue_loop' ), 1, 4 );
add_filter( 'um_restrict_content_hide_metabox', array( &$this, 'hide_metabox_restrict_content_shop' ), 10, 1 );
add_filter( 'um_admin_access_settings_fields', array( &$this, 'wpml_post_options' ), 10, 2 );
}
/**
* Boolean check if we're viewing UM backend
* Add option for WPML
*
* @param array $fields
* @param array $data
*
* @return array
*/
function wpml_post_options( $fields, $data ) {
global $post;
if ( ! function_exists( 'icl_get_current_language' ) ) {
return $fields;
}
if ( empty( $post->post_type ) || $post->post_type != 'page' ) {
return $fields;
}
$fields[] = array(
'id' => '_um_wpml_user',
'type' => 'checkbox',
'label' => __( 'This is a translation of UM profile page?', 'ultimate-member' ),
'value' => ! empty( $data['_um_wpml_user'] ) ? $data['_um_wpml_user'] : 0
);
$fields[] = array(
'id' => '_um_wpml_account',
'type' => 'checkbox',
'label' => __( 'This is a translation of UM account page?', 'ultimate-member' ),
'value' => ! empty( $data['_um_wpml_account'] ) ? $data['_um_wpml_account'] : 0
);
return $fields;
}
/**
* @param $hide
*
* @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') ) )
function hide_metabox_restrict_content_shop( $hide ) {
if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
$_GET['post'] == wc_get_page_id( 'shop' ) ) {
return true;
return false;
}
return $hide;
}
/**
* Filter validation types on loop
*
* @param $break
* @param $key
* @param $form_id
* @param $field_array
*
* @return bool
*/
function validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
// show unique username validation only for user_login field
if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
return false;
}
return $break;
}
@@ -1072,7 +1135,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
function load_modal_content() {
$screen = get_current_screen();
if ( $this->is_UM_admin() ) {
if ( UM()->admin()->is_um_screen() ) {
foreach ( glob( um_path . 'includes/admin/templates/modal/*.php' ) as $modal_content ) {
include_once $modal_content;
}
+407 -85
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Notices' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
/**
@@ -13,15 +13,192 @@ if ( ! class_exists( 'Admin_Notices' ) ) {
*/
class Admin_Notices {
/**
* Notices list
*
* @var array
*/
var $list = array();
/**
* Admin_Notices constructor.
*/
function __construct() {
add_action( 'admin_init', array( &$this, 'create_languages_folder' ) );
add_action( 'admin_notices', array( &$this, 'main_notices' ), 1 );
add_action( 'admin_notices', array( &$this, 'localize_note' ), 2 );
add_action( 'admin_notices', array( &$this, 'show_update_messages' ), 10 );
add_action( 'admin_init', array( &$this, 'create_list' ), 10 );
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
}
function create_list() {
$this->old_extensions_notice();
$this->main_notices();
$this->localize_note();
$this->show_update_messages();
$this->check_wrong_install_folder();
$this->admin_notice_tracking();
$this->need_upgrade();
$this->check_wrong_licenses();
/**
* UM hook
*
* @type action
* @title um_admin_create_notices
* @description Add notices to wp-admin
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_create_notices', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_admin_create_notices', 'my_admin_create_notices', 10 );
* function my_admin_create_notices() {
* // your code here
* }
* ?>
*/
do_action( 'um_admin_create_notices' );
}
/**
* @return array
*/
function get_admin_notices() {
return $this->list;
}
/**
* @param $admin_notices
*/
function set_admin_notices( $admin_notices ) {
$this->list = $admin_notices;
}
/**
* @param $a
* @param $b
*
* @return mixed
*/
function notice_priority_sort( $a, $b ) {
if ( $a['priority'] == $b['priority'] ) {
return 0;
}
return ( $a['priority'] < $b['priority'] ) ? -1 : 1;
}
/**
* Add notice to UM notices array
*
* @param string $key
* @param array $data
* @param int $priority
*/
function add_notice( $key, $data, $priority = 10 ) {
$admin_notices = $this->get_admin_notices();
if ( empty( $admin_notices[ $key ] ) ) {
$admin_notices[ $key ] = array_merge( $data, array( 'priority' => $priority ) );
$this->set_admin_notices( $admin_notices );
}
}
/**
* Remove notice from UM notices array
*
* @param string $key
*/
function remove_notice( $key ) {
$admin_notices = $this->get_admin_notices();
if ( ! empty( $admin_notices[ $key ] ) ) {
unset( $admin_notices[ $key ] );
$this->set_admin_notices( $admin_notices );
}
}
/**
* Render all admin notices
*/
function render_notices() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$admin_notices = $this->get_admin_notices();
$hidden = get_user_meta( get_current_user_id(), 'um_hidden_admin_notices' );
$hidden = empty( $hidden ) ? array() : $hidden;
uasort( $admin_notices, array( &$this, 'notice_priority_sort' ) );
foreach ( $admin_notices as $key => $admin_notice ) {
if ( empty( $hidden ) || ! in_array( $key, $hidden ) ) {
$this->display_notice( $key );
}
}
/**
* 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
* <?php
* add_action( 'um_admin_after_main_notices', 'my_admin_after_main_notices', 10 );
* function my_admin_after_main_notices() {
* // your code here
* }
* ?>
*/
do_action( 'um_admin_after_main_notices' );
}
/**
* Display single admin notice
*
* @param string $key
* @param bool $echo
*
* @return void|string
*/
function display_notice( $key, $echo = true ) {
$admin_notices = $this->get_admin_notices();
if ( empty( $admin_notices[ $key ] ) ) {
return;
}
$notice_data = $admin_notices[ $key ];
$class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated';
ob_start(); ?>
<div class="<?php echo esc_attr( $class ) ?> um-admin-notice">
<?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?>
</div>
<?php $notice = ob_get_clean();
if ( $echo ) {
echo $notice;
return;
} else {
return $notice;
}
}
@@ -42,81 +219,96 @@ if ( ! class_exists( 'Admin_Notices' ) ) {
}
/**
* Show notice for customers with old extension's versions
*/
function old_extensions_notice() {
$show = false;
$slugs = array_map( function( $item ) {
return 'um-' . $item . '/um-' . $item . '.php';
}, array_keys( UM()->dependencies()->ext_required_version ) );
$active_plugins = UM()->dependencies()->get_active_plugins();
foreach ( $slugs as $slug ) {
if ( in_array( $slug, $active_plugins ) ) {
$plugin_data = get_plugin_data( um_path . '..' . DIRECTORY_SEPARATOR . $slug );
if ( version_compare( '2.0', $plugin_data['Version'], '>' ) ) {
$show = true;
break;
}
}
}
if ( ! $show ) {
return;
}
$this->add_notice( 'old_extensions', array(
'class' => 'error',
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p>',
), 0 );
}
/**
* Show main notices
*/
function main_notices() {
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 ) {
echo '<div class="updated" style="border-color: #0085ba;"><p>';
echo sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') );
echo '</p></div>';
}
// Regarding page setup
$pages = UM()->config()->permalinks;
if ( $pages && is_array( $pages ) ) {
$err = false;
foreach( $pages as $slug => $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 ( $err ) {
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.','ultimate-member') . '</p></div>';
}
if ( isset( $pages['user'] ) ) {
$test = get_post( $pages['user'] );
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('Ultimate Member Setup Error: User page can not be a child page.','ultimate-member') . '</p></div>';
}
}
if ( isset( $pages['account'] ) ) {
$test = get_post( $pages['account'] );
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
echo '<div class="updated" style="border-color: #0085ba;"><p>' . __('Ultimate Member Setup Error: Account page can not be a child page.','ultimate-member') . '</p></div>';
}
}
}
/**
* 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
* <?php
* add_action( 'um_admin_after_main_notices', 'my_admin_after_main_notices', 10 );
* function my_admin_after_main_notices() {
* // your code here
* }
* ?>
*/
do_action( 'um_admin_after_main_notices' );
if ( ! extension_loaded( 'exif' ) && ! $hide_exif_notice ) {
$this->add_notice( 'exif_disabled', array(
'class' => 'updated',
'message' => '<p>' . sprintf(__( 'Exif is not enabled on your server. Mobile photo uploads will not be rotated correctly until you enable the exif extension. <a href="%s">Hide this notice</a>', 'ultimate-member' ), add_query_arg('um_adm_action', 'um_hide_exif_notice') ) . '</p>',
), 10 );
}
// Regarding page setup
$pages = UM()->config()->permalinks;
if ( $pages && is_array( $pages ) ) {
$err = false;
foreach ( $pages as $slug => $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 ( $err ) {
$this->add_notice( 'wrong_pages', array(
'class' => 'updated',
'message' => '<p>' . __( 'One or more of your Ultimate Member pages are not correctly setup. Please visit <strong>Ultimate Member > Settings</strong> to re-assign your missing pages.', 'ultimate-member' ) . '</p>',
), 20 );
}
if ( isset( $pages['user'] ) ) {
$test = get_post( $pages['user'] );
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
$this->add_notice( 'wrong_user_page', array(
'class' => 'updated',
'message' => '<p>' . __( 'Ultimate Member Setup Error: User page can not be a child page.', 'ultimate-member' ) . '</p>',
), 25 );
}
}
if ( isset( $pages['account'] ) ) {
$test = get_post( $pages['account'] );
if ( isset( $test->post_parent ) && $test->post_parent > 0 ) {
$this->add_notice( 'wrong_account_page', array(
'class' => 'updated',
'message' => '<p>' . __( 'Ultimate Member Setup Error: Account page can not be a child page.', 'ultimate-member' ) . '</p>',
), 30 );
}
}
}
}
@@ -128,6 +320,7 @@ if ( ! class_exists( 'Admin_Notices' ) ) {
if ( ! $locale || strstr( $locale, 'en_' ) ) {
return;
}
if ( file_exists( WP_LANG_DIR . '/plugins/ultimatemember-' . $locale . '.mo' ) ) {
return;
}
@@ -141,21 +334,17 @@ if ( ! class_exists( 'Admin_Notices' ) ) {
$download_uri = add_query_arg( 'um_adm_action', 'um_language_downloader' );
echo '<div class="updated" style="border-color: #0085ba;"><p>';
echo sprintf(__('Your site language is <strong>%1$s</strong>. Good news! Ultimate Member is already available in <strong>%2$s language</strong>. <a href="%3$s">Download the translation</a> files and start using the plugin in your language now. <a href="%4$s">Hide this notice</a>','ultimate-member'), $locale, UM()->available_languages[$locale], $download_uri, add_query_arg('um_adm_action', 'um_hide_locale_notice') );
echo '</p></div>';
$this->add_notice( 'locale', array(
'class' => 'updated',
'message' => '<p>' . sprintf( __( 'Your site language is <strong>%1$s</strong>. Good news! Ultimate Member is already available in <strong>%2$s language</strong>. <a href="%3$s">Download the translation</a> files and start using the plugin in your language now. <a href="%4$s">Hide this notice</a>','ultimate-member'), $locale, UM()->available_languages[ $locale ], $download_uri, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '</p>',
), 40 );
} else {
echo '<div class="updated" style="border-color: #0085ba;"><p>';
echo sprintf(__('Ultimate Member has not yet been translated to your langeuage: <strong>%1$s</strong>. If you have translated the plugin you need put these files <code>ultimatemember-%1$s.po and ultimatemember-%1$s.mo</code> in <strong>/wp-content/languages/plugins/</strong> for the plugin to be translated in your language. <a href="%2$s">Hide this notice</a>','ultimate-member'), $locale, add_query_arg('um_adm_action', 'um_hide_locale_notice') );
echo '</p></div>';
$this->add_notice( 'locale', array(
'class' => 'updated',
'message' => '<p>' . sprintf( __( 'Ultimate Member has not yet been translated to your language: <strong>%1$s</strong>. If you have translated the plugin you need put these files <code>ultimatemember-%1$s.po and ultimatemember-%1$s.mo</code> in <strong>/wp-content/languages/plugins/</strong> for the plugin to be translated in your language. <a href="%2$s">Hide this notice</a>', 'ultimate-member' ), $locale, add_query_arg( 'um_adm_action', 'um_hide_locale_notice' ) ) . '</p>',
), 40 );
}
@@ -233,14 +422,147 @@ if ( ! class_exists( 'Admin_Notices' ) ) {
if ( ! empty( $messages ) ) {
foreach ( $messages as $message ) {
if ( isset( $message['err_content'] ) ) {
echo '<div class="error"><p>' . $message['err_content'] . '</p></div>';
$this->add_notice( 'actions', array(
'class' => 'error',
'message' => '<p>' . $message['err_content'] . '</p>',
), 50 );
} else {
echo '<div class="updated" style="border-color: #0085ba;"><p>' . $message['content'] . '</p></div>';
$this->add_notice( 'actions', array(
'class' => 'updated',
'message' => '<p>' . $message['content'] . '</p>',
), 50 );
}
}
}
}
/**
* Check if plugin is installed with correct folder
*/
function check_wrong_install_folder() {
$invalid_folder = false;
$slug_array = explode( '/', um_plugin );
if ( $slug_array[0] != 'ultimate-member' ) {
$invalid_folder = true;
}
if ( $invalid_folder ) {
$this->add_notice( 'invalid_dir', array(
'class' => 'error',
'message' => '<p>' . sprintf( __( 'You have installed <strong>%s</strong> with wrong folder name. Correct folder name is <strong>"ultimate-member"</strong>.', 'ultimate-member' ), ultimatemember_plugin_name ) . '</p>',
), 1 );
}
}
/**
* Show admin notices
*/
public function admin_notice_tracking() {
if ( ! current_user_can( 'manage_options' ) )
return;
$hide_notice = get_option( 'um_tracking_notice' );
if ( $hide_notice )
return;
$optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_into_tracking' ) );
$optout_url = esc_url( add_query_arg( 'um_adm_action', 'opt_out_of_tracking' ) );
ob_start(); ?>
<p>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
</p>
<p>
<a href="<?php echo esc_url( $optin_url ) ?>" class="button button-primary"><?php _e( 'Subscribe to mailing list', 'ultimate-member' ) ?></a>
&nbsp;
<a href="<?php echo esc_url( $optout_url ) ?>" class="button-secondary"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
</p>
<?php $message = ob_get_clean();
$this->add_notice( 'invalid_dir', array(
'class' => 'updated',
'message' => $message,
), 2 );
}
function check_wrong_licenses() {
$invalid_license = 0;
$arr_inactive_license_keys = array();
if ( empty( UM()->admin_settings()->settings_structure['licenses']['fields'] ) ) {
return;
}
foreach ( UM()->admin_settings()->settings_structure['licenses']['fields'] as $field_data ) {
$license = get_option( "{$field_data['id']}_edd_answer" );
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license )
continue;
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) {
$arr_inactive_license_keys[ ] = $license->item_name;
}
$invalid_license++;
}
if ( ! empty( $arr_inactive_license_keys ) ) {
$this->add_notice( 'license_key', array(
'class' => 'error',
'message' => '<p>' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.UltimateMember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) . '</p>',
), 3 );
}
if ( $invalid_license ) {
$this->add_notice( 'license_key', array(
'class' => 'error',
'message' => '<p>' . sprintf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) . '</p>',
), 3 );
}
}
function need_upgrade() {
if ( ! empty( UM()->admin_upgrade()->necessary_packages ) ) {
$url = add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) );
ob_start(); ?>
<p>
<?php printf( __( '<strong>%s version %s</strong> needs to be updated for correct working.<br />It is necessary to update the structure of the database and options that are associated with <strong>%s %s</strong>.<br />Please visit <a href="%s">"Upgrade"</a> page and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, ultimatemember_version, $url ); ?>
</p>
<p>
<a href="<?php echo esc_url( $url ) ?>" class="button button-primary"><?php _e( 'Upgrade Now', 'ultimate-member' ) ?></a>
&nbsp;
</p>
<?php $message = ob_get_clean();
$this->add_notice( 'upgrade', array(
'class' => 'error',
'message' => $message,
), 4 );
} else {
if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) {
$this->add_notice( 'upgrade', array(
'class' => 'updated',
'message' => '<p>' . sprintf( __( '<strong>%s %s</strong> Successfully Upgraded', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version ) . '</p>',
), 4 );
}
}
}
}
}
+3 -59
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Settings' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
/**
@@ -75,11 +75,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
add_filter( 'um_change_settings_before_save', array( $this, 'remove_empty_values' ), 10, 1 );
//invalid licenses notice
add_action( 'admin_notices', array( $this, 'check_wrong_licenses' ) );
add_action( 'admin_init', array( &$this, 'um_download_install_info' ) );
}
@@ -1037,12 +1033,6 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
'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',
@@ -1131,8 +1121,8 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
* 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' ) );
}
add_submenu_page( 'ultimatemember', __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( &$this, 'settings_page' ) );
}
/**
@@ -1666,52 +1656,6 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
}
/**
*
*/
function check_wrong_licenses() {
$invalid_license = 0;
$arr_inactive_license_keys = array();
if ( empty( $this->settings_structure['licenses']['fields'] ) )
return;
foreach ( $this->settings_structure['licenses']['fields'] as $field_data ) {
$license = get_option( "{$field_data['id']}_edd_answer" );
if ( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license )
continue;
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ){
$arr_inactive_license_keys[ ] = $license->item_name;
}
$invalid_license++;
}
if ( ! empty( $arr_inactive_license_keys ) ) { ?>
<div class="error">
<p>
<?php printf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.UltimateMember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, 'https://ultimatemember.com' ) ; ?>
</p>
</div>
<?php }
if ( $invalid_license ) { ?>
<div class="error">
<p>
<?php printf( __( 'You have %d invalid or expired license keys for %s. Please go to the <a href="%s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, ultimatemember_plugin_name, add_query_arg( array('page'=>'um_options', 'tab' => 'licenses'), admin_url( 'admin.php' ) ) ) ?>
</p>
</div>
<?php }
}
/**
*
*/
+253 -6
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Upgrade' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
/**
@@ -21,6 +21,8 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
* @var
*/
var $update_versions;
var $update_packages;
var $necessary_packages;
/**
@@ -34,18 +36,238 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
*/
function __construct() {
$this->packages_dir = plugin_dir_path( __FILE__ ) . 'packages' . DIRECTORY_SEPARATOR;
$this->necessary_packages = $this->need_run_upgrades();
$um_last_version_upgrade = get_option( 'um_last_version_upgrade' );
if ( ! empty( $this->necessary_packages ) ) {
$this->init_packages_ajax();
add_action( 'admin_menu', array( $this, 'admin_menu' ), 0 );
if ( ! $um_last_version_upgrade || version_compare( $um_last_version_upgrade, ultimatemember_version, '<' ) )
add_action( 'admin_init', array( $this, 'packages' ), 10 );
add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) );
add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) );
}
}
/**
* Get array of necessary upgrade packages
*
* @return array
*/
function need_run_upgrades() {
$um_last_version_upgrade = get_option( 'um_last_version_upgrade' );
//first install
if ( ! $um_last_version_upgrade ) {
$um_last_version_upgrade = '1.3.88';
}
$diff_packages = array();
$all_packages = $this->get_packages();
foreach ( $all_packages as $package ) {
if ( version_compare( $um_last_version_upgrade, $package, '<' ) ) {
$diff_packages[] = $package;
}
}
return $diff_packages;
}
/**
* Get all upgrade packages
*
* @return array
*/
function get_packages() {
$update_versions = array();
$handle = opendir( $this->packages_dir );
if ( $handle ) {
while ( false !== ( $filename = readdir( $handle ) ) ) {
if ( $filename != '.' && $filename != '..' ) {
if ( is_dir( $this->packages_dir . DIRECTORY_SEPARATOR . $filename ) ) {
$update_versions[] = $filename;
}
}
}
closedir( $handle );
usort( $update_versions, array( &$this, 'version_compare_sort' ) );
}
return $update_versions;
}
/**
*
*/
function init_packages_ajax() {
foreach ( $this->necessary_packages as $package ) {
$hooks_file = $this->packages_dir . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . 'hooks.php';
if ( file_exists( $hooks_file ) ) {
$pack_ajax_hooks = include $hooks_file;
foreach ( $pack_ajax_hooks as $action => $function ) {
add_action( 'wp_ajax_um_' . $action, "um_upgrade_$function" );
}
}
}
}
/**
*
*/
function init_packages_ajax_handlers() {
foreach ( $this->necessary_packages as $package ) {
$handlers_file = $this->packages_dir . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . 'functions.php';
if ( file_exists( $handlers_file ) ) {
include $handlers_file;
}
}
}
/**
* Add Upgrades admin menu
*/
function admin_menu() {
add_submenu_page( 'ultimatemember', __( 'Upgrade', 'ultimate-member' ), '<span style="color:#ca4a1f;">' . __( 'Upgrade', 'ultimate-member' ) . '</span>', 'manage_options', 'um_upgrade', array( &$this, 'upgrade_page' ) );
}
/**
* Upgrade Menu Callback Page
*/
function upgrade_page() {
$um_last_version_upgrade = get_option( 'um_last_version_upgrade', __( 'empty', 'ultimate-member' ) ); ?>
<div class="wrap">
<h2><?php printf( __( '%s - Upgrade Process', 'ultimate-member' ), ultimatemember_plugin_name ) ?></h2>
<p><?php printf( __( 'You have installed %s version. Your latest DB version is %s. Before the click to "Run" button make sure that did the following:', 'ultimate-member' ), ultimatemember_version, $um_last_version_upgrade ) ?></p>
<ul style="list-style: inside;">
<li><?php _e( 'Create full site\'s backup.', 'ultimate-member' ) ?></li>
<li><?php _e( 'Set maintenance mode (if you need)', 'ultimate-member' ) ?></li>
<li><?php _e( 'You have nice Internet connection', 'ultimate-member' ) ?></li>
</ul>
<p><?php _e( 'After the click to "Run" button, the update process will be started. All information will be displayed in "Upgrade Log" field.', 'ultimate-member' ); ?></p>
<p><?php _e( 'If the update was successful, you will see a corresponding message. Otherwise, contact technical support if the update failed.', 'ultimate-member' ); ?></p>
<h4><?php printf( __( 'Upgrade Log' ), ultimatemember_plugin_name ) ?></h4>
<div id="upgrade_log" style="width: 100%;height:300px; overflow: auto;border: 1px solid #a1a1a1;margin: 0 0 10px 0;"></div>
<div>
<input type="button" id="run_upgrade" class="button button-primary" value="<?php esc_attr_e( 'Run', 'ultimate-member' ) ?>"/>
</div>
</div>
<script type="text/javascript">
var um_packages;
jQuery( document ).ready( function() {
jQuery( '#run_upgrade' ).click( function() {
jQuery(this).prop( 'disabled', true );
um_add_upgrade_log( 'Upgrade Process Started...' );
um_add_upgrade_log( 'Get Upgrades Packages...' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_get_packages'
},
success: function( response ) {
um_packages = response.data.packages;
um_add_upgrade_log( 'Upgrades Packages are ready, start unpacking...' );
//run first package....the running of the next packages will be at each init.php file
um_run_upgrade();
}
});
});
});
/**
*
* @returns {boolean}
*/
function um_run_upgrade() {
if ( um_packages.length ) {
var pack = um_packages.shift();
um_add_upgrade_log( '<br />=================================================================' );
um_add_upgrade_log( '<h4 style="font-weight: bold;">Prepare package "' + pack + '" version...</h4>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'html',
data: {
action: 'um_run_package',
pack: pack
},
success: function( html ) {
um_add_upgrade_log( 'Package "' + pack + '" is ready. Start the execution...' );
jQuery( '#run_upgrade' ).after( html );
}
});
} else {
window.location = '<?php echo add_query_arg( array( 'page' => 'ultimatemember', 'msg' => 'updated' ), admin_url( 'admin.php' ) ) ?>'
}
return false;
}
/**
*
* @param line
*/
function um_add_upgrade_log( line ) {
var log_field = jQuery( '#upgrade_log' );
var previous_html = log_field.html();
log_field.html( previous_html + line + "<br />" );
}
function um_wrong_ajax() {
um_add_upgrade_log( 'Wrong AJAX response...' );
um_add_upgrade_log( 'Your upgrade was crashed, please contact with support' );
}
function um_something_wrong() {
um_add_upgrade_log( 'Something went wrong with AJAX request...' );
um_add_upgrade_log( 'Your upgrade was crashed, please contact with support' );
}
</script>
<?php
}
function ajax_run_package() {
if ( empty( $_POST['pack'] ) ) {
exit('');
} else {
ob_start();
include $this->packages_dir . DIRECTORY_SEPARATOR . $_POST['pack'] . DIRECTORY_SEPARATOR . 'init.php';
ob_get_flush();
exit;
}
}
function ajax_get_packages() {
$update_versions = $this->need_run_upgrades();
wp_send_json_success( array( 'packages' => $update_versions ) );
}
/**
* Load packages
*/
public function packages() {
/*public function packages() {
if ( ! ini_get( 'safe_mode' ) ) {
@set_time_limit(0);
}
@@ -70,7 +292,7 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
update_option( 'um_last_version_upgrade', $update_version );
}
}
}
}*/
/**
@@ -93,6 +315,31 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
}
/**
* Parse packages dir for packages files
*/
/*function set_update_versions_() {
$update_versions = array();
$handle = opendir( $this->packages_dir );
if ( $handle ) {
while ( false !== ( $filename = readdir( $handle ) ) ) {
if ( $filename != '.' && $filename != '..' ) {
var_dump( $filename );
if ( is_dir( $this->packages_dir . DIRECTORY_SEPARATOR . $filename ) ) {
$update_versions[] = $filename;
}
}
}
closedir( $handle );
usort( $update_versions, array( &$this, 'version_compare_sort' ) );
$this->update_packages = $update_versions;
}
}*/
/**
* Sort versions by version compare function
* @param $a
+66 -2
View File
@@ -4,7 +4,7 @@ namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Admin_Users' ) ) {
if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
/**
@@ -31,7 +31,71 @@ if ( ! class_exists( 'Admin_Users' ) ) {
add_filter( 'views_users', array( &$this, 'add_status_links' ) );
add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
add_action( 'um_admin_user_action_hook', array( &$this, 'user_action_hook' ), 10, 1 );
}
/**
* Does an action to user asap
*
* @param string $action
*/
function user_action_hook( $action ) {
switch ( $action ) {
default:
/**
* UM hook
*
* @type action
* @title um_admin_custom_hook_{$action}
* @description Integration hook on user action
* @input_vars
* [{"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_custom_hook_{$action}', 'my_admin_custom_hook', 10, 1 );
* function my_admin_after_main_notices( $user_id ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
break;
case 'um_put_as_pending':
UM()->user()->pending();
break;
case 'um_approve_membership':
case 'um_reenable':
UM()->user()->approve();
break;
case 'um_reject_membership':
UM()->user()->reject();
break;
case 'um_resend_activation':
UM()->user()->email_pending();
break;
case 'um_deactivate':
UM()->user()->deactivate();
break;
case 'um_delete':
if ( is_admin() ) {
wp_die( 'This action is not allowed in backend.', 'ultimate-member' );
}
UM()->user()->delete();
break;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
function um_upgrade_usermetaquery1339() {
include 'usermeta_query.php';
update_option( 'um_last_version_upgrade', '1.3.39' );
wp_send_json_success( array( 'message' => 'Usermeta was upgraded successfully' ) );
}
+5
View File
@@ -0,0 +1,5 @@
<?php
return array(
'usermetaquery1339' => 'usermetaquery1339',
);
+30
View File
@@ -0,0 +1,30 @@
<?php ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
um_add_upgrade_log( 'Upgrade Usermeta...' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_usermetaquery1339'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
//switch to the next package
um_run_upgrade();
} else {
um_add_upgrade_log( 'Wrong AJAX response...' );
um_add_upgrade_log( 'Your upgrade was crashed, please contact with support' );
}
},
error: function() {
um_add_upgrade_log( 'Something went wrong with AJAX request...' );
um_add_upgrade_log( 'Your upgrade was crashed, please contact with support' );
}
});
});
</script>
@@ -1,11 +1,5 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* This populates all existing UM users with meta_key `last_login` as `user_registered` if the meta key doesn't exist.
* Target Version: 1.3.39
*/
global $wpdb;
$wpdb->query(
'INSERT INTO '.$wpdb->usermeta.'(user_id, meta_key, meta_value)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,143 @@
<?php
$roles_associations = get_option( 'um_roles_associations' );
//Content Restriction transfer
//for check all post types and taxonomies
$all_post_types = get_post_types( array( 'public' => true ) );
$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_post_types as $key => $value ) {
$all_post_types[ $key ] = true;
}
foreach ( $all_taxonomies as $key => $value ) {
$all_taxonomies[ $key ] = true;
}
UM()->options()->update( 'restricted_access_post_metabox', $all_post_types );
UM()->options()->update( 'restricted_access_taxonomy_metabox', $all_taxonomies );
$roles_array = UM()->roles()->get_roles( false, array( 'administrator' ) );
/*$posts = get_posts( array(
'post_type' => 'any',
'meta_key' => '_um_custom_access_settings',
'meta_value' => '1',
'fields' => 'ids',
'numberposts' => -1
) );*/
$p_query = new WP_Query;
$posts = $p_query->query( array(
'post_type' => 'any',
'meta_key' => '_um_custom_access_settings',
'meta_value' => '1',
'posts_per_page' => -1,
'fields' => 'ids'
) );
if ( ! empty( $posts ) ) {
foreach ( $posts as $post_id ) {
$um_accessible = get_post_meta( $post_id, '_um_accessible', true );
$um_access_roles = get_post_meta( $post_id, '_um_access_roles', true );
$um_access_redirect = ( $um_accessible == '2' ) ? get_post_meta( $post_id, '_um_access_redirect', true ) : get_post_meta( $post_id, '_um_access_redirect2', true );
$access_roles = array();
if ( ! empty( $um_access_roles ) ) {
foreach ( $roles_array as $role => $role_label ) {
//if ( in_array( substr( $role, 3 ), $um_access_roles ) )
if ( false !== array_search( $role, $roles_associations ) && in_array( array_search( $role, $roles_associations ), $um_access_roles ) )
$access_roles[ $role ] = '1';
else
$access_roles[ $role ] = '0';
}
} else {
foreach ( $roles_array as $role => $role_label ) {
$access_roles[ $role ] = '0';
}
}
$restrict_options = array(
'_um_custom_access_settings' => '1',
'_um_accessible' => $um_accessible,
'_um_access_roles' => $access_roles,
'_um_noaccess_action' => '1',
'_um_restrict_by_custom_message' => '0',
'_um_restrict_custom_message' => '',
'_um_access_redirect' => '1',
'_um_access_redirect_url' => ! empty( $um_access_redirect ) ? $um_access_redirect : '',
'_um_access_hide_from_queries' => '0',
);
update_post_meta( $post_id, 'um_content_restriction', $restrict_options );
}
}
$all_taxonomies = get_taxonomies( array( 'public' => true ) );
$exclude_taxonomies = UM()->excluded_taxonomies();
foreach ( $all_taxonomies as $key => $taxonomy ) {
if ( in_array( $key , $exclude_taxonomies ) )
continue;
$terms = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
'fields' => 'ids'
) );
if ( empty( $terms ) )
continue;
foreach ( $terms as $term_id ) {
$term_meta = get_option( "category_{$term_id}" );
if ( empty( $term_meta ) )
continue;
$um_accessible = ! empty( $term_meta['_um_accessible'] ) ? $term_meta['_um_accessible'] : false;
$um_access_roles = ! empty( $term_meta['_um_roles'] ) ? $term_meta['_um_roles'] : array();
$redirect = ! empty( $term_meta['_um_redirect'] ) ? $term_meta['_um_redirect'] : '';
$redirect2 = ! empty( $term_meta['_um_redirect2'] ) ? $term_meta['_um_redirect2'] : '';
$um_access_redirect = ( $um_accessible == '2' ) ? $redirect : $redirect2;
$access_roles = array();
if ( ! empty( $um_access_roles ) ) {
foreach ( $roles_array as $role => $role_label ) {
if ( false !== array_search( $role, $roles_associations ) && in_array( array_search( $role, $roles_associations ), $um_access_roles ) )
$access_roles[ $role ] = '1';
else
$access_roles[ $role ] = '0';
}
} else {
foreach ( $roles_array as $role => $role_label ) {
$access_roles[ $role ] = '0';
}
}
$restrict_options = array(
'_um_custom_access_settings' => '1',
'_um_accessible' => $um_accessible,
'_um_access_roles' => $access_roles,
'_um_noaccess_action' => '1',
'_um_restrict_by_custom_message' => '0',
'_um_restrict_custom_message' => '',
'_um_access_redirect' => '1',
'_um_access_redirect_url' => ! empty( $um_access_redirect ) ? $um_access_redirect : '',
'_um_access_hide_from_queries' => '0',
);
update_term_meta( $term_id, 'um_content_restriction', $restrict_options );
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Transferring email templates to new logic
*/
$templates_in_theme = 0;
$emails = UM()->config()->email_notifications;
foreach ( $emails as $email_key => $value ) {
$in_theme = UM()->mail()->template_in_theme( $email_key, true );
$theme_template_path = UM()->mail()->get_template_file( 'theme', $email_key );
if ( ! $in_theme ) {
$html_email = UM()->options()->get( 'email_html' );
if ( $html_email ) {
if ( ! UM()->mail()->copy_email_template( $email_key ) ) {
$setting_value = UM()->options()->get( $email_key );
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $setting_value );
fclose( $fp );
} else {
$templates_in_theme++;
}
} else {
$setting_value = UM()->options()->get( $email_key );
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $setting_value );
fclose( $fp );
}
} else {
$theme_template_path_html = UM()->mail()->get_template_file( 'theme', $email_key, true );
$setting_value = preg_replace( '/<\/body>|<\/head>|<html>|<\/html>|<body.*?>|<head.*?>/' , '', file_get_contents( $theme_template_path_html ) );
if ( file_exists( $theme_template_path_html ) ) {
if ( copy( $theme_template_path_html, $theme_template_path ) ) {
$fp = fopen( $theme_template_path, "w" );
$result = fputs( $fp, $setting_value );
fclose( $fp );
$templates_in_theme++;
}
}
}
}
if ( $templates_in_theme > 0 ) {
UM()->options()->update( 'email_html', true );
} else {
UM()->options()->update( 'email_html', false );
}
@@ -0,0 +1,305 @@
<?php
function um_upgrade_styles20beta1() {
um_maybe_unset_time_limit();
include 'styles.php';
wp_send_json_success( array( 'message' => __( 'Styles was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_user_roles20beta1() {
um_maybe_unset_time_limit();
/**
* @var $response_roles_data
*/
include 'user_roles.php';
wp_send_json_success( array( 'message' => __( 'User Roles was upgraded successfully', 'ultimate-member' ), 'roles' => $response_roles_data ) );
}
function um_upgrade_get_users_per_role20beta1() {
um_maybe_unset_time_limit();
if ( ! empty( $_POST['key_in_meta'] ) ) {
$args = array(
'meta_query' => array(
array(
'key' => 'role',
'value' => $_POST['key_in_meta']
)
),
'number' => '',
'count_total' => false,
'fields' => 'ids'
);
$users = get_users( $args );
$count = count( $users );
wp_send_json_success( array( 'count' => $count ) );
} else {
wp_send_json_error();
}
}
function um_upgrade_update_users_per_page20beta1() {
um_maybe_unset_time_limit();
if ( ! empty( $_POST['key_in_meta'] ) && ! empty( $_POST['role_key'] ) && ! empty( $_POST['page'] ) ) {
$users_per_page = 100;
$all_wp_roles = array_keys( get_editable_roles() );
$args = array(
'meta_query' => array(
array(
'key' => 'role',
'value' => $_POST['key_in_meta']
)
),
'paged' => $_POST['page'],
'number' => $users_per_page,
);
$all_users = get_users( $args );
//update roles for users
foreach ( $all_users as $k => $user ) {
$user_object = get_userdata( $user->ID );
if ( ! in_array( $_POST['role_key'], $all_wp_roles ) ) {
$user_object->add_role( 'um_' . $_POST['role_key'] );
} else {
if ( ! in_array( $_POST['role_key'], (array) $user_object->roles ) ) {
$user_object->add_role( $_POST['role_key'] );
}
}
}
$from = ( $_POST['page'] * $users_per_page ) - $users_per_page + 1;
$to = $_POST['page'] * $users_per_page;
wp_send_json_success( array( 'message' => sprintf( __( 'Users from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
} else {
wp_send_json_error();
}
}
function um_upgrade_content_restriction20beta1() {
um_maybe_unset_time_limit();
include 'content_restriction.php';
wp_send_json_success( array( 'message' => 'Content restriction settings was upgraded successfully' ) );
}
function um_upgrade_settings20beta1() {
um_maybe_unset_time_limit();
include 'settings.php';
wp_send_json_success( array( 'message' => __( 'Settings was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_menus20beta1() {
um_maybe_unset_time_limit();
include 'menus.php';
wp_send_json_success( array( 'message' => __( 'Menus settings was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_mc_lists20beta1() {
um_maybe_unset_time_limit();
include 'mc_lists.php';
wp_send_json_success( array( 'message' => __( 'Mailchimp Lists was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_social_login20beta1() {
um_maybe_unset_time_limit();
include 'social_login.php';
wp_send_json_success( array( 'message' => __( 'Social login forms was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_cpt20beta1() {
um_maybe_unset_time_limit();
include 'um_cpt.php';
wp_send_json_success( array( 'message' => __( 'UM Custom Posts was upgraded successfully', 'ultimate-member' ) ) );
}
function um_upgrade_get_forums20beta1() {
um_maybe_unset_time_limit();
$bb_forums = get_posts( array(
'post_type' => 'forum',
'numberposts' => -1,
'fields' => 'ids'
) );
wp_send_json_success( array( 'count' => count( $bb_forums ), 'message' => __( 'Forums are ready for upgrade', 'ultimate-member' ) ) );
}
function um_upgrade_update_forum_per_page20beta1() {
um_maybe_unset_time_limit();
if ( ! empty( $_POST['page'] ) ) {
$posts_per_page = 100;
$roles_associations = get_option( 'um_roles_associations' );
/*$bb_forums = get_posts( array(
'post_type' => 'forum',
'paged' => $_POST['page'],
'numberposts' => $posts_per_page,
'fields' => 'ids'
) );*/
$p_query = new WP_Query;
$bb_forums = $p_query->query( array(
'post_type' => 'forum',
'paged' => $_POST['page'],
'posts_per_page' => $posts_per_page,
'fields' => 'ids'
) );
foreach ( $bb_forums as $forum_id ) {
$bbpress_can_topic = get_post_meta( $forum_id, '_um_bbpress_can_topic', true );
$bbpress_can_topic = ! $bbpress_can_topic ? array() : $bbpress_can_topic;
if ( ! empty( $bbpress_can_topic ) ) {
foreach ( $bbpress_can_topic as $i => $role_k ) {
$bbpress_can_topic[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $forum_id, '_um_bbpress_can_topic', $bbpress_can_topic );
}
$bbpress_can_reply = get_post_meta( $forum_id, '_um_bbpress_can_reply', true );
$bbpress_can_reply = ! $bbpress_can_reply ? array() : $bbpress_can_reply;
if ( ! empty( $bbpress_can_reply ) ) {
foreach ( $bbpress_can_reply as $i => $role_k ) {
$bbpress_can_reply[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $forum_id, '_um_bbpress_can_reply', $bbpress_can_reply );
}
}
$from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
$to = $_POST['page'] * $posts_per_page;
wp_send_json_success( array( 'message' => sprintf( __( 'Forums from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
} else {
wp_send_json_error();
}
}
function um_upgrade_get_products20beta1() {
um_maybe_unset_time_limit();
$wc_products = get_posts( array(
'post_type' => 'product',
'numberposts' => -1,
'fields' => 'ids'
) );
wp_send_json_success( array( 'count' => count( $wc_products ), 'message' => __( 'Woocommerce Products are ready for upgrade', 'ultimate-member' ) ) );
}
function um_upgrade_update_products_per_page20beta1() {
um_maybe_unset_time_limit();
if ( ! empty( $_POST['page'] ) ) {
$posts_per_page = 100;
$roles_associations = get_option( 'um_roles_associations' );
/*$wc_products = get_posts( array(
'post_type' => 'product',
'numberposts' => $posts_per_page,
'paged' => $_POST['page'],
'fields' => 'ids'
) );*/
$p_query = new WP_Query;
$wc_products = $p_query->query( array(
'post_type' => 'product',
'paged' => $_POST['page'],
'posts_per_page' => $posts_per_page,
'fields' => 'ids'
) );
foreach ( $wc_products as $product_id ) {
$woo_product_role = get_post_meta( $product_id, '_um_woo_product_role', true );
if ( ! empty( $woo_product_role ) ) {
$woo_product_role = $roles_associations[ $woo_product_role ];
update_post_meta( $product_id, '_um_woo_product_role', $woo_product_role );
}
$woo_product_activated_role = get_post_meta( $product_id, '_um_woo_product_activated_role', true );
if ( ! empty( $woo_product_activated_role ) ) {
$woo_product_activated_role = $roles_associations[ $woo_product_activated_role ];
update_post_meta( $product_id, '_um_woo_product_activated_role', $woo_product_activated_role );
}
$woo_product_downgrade_pending_role = get_post_meta( $product_id, '_um_woo_product_downgrade_pending_role', true );
if ( ! empty( $woo_product_downgrade_pending_role ) ) {
$woo_product_downgrade_pending_role = $roles_associations[ $woo_product_downgrade_pending_role ];
update_post_meta( $product_id, '_um_woo_product_downgrade_pending_role', $woo_product_downgrade_pending_role );
}
$woo_product_downgrade_onhold_role = get_post_meta( $product_id, '_um_woo_product_downgrade_onhold_role', true );
if ( ! empty( $woo_product_downgrade_onhold_role ) ) {
$woo_product_downgrade_onhold_role = $roles_associations[ $woo_product_downgrade_onhold_role ];
update_post_meta( $product_id, '_um_woo_product_downgrade_onhold_role', $woo_product_downgrade_onhold_role );
}
$woo_product_downgrade_expired_role = get_post_meta( $product_id, '_um_woo_product_downgrade_expired_role', true );
if ( ! empty( $woo_product_downgrade_expired_role ) ) {
$woo_product_downgrade_expired_role = $roles_associations[ $woo_product_downgrade_expired_role ];
update_post_meta( $product_id, '_um_woo_product_downgrade_expired_role', $woo_product_downgrade_expired_role );
}
$woo_product_downgrade_cancelled_role = get_post_meta( $product_id, '_um_woo_product_downgrade_cancelled_role', true );
if ( ! empty( $woo_product_downgrade_cancelled_role ) ) {
$woo_product_downgrade_cancelled_role = $roles_associations[ $woo_product_downgrade_cancelled_role ];
update_post_meta( $product_id, '_um_woo_product_downgrade_cancelled_role', $woo_product_downgrade_cancelled_role );
}
}
$from = ( $_POST['page'] * $posts_per_page ) - $posts_per_page + 1;
$to = $_POST['page'] * $posts_per_page;
wp_send_json_success( array( 'message' => sprintf( __( 'Woocommerce Products from %s to %s was upgraded successfully...', 'ultimate-member' ), $from, $to ) ) );
} else {
wp_send_json_error();
}
}
function um_upgrade_email_templates20beta1() {
um_maybe_unset_time_limit();
include 'email_templates.php';
update_option( 'um_last_version_upgrade', '2.0-beta1' );
delete_option( 'um_roles_associations' );
wp_send_json_success( array( 'message' => __( 'Email Templates was upgraded successfully', 'ultimate-member' ) ) );
}
@@ -0,0 +1,22 @@
<?php
return array(
'styles20beta1' => 'styles20beta1',
'user_roles20beta1' => 'user_roles20beta1',
'get_users_per_role20beta1' => 'get_users_per_role20beta1',
'update_users_per_page20beta1' => 'update_users_per_page20beta1',
'email_templates20beta1' => 'email_templates20beta1',
'settings20beta1' => 'settings20beta1',
'content_restriction20beta1' => 'content_restriction20beta1',
'menus20beta1' => 'menus20beta1',
'mc_lists20beta1' => 'mc_lists20beta1',
'social_login20beta1' => 'social_login20beta1',
'cpt20beta1' => 'cpt20beta1',
'get_forums20beta1' => 'get_forums20beta1',
'update_forum_per_page20beta1' => 'update_forum_per_page20beta1',
'get_products20beta1' => 'get_products20beta1',
'update_products_per_page20beta1' => 'update_products_per_page20beta1',
);
@@ -0,0 +1,426 @@
<?php ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
var um_roles_data;
var users_per_page = 100;
var users_pages;
var forums_pages;
var products_pages;
var current_page = 1;
//upgrade styles
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Styles...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_styles20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_roles();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
function upgrade_roles() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Roles...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_user_roles20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
um_roles_data = response.data.roles;
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Users...', 'ultimate-member' ) ) ?>' );
get_users_per_role();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
/**
*
* @returns {boolean}
*/
function get_users_per_role() {
current_page = 1;
if ( um_roles_data.length ) {
var role = um_roles_data.shift();
um_add_upgrade_log( '<?php echo esc_js( __( 'Getting ', 'ultimate-member' ) ) ?>"' + role.role_key + '"<?php echo esc_js( __( ' users...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_get_users_per_role20beta1',
key_in_meta: role.key_in_meta
},
success: function( response ) {
if ( typeof response.data.count != 'undefined' ) {
um_add_upgrade_log( '<?php echo esc_js( __( 'There are ', 'ultimate-member' ) ) ?>' + response.data.count + '<?php echo esc_js( __( ' users...', 'ultimate-member' ) ) ?>' );
um_add_upgrade_log( '<?php echo esc_js( __( 'Start users upgrading...', 'ultimate-member' ) ) ?>');
users_pages = Math.ceil( response.data.count / users_per_page );
update_user_per_page( role.role_key, role.key_in_meta );
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
} else {
upgrade_content_restriction();
}
return false;
}
function update_user_per_page( role_key, key_in_meta ) {
if ( current_page <= users_pages ) {
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_update_users_per_page20beta1',
role_key: role_key,
key_in_meta: key_in_meta,
page: current_page
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
current_page++;
update_user_per_page( role_key, key_in_meta );
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
} else {
get_users_per_role();
}
}
function upgrade_content_restriction() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Content Restriction Settings...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_content_restriction20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_settings();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function upgrade_settings() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Settings...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_settings20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_menus();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function upgrade_menus() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Menu Items...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_menus20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_mc_lists();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function upgrade_mc_lists() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Mailchimp Lists...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_mc_lists20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_social_login();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function upgrade_social_login() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Social Login Forms...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_social_login20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
upgrade_cpt();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function upgrade_cpt() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade UM Custom Post Types...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_cpt20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
get_forums();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function get_forums() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade bbPress Forums...', 'ultimate-member' ) ) ?>' );
um_add_upgrade_log( '<?php echo esc_js( __( 'Get bbPress Forums count...', 'ultimate-member' ) ) ?>' );
current_page = 1;
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_get_forums20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
forums_pages = Math.ceil( response.data.count / users_per_page );
update_forums_per_page();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function update_forums_per_page() {
if ( current_page <= forums_pages ) {
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_update_forum_per_page20beta1',
page: current_page
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
current_page++;
update_forums_per_page();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
} else {
get_products();
}
}
function get_products() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Woocommerce Products...', 'ultimate-member' ) ) ?>' );
um_add_upgrade_log( '<?php echo esc_js( __( 'Get all Products...', 'ultimate-member' ) ) ?>' );
current_page = 1;
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_get_products20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
products_pages = Math.ceil( response.data.count / users_per_page );
update_products_per_page();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
function update_products_per_page() {
if ( current_page <= products_pages ) {
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_update_products_per_page20beta1',
page: current_page
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
current_page++;
update_products_per_page();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
} else {
upgrade_email_templates();
}
}
function upgrade_email_templates() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Upgrade Email Templates...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
type: 'POST',
dataType: 'json',
data: {
action: 'um_email_templates20beta1'
},
success: function( response ) {
if ( typeof response.data != 'undefined' ) {
um_add_upgrade_log( response.data.message );
//switch to the next package
um_run_upgrade();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
}
});
</script>
@@ -0,0 +1,27 @@
<?php
$roles_associations = get_option( 'um_roles_associations' );
/*$mc_lists = get_posts( array(
'post_type' => 'um_mailchimp',
'numberposts' => -1,
'fields' => 'ids'
) );*/
$p_query = new WP_Query;
$mc_lists = $p_query->query( array(
'post_type' => 'um_mailchimp',
'posts_per_page' => -1,
'fields' => 'ids'
) );
foreach ( $mc_lists as $list_id ) {
$um_roles = get_post_meta( $list_id, '_um_roles', true );
$um_roles = ! $um_roles ? array() : $um_roles;
if ( ! empty( $um_roles ) ) {
foreach ( $um_roles as $i => $role_k ) {
$um_roles[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $list_id, '_um_roles', $um_roles );
}
}
@@ -0,0 +1,26 @@
<?php
$roles_associations = get_option( 'um_roles_associations' );
/**
* Transferring menu restriction data
*/
$menus = get_posts( array(
'post_type' => 'nav_menu_item',
'meta_query' => array(
array(
'key' => 'menu-item-um_nav_roles',
'compare' => 'EXISTS',
)
),
'numberposts' => -1,
) );
foreach ( $menus as $menu ) {
$menu_roles = get_post_meta( $menu->ID, 'menu-item-um_nav_roles', true );
foreach ( $menu_roles as $i => $role_k ) {
$menu_roles[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $menu->ID, 'menu-item-um_nav_roles', $menu_roles );
}
@@ -0,0 +1,161 @@
<?php
//remove old options
UM()->options()->remove( 'active_color' );
UM()->options()->remove( 'secondary_color' );
UM()->options()->remove( 'profile_align' );
UM()->options()->remove( 'register_align' );
UM()->options()->remove( 'login_align' );
UM()->options()->remove( 'primary_btn_color' );
UM()->options()->remove( 'primary_btn_hover' );
UM()->options()->remove( 'primary_btn_text' );
UM()->options()->remove( 'secondary_btn_color' );
UM()->options()->remove( 'secondary_btn_hover' );
UM()->options()->remove( 'secondary_btn_text' );
UM()->options()->remove( 'help_tip_color' );
UM()->options()->remove( 'form_field_label' );
UM()->options()->remove( 'form_border' );
UM()->options()->remove( 'form_border_hover' );
UM()->options()->remove( 'form_bg_color' );
UM()->options()->remove( 'form_bg_color_focus' );
UM()->options()->remove( 'form_text_color' );
UM()->options()->remove( 'form_placeholder' );
UM()->options()->remove( 'form_icon_color' );
UM()->options()->remove( 'form_asterisk_color' );
UM()->options()->remove( 'profile_photocorner' );
UM()->options()->remove( 'profile_main_bg' );
UM()->options()->remove( 'profile_header_bg' );
UM()->options()->remove( 'profile_header_text' );
UM()->options()->remove( 'profile_header_link_color' );
UM()->options()->remove( 'profile_header_link_hcolor' );
UM()->options()->remove( 'profile_header_icon_color' );
UM()->options()->remove( 'profile_header_icon_hcolor' );
//remove duplicates for UM Pages settings
delete_option( 'um_core_pages' );
$roles_associations = get_option( 'um_roles_associations' );
$profile_tab_main_roles = UM()->options()->get( 'profile_tab_main_roles' );
$profile_tab_main_roles = ! $profile_tab_main_roles ? array() : $profile_tab_main_roles;
if ( ! empty( $profile_tab_main_roles ) ) {
foreach ( $profile_tab_main_roles as $i => $role_k ) {
$profile_tab_main_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_main_roles', $profile_tab_main_roles );
}
$profile_tab_posts_roles = UM()->options()->get( 'profile_tab_posts_roles' );
$profile_tab_posts_roles = ! $profile_tab_posts_roles ? array() : $profile_tab_posts_roles;
if ( ! empty( $profile_tab_posts_roles ) ) {
foreach ( $profile_tab_posts_roles as $i => $role_k ) {
$profile_tab_posts_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_posts_roles', $profile_tab_posts_roles );
}
$profile_tab_comments_roles = UM()->options()->get( 'profile_tab_comments_roles' );
$profile_tab_comments_roles = ! $profile_tab_comments_roles ? array() : $profile_tab_comments_roles;
if ( ! empty( $profile_tab_comments_roles ) ) {
foreach ( $profile_tab_comments_roles as $i => $role_k ) {
$profile_tab_comments_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_comments_roles', $profile_tab_comments_roles );
}
$profile_tab_activity_roles = UM()->options()->get( 'profile_tab_activity_roles' );
$profile_tab_activity_roles = ! $profile_tab_activity_roles ? array() : $profile_tab_activity_roles;
if ( ! empty( $profile_tab_activity_roles ) ) {
foreach ( $profile_tab_activity_roles as $i => $role_k ) {
$profile_tab_activity_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_activity_roles', $profile_tab_activity_roles );
}
$profile_tab_messages_roles = UM()->options()->get( 'profile_tab_messages_roles' );
$profile_tab_messages_roles = ! $profile_tab_messages_roles ? array() : $profile_tab_messages_roles;
if ( ! empty( $profile_tab_messages_roles ) ) {
foreach ( $profile_tab_messages_roles as $i => $role_k ) {
$profile_tab_messages_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_messages_roles', $profile_tab_messages_roles );
}
$profile_tab_reviews_roles = UM()->options()->get( 'profile_tab_reviews_roles' );
$profile_tab_reviews_roles = ! $profile_tab_reviews_roles ? array() : $profile_tab_reviews_roles;
if ( ! empty( $profile_tab_reviews_roles ) ) {
foreach ( $profile_tab_reviews_roles as $i => $role_k ) {
$profile_tab_reviews_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_reviews_roles', $profile_tab_reviews_roles );
}
$profile_tab_purchases_roles = UM()->options()->get( 'profile_tab_purchases_roles' );
$profile_tab_purchases_roles = ! $profile_tab_purchases_roles ? array() : $profile_tab_purchases_roles;
if ( ! empty( $profile_tab_purchases_roles ) ) {
foreach ( $profile_tab_purchases_roles as $i => $role_k ) {
$profile_tab_purchases_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_purchases_roles', $profile_tab_purchases_roles );
}
$profile_tab_product_reviews = UM()->options()->get( 'profile_tab_product-reviews_roles' );
$profile_tab_product_reviews = ! $profile_tab_product_reviews ? array() : $profile_tab_product_reviews;
if ( ! empty( $profile_tab_product_reviews ) ) {
foreach ( $profile_tab_product_reviews as $i => $role_k ) {
$profile_tab_product_reviews[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_product-reviews_roles', $profile_tab_product_reviews );
}
$profile_tab_forums_roles = UM()->options()->get( 'profile_tab_forums_roles' );
$profile_tab_forums_roles = ! $profile_tab_forums_roles ? array() : $profile_tab_forums_roles;
if ( ! empty( $profile_tab_forums_roles ) ) {
foreach ( $profile_tab_forums_roles as $i => $role_k ) {
$profile_tab_forums_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_forums_roles', $profile_tab_forums_roles );
}
$profile_tab_friends_roles = UM()->options()->get( 'profile_tab_friends_roles' );
$profile_tab_friends_roles = ! $profile_tab_friends_roles ? array() : $profile_tab_friends_roles;
if ( ! empty( $profile_tab_friends_roles ) ) {
foreach ( $profile_tab_friends_roles as $i => $role_k ) {
$profile_tab_friends_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'profile_tab_friends_roles', $profile_tab_friends_roles );
}
$register_role = UM()->options()->get( 'register_role' );
if ( ! empty( $register_role ) ) {
$register_role = $roles_associations[ $register_role ];
UM()->options()->update( 'register_role', $register_role );
}
$woo_oncomplete_role = UM()->options()->get( 'woo_oncomplete_role' );
if ( ! empty( $woo_oncomplete_role ) ) {
$woo_oncomplete_role = $roles_associations[ $woo_oncomplete_role ];
UM()->options()->update( 'woo_oncomplete_role', $woo_oncomplete_role );
}
$woo_oncomplete_except_roles = UM()->options()->get( 'woo_oncomplete_except_roles' );
$woo_oncomplete_except_roles = ! $woo_oncomplete_except_roles ? array() : $woo_oncomplete_except_roles;
if ( ! empty( $woo_oncomplete_except_roles ) ) {
foreach ( $woo_oncomplete_except_roles as $i => $role_k ) {
$woo_oncomplete_except_roles[ $i ] = $roles_associations[ $role_k ];
}
UM()->options()->update( 'woo_oncomplete_except_roles', $woo_oncomplete_except_roles );
}
@@ -0,0 +1,24 @@
<?php
$roles_associations = get_option( 'um_roles_associations' );
/*$um_social_login = get_posts( array(
'post_type' => 'um_social_login',
'numberposts' => -1,
'fields' => 'ids'
) );*/
$p_query = new WP_Query;
$um_social_login = $p_query->query( array(
'post_type' => 'um_social_login',
'posts_per_page' => -1,
'fields' => 'ids'
) );
foreach ( $um_social_login as $social_login_id ) {
$assigned_role = get_post_meta( $social_login_id, '_um_assigned_role', true );
if ( ! empty( $assigned_role ) ) {
$assigned_role = $roles_associations[ $assigned_role ];
update_post_meta( $social_login_id, '_um_assigned_role', $assigned_role );
}
}
@@ -0,0 +1,897 @@
<?php
global $wpdb;
$old_options = get_option( 'um_options' );
add_option( 'um_options_backup20', $old_options );
$forms_query = new WP_Query;
$registration_forms = $forms_query->query( array(
'post_type' => 'um_form',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_um_mode',
'value' => 'register'
),
array(
'relation' => 'OR',
array(
'key' => '_um_register_use_globals',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_um_register_use_globals',
'value' => true,
'compare' => '!='
)
),
),
'posts_per_page' => -1,
'fields' => 'ids'
) );
$forms_query = new WP_Query;
$login_forms = $forms_query->query( array(
'post_type' => 'um_form',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_um_mode',
'value' => 'login'
),
array(
'relation' => 'OR',
array(
'key' => '_um_login_use_globals',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_um_login_use_globals',
'value' => true,
'compare' => '!='
)
),
),
'posts_per_page' => -1,
'fields' => 'ids'
) );
$forms_query = new WP_Query;
$profile_forms = $forms_query->query( array(
'post_type' => 'um_form',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_um_mode',
'value' => 'profile'
),
array(
'relation' => 'OR',
array(
'key' => '_um_profile_use_globals',
'compare' => 'NOT EXISTS'
),
array(
'key' => '_um_profile_use_globals',
'value' => true,
'compare' => '!='
)
),
),
'posts_per_page' => -1,
'fields' => 'ids'
) );
$css = '';
$active_color = UM()->options()->get( 'active_color' );
if ( $active_color ) {
$css .= "
.um .um-tip:hover,
.um .um-field-radio.active:not(.um-field-radio-state-disabled) i,
.um .um-field-checkbox.active:not(.um-field-radio-state-disabled) i,
.um .um-member-name a:hover,
.um .um-member-more a:hover,
.um .um-member-less a:hover,
.um .um-members-pagi a:hover,
.um .um-cover-add:hover,
.um .um-profile-subnav a.active,
.um .um-item-meta a,
.um-account-name a:hover,
.um-account-nav a.current,
.um-account-side li a.current span.um-account-icon,
.um-account-side li a.current:hover span.um-account-icon,
.um-dropdown li a:hover,
i.um-active-color,
span.um-active-color
{
color: $active_color;
}
.um .um-field-group-head,
.picker__box,
.picker__nav--prev:hover,
.picker__nav--next:hover,
.um .um-members-pagi span.current,
.um .um-members-pagi span.current:hover,
.um .um-profile-nav-item.active a,
.um .um-profile-nav-item.active a:hover,
.upload,
.um-modal-header,
.um-modal-btn,
.um-modal-btn.disabled,
.um-modal-btn.disabled:hover,
div.uimob800 .um-account-side li a.current,
div.uimob800 .um-account-side li a.current:hover
{
background: $active_color;
}
";
}
$secondary_color = UM()->options()->get( 'secondary_color' );
if ( $secondary_color ) {
$css .= "
.um .um-field-group-head:hover,
.picker__footer,
.picker__header,
.picker__day--infocus:hover,
.picker__day--outfocus:hover,
.picker__day--highlighted:hover,
.picker--focused .picker__day--highlighted,
.picker__list-item:hover,
.picker__list-item--highlighted:hover,
.picker--focused .picker__list-item--highlighted,
.picker__list-item--selected,
.picker__list-item--selected:hover,
.picker--focused .picker__list-item--selected {
background: $secondary_color;
}
";
}
$css .= "
.um {
margin-left: auto!important;
margin-right: auto!important;
}";
$primary_btn_color = UM()->options()->get( 'primary_btn_color' );
if ( $primary_btn_color ) {
$css .= "
.um input[type=submit]:disabled:hover {
background: $primary_btn_color;
}
.um input[type=submit].um-button,
.um input[type=submit].um-button:focus,
.um a.um-button,
.um a.um-button.um-disabled:hover,
.um a.um-button.um-disabled:focus,
.um a.um-button.um-disabled:active {
background: $primary_btn_color;
}
.um a.um-link {
color: $primary_btn_color;
}
";
}
$primary_btn_hover = UM()->options()->get( 'primary_btn_hover' );
if ( $primary_btn_hover ) {
$css .= "
.um input[type=submit].um-button:hover,
.um a.um-button:hover {
background-color: $primary_btn_hover;
}
.um a.um-link:hover,
.um a.um-link-hvr:hover {
color: $primary_btn_hover;
}
";
}
$primary_btn_text = UM()->options()->get( 'primary_btn_text' );
if ( $primary_btn_text ) {
$css .= "
.um .um-button {
color: $primary_btn_text;
}
";
}
$secondary_btn_color = UM()->options()->get( 'secondary_btn_color' );
if ( $secondary_btn_color ) {
$css .= "
.um .um-button.um-alt,
.um input[type=submit].um-button.um-alt {
background: $secondary_btn_color;
}
";
}
$secondary_btn_hover = UM()->options()->get( 'secondary_btn_hover' );
if ( $secondary_btn_hover ) {
$css .= "
.um .um-button.um-alt:hover,
.um input[type=submit].um-button.um-alt:hover{
background: $secondary_btn_hover;
}
";
}
$secondary_btn_text = UM()->options()->get( 'secondary_btn_text' );
if ( $secondary_btn_text ) {
$css .= "
.um .um-button.um-alt,
.um input[type=submit].um-button.um-alt {
color: $secondary_btn_text;
}
";
}
$help_tip_color = UM()->options()->get( 'help_tip_color' );
if ( $help_tip_color ) {
$css .= "
.um .um-tip {
color: $help_tip_color;
}
";
}
$form_field_label = UM()->options()->get( 'form_field_label' );
if ( $form_field_label ) {
$css .= "
.um .um-field-label {
color: $form_field_label;
}
";
}
$form_border = UM()->options()->get( 'form_border' );
if ( $form_border ) {
$css .= "
.um .um-form input[type=text],
.um .um-form input[type=tel],
.um .um-form input[type=number],
.um .um-form input[type=password],
.um .um-form textarea,
.um .upload-progress,
.select2-container .select2-choice,
.select2-drop,
.select2-container-multi .select2-choices,
.select2-drop-active,
.select2-drop.select2-drop-above
{
border: $form_border !important;
}
.um .um-form .select2-container-multi .select2-choices .select2-search-field input[type=text] {
border: none !important
}
";
}
$form_border_hover = UM()->options()->get( 'form_border_hover' );
if ( $form_border_hover ) {
$css .= "
.um .um-form input[type=text]:focus,
.um .um-form input[type=tel]:focus,
.um .um-form input[type=number]:focus,
.um .um-form input[type=password]:focus,
.um .um-form .um-datepicker.picker__input.picker__input--active,
.um .um-form .um-datepicker.picker__input.picker__input--target,
.um .um-form textarea:focus {
border: $form_border_hover !important;
}
";
}
$form_bg_color = UM()->options()->get( 'form_bg_color' );
if ( $form_bg_color ) {
$css .= "
.um .um-form input[type=text],
.um .um-form input[type=tel],
.um .um-form input[type=number],
.um .um-form input[type=password],
.um .um-form textarea,
.select2-container .select2-choice,
.select2-container-multi .select2-choices
{
background-color: $form_bg_color;
}
";
}
$form_bg_color_focus = UM()->options()->get( 'form_bg_color_focus' );
if ( $form_bg_color_focus ) {
$css .= "
.um .um-form input[type=text]:focus,
.um .um-form input[type=tel]:focus,
.um .um-form input[type=number]:focus,
.um .um-form input[type=password]:focus,
.um .um-form textarea:focus {
background-color: $form_bg_color_focus;
}
";
}
$form_text_color = UM()->options()->get( 'form_text_color' );
if ( $form_text_color ) {
$css .= "
.um .um-form input[type=text],
.um .um-form input[type=tel],
.um .um-form input[type=password],
.um .um-form textarea
{
color: $form_text_color;
}
.um .um-form input:-webkit-autofill {
-webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
-webkit-text-fill-color: $form_text_color;
}
.um .um-form input:-webkit-autofill:focus {
-webkit-box-shadow: none,0 0 0 50px white inset;
-webkit-text-fill-color: $form_text_color;
}
";
}
$form_placeholder = UM()->options()->get( 'form_placeholder' );
if ( $form_placeholder ) {
$css .= "
.um .um-form ::-webkit-input-placeholder
{
color: $form_placeholder;
opacity: 1 !important;
}
.um .um-form ::-moz-placeholder
{
color: $form_placeholder;
opacity: 1 !important;
}
.um .um-form ::-moz-placeholder
{
color: $form_placeholder;
opacity: 1 !important;
}
.um .um-form ::-ms-input-placeholder
{
color: $form_placeholder;
opacity: 1 !important;
}
.select2-default,
.select2-default *,
.select2-container-multi .select2-choices .select2-search-field input
{
color: $form_placeholder;
}
";
}
$form_icon_color = UM()->options()->get( 'form_icon_color' );
if ( $form_icon_color ) {
$css .= "
.um .um-field-icon i,
.select2-container .select2-choice .select2-arrow:before,
.select2-search:before,
.select2-search-choice-close:before
{
color: $form_icon_color;
}
";
}
$form_asterisk_color = UM()->options()->get( 'form_asterisk_color' );
if ( $form_asterisk_color ) {
$css .= "
.um span.um-req
{
color: $form_asterisk_color;
}
";
}
$profile_photocorner = UM()->options()->get( 'profile_photocorner' );
if ( $profile_photocorner == 1 ) {
$css .= "
.um .um-profile-photo a.um-profile-photo-img,
.um .um-profile-photo img,
.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 999px !important;
-webkit-border-radius: 999px !important;
border-radius: 999px !important
}
";
} else if ( $profile_photocorner == 2 ) {
$css .= "
.um .um-profile-photo a.um-profile-photo-img,
.um .um-profile-photo img,
.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 4px !important;
-webkit-border-radius: 4px !important;
border-radius: 4px !important
}
";
} else if ( $profile_photocorner == 3 ) {
$css .= "
.um .um-profile-photo a.um-profile-photo-img,
.um .um-profile-photo img,
.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 0px !important;
-webkit-border-radius: 0px !important;
border-radius: 0px !important
}
";
}
$profile_main_bg = UM()->options()->get( 'profile_main_bg' );
if ( $profile_main_bg ) {
$css .= "
.um-profile {
background-color: $profile_main_bg;
}
";
}
$profile_header_bg = UM()->options()->get( 'profile_header_bg' );
if ( $profile_header_bg ) {
$css .= "
.um-profile.um .um-header {
background-color: $profile_header_bg;
}
";
}
$profile_header_text = UM()->options()->get( 'profile_header_text' );
if ( $profile_header_text ) {
$css .= "
.um-profile.um .um-profile-meta {
color: $profile_header_text;
}
";
}
$profile_header_link_color = UM()->options()->get( 'profile_header_link_color' );
if ( $profile_header_link_color ) {
$css .= "
.um-profile.um .um-name a {
color: $profile_header_link_color;
}
";
}
$profile_header_link_hcolor = UM()->options()->get( 'profile_header_link_hcolor' );
if ( $profile_header_link_hcolor ) {
$css .= "
.um-profile.um .um-name a:hover {
color: $profile_header_link_hcolor;
}
";
}
$profile_header_icon_color = UM()->options()->get( 'profile_header_icon_color' );
if ( $profile_header_icon_color ) {
$css .= "
.um-profile.um .um-profile-headericon a {
color: $profile_header_icon_color;
}
";
}
$profile_header_icon_hcolor = UM()->options()->get( 'profile_header_icon_hcolor' );
if ( $profile_header_icon_hcolor ) {
$css .= "
.um-profile.um .um-profile-headericon a:hover,
.um-profile.um .um-profile-edit-a.active {
color: $profile_header_icon_hcolor;
}
";
}
foreach ( $registration_forms as $form_id ) {
$align = get_post_meta( $form_id, '_um_register_align', true );
if ( $align && $align != 'center' ) {
$css .= "
.um-$form_id.um {
float: $align;
}
";
}
$primary_btn_color = get_post_meta( $form_id, '_um_register_primary_btn_color', true );
if ( $primary_btn_color ) {
$css .= "
.um-$form_id.um input[type=submit]:disabled:hover {
background: $primary_btn_color;
}
.um-$form_id.um input[type=submit].um-button,
.um-$form_id.um input[type=submit].um-button:focus,
.um-$form_id.um a.um-button,
.um-$form_id.um a.um-button.um-disabled:hover,
.um-$form_id.um a.um-button.um-disabled:focus,
.um-$form_id.um a.um-button.um-disabled:active {
background: $primary_btn_color;
}
.um-$form_id.um a.um-link {
color: $primary_btn_color;
}
";
}
$primary_btn_hover = get_post_meta( $form_id, '_um_register_primary_btn_hover', true );
if ( $primary_btn_hover ) {
$css .= "
.um-$form_id.um input[type=submit].um-button:hover,
.um-$form_id.um a.um-button:hover {
background-color: $primary_btn_hover;
}
.um-$form_id.um a.um-link:hover,
.um-$form_id.um a.um-link-hvr:hover {
color: $primary_btn_hover;
}
";
}
$primary_btn_text = get_post_meta( $form_id, '_um_register_primary_btn_text', true );
if ( $primary_btn_text ) {
$css .= "
.um-$form_id.um .um-button {
color: $primary_btn_text;
}
";
}
$secondary_button = get_post_meta( $form_id, '_um_register_secondary_btn', true );
if ( $secondary_button ) {
$secondary_btn_color = get_post_meta( $form_id, '_um_register_secondary_btn_color', true );
if ( $secondary_btn_color ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
background: $secondary_btn_color;
}
";
}
$secondary_btn_hover = get_post_meta( $form_id, '_um_register_secondary_btn_hover', true );
if ( $secondary_btn_hover ) {
$css .= "
.um-$form_id.um .um-button.um-alt:hover,
.um-$form_id.um input[type=submit].um-button.um-alt:hover{
background: $secondary_btn_hover;
}
";
}
$secondary_btn_text = get_post_meta( $form_id, '_um_register_secondary_btn_text', true );
if ( $secondary_btn_text ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
color: $secondary_btn_text;
}
";
}
}
}
foreach ( $login_forms as $form_id ) {
$align = get_post_meta( $form_id, '_um_login_align', true );
if ( $align && $align != 'center' ) {
$css .= "
.um-$form_id.um {
float: $align;
}
";
}
$primary_btn_color = get_post_meta( $form_id, '_um_login_primary_btn_color', true );
if ( $primary_btn_color ) {
$css .= "
.um-$form_id.um input[type=submit]:disabled:hover {
background: $primary_btn_color;
}
.um-$form_id.um input[type=submit].um-button,
.um-$form_id.um input[type=submit].um-button:focus,
.um-$form_id.um a.um-button,
.um-$form_id.um a.um-button.um-disabled:hover,
.um-$form_id.um a.um-button.um-disabled:focus,
.um-$form_id.um a.um-button.um-disabled:active {
background: $primary_btn_color;
}
.um-$form_id.um a.um-link {
color: $primary_btn_color;
}
";
}
$primary_btn_hover = get_post_meta( $form_id, '_um_login_primary_btn_hover', true );
if ( $primary_btn_hover ) {
$css .= "
.um-$form_id.um input[type=submit].um-button:hover,
.um-$form_id.um a.um-button:hover {
background-color: $primary_btn_hover;
}
.um-$form_id.um a.um-link:hover,
.um-$form_id.um a.um-link-hvr:hover {
color: $primary_btn_hover;
}
";
}
$primary_btn_text = get_post_meta( $form_id, '_um_login_primary_btn_text', true );
if ( $primary_btn_text ) {
$css .= "
.um-$form_id.um .um-button {
color: $primary_btn_text;
}
";
}
$secondary_button = get_post_meta( $form_id, '_um_login_secondary_btn', true );
if ( $secondary_button ) {
$secondary_btn_color = get_post_meta( $form_id, '_um_login_secondary_btn_color', true );
if ( $secondary_btn_color ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
background: $secondary_btn_color;
}
";
}
$secondary_btn_hover = get_post_meta( $form_id, '_um_login_secondary_btn_hover', true );
if ( $secondary_btn_hover ) {
$css .= "
.um-$form_id.um .um-button.um-alt:hover,
.um-$form_id.um input[type=submit].um-button.um-alt:hover{
background: $secondary_btn_hover;
}
";
}
$secondary_btn_text = get_post_meta( $form_id, '_um_login_secondary_btn_text', true );
if ( $secondary_btn_text ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
color: $secondary_btn_text;
}
";
}
}
}
foreach ( $profile_forms as $form_id ) {
$align = get_post_meta( $form_id, '_um_profile_align', true );
if ( $align && $align != 'center' ) {
$css .= "
.um-$form_id.um {
float: $align;
}
";
}
$primary_btn_color = get_post_meta( $form_id, '_um_profile_primary_btn_color', true );
if ( $primary_btn_color ) {
$css .= "
.um-$form_id.um input[type=submit]:disabled:hover {
background: $primary_btn_color;
}
.um-$form_id.um input[type=submit].um-button,
.um-$form_id.um input[type=submit].um-button:focus,
.um-$form_id.um a.um-button,
.um-$form_id.um a.um-button.um-disabled:hover,
.um-$form_id.um a.um-button.um-disabled:focus,
.um-$form_id.um a.um-button.um-disabled:active {
background: $primary_btn_color;
}
.um-$form_id.um a.um-link {
color: $primary_btn_color;
}
";
}
$primary_btn_hover = get_post_meta( $form_id, '_um_profile_primary_btn_hover', true );
if ( $primary_btn_hover ) {
$css .= "
.um-$form_id.um input[type=submit].um-button:hover,
.um-$form_id.um a.um-button:hover {
background-color: $primary_btn_hover;
}
.um-$form_id.um a.um-link:hover,
.um-$form_id.um a.um-link-hvr:hover {
color: $primary_btn_hover;
}
";
}
$primary_btn_text = get_post_meta( $form_id, '_um_profile_primary_btn_text', true );
if ( $primary_btn_text ) {
$css .= "
.um-$form_id.um .um-button {
color: $primary_btn_text;
}
";
}
$secondary_button = get_post_meta( $form_id, '_um_profile_secondary_btn', true );
if ( $secondary_button ) {
$secondary_btn_color = get_post_meta( $form_id, '_um_profile_secondary_btn_color', true );
if ( $secondary_btn_color ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
background: $secondary_btn_color;
}
";
}
$secondary_btn_hover = get_post_meta( $form_id, '_um_profile_secondary_btn_hover', true );
if ( $secondary_btn_hover ) {
$css .= "
.um-$form_id.um .um-button.um-alt:hover,
.um-$form_id.um input[type=submit].um-button.um-alt:hover{
background: $secondary_btn_hover;
}
";
}
$secondary_btn_text = get_post_meta( $form_id, '_um_profile_secondary_btn_text', true );
if ( $secondary_btn_text ) {
$css .= "
.um-$form_id.um .um-button.um-alt,
.um-$form_id.um input[type=submit].um-button.um-alt {
color: $secondary_btn_text;
}
";
}
}
$profile_photocorner = get_post_meta( $form_id, '_um_profile_photocorner', true );
if ( $profile_photocorner == 1 ) {
$css .= "
.um-$form_id.um .um-profile-photo a.um-profile-photo-img,
.um-$form_id.um .um-profile-photo img,
.um-$form_id.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 999px !important;
-webkit-border-radius: 999px !important;
border-radius: 999px !important
}
";
} else if ( $profile_photocorner == 2 ) {
$css .= "
.um-$form_id.um .um-profile-photo a.um-profile-photo-img,
.um-$form_id.um .um-profile-photo img,
.um-$form_id.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 4px !important;
-webkit-border-radius: 4px !important;
border-radius: 4px !important
}
";
} else if ( $profile_photocorner == 3 ) {
$css .= "
.um-$form_id.um .um-profile-photo a.um-profile-photo-img,
.um-$form_id.um .um-profile-photo img,
.um-$form_id.um .um-profile-photo span.um-profile-photo-overlay
{
-moz-border-radius: 0px !important;
-webkit-border-radius: 0px !important;
border-radius: 0px !important
}
";
}
$profile_main_bg = get_post_meta( $form_id, '_um_profile_main_bg', true );
if ( $profile_main_bg ) {
$css .= "
.um-$form_id.um-profile {
background-color: $profile_main_bg;
}
";
}
$main_text_color = get_post_meta( $form_id, '_um_profile_main_text_color', true );
if ( $main_text_color ) {
$css .= "
.um-$form_id.um .um-profile-body.main *{
color: $main_text_color;
}
";
}
$profile_header_bg = get_post_meta( $form_id, '_um_profile_header_bg', true );
if ( $profile_header_bg ) {
$css .= "
.um-$form_id.um .um-header {
background-color: $profile_header_bg;
}
";
}
$profile_header_text = get_post_meta( $form_id, '_um_profile_header_text', true );
if ( $profile_header_text ) {
$css .= "
.um-$form_id.um .um-profile-meta {
color: $profile_header_text;
}
";
}
$profile_header_link_color = get_post_meta( $form_id, '_um_profile_header_link_color', true );
if ( $profile_header_link_color ) {
$css .= "
.um-$form_id.um .um-name a {
color: $profile_header_link_color;
}
";
}
$profile_header_link_hcolor = get_post_meta( $form_id, '_um_profile_header_link_hcolor', true );
if ( $profile_header_link_hcolor ) {
$css .= "
.um-$form_id.um .um-name a:hover {
color: $profile_header_link_hcolor;
}
";
}
$profile_header_icon_color = get_post_meta( $form_id, '_um_profile_header_icon_color', true );
if ( $profile_header_icon_color ) {
$css .= "
.um-$form_id.um .um-profile-headericon a {
color: $profile_header_icon_color;
}
";
}
$profile_header_icon_hcolor = get_post_meta( $form_id, '_um_profile_header_icon_hcolor', true );
if ( $profile_header_icon_hcolor ) {
$css .= "
.um-$form_id.um .um-profile-headericon a:hover,
.um-$form_id.um .um-profile-edit-a.active {
color: $profile_header_icon_hcolor;
}
";
}
}
$uploads = wp_upload_dir();
$upload_dir = $uploads['basedir'] . DIRECTORY_SEPARATOR . 'ultimatemember' . DIRECTORY_SEPARATOR;
$css_doc_file = fopen( $upload_dir. 'um_old_settings.css', 'w+' );
fwrite( $css_doc_file, $css );
fclose( $css_doc_file );
@@ -0,0 +1,61 @@
<?php
$roles_associations = get_option( 'um_roles_associations' );
//for metadata for all UM forms
//"use_global" meta change to "_use_custom_settings"
//also update for forms metadata where "member" or "admin"
$forms_query = new WP_Query;
$forms = $forms_query->query( array(
'post_type' => 'um_form',
'posts_per_page' => -1,
'fields' => 'ids'
) );
foreach ( $forms as $form_id ) {
$form_type = get_post_meta( $form_id, '_um_mode', true );
if ( ! empty( $form_type ) ) {
$use_globals = get_post_meta( $form_id, "_um_{$form_type}_use_globals", true );
$use_custom_settings = empty( $use_globals ) ? true : false;
update_post_meta( $form_id, "_um_{$form_type}_use_custom_settings", $use_custom_settings );
delete_post_meta( $form_id, "_um_{$form_type}_use_globals" );
$role = get_post_meta( $form_id, "_um_{$form_type}_role", true );
if ( $role ) {
update_post_meta( $form_id, "_um_{$form_type}_role", $roles_associations[ $role ] );
}
}
}
//for metadata for all UM Member Directories
//also update for forms metadata where "member" or "admin"
$forms_query = new WP_Query;
$member_directories = $forms_query->query( array(
'post_type' => 'um_directory',
'posts_per_page' => -1,
'fields' => 'ids'
) );
foreach ( $member_directories as $directory_id ) {
$directory_roles = get_post_meta( $directory_id, '_um_roles', true );
if ( ! empty( $directory_roles ) ) {
foreach ( $directory_roles as $i => $role_k ) {
$directory_roles[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $directory_id, '_um_roles', $directory_roles );
}
$um_roles_can_search = get_post_meta( $directory_id, '_um_roles_can_search', true );
if ( ! empty( $um_roles_can_search ) ) {
foreach ( $um_roles_can_search as $i => $role_k ) {
$um_roles_can_search[ $i ] = $roles_associations[ $role_k ];
}
update_post_meta( $directory_id, '_um_roles_can_search', $um_roles_can_search );
}
}
@@ -0,0 +1,158 @@
<?php
global $wpdb;
$response_roles_data = array();
//UM Roles to WP Roles
//all UM Roles from post type
$role_keys = array();
register_post_type( 'um_role', array(
'labels' => array(
'name' => __( 'User Roles' ),
'singular_name' => __( 'User Role' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __('Add New User Role' ),
'edit_item' => __('Edit User Role'),
'not_found' => __('You did not create any user roles yet'),
'not_found_in_trash' => __('Nothing found in Trash'),
'search_items' => __('Search User Roles')
),
'show_ui' => true,
'show_in_menu' => false,
'public' => false,
'supports' => array('title')
) );
$um_roles = get_posts( array(
'post_type' => 'um_role',
'posts_per_page' => -1,
'post_status' => 'publish'
) );
$roles_associations = array();
$all_wp_roles = array_keys( get_editable_roles() );
if ( ! empty( $um_roles ) ) {
foreach ( $um_roles as $um_role ) {
//old role key which inserted for each user to usermeta "role"
$key_in_meta = $um_role->post_name;
if ( preg_match( "/[a-z0-9]+$/i", $um_role->post_title ) ) {
$role_key = sanitize_title( $um_role->post_title );
} else {
$auto_increment = UM()->options()->get( 'custom_roles_increment' );
$auto_increment = ! empty( $auto_increment ) ? $auto_increment : 1;
$role_key = 'custom_role_' . $auto_increment;
$auto_increment++;
UM()->options()->update( 'custom_roles_increment', $auto_increment );
}
if ( ! in_array( $role_key, $all_wp_roles ) ) {
$role_keys[] = $role_key;
}
$all_role_metadata = $wpdb->get_results( $wpdb->prepare(
"SELECT pm.meta_key,
pm.meta_value
FROM {$wpdb->postmeta} pm
WHERE pm.post_id = %d AND
pm.meta_key LIKE %s",
$um_role->ID,
"_um_%"
), ARRAY_A );
$role_metadata = array();
if ( ! empty( $all_role_metadata ) ) {
foreach ( $all_role_metadata as $metadata ) {
if ( '_um_can_edit_roles' == $metadata['meta_key'] || '_um_can_delete_roles' == $metadata['meta_key']
|| '_um_can_view_roles' == $metadata['meta_key'] || '_um_can_follow_roles' == $metadata['meta_key']
|| '_um_can_friend_roles' == $metadata['meta_key'] || '_um_can_review_roles' == $metadata['meta_key'] ) {
$metadata['meta_value'] = maybe_unserialize( $metadata['meta_value'] );
}
$role_metadata[ $metadata['meta_key'] ] = $metadata['meta_value'];
}
}
if ( ! in_array( $role_key, $all_wp_roles ) ) {
$role_meta = array_merge( $role_metadata, array(
'name' => $um_role->post_title,
'wp_capabilities' => array( 'read' => true ),
'_um_is_custom' => true,
) );
} else {
$role_meta = $role_metadata;
}
//$old_key = ! empty( $role_meta['_um_core'] ) ? $role_meta['_um_core'] : $role_key;
if ( ! in_array( $role_key, $all_wp_roles ) ) {
$roles_associations[ $key_in_meta ] = 'um_' . $role_key;
} else {
$roles_associations[ $key_in_meta ] = $role_key;
}
$response_roles_data[] = array(
'role_key' => $role_key,
'key_in_meta' => $key_in_meta
);
if ( ! empty( $role_meta['_um_core'] ) )
unset( $role_meta['_um_core'] );
update_option( "um_role_{$role_key}_meta", $role_meta );
}
//update user role meta where role keys stored
foreach ( $um_roles as $um_role ) {
$key_in_meta = $um_role->post_name;
$role_key = $roles_associations[ $key_in_meta ];
if ( strpos( $role_key, 'um_' ) === 0 )
$role_key = substr( $role_key, 3 );
$role_meta = get_option( "um_role_{$role_key}_meta" );
$role_metadata = array();
if ( ! empty( $role_meta ) ) {
foreach ( $role_meta as $metakey => $metadata ) {
if ( '_um_can_edit_roles' == $metakey || '_um_can_delete_roles' == $metakey
|| '_um_can_view_roles' == $metakey || '_um_can_follow_roles' == $metakey
|| '_um_can_friend_roles' == $metakey || '_um_can_review_roles' == $metakey ) {
if ( ! empty( $metadata ) ) {
foreach ( $metadata as $i => $role_k ) {
$metadata[ $i ] = $roles_associations[ $role_k ];
}
}
} elseif ( '_um_profilec_upgrade_role' == $metakey ) {
$metadata = $roles_associations[ $metadata ];
}
$role_meta[ $metakey ] = $metadata;
}
}
update_option( "um_role_{$role_key}_meta", $role_meta );
}
}
update_option( 'um_roles', $role_keys );
global $wp_roles, $wp_version;
if ( version_compare( $wp_version, '4.9', '<' ) ) {
$wp_roles->_init();
} elseif ( method_exists( $wp_roles, 'for_site' ) ) {
$wp_roles->for_site( get_current_blog_id() );
}
//temporary option
update_option( 'um_roles_associations', $roles_associations );
@@ -1,95 +0,0 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Put status handler in modal
*/
function um_admin_add_message_handlers() {
?>
<div class="um-admin-error-block"></div>
<div class="um-admin-success-block"></div>
<?php
}
add_action( 'um_admin_field_modal_header', 'um_admin_add_message_handlers' );
/**
* Footer of modal
*
* @param $form_id
* @param $field_args
* @param $in_edit
* @param $edit_array
*/
function um_admin_add_conditional_support( $form_id, $field_args, $in_edit, $edit_array ) {
$metabox = UM()->metabox();
if ( isset( $field_args['conditional_support'] ) && $field_args['conditional_support'] == 0 ) {
return;
} ?>
<div class="um-admin-btn-toggle">
<?php if ( $in_edit ) { $metabox->in_edit = true; $metabox->edit_array = $edit_array; ?>
<a href="#"><i class="um-icon-plus"></i><?php _e('Manage conditional fields support'); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
<?php } else { ?>
<a href="#"><i class="um-icon-plus"></i><?php _e('Add conditional fields support'); ?></a> <?php UM()->tooltip( __( 'Here you can setup conditional logic to show/hide this field based on specific fields value or conditions', 'ultimate-member' ) ); ?>
<?php } ?>
<div class="um-admin-btn-content">
<p class="um-admin-reset-conditions"><a href="#" class="button button-primary"><?php _e('Reset all rules','ultimate-member'); ?></a></p>
<div class="um-admin-clear"></div>
<?php if ( isset( $edit_array['conditions'] ) ) {
foreach ( $edit_array['conditions'] as $k => $arr ) {
if ( $k == 0 ) $k = '';
?>
<div class="um-admin-cur-condition">
<?php $metabox->field_input( '_conditional_action' . $k, $form_id ); ?>
<?php $metabox->field_input( '_conditional_field' . $k , $form_id ); ?>
<?php $metabox->field_input( '_conditional_operator' . $k, $form_id ); ?>
<?php $metabox->field_input( '_conditional_value' . $k, $form_id ); ?>
<?php if ( $k == '' ) { ?>
<p><a href="#" class="um-admin-new-condition button um-admin-tipsy-n" title="Add new condition"><i class="um-icon-plus" style="margin-right:0!important"></i></a></p>
<?php } else { ?>
<p><a href="#" class="um-admin-remove-condition button um-admin-tipsy-n" title="Remove condition"><i class="um-icon-close" style="margin-right:0!important"></i></a></p>
<?php } ?>
<div class="um-admin-clear"></div>
</div>
<?php
}
} else { ?>
<div class="um-admin-cur-condition">
<?php $metabox->field_input( '_conditional_action', $form_id ); ?>
<?php $metabox->field_input( '_conditional_field', $form_id ); ?>
<?php $metabox->field_input( '_conditional_operator', $form_id ); ?>
<?php $metabox->field_input( '_conditional_value', $form_id ); ?>
<p><a href="#" class="um-admin-new-condition button um-admin-tipsy-n" title="Add new condition"><i class="um-icon-plus" style="margin-right:0!important"></i></a></p>
<div class="um-admin-clear"></div>
</div>
<?php } ?>
</div>
</div>
<?php
}
add_action( 'um_admin_field_modal_footer', 'um_admin_add_conditional_support', 10, 4 );
@@ -1,66 +0,0 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Does an action to user asap
*
* @param string $action
*/
function um_admin_user_action_hook( $action ) {
switch ( $action ) {
default:
/**
* UM hook
*
* @type action
* @title um_admin_custom_hook_{$action}
* @description Integration hook on user action
* @input_vars
* [{"var":"$user_id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_custom_hook_{$action}', 'my_admin_custom_hook', 10, 1 );
* function my_admin_after_main_notices( $user_id ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
break;
case 'um_put_as_pending':
UM()->user()->pending();
break;
case 'um_approve_membership':
case 'um_reenable':
UM()->user()->approve();
break;
case 'um_reject_membership':
UM()->user()->reject();
break;
case 'um_resend_activation':
UM()->user()->email_pending();
break;
case 'um_deactivate':
UM()->user()->deactivate();
break;
case 'um_delete':
if ( is_admin() ) {
wp_die( 'This action is not allowed in backend.', 'ultimate-member' );
}
UM()->user()->delete();
break;
}
}
add_action( 'um_admin_user_action_hook', 'um_admin_user_action_hook', 10, 1 );
-253
View File
@@ -1,253 +0,0 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Add option for WPML
*
* @param array $fields
* @param array $data
*
* @return array
*/
function um_admin_wpml_post_options( $fields, $data ) {
global $post;
if ( ! function_exists( 'icl_get_current_language' ) )
return $fields;
if ( empty( $post->post_type ) || $post->post_type != 'page' )
return $fields;
$fields[] = array(
'id' => '_um_wpml_user',
'type' => 'checkbox',
'label' => __( 'This is a translation of UM profile page?', 'ultimate-member' ),
'value' => ! empty( $data['_um_wpml_user'] ) ? $data['_um_wpml_user'] : 0
);
$fields[] = array(
'id' => '_um_wpml_account',
'type' => 'checkbox',
'label' => __( 'This is a translation of UM account page?', 'ultimate-member' ),
'value' => ! empty( $data['_um_wpml_account'] ) ? $data['_um_wpml_account'] : 0
);
return $fields;
}
add_filter( 'um_admin_access_settings_fields', 'um_admin_wpml_post_options', 10, 2 );
/**
* Clear all users cache
*
* @param $action
*/
function um_admin_do_action__user_cache( $action ) {
global $wpdb;
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
exit( wp_redirect( $url ) );
}
add_action( 'um_admin_do_action__user_cache', 'um_admin_do_action__user_cache' );
/**
* Purge temp uploads dir
* @param $action
*/
function um_admin_do_action__purge_temp( $action ){
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
UM()->files()->remove_dir( UM()->files()->upload_temp );
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'purged_temp' ), admin_url( 'admin.php' ) );
exit( wp_redirect( $url ) );
}
add_action( 'um_admin_do_action__purge_temp', 'um_admin_do_action__purge_temp' );
/**
* Duplicate form
*
* @param $action
*/
function um_admin_do_action__duplicate_form( $action ) {
if ( ! is_admin() || ! current_user_can('manage_options') ) die();
if ( ! isset( $_REQUEST['post_id'] ) || ! is_numeric( $_REQUEST['post_id'] ) ) die();
$post_id = $_REQUEST['post_id'];
$n = array(
'post_type' => 'um_form',
'post_title' => sprintf( __( 'Duplicate of %s', 'ultimate-member' ), get_the_title( $post_id ) ),
'post_status' => 'publish',
'post_author' => get_current_user_id(),
);
$n_id = wp_insert_post( $n );
$n_fields = get_post_custom( $post_id );
foreach ( $n_fields as $key => $value ) {
if ( $key == '_um_custom_fields' ) {
$the_value = unserialize( $value[0] );
} else {
$the_value = $value[0];
}
update_post_meta( $n_id, $key, $the_value );
}
delete_post_meta($n_id, '_um_core');
$url = admin_url('edit.php?post_type=um_form');
$url = add_query_arg('update','form_duplicated',$url);
exit( wp_redirect( $url ) );
}
add_action( 'um_admin_do_action__duplicate_form', 'um_admin_do_action__duplicate_form' );
/**
* Download a language remotely
*
* @param $action
*/
function um_admin_do_action__um_language_downloader( $action ) {
if ( !is_admin() || !current_user_can('manage_options') ) die();
$locale = get_option('WPLANG');
if ( !$locale ) return;
if ( !isset( UM()->available_languages[$locale] ) ) return;
$path = UM()->files()->upload_basedir;
$path = str_replace('/uploads/ultimatemember','',$path);
$path = $path . '/languages/plugins/';
$path = str_replace('//','/',$path);
$remote = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.po';
$remote2 = 'https://ultimatemember.com/wp-content/languages/plugins/ultimatemember-' . $locale . '.mo';
$remote_tmp = download_url( $remote, $timeout = 300 );
copy( $remote_tmp, $path . 'ultimatemember-' . $locale . '.po' );
unlink( $remote_tmp );
$remote2_tmp = download_url( $remote2, $timeout = 300 );
copy( $remote2_tmp, $path . 'ultimatemember-' . $locale . '.mo' );
unlink( $remote2_tmp );
$url = remove_query_arg('um_adm_action', UM()->permalinks()->get_current_url() );
$url = add_query_arg('update','language_updated',$url);
exit( wp_redirect($url) );
}
add_action( 'um_admin_do_action__um_language_downloader', 'um_admin_do_action__um_language_downloader' );
/**
* Action to hide notices in admin
*
* @param $action
*/
function um_admin_do_action__hide_notice( $action ) {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
update_option( $action, 1 );
exit( wp_redirect( remove_query_arg( 'um_adm_action' ) ) );
}
add_action( 'um_admin_do_action__um_hide_locale_notice', 'um_admin_do_action__hide_notice' );
add_action( 'um_admin_do_action__um_can_register_notice', 'um_admin_do_action__hide_notice' );
add_action( 'um_admin_do_action__um_hide_exif_notice', 'um_admin_do_action__hide_notice' );
/**
* Various user actions
*
* @param $action
*/
function um_admin_do_action__user_action( $action ) {
if ( !is_admin() || !current_user_can( 'edit_users' ) ) die();
if ( !isset( $_REQUEST['sub'] ) ) die();
if ( !isset($_REQUEST['user_id']) ) die();
um_fetch_user( $_REQUEST['user_id'] );
$subaction = $_REQUEST['sub'];
/**
* UM hook
*
* @type action
* @title um_admin_user_action_hook
* @description Action on bulk user subaction
* @input_vars
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
* function my_admin_user_action( $subaction ) {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_hook", $subaction );
/**
* UM hook
*
* @type action
* @title um_admin_user_action_{$subaction}_hook
* @description Action on bulk user subaction
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
* @example
* <?php
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
* function my_admin_user_action() {
* // your code here
* }
* ?>
*/
do_action( "um_admin_user_action_{$subaction}_hook" );
um_reset_user();
wp_redirect( add_query_arg( 'update', 'user_updated', admin_url('?page=ultimatemember') ) );
exit;
}
add_action( 'um_admin_do_action__user_action', 'um_admin_do_action__user_action' );
/**
* Add any custom links to plugin page
*
* @param array $links
*
* @return array
*/
function ultimatemember_plugin_links( $links ) {
$more_links[] = '<a href="http://docs.ultimatemember.com/">' . __( 'Docs', 'ultimate-member' ) . '</a>';
$more_links[] = '<a href="'.admin_url().'admin.php?page=um_options">' . __( 'Settings', 'ultimate-member' ) . '</a>';
$links = $more_links + $links;
return $links;
}
$prefix = is_network_admin() ? 'network_admin_' : '';
add_filter( "{$prefix}plugin_action_links_" . um_plugin, 'ultimatemember_plugin_links' );
@@ -1,200 +0,0 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Modify field args just before it is saved into form
*
* @param $array
*
* @return mixed
*/
function um_admin_pre_save_field_to_form( $array ){
unset( $array['conditions'] );
if ( isset($array['conditional_field']) && !empty( $array['conditional_action'] ) && !empty( $array['conditional_operator'] ) ) {
$array['conditional_value'] = ! empty( $array['conditional_value'] ) ? $array['conditional_value'] : '';
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
}
if ( isset($array['conditional_field1']) && !empty( $array['conditional_action1'] ) && !empty( $array['conditional_operator1'] ) ) {
$array['conditional_value1'] = ! empty( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
}
if ( isset($array['conditional_field2']) && !empty( $array['conditional_action2'] ) && !empty( $array['conditional_operator2'] ) ) {
$array['conditional_value2'] = ! empty( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
}
if ( isset($array['conditional_field3']) && !empty( $array['conditional_action3'] ) && !empty( $array['conditional_operator3'] ) ) {
$array['conditional_value3'] = ! empty( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
}
if ( isset($array['conditional_field4']) && !empty( $array['conditional_action4'] ) && !empty( $array['conditional_operator4'] ) ) {
$array['conditional_value4'] = ! empty( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
}
return $array;
}
add_filter('um_admin_pre_save_field_to_form', 'um_admin_pre_save_field_to_form', 1 );
/**
* Some fields may require extra fields before saving
*
* @param $array
*
* @return mixed
*/
function um_admin_pre_save_fields_hook( $array ) {
extract( $array );
/**
* UM hook
*
* @type filter
* @title um_fields_without_metakey
* @description Field Types without meta key
* @input_vars
* [{"var":"$types","type":"array","desc":"Field Types"}]
* @change_log
* ["Since: 2.0"]
* @usage add_filter( 'um_fields_without_metakey', 'function_name', 10, 1 );
* @example
* <?php
* add_filter( 'um_fields_without_metakey', 'my_fields_without_metakey', 10, 1 );
* function my_fields_without_metakey( $types ) {
* // your code here
* return $types;
* }
* ?>
*/
$fields_without_metakey = apply_filters( 'um_fields_without_metakey', array(
'block',
'shortcode',
'spacing',
'divider',
'group'
) );
$fields = UM()->query()->get_attr('custom_fields', $form_id);
$count = 1;
if ( isset( $fields ) && !empty( $fields) ) $count = count($fields)+1;
// set unique meta key
if ( in_array( $field_type, $fields_without_metakey ) && !isset($array['post']['_metakey']) ) {
$array['post']['_metakey'] = "um_{$field_type}_{$form_id}_{$count}";
}
// set position
if ( !isset( $array['post']['_position'] ) ) {
$array['post']['_position'] = $count;
}
return $array;
}
add_filter('um_admin_pre_save_fields_hook', 'um_admin_pre_save_fields_hook', 1 );
/**
* Apply a filter to handle errors for field updating in backend
*
* @param $errors
* @param $array
*
* @return mixed
*/
function um_admin_field_update_error_handling( $errors, $array ){
extract( $array );
$field_attr = UM()->builtin()->get_core_field_attrs( $field_type );
if ( isset( $field_attr['validate'] ) ) {
$validate = $field_attr['validate'];
foreach ( $validate as $post_input => $arr ) {
$mode = $arr['mode'];
switch ( $mode ) {
case 'numeric':
if ( !empty( $array['post'][$post_input] ) && !is_numeric( $array['post'][$post_input] ) ){
$errors[$post_input] = $validate[$post_input]['error'];
}
break;
case 'unique':
if ( !isset( $array['post']['edit_mode'] ) ) {
if ( UM()->builtin()->unique_field_err( $array['post'][$post_input] ) ) {
$errors[$post_input] = UM()->builtin()->unique_field_err( $array['post'][$post_input] );
}
}
break;
case 'required':
if ( $array['post'][$post_input] == '' )
$errors[$post_input] = $validate[$post_input]['error'];
break;
case 'range-start':
if ( UM()->builtin()->date_range_start_err( $array['post'][$post_input] ) && $array['post']['_range'] == 'date_range' )
$errors[$post_input] = UM()->builtin()->date_range_start_err( $array['post'][$post_input] );
break;
case 'range-end':
if ( UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] ) && $array['post']['_range'] == 'date_range' )
$errors[$post_input] = UM()->builtin()->date_range_end_err( $array['post'][$post_input], $array['post']['_range_start'] );
break;
}
}
}
return $errors;
}
add_filter('um_admin_field_update_error_handling', 'um_admin_field_update_error_handling', 1, 2 );
/**
* Filter validation types on loop
*
* @param $break
* @param $key
* @param $form_id
* @param $field_array
*
* @return bool
*/
function um_builtin_validation_types_continue_loop( $break, $key, $form_id, $field_array ) {
// show unique username validation only for user_login field
if ( isset( $field_array['metakey'] ) && $field_array['metakey'] == 'user_login' && $key !== 'unique_username' ) {
return false;
}
return $break;
}
add_filter( 'um_builtin_validation_types_continue_loop', 'um_builtin_validation_types_continue_loop', 1, 4 );
/**
* @param $hide
*
* @return bool
*/
function um_hide_metabox_restrict_content_shop( $hide ) {
if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
$_GET['post'] == wc_get_page_id( 'shop' ) ) {
return true;
}
return $hide;
}
add_filter( 'um_restrict_content_hide_metabox', 'um_hide_metabox_restrict_content_shop', 10, 1 );
+1 -1
View File
@@ -11,7 +11,7 @@
'type' => 'checkbox',
'label' => __( 'Can view default homepage?', 'ultimate-member' ),
'tooltip' => __( 'Allow this user role to view your site\'s homepage', 'ultimate-member' ),
'value' => ! empty( $role['_um_default_homepage'] ) ? $role['_um_default_homepage'] : 1,
'value' => isset( $role['_um_default_homepage'] ) ? $role['_um_default_homepage'] : 1,
),
array(
'id' => '_um_redirect_homepage',
@@ -114,6 +114,8 @@ if ( ! empty( $_POST['role'] ) ) {
update_option( "um_role_{$id}_meta", $role_meta );
UM()->user()->remove_cache_all_users();
um_js_redirect( $redirect );
}
}
+13 -1
View File
@@ -427,6 +427,19 @@ if ( ! class_exists( 'um\Config' ) ) {
'recipient' => 'user',
'default_active' => true
),
'changedaccount_email' => array(
'key' => 'changedaccount_email',
'title' => __( 'Account Updated Email','ultimate-member' ),
'subject' => 'Your account at {site_name} was updated',
'body' => 'Hi {display_name},<br /><br />' .
'You recently updated your {site_name} account.<br /><br />' .
'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
'Thanks,<br />' .
'{site_name}',
'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
'recipient' => 'user',
'default_active'=> true
),
'notification_new_user' => array(
'key' => 'notification_new_user',
'title' => __( 'New User Notification','ultimate-member' ),
@@ -516,7 +529,6 @@ if ( ! class_exists( 'um\Config' ) ) {
'cover_min_width' => 1000,
'profile_photo_max_size' => 999999999,
'cover_photo_max_size' => 999999999,
'menu_item_workaround' => 0,
'custom_roles_increment' => 1,
);
+3 -3
View File
@@ -47,14 +47,14 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
'private-content' => '2.0',
'profile-completeness' => '2.0.1',
'recaptcha' => '2.0',
'reviews' => '2.0.2',
'reviews' => '2.0.3',
'social-activity' => '2.0.1',
'social-login' => '2.0.1',
'terms-conditions' => '2.0',
'user-location' => '2.0',
'user-tags' => '2.0',
'verified-users' => '2.0',
'woocommerce' => '2.0',
'verified-users' => '2.0.1',
'woocommerce' => '2.0.1',
'restrict-content' => '2.0',
'beaver-builder' => '2.0',
);
+27
View File
@@ -343,5 +343,32 @@ if ( ! class_exists( 'UM_Functions' ) ) {
return apply_filters( 'um_locate_template', $template, $template_name, $path );
}
function cpt_list() {
/**
* UM hook
*
* @type filter
* @title um_cpt_list
* @description Extend UM Custom Post Types
* @input_vars
* [{"var":"$list","type":"array","desc":"Custom Post Types list"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_cpt_list', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_cpt_list', 'my_cpt_list', 10, 1 );
* function my_admin_pending_queue( $list ) {
* // your code here
* return $list;
* }
* ?>
*/
$cpt = apply_filters( 'um_cpt_list', array( 'um_form', 'um_directory' ) );
return $cpt;
}
}
}
+37 -27
View File
@@ -1,6 +1,5 @@
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
if ( ! class_exists( 'UM' ) ) {
@@ -14,7 +13,6 @@ if ( ! class_exists( 'UM' ) ) {
* @method UM_Followers_API Followers_API()
* @method UM_Friends_API Friends_API()
* @method UM_Instagram_API Instagram_API()
* @method UM_Invitations_API Invitations_API()
* @method UM_Mailchimp_API Mailchimp_API()
* @method UM_Messaging_API Messaging_API()
* @method UM_myCRED_API myCRED_API()
@@ -72,8 +70,9 @@ if ( ! class_exists( 'UM' ) ) {
* @return UM - Main instance
*/
static public function instance() {
if ( is_null( self::$instance ) )
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
@@ -186,14 +185,14 @@ if ( ! class_exists( 'UM' ) ) {
'sv_SE' => 'Svenska',
'pl_PL' => 'Polski',
'cs_CZ' => 'Czech',
'el' => 'Greek',
'el' => 'Greek',
'id_ID' => 'Indonesian',
'zh_CN' => '简体中文',
'ru_RU' => 'Русский',
'tr_TR' => 'Türkçe',
'fa_IR' => 'Farsi',
'he_IL' => 'Hebrew',
'ar' => 'العربية',
'ar' => 'العربية',
);
/**
@@ -275,7 +274,7 @@ if ( ! class_exists( 'UM' ) ) {
// include hook files
add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
//add_action( 'init', array( &$this, 'old_extensions_notice' ), 0 );
//run activation
register_activation_hook( um_plugin, array( &$this, 'activation' ) );
@@ -294,7 +293,7 @@ if ( ! class_exists( 'UM' ) ) {
/**
* Show notice for customers with old extension's versions
*/
function old_extensions_notice() {
/*function old_extensions_notice() {
if ( ! is_admin() ) {
return;
}
@@ -326,10 +325,10 @@ if ( ! class_exists( 'UM' ) ) {
/*global $um_woocommerce;
remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
$um_woocommerce->plugin_inactive = true;*/
$um_woocommerce->plugin_inactive = true;*
echo '<div class="error"><p>' . sprintf( __( '<strong>%s %s</strong> requires 2.0 extensions. You have pre 2.0 extensions installed on your site. <br /> Please update %s extensions to latest versions. For more info see this <a href="%s" target="_blank">doc</a>.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, ultimatemember_plugin_name, 'http://docs.ultimatemember.com/article/266-updating-to-2-0-versions-of-extensions' ) . '</p></div>';
}
}*/
/**
@@ -373,18 +372,41 @@ if ( ! class_exists( 'UM' ) ) {
* @since 2.0
*/
function activation() {
if ( is_multisite() ) {
//get all blogs
$blogs = get_sites();
if ( ! empty( $blogs ) ) {
foreach( $blogs as $blog ) {
switch_to_blog( $blog->blog_id );
//make activation script for each sites blog
$this->single_site_activation();
restore_current_blog();
}
}
} else {
$this->single_site_activation();
}
}
/**
* Single site plugin activation handler
*/
function single_site_activation() {
//first install
$version = get_option( 'um_version' );
if ( ! $version ) {
update_option( 'um_last_version_upgrade', ultimatemember_version );
//show avatars on first install
if ( ! get_option( 'show_avatars' ) )
if ( ! get_option( 'show_avatars' ) ) {
update_option( 'show_avatars', 1 );
}
}
if ( $version != ultimatemember_version )
if ( $version != ultimatemember_version ) {
update_option( 'um_version', ultimatemember_version );
}
//run setup
$this->common()->create_post_types();
@@ -407,6 +429,7 @@ if ( ! class_exists( 'UM' ) ) {
$this->admin();
$this->ajax_init();
$this->metabox();
$this->admin_upgrade()->init_packages_ajax_handlers();
} elseif ( $this->is_request( 'admin' ) ) {
$this->admin();
$this->admin_menu();
@@ -414,7 +437,6 @@ if ( ! class_exists( 'UM' ) ) {
$this->admin_settings();
$this->columns();
$this->admin_enqueue();
$this->functions();
$this->metabox();
$this->notices();
$this->users();
@@ -589,19 +611,6 @@ if ( ! class_exists( 'UM' ) ) {
}
/**
* @since 2.0
*
* @return um\admin\core\Admin_Functions()
*/
function functions() {
if ( empty( $this->classes['admin_functions'] ) ) {
$this->classes['admin_functions'] = new um\admin\core\Admin_Functions();
}
return $this->classes['admin_functions'];
}
/**
* @since 2.0
*
@@ -1226,5 +1235,6 @@ function UM() {
return UM::instance();
}
// Global for backwards compatibility.
$GLOBALS['ultimatemember'] = UM();
+22 -6
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Access' ) ) {
if ( ! class_exists( 'um\core\Access' ) ) {
/**
@@ -322,8 +322,9 @@ if ( ! class_exists( 'Access' ) ) {
//if current page not in exclude URLs
//get redirect URL if not set get login page by default
$redirect = UM()->options()->get( 'access_redirect' );
if ( ! $redirect )
if ( ! $redirect ) {
$redirect = um_get_core_page( 'login' );
}
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), $redirect ) ), 'global' );
} else {
@@ -567,7 +568,7 @@ if ( ! class_exists( 'Access' ) ) {
* Restrict content new logic
*
* @param $posts
* @param $query
* @param \WP_Query $query
* @return array
*/
function filter_protected_posts( $posts, $query ) {
@@ -581,6 +582,13 @@ if ( ! class_exists( 'Access' ) ) {
//other filter
foreach ( $posts as $post ) {
//Woocommerce AJAX fixes....remove filtration on wc-ajax which goes to Front Page
if ( ! empty( $_GET['wc-ajax'] ) /*&& $query->is_front_page()*/ ) {
$filtered_posts[] = $post;
continue;
}
$restriction = $this->get_post_privacy_settings( $post );
if ( ! $restriction ) {
@@ -588,6 +596,8 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
$is_singular = $query->is_singular();
//post is private
if ( '0' == $restriction['_um_accessible'] ) {
$filtered_posts[] = $post;
@@ -595,6 +605,8 @@ if ( ! class_exists( 'Access' ) ) {
} elseif ( '1' == $restriction['_um_accessible'] ) {
//if post for not logged in users and user is not logged in
if ( ! is_user_logged_in() ) {
$this->singular_page = true;
$filtered_posts[] = $post;
continue;
} else {
@@ -604,7 +616,7 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
if ( empty( $query->is_singular ) ) {
if ( empty( $is_singular ) ) {
//if not single query when exclude if set _um_access_hide_from_queries
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
@@ -691,6 +703,8 @@ if ( ! class_exists( 'Access' ) ) {
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
if ( $custom_restrict ) {
$this->singular_page = true;
$filtered_posts[] = $post;
continue;
}
@@ -698,12 +712,14 @@ if ( ! class_exists( 'Access' ) ) {
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
$this->singular_page = true;
$filtered_posts[] = $post;
continue;
}
}
if ( empty( $query->is_singular ) ) {
if ( empty( $is_singular ) ) {
//if not single query when exclude if set _um_access_hide_from_queries
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
@@ -790,7 +806,7 @@ if ( ! class_exists( 'Access' ) ) {
}
} else {
if ( empty( $query->is_singular ) ) {
if ( empty( $is_singular ) ) {
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Account' ) ) {
if ( ! class_exists( 'um\core\Account' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if executed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'AJAX_Common' ) ) {
if ( ! class_exists( 'um\core\AJAX_Common' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Builtin' ) ) {
if ( ! class_exists( 'um\core\Builtin' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Chart' ) ) {
if ( ! class_exists( 'um\core\Chart' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Common' ) ) {
if ( ! class_exists( 'um\core\Common' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Cron' ) ) {
if ( ! class_exists( 'um\core\Cron' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Date_Time' ) ) {
if ( ! class_exists( 'um\core\Date_Time' ) ) {
/**
+31 -29
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Enqueue' ) ) {
if ( ! class_exists( 'um\core\Enqueue' ) ) {
/**
@@ -73,45 +73,47 @@ if ( ! class_exists( 'Enqueue' ) ) {
function wp_enqueue_scripts() {
global $post;
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined('UM_SCRIPT_DEBUG') ) ? '' : '.min';
$exclude = UM()->options()->get( 'js_css_exclude' );
if ( is_array( $exclude ) ) {
array_filter( $exclude );
}
if ( $exclude && !is_admin() && is_array( $exclude ) ) {
$this->suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'UM_SCRIPT_DEBUG' ) ) ? '' : '.min';
if ( ! is_admin() ) {
$c_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
foreach( $exclude as $match ) {
if ( ! empty( $c_url ) && strstr( $c_url, untrailingslashit( $match ) ) ) {
return;
}
$exclude = UM()->options()->get( 'js_css_exclude' );
if ( is_array( $exclude ) ) {
array_filter( $exclude );
}
}
$include = UM()->options()->get('js_css_include');
if ( is_array( $include ) ) {
array_filter( $include );
}
if ( $include && !is_admin() && is_array( $include ) ) {
$c_url = UM()->permalinks()->get_current_url( get_option('permalink_structure') );
foreach( $include as $match ) {
if ( strstr( $c_url, untrailingslashit( $match ) ) ) {
$force_load = true;
} else {
if ( !isset( $force_load ) ) {
$force_load = false;
if ( $exclude && is_array( $exclude ) ) {
foreach ( $exclude as $match ) {
$sub_match = untrailingslashit( $match );
if ( ! empty( $c_url ) && ! empty( $sub_match ) && strstr( $c_url, $sub_match ) ) {
return;
}
}
}
$include = UM()->options()->get( 'js_css_include' );
if ( is_array( $include ) ) {
array_filter( $include );
}
if ( $include && is_array( $include ) ) {
foreach ( $include as $match ) {
$sub_match = untrailingslashit( $match );
if ( ! empty( $c_url ) && ! empty( $sub_match ) && strstr( $c_url, $sub_match ) ) {
$force_load = true;
} else {
if ( ! isset( $force_load ) ) {
$force_load = false;
}
}
}
}
}
if ( isset($force_load) && $force_load == false ) return;
if ( isset( $force_load ) && $force_load == false ) {
return;
}
/**
* UM hook
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'External_Integrations' ) ) {
if ( ! class_exists( 'um\core\External_Integrations' ) ) {
/**
+9 -9
View File
@@ -5,7 +5,7 @@ namespace um\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Fields' ) ) {
if ( ! class_exists( 'um\core\Fields' ) ) {
/**
@@ -448,18 +448,18 @@ if ( ! class_exists( 'Fields' ) ) {
$label = apply_filters( 'um_edit_label_all_fields', $label, $data );
}
$output .= '<label for="' . $key . UM()->form()->form_suffix . '">' . __( $label, UM_TEXTDOMAIN ) . '</label>';
$output .= '<label for="' . $key . UM()->form()->form_suffix . '">' . __( $label, 'ultimate-member' ) . '</label>';
if (isset( $data['help'] ) && !empty( $data['help'] ) && $this->viewing == false && !strstr( $key, 'confirm_user_pass' )) {
if (!UM()->mobile()->isMobile()) {
if (!isset( $this->disable_tooltips )) {
$output .= '<span class="um-tip um-tip-w" title="' . __( $data['help'], UM_TEXTDOMAIN ) . '"><i class="um-icon-help-circled"></i></span>';
$output .= '<span class="um-tip um-tip-w" title="' . __( $data['help'], 'ultimate-member' ) . '"><i class="um-icon-help-circled"></i></span>';
}
}
if (UM()->mobile()->isMobile() || isset( $this->disable_tooltips )) {
$output .= '<span class="um-tip-text">' . __( $data['help'], UM_TEXTDOMAIN ) . '</span>';
$output .= '<span class="um-tip-text">' . __( $data['help'], 'ultimate-member' ) . '</span>';
}
}
@@ -2561,7 +2561,7 @@ if ( ! class_exists( 'Fields' ) ) {
$field_value = $v;
}
$output .= '>' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</option>';
$output .= '>' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</option>';
}
@@ -2876,7 +2876,7 @@ if ( ! class_exists( 'Fields' ) ) {
$output .= ' />';
$output .= '<span class="um-field-radio-state"><i class="' . $class . '"></i></span>';
$output .= '<span class="um-field-radio-option">' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</span>';
$output .= '<span class="um-field-radio-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
$output .= '</label>';
if ($i % 2 == 0) {
@@ -3030,7 +3030,7 @@ if ( ! class_exists( 'Fields' ) ) {
* ?>
*/
$um_field_checkbox_item_title = apply_filters( "um_field_checkbox_item_title", $um_field_checkbox_item_title, $key, $v, $data );
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</span>';
$output .= '<span class="um-field-checkbox-option">' . __( $um_field_checkbox_item_title, 'ultimate-member' ) . '</span>';
$output .= '</label>';
if ($i % 2 == 0) {
@@ -3075,7 +3075,7 @@ if ( ! class_exists( 'Fields' ) ) {
if (!empty( $fields )) {
$output .= '<div class="um-field-group" data-max_entries="' . $max_entries . '">
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . __( $label, UM_TEXTDOMAIN ) . '</div>';
<div class="um-field-group-head"><i class="um-icon-plus"></i>' . __( $label, 'ultimate-member' ) . '</div>';
$output .= '<div class="um-field-group-body"><a href="#" class="um-field-group-cancel"><i class="um-icon-close"></i></a>';
foreach ($fields as $subkey => $subdata) {
@@ -3137,7 +3137,7 @@ if ( ! class_exists( 'Fields' ) ) {
global $wp_roles;
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
}, get_option( 'um_roles', array() ) );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
$roles = UM()->roles()->get_roles( false, $exclude_roles );
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Files' ) ) {
if ( ! class_exists( 'um\core\Files' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'FontIcons' ) ) {
if ( ! class_exists( 'um\core\FontIcons' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Form' ) ) {
if ( ! class_exists( 'um\core\Form' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Login' ) ) {
if ( ! class_exists( 'um\core\Login' ) ) {
class Login {
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Logout' ) ) {
if ( ! class_exists( 'um\core\Logout' ) ) {
/**
+27 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mail' ) ) {
if ( ! class_exists( 'um\core\Mail' ) ) {
/**
@@ -322,6 +322,32 @@ if ( ! class_exists( 'Mail' ) ) {
$message = ob_get_clean();
/**
* UM hook
*
* @type filter
* @title um_email_send_message_content
* @description Change email notification message content
* @input_vars
* [{"var":"$message","type":"string","desc":"Message Content"},
* {"var":"$template","type":"string","desc":"Template Key"},
* {"var":"$args","type":"string","desc":"Notification Arguments"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_email_send_message_content', 'function_name', 10, 3 ); ?>
* @example
* <?php
* add_filter( 'um_email_send_message_content', 'my_email_send_message_content', 10, 3 );
* function my_email_send_message_content( $message, $template, $args ) {
* // your code here
* return $message;
* }
* ?>
*/
$message = apply_filters( 'um_email_send_message_content', $message, $slug, $args );
// Convert tags in email template
return um_convert_tags( $message, $args );
}
+2 -3
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Members' ) ) {
if ( ! class_exists( 'um\core\Members' ) ) {
/**
@@ -366,7 +366,7 @@ if ( ! class_exists( 'Members' ) ) {
$query_args['paged'] = $members_page;
if ( ! um_user( 'can_view_all' ) && is_user_logged_in() ) {
if ( ! UM()->roles()->um_user_can( 'can_view_all' ) && is_user_logged_in() ) {
//unset( $query_args );
$query_args = array();
}
@@ -393,7 +393,6 @@ if ( ! class_exists( 'Members' ) ) {
do_action( 'um_user_before_query', $query_args );
$users = new \WP_User_Query( $query_args );
/**
* UM hook
*
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Modal' ) ) {
if ( ! class_exists( 'um\core\Modal' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Options' ) ) {
if ( ! class_exists( 'um\core\Options' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Password' ) ) {
if ( ! class_exists( 'um\core\Password' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Permalinks' ) ) {
if ( ! class_exists( 'um\core\Permalinks' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Plugin_Updater' ) ) {
if ( ! class_exists( 'um\core\Plugin_Updater' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Profile' ) ) {
if ( ! class_exists( 'um\core\Profile' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Query' ) ) {
if ( ! class_exists( 'um\core\Query' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Register' ) ) {
if ( ! class_exists( 'um\core\Register' ) ) {
/**
+5 -3
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'REST_API' ) ) {
if ( ! class_exists( 'um\core\REST_API' ) ) {
/**
@@ -1021,9 +1021,11 @@ if ( ! class_exists( 'REST_API' ) ) {
</tr>
</tbody>
</table>
<?php }
$content .= ob_get_clean();
<?php $content .= ob_get_clean();
}
return $content;
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Rewrite' ) ) {
if ( ! class_exists( 'um\core\Rewrite' ) ) {
/**
+19 -1
View File
@@ -5,7 +5,7 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Roles_Capabilities' ) ) {
if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
/**
@@ -280,6 +280,24 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
}
/**
* Remove user role
*
* @param $user_id
* @param $role
*/
function set_role_wp( $user_id, $role ) {
// Validate user id
$user = get_userdata( $user_id );
// User exists
if ( ! empty( $user ) ) {
// Remove role
$user->add_role( $role );
}
}
/**
* Set roles to user (remove all previous roles)
* make user only with $roles roles
+1 -1
View File
@@ -3,7 +3,7 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Router' ) ) {
if ( ! class_exists( 'um\core\Router' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Setup' ) ) {
if ( ! class_exists( 'um\core\Setup' ) ) {
/**
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Shortcodes' ) ) {
if ( ! class_exists( 'um\core\Shortcodes' ) ) {
/**
+1 -31
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Tracking' ) ) {
if ( ! class_exists( 'um\core\Tracking' ) ) {
/**
@@ -27,8 +27,6 @@ if ( ! class_exists( 'Tracking' ) ) {
$this->schedule_send();
add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 );
add_action( 'um_admin_do_action__opt_into_tracking', array( $this, 'um_admin_do_action__opt_into_tracking' ) );
add_action( 'um_admin_do_action__opt_out_of_tracking', array( $this, 'um_admin_do_action__opt_out_of_tracking' ) );
}
@@ -183,33 +181,5 @@ if ( ! class_exists( 'Tracking' ) ) {
add_action( 'um_daily_scheduled_events', array( $this, 'send_checkin' ) );
}
/**
* Show admin notices
*/
public function admin_notices() {
if( ! current_user_can( 'manage_options' ) )
return;
$hide_notice = get_option('um_tracking_notice');
if ( $hide_notice )
return;
$optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_into_tracking' ) );
$optout_url = esc_url( add_query_arg( 'um_adm_action', 'opt_out_of_tracking' ) );
echo '<div class="updated um-admin-notice"><p>';
printf( __( 'Thanks for installing <strong>%s</strong>! The core plugin is free but we also sell extensions which allow us to continue developing and supporting the plugin full time. If you subscribe to our mailing list (no spam) we will email you a 20%% discount code which you can use to purchase the <a href="%s" target="_blank">extensions bundle</a>.', 'ultimate-member' ), ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' );
echo '</p>';
echo '<p><a href="' . esc_url( $optin_url ) . '" class="button button-primary">' . __( 'Subscribe to mailing list', 'ultimate-member' ) . '</a>';
echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'No thanks', 'ultimate-member' ) . '</a></p></div>';
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'User_posts' ) ) {
if ( ! class_exists( 'um\core\User_posts' ) ) {
/**
+20 -5
View File
@@ -5,7 +5,7 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'User' ) ) {
if ( ! class_exists( 'um\core\User' ) ) {
/**
@@ -650,6 +650,15 @@ if ( ! class_exists( 'User' ) ) {
}
/**
* Remove cache for all users
*/
function remove_cache_all_users() {
global $wpdb;
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
}
/**
* This method lets you set a user. For example, to retrieve a profile or anything related to that user.
*
@@ -1306,8 +1315,14 @@ if ( ! class_exists( 'User' ) ) {
// send email notifications
if ( $send_mail ) {
UM()->mail()->send( um_user('user_email'), 'deletion_email' );
UM()->mail()->send( um_admin_email(), 'notification_deletion', array('admin' => true ) );
UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
}
}
}
// remove uploads
@@ -1316,7 +1331,7 @@ if ( ! class_exists( 'User' ) ) {
// remove user
if ( is_multisite() ) {
if ( !function_exists('wpmu_delete_user') ) {
if ( ! function_exists( 'wpmu_delete_user' ) ) {
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
}
@@ -1324,7 +1339,7 @@ if ( ! class_exists( 'User' ) ) {
} else {
if ( !function_exists('wp_delete_user') ) {
if ( ! function_exists( 'wp_delete_user' ) ) {
require_once( ABSPATH . 'wp-admin/includes/user.php' );
}
+1 -1
View File
@@ -4,7 +4,7 @@ namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Validation' ) ) {
if ( ! class_exists( 'um\core\Validation' ) ) {
/**
+56 -33
View File
@@ -162,39 +162,37 @@ function um_submit_account_details( $args ) {
if ( 'delete' == $current_tab && isset( $_POST['single_user_password'] ) && wp_check_password( $_POST['single_user_password'], $user->data->user_pass, $user->data->ID ) ) {
if ( current_user_can( 'delete_users' ) || um_user( 'can_delete_profile' ) ) {
if ( ! um_user( 'super_admin' ) ) {
UM()->user()->delete();
UM()->user()->delete();
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) == 'redirect_home' ) {
um_redirect_home();
} elseif ( um_user( 'delete_redirect_url' ) ) {
/**
* UM hook
*
* @type filter
* @title um_delete_account_redirect_url
* @description Change redirect URL after delete account
* @input_vars
* [{"var":"$url","type":"string","desc":"Redirect URL"},
* {"var":"$id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_delete_account_redirect_url', 'function_name', 10, 2 ); ?>
* @example
* <?php
* add_filter( 'um_delete_account_redirect_url', 'my_delete_account_redirect_url', 10, 2 );
* function my_delete_account_redirect_url( $url, $id ) {
* // your code here
* return $url;
* }
* ?>
*/
$redirect_url = apply_filters( 'um_delete_account_redirect_url', um_user( 'delete_redirect_url' ), um_user( 'ID' ) );
exit( wp_redirect( $redirect_url ) );
} else {
um_redirect_home();
}
if ( um_user( 'after_delete' ) && um_user( 'after_delete' ) == 'redirect_home' ) {
um_redirect_home();
} elseif ( um_user( 'delete_redirect_url' ) ) {
/**
* UM hook
*
* @type filter
* @title um_delete_account_redirect_url
* @description Change redirect URL after delete account
* @input_vars
* [{"var":"$url","type":"string","desc":"Redirect URL"},
* {"var":"$id","type":"int","desc":"User ID"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_delete_account_redirect_url', 'function_name', 10, 2 ); ?>
* @example
* <?php
* add_filter( 'um_delete_account_redirect_url', 'my_delete_account_redirect_url', 10, 2 );
* function my_delete_account_redirect_url( $url, $id ) {
* // your code here
* return $url;
* }
* ?>
*/
$redirect_url = apply_filters( 'um_delete_account_redirect_url', um_user( 'delete_redirect_url' ), um_user( 'ID' ) );
exit( wp_redirect( $redirect_url ) );
} else {
um_redirect_home();
}
}
}
@@ -416,4 +414,29 @@ add_action( 'wp_footer', 'um_account_secure_registered_fields' );
function um_after_user_account_updated_permalink( $user_id, $changed ) {
UM()->user()->generate_profile_slug( $user_id );
}
add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 );
add_action( 'um_after_user_account_updated', 'um_after_user_account_updated_permalink', 10, 2 );
/**
* Update Account Email Notification
*
* @param $user_id
* @param $changed
*/
function um_account_updated_notification( $user_id, $changed ) {
um_fetch_user( $user_id );
UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
}
add_action( 'um_after_user_account_updated', 'um_account_updated_notification', 20, 2 );
/**
* Disable WP native email notification when change email on user account
*
* @param $user_id
* @param $changed
*/
function um_disable_native_email_notificatiion( $changed, $user_id ) {
add_filter( 'send_email_change_email', '__return_false' );
}
add_action( 'um_account_pre_update_profile', 'um_disable_native_email_notificatiion', 10, 2 );
+9 -4
View File
@@ -115,10 +115,15 @@ add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
function um_send_registration_notification( $user_id, $args ) {
um_fetch_user( $user_id );
if ( um_user( 'status' ) != 'pending' ) {
UM()->mail()->send( um_admin_email(), 'notification_new_user', array( 'admin' => true ) );
} else {
UM()->mail()->send( um_admin_email(), 'notification_review', array( 'admin' => true ) );
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
if ( um_user( 'status' ) != 'pending' ) {
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
} else {
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
}
}
}
}
add_action( 'um_registration_complete', 'um_send_registration_notification', 10, 2 );
@@ -4,7 +4,7 @@ namespace um\lib\mobiledetect;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Um_Mobile_Detect' ) ) {
if ( ! class_exists( 'um\lib\mobiledetect\Um_Mobile_Detect' ) ) {
class Um_Mobile_Detect {
/**
* Mobile detection type.
+2 -1
View File
@@ -2,7 +2,8 @@
/**
* Deprecated functions
*
* Where functions come to die.
* Where public functions come to die.
*
*
*/
+34 -3
View File
@@ -1,7 +1,7 @@
<?php
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
//Make public functions without class creation
/**
@@ -860,6 +860,10 @@ function um_get_core_page( $slug, $updated = false ) {
function um_is_core_page( $page ) {
global $post;
if ( empty( $post ) ) {
return false;
}
if ( isset( $post->ID ) && isset( UM()->config()->permalinks[ $page ] ) && $post->ID == UM()->config()->permalinks[ $page ] )
return true;
@@ -1400,6 +1404,23 @@ function um_admin_email() {
}
/**
* Get admin e-mails
*
* @return array
*/
function um_multi_admin_email() {
$emails = UM()->options()->get( 'admin_email' );
$emails_array = explode( ',', $emails );
if ( ! empty( $emails_array ) ) {
$emails_array = array_map( 'trim', $emails_array );
}
return $emails_array;
}
/**
* Display a link to profile page
*
@@ -2386,4 +2407,14 @@ function is_ultimatemember() {
return true;
return false;
}
/**
* Maybe set empty time limit
*/
function um_maybe_unset_time_limit() {
if ( ! ini_get( 'safe_mode' ) ) {
@set_time_limit(0);
}
}
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
<?php
?>
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
<div style="color: #444444;font-weight: normal;">
<div style="text-align: center;font-weight:600;font-size:26px;padding: 10px 0;border-bottom: solid 3px #eeeeee;">{site_name}</div>
<div style="clear:both"></div>
</div>
<div style="padding: 0 30px 30px 30px;border-bottom: 3px solid #eeeeee;">
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">You recently updated your account.</div>
<div style="padding: 10px 0 50px 0;text-align: center;"><a href="{user_account_link}" style="background: #555555;color: #fff;padding: 12px 30px;text-decoration: none;border-radius: 3px;letter-spacing: 0.3px;">Go to your Account</a></div>
<div style="padding: 15px;background: #eee;border-radius: 3px;text-align: center;">If you did not make this change and believe your account has been compromised, please <a href="mailto:{admin_email}" style="color: #3ba1da;text-decoration: none;">contact us</a> ASAP.</div>
</div>
<div style="color: #999;padding: 20px 30px">
<div style="">Thank you!</div>
<div style="">The <a href="{site_url}" style="color: #3ba1da;text-decoration: none;">{site_name}</a> Team</div>
</div>
</div>
+7 -1
View File
@@ -3,7 +3,7 @@
Plugin Name: Ultimate Member
Plugin URI: http://ultimatemember.com/
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
Version: 2.0.2
Version: 2.0.4
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member
@@ -15,7 +15,13 @@ defined( 'ABSPATH' ) || exit;
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$plugin_data = get_plugin_data( __FILE__ );
/**
* Textdomain constant backward compatibility will be removed in future releases
*
* @todo remove in future releases
*/
define( 'UM_TEXTDOMAIN', 'ultimate-member' );
define( 'um_url', plugin_dir_url( __FILE__ ) );
define( 'um_path', plugin_dir_path( __FILE__ ) );
define( 'um_plugin', plugin_basename( __FILE__ ) );