mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge branch 'feature/ajax_upgrade_process'
This commit is contained in:
@@ -144,39 +144,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-color: #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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1131,8 +1131,8 @@ if ( ! class_exists( 'um\admin\core\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' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
||||
* @var
|
||||
*/
|
||||
var $update_versions;
|
||||
var $update_packages;
|
||||
var $necessary_packages;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,18 +36,249 @@ if ( ! class_exists( 'um\admin\core\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 ) ) {
|
||||
add_action( 'admin_notices', array( $this, 'need_upgrade' ) );
|
||||
|
||||
if ( ! $um_last_version_upgrade || version_compare( $um_last_version_upgrade, ultimatemember_version, '<' ) )
|
||||
add_action( 'admin_init', array( $this, 'packages' ), 10 );
|
||||
$this->init_packages_ajax();
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ), 0 );
|
||||
|
||||
add_action( 'wp_ajax_um_run_package', array( $this, 'ajax_run_package' ) );
|
||||
add_action( 'wp_ajax_um_get_packages', array( $this, 'ajax_get_packages' ) );
|
||||
} else {
|
||||
add_action( 'admin_notices', array( $this, 'updated_successfully' ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function need_upgrade() {
|
||||
?>
|
||||
<div class="error"><p><?php printf( __( '<strong>%s version %s</strong> needs to be updated. Please visit to "Upgrade" page <a href="%s">here</a> and run the upgrade process.', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_version, add_query_arg( array( 'page' => 'um_upgrade' ), admin_url( 'admin.php' ) ) ) ?></p></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
function updated_successfully() {
|
||||
if ( isset( $_GET['msg'] ) && 'updated' == $_GET['msg'] ) { ?>
|
||||
<div class="updated"><p><?php _e( 'Successfully Upgraded', 'ultimate-member' ) ?></p></div>
|
||||
<?php }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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' ); ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e( 'Ultimate Member - Upgrade Process', 'ultimate-member' ) ?></h2>
|
||||
<p>You have installed <?php echo ultimatemember_version ?> you need to upgrade your previous <?php echo $um_last_version_upgrade ?></p>
|
||||
<h4>Upgrade Log</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 +303,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Upgrade' ) ) {
|
||||
update_option( 'um_last_version_upgrade', $update_version );
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,6 +326,31 @@ if ( ! class_exists( 'um\admin\core\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
|
||||
|
||||
@@ -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' ) );
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'usermetaquery1339' => 'usermetaquery1339',
|
||||
);
|
||||
+30
@@ -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>
|
||||
Vendored
-6
@@ -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,134 @@
|
||||
<?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
|
||||
) );
|
||||
|
||||
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,41 @@
|
||||
<?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 ) {
|
||||
$setting_value = UM()->options()->get( $email_key );
|
||||
|
||||
UM()->mail()->copy_email_template( $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,290 @@
|
||||
<?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'
|
||||
) );
|
||||
|
||||
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'
|
||||
) );
|
||||
|
||||
|
||||
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,20 @@
|
||||
<?php
|
||||
$roles_associations = get_option( 'um_roles_associations' );
|
||||
|
||||
$mc_lists = get_posts( array(
|
||||
'post_type' => 'um_mailchimp',
|
||||
'numberposts' => -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,17 @@
|
||||
<?php
|
||||
$roles_associations = get_option( 'um_roles_associations' );
|
||||
|
||||
$um_social_login = get_posts( array(
|
||||
'post_type' => 'um_social_login',
|
||||
'numberposts' => -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,868 @@
|
||||
<?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(
|
||||
'key' => '_um_register_use_globals',
|
||||
'value' => true
|
||||
)
|
||||
),
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
|
||||
$login_forms = $forms_query->query( array(
|
||||
'post_type' => 'um_form',
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => '_um_mode',
|
||||
'value' => 'login'
|
||||
),
|
||||
array(
|
||||
'key' => '_um_login_use_globals',
|
||||
'value' => true
|
||||
)
|
||||
),
|
||||
'fields' => 'ids'
|
||||
) );
|
||||
|
||||
$profile_forms = $forms_query->query( array(
|
||||
'post_type' => 'um_form',
|
||||
'meta_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'key' => '_um_mode',
|
||||
'value' => 'profile'
|
||||
),
|
||||
array(
|
||||
'key' => '_um_profile_use_globals',
|
||||
'value' => true
|
||||
)
|
||||
),
|
||||
'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,59 @@
|
||||
<?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 = get_posts( array(
|
||||
'post_type' => 'um_form',
|
||||
'numberposts' => -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"
|
||||
$member_directories = get_posts( array(
|
||||
'post_type' => 'um_directory',
|
||||
'numberposts' => -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 );
|
||||
@@ -430,6 +430,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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2386,4 +2390,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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user