Merge pull request #1432 from ultimatemember/development/2.8.x

Version 2.8.3
This commit is contained in:
Mykyta Synelnikov
2024-02-19 11:44:40 +02:00
committed by GitHub
74 changed files with 3437 additions and 3642 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ GNU Version 2 or Any Later Version
### IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSION 2.6.7 PATCHES SECURITY PRIVILEGE ESCALATION VULNERABILITY. PLEASE SEE [THIS ARTICLE](https://docs.ultimatemember.com/article/1866-security-incident-update-and-recommended-actions) FOR MORE INFORMATION
[Official Release Version: 2.8.2](https://github.com/ultimatemember/ultimatemember/releases/tag/2.8.2).
[Official Release Version: 2.8.3](https://github.com/ultimatemember/ultimatemember/releases/tag/2.8.3).
## Changelog
+6 -6
View File
@@ -1,9 +1,6 @@
.um-form-table .um-forms-line[data-conditional] {
display: none; }
.um-form-table .um-forms-line[data-field_type="checkbox"] td label {
font-style: italic; }
.um-form-table .um-forms-line label .um-req {
color: #a00;
margin: 0 0 0 3px;
@@ -68,9 +65,12 @@
display: block;
margin: 0 0 5px 0; }
.um-form-table .description {
font-style: italic;
clear: both; }
.um-external-link-icon {
width: 1em;
height: 1em;
margin: 0;
vertical-align: middle;
fill: currentcolor; }
.um_admin_fonticon_wrapper {
display: flex;
+1 -1
View File
File diff suppressed because one or more lines are too long
+11 -7
View File
@@ -7,10 +7,6 @@
.#{$prefix}forms-line
&[data-conditional]
display: none
&[data-field_type="checkbox"]
td
label
font-style: italic
label
.#{$prefix}req
color: $required-asterisk
@@ -88,6 +84,7 @@
label
margin: 0 0 5px 0
display: inline-block
//font-weight: bold
&[data-field_type="icon"]
td
@@ -95,9 +92,16 @@
width: 100%
display: block
margin: 0 0 5px 0
.description
font-style: italic
clear: both
//.description
// font-style: italic
// clear: both
.um-external-link-icon
width: 1em
height: 1em
margin: 0
vertical-align: middle
fill: currentcolor
.um_admin_fonticon_wrapper
+flex( row, flex-start, center, nowrap )
+5
View File
@@ -32,3 +32,8 @@
float: left;
display: block;
line-height: 37px; }
#um-admin-form-publish #major-publishing-actions {
padding-top: 0;
padding-left: 0;
padding-right: 0; }
+1 -1
View File
@@ -1 +1 @@
#um-roles .row-actions .reset a{color:#a00}#um-roles .row-actions .reset a:hover{color:red}.wp-list-table.roles .column-core,.wp-list-table.roles .column-users{width:15%;text-align:center!important}.wp-list-table.roles .column-admin_access,.wp-list-table.roles .column-priority{width:10%;text-align:center!important}@media screen and (max-width:782px){.wp-list-table.roles .column-admin_access,.wp-list-table.roles .column-core,.wp-list-table.roles .column-priority,.wp-list-table.roles .column-users{text-align:left!important}}#um-admin-form-wp-capabilities .um-metadata-line th{width:auto}#um-admin-form-wp-capabilities .um-metadata-line td{width:20px}#um_edit_role #titlewrap>span{width:40px;font-size:24px;float:left;display:block;line-height:37px}
#um-roles .row-actions .reset a{color:#a00}#um-roles .row-actions .reset a:hover{color:red}.wp-list-table.roles .column-core,.wp-list-table.roles .column-users{width:15%;text-align:center!important}.wp-list-table.roles .column-admin_access,.wp-list-table.roles .column-priority{width:10%;text-align:center!important}@media screen and (max-width:782px){.wp-list-table.roles .column-admin_access,.wp-list-table.roles .column-core,.wp-list-table.roles .column-priority,.wp-list-table.roles .column-users{text-align:left!important}}#um-admin-form-wp-capabilities .um-metadata-line th{width:auto}#um-admin-form-wp-capabilities .um-metadata-line td{width:20px}#um_edit_role #titlewrap>span{width:40px;font-size:24px;float:left;display:block;line-height:37px}#um-admin-form-publish #major-publishing-actions{padding-top:0;padding-left:0;padding-right:0}
+7
View File
@@ -42,3 +42,10 @@
float: left
display: block
line-height: 37px
#um-admin-form-publish
#major-publishing-actions
padding-top: 0
padding-left: 0
padding-right: 0
+20 -22
View File
@@ -1,14 +1,3 @@
#um-settings-wrap .subsubsub {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
margin-left: -3px;
margin-right: -3px; }
#um-settings-wrap .subsubsub a {
margin: 0 3px; }
.um-settings-section .description {
font-style: italic; }
@@ -37,8 +26,8 @@
width: 25%; }
.column-configure {
width: 60px;
text-align: center; }
width: 10%;
text-align: right; }
th.column-email.column-primary {
padding-left: 48px; }
@@ -46,16 +35,19 @@ th.column-email.column-primary {
.um-form-table .um-forms-line td {
padding-right: 0; }
#um-settings-template-versions .wp-list-table .column-core_version {
width: 100px;
text-align: center; }
#um-settings-emails {
margin: 15px 0; }
#um-settings-template-versions .wp-list-table .column-theme_version {
width: 100px;
text-align: center; }
#um-settings-template-versions .wp-list-table .column-status {
width: 260px; }
#um-settings-template-versions {
margin: 15px 0; }
#um-settings-template-versions .wp-list-table .column-core_version {
width: 100px;
text-align: center; }
#um-settings-template-versions .wp-list-table .column-theme_version {
width: 100px;
text-align: center; }
#um-settings-template-versions .wp-list-table .column-status {
width: 260px; }
#um-settings-form {
float: left;
@@ -64,6 +56,12 @@ th.column-email.column-primary {
#um-settings-form .subsubsub {
float: left;
width: 100%; }
#um-settings-form h2.title a.um-back-button {
font-weight: normal;
font-size: 30px;
line-height: 1;
text-decoration: none;
margin-right: 5px; }
.um-settings-line .multi-checkbox-line {
float: left;
+1 -1
View File
@@ -1 +1 @@
#um-settings-wrap .subsubsub{display:flex;flex-direction:row;justify-content:flex-start;align-items:center;flex-wrap:wrap;margin-left:-3px;margin-right:-3px}#um-settings-wrap .subsubsub a{margin:0 3px}.um-settings-section .description{font-style:italic}.um-notification-status{margin-right:18px;font-size:28px;line-height:22px;color:#c74a4a;float:left;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-notification-status.um-notification-is-active{color:#7acf58}.um-email-configure span{line-height:24px}.um-long-field{width:100%}.um-medium-field{width:50%}.um-small-field{width:25%}.column-configure{width:60px;text-align:center}th.column-email.column-primary{padding-left:48px}.um-form-table .um-forms-line td{padding-right:0}#um-settings-template-versions .wp-list-table .column-core_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-theme_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-status{width:260px}#um-settings-form{float:left;width:100%;margin:0}#um-settings-form .subsubsub{float:left;width:100%}.um-settings-line .multi-checkbox-line{float:left;width:100%;clear:both;margin:0 0 10px 0;padding:0}.um-settings-line .multi-checkbox-column{float:left;margin:0;padding:0}.um-settings-line .multi-checkbox-column label{float:left;width:100%}.wrap-licenses .form-table,.wrap-licenses caption,.wrap-licenses tbody,.wrap-licenses td,.wrap-licenses tfoot,.wrap-licenses th,.wrap-licenses thead,.wrap-licenses tr{display:block}.wrap-licenses .form-table tr{float:left;margin:0 15px 15px 0;background:#fff;border:1px solid #ccc;width:30.5%;max-width:350px;padding:14px;min-height:240px;position:relative;box-sizing:border-box}.wrap-licenses .form-table th{background:#f9f9f9;padding:14px;border-bottom:1px solid #ccc;margin:-14px -14px 20px;width:100%}.wrap-licenses .form-table td{padding:0}.wrap-licenses td input.regular-text{margin:0 0 8px;width:100%}.wrap-licenses .edd-license-data[class*=edd-license-]{position:absolute;background:#fafafa;padding:14px;border-top:1px solid #eee;margin:20px -14px -14px;min-height:67px;width:100%;bottom:14px;box-sizing:border-box}.wrap-licenses .edd-license-data[class*=edd-license-] a{color:#444}.wrap-licenses .edd-license-data[class*=edd-license-] a:hover{text-decoration:none}.wrap-licenses .edd-license-data.license-expires-soon-notice{background-color:#00a0d2;color:#fff;border-color:#00a0d2}.wrap-licenses .edd-license-data.license-expires-soon-notice a{color:#fff}.wrap-licenses .edd-license-data.license-expires-soon-notice a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-expired{background-color:#e24e4e;color:#fff;border-color:#e24e4e}.wrap-licenses .edd-license-data.edd-license-expired a{color:#fff}.wrap-licenses .edd-license-data.edd-license-expired a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-valid{background-color:#5abc55;color:#fff;border-color:#5abc55}.wrap-licenses .edd-license-data.edd-license-error,.wrap-licenses .edd-license-data.edd-license-invalid,.wrap-licenses .edd-license-data.edd-license-item_name_mismatch,.wrap-licenses .edd-license-data.edd-license-missing,.wrap-licenses .edd-license-data.edd-license-site_inactive{background-color:#ffebcd;border-color:#ffebcd}.wrap-licenses .edd-license-data p{font-size:13px;margin-top:0}.wrap-licenses~p.submit{clear:both}@media screen and (max-width:980px){.wrap-licenses .form-table tr{width:calc(50% - 15px);max-width:none}}@media screen and (max-width:782px){#um-settings-template-versions .wp-list-table .column-core_version,#um-settings-template-versions .wp-list-table .column-theme_version{width:auto;text-align:left}.wrap-licenses .form-table tr{width:100%;margin-right:0;max-width:none}.um-settings-line .multi-checkbox-column{width:100%!important}.um-settings-line .multi-checkbox-column label{line-height:30px!important}.um-medium-field{width:100%}.um-small-field{width:50%}}.um_setting_ajax_button_response.complete{color:#7acf58;font-style:italic}.wp-core-ui .button.um_license_activate,.wp-core-ui .button.um_license_deactivate,.wp-core-ui .button.um_license_reactivate{margin-top:5px}.um-media-upload .um-media-upload-url{margin-bottom:5px}
.um-settings-section .description{font-style:italic}.um-notification-status{margin-right:18px;font-size:28px;line-height:22px;color:#c74a4a;float:left;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}.um-notification-status.um-notification-is-active{color:#7acf58}.um-email-configure span{line-height:24px}.um-long-field{width:100%}.um-medium-field{width:50%}.um-small-field{width:25%}.column-configure{width:10%;text-align:right}th.column-email.column-primary{padding-left:48px}.um-form-table .um-forms-line td{padding-right:0}#um-settings-emails{margin:15px 0}#um-settings-template-versions{margin:15px 0}#um-settings-template-versions .wp-list-table .column-core_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-theme_version{width:100px;text-align:center}#um-settings-template-versions .wp-list-table .column-status{width:260px}#um-settings-form{float:left;width:100%;margin:0}#um-settings-form .subsubsub{float:left;width:100%}#um-settings-form h2.title a.um-back-button{font-weight:400;font-size:30px;line-height:1;text-decoration:none;margin-right:5px}.um-settings-line .multi-checkbox-line{float:left;width:100%;clear:both;margin:0 0 10px 0;padding:0}.um-settings-line .multi-checkbox-column{float:left;margin:0;padding:0}.um-settings-line .multi-checkbox-column label{float:left;width:100%}.wrap-licenses .form-table,.wrap-licenses caption,.wrap-licenses tbody,.wrap-licenses td,.wrap-licenses tfoot,.wrap-licenses th,.wrap-licenses thead,.wrap-licenses tr{display:block}.wrap-licenses .form-table tr{float:left;margin:0 15px 15px 0;background:#fff;border:1px solid #ccc;width:30.5%;max-width:350px;padding:14px;min-height:240px;position:relative;box-sizing:border-box}.wrap-licenses .form-table th{background:#f9f9f9;padding:14px;border-bottom:1px solid #ccc;margin:-14px -14px 20px;width:100%}.wrap-licenses .form-table td{padding:0}.wrap-licenses td input.regular-text{margin:0 0 8px;width:100%}.wrap-licenses .edd-license-data[class*=edd-license-]{position:absolute;background:#fafafa;padding:14px;border-top:1px solid #eee;margin:20px -14px -14px;min-height:67px;width:100%;bottom:14px;box-sizing:border-box}.wrap-licenses .edd-license-data[class*=edd-license-] a{color:#444}.wrap-licenses .edd-license-data[class*=edd-license-] a:hover{text-decoration:none}.wrap-licenses .edd-license-data.license-expires-soon-notice{background-color:#00a0d2;color:#fff;border-color:#00a0d2}.wrap-licenses .edd-license-data.license-expires-soon-notice a{color:#fff}.wrap-licenses .edd-license-data.license-expires-soon-notice a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-expired{background-color:#e24e4e;color:#fff;border-color:#e24e4e}.wrap-licenses .edd-license-data.edd-license-expired a{color:#fff}.wrap-licenses .edd-license-data.edd-license-expired a:hover{text-decoration:none}.wrap-licenses .edd-license-data.edd-license-valid{background-color:#5abc55;color:#fff;border-color:#5abc55}.wrap-licenses .edd-license-data.edd-license-error,.wrap-licenses .edd-license-data.edd-license-invalid,.wrap-licenses .edd-license-data.edd-license-item_name_mismatch,.wrap-licenses .edd-license-data.edd-license-missing,.wrap-licenses .edd-license-data.edd-license-site_inactive{background-color:#ffebcd;border-color:#ffebcd}.wrap-licenses .edd-license-data p{font-size:13px;margin-top:0}.wrap-licenses~p.submit{clear:both}@media screen and (max-width:980px){.wrap-licenses .form-table tr{width:calc(50% - 15px);max-width:none}}@media screen and (max-width:782px){#um-settings-template-versions .wp-list-table .column-core_version,#um-settings-template-versions .wp-list-table .column-theme_version{width:auto;text-align:left}.wrap-licenses .form-table tr{width:100%;margin-right:0;max-width:none}.um-settings-line .multi-checkbox-column{width:100%!important}.um-settings-line .multi-checkbox-column label{line-height:30px!important}.um-medium-field{width:100%}.um-small-field{width:50%}}.um_setting_ajax_button_response.complete{color:#7acf58;font-style:italic}.wp-core-ui .button.um_license_activate,.wp-core-ui .button.um_license_deactivate,.wp-core-ui .button.um_license_reactivate{margin-top:5px}.um-media-upload .um-media-upload-url{margin-bottom:5px}
+20 -9
View File
@@ -2,13 +2,13 @@
@import "mixins"
@import "colors"
##{$prefix}settings-wrap
.subsubsub
+flex( row, flex-start, center, wrap )
margin-left: -3px
margin-right: -3px
a
margin: 0 3px
//##{$prefix}settings-wrap
// .subsubsub
// +flex( row, flex-start, center, wrap )
// margin-left: -3px
// margin-right: -3px
// a
// margin: 0 3px
.#{$prefix}settings-section
.description
@@ -38,8 +38,8 @@
width: 25%
.column-configure
width: 60px
text-align: center
width: 10%
text-align: right
th.column-email.column-primary
padding-left: 48px
@@ -50,7 +50,11 @@ th.column-email.column-primary
td
padding-right: 0
##{$prefix}settings-emails
margin: 15px 0
##{$prefix}settings-template-versions
margin: 15px 0
.wp-list-table
.column-core_version
width: 100px
@@ -68,6 +72,13 @@ th.column-email.column-primary
.subsubsub
float: left
width: 100%
h2.title
a.um-back-button
font-weight: normal
font-size: 30px
line-height: 1
text-decoration: none
margin-right: 5px
.#{$prefix}settings-line
+22 -2
View File
@@ -898,12 +898,32 @@ small.um-max-filesize span{
.um-search-area .um-search-field {
width: 100%;
margin: 0;
padding-left: 25px;
}
.rtl .um-search-area .um-search-field {
padding-right: 25px;
padding-left: initial;
}
.um-search-area .um-search-icon {
position: absolute;
top: 7px;
right: 10px;
height: 100%;
left: 6px;
top: 0;
}
.rtl .um-search-area .um-search-icon {
right: 6px;
left: initial;
}
.um-faicon-search:before {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
/*
+1 -1
View File
File diff suppressed because one or more lines are too long
+49 -2
View File
@@ -97,6 +97,52 @@ function um_admin_init_users_select() {
}
function um_admin_init_pages_select() {
// multiple select with AJAX search
jQuery('.um-pages-select2').select2({
ajax: {
url: wp.ajax.settings.url,
dataType: 'json',
delay: 250, // delay in ms while typing when to perform a AJAX search
data: function( params ) {
return {
search: params.term, // search query
action: 'um_get_pages_list', // AJAX action for admin-ajax.php
page: params.page || 1, // infinite scroll pagination
nonce: um_admin_scripts.nonce
};
},
processResults: function( data, params ) {
params.page = params.page || 1;
var options = [];
if ( data ) {
// data is the array of arrays, and each of them contains ID and the Label of the option
jQuery.each( data, function( index, text ) { // do not forget that "index" is just auto incremented value
if ( index === 'total_count' ) {
return;
}
options.push( { id: text[0], text: text[1] } );
});
}
return {
results: options,
pagination: {
more: ( params.page * 10 ) < data.total_count
}
};
},
cache: true
},
placeholder: jQuery(this).data('placeholder'),
minimumInputLength: 0, // the minimum of symbols to input before perform a search
allowClear: true,
});
}
/**
*
* @param field_key
@@ -123,6 +169,7 @@ function um_same_page_something_wrong( field_key ) {
jQuery(document).ready( function() {
um_admin_init_users_select();
um_admin_init_pages_select();
/**
* Same page upgrade field
@@ -130,9 +177,9 @@ jQuery(document).ready( function() {
jQuery( document.body ).on( 'click', '.um-forms-field[data-log-object]', function() {
var obj = jQuery( this ).data( 'log-object' );
if ( jQuery( this ).is( ':checked' ) ) {
jQuery( this ).siblings( '.um-same-page-update-' + obj ).show();
jQuery( this ).parents('label').siblings( '.um-same-page-update-' + obj ).show();
} else {
jQuery( this ).siblings( '.um-same-page-update-' + obj ).hide();
jQuery( this ).parents('label').siblings( '.um-same-page-update-' + obj ).hide();
}
});
+1 -1
View File
File diff suppressed because one or more lines are too long
+5 -1
View File
@@ -593,7 +593,11 @@ function um_modal_responsive() {
if ( w <= 500 ) {
modal.animate({ 'bottom' : 0 }, 300);
} else {
modal.animate({ 'bottom' : half_gap }, 300);
if ( h - parseInt(half_gap) > h ) {
modal.animate({ 'bottom' : 0 }, 300);
} else {
modal.animate({ 'bottom' : half_gap }, 300);
}
}
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long
+103 -36
View File
@@ -1,6 +1,8 @@
<?php
namespace um\admin;
use WP_Query;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@@ -69,6 +71,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
add_action( 'um_admin_do_action__check_templates_version', array( &$this, 'check_templates_version' ) );
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
add_action( 'um_admin_do_action__install_predefined_page', array( &$this, 'install_predefined_page' ) );
add_action( 'parent_file', array( &$this, 'parent_file' ), 9 );
add_filter( 'gettext', array( &$this, 'gettext' ), 10, 4 );
@@ -1617,33 +1620,108 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
public function install_core_pages() {
UM()->setup()->install_default_pages();
//check empty pages in settings
$empty_pages = array();
$pages = UM()->config()->permalinks;
if ( $pages && is_array( $pages ) ) {
foreach ( $pages as $slug => $page_id ) {
$page = get_post( $page_id );
if ( ! isset( $page->ID ) && array_key_exists( $slug, UM()->config()->core_pages ) ) {
$empty_pages[] = $slug;
}
}
}
//if there aren't empty pages - then hide pages notice
if ( empty( $empty_pages ) ) {
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
$hidden_notices[] = 'wrong_pages';
update_option( 'um_hidden_admin_notices', $hidden_notices );
}
// Auto dismiss 'wrong_pages' notice if it's visible
$this->dismiss_wrong_pages();
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
wp_safe_redirect( $url );
exit;
}
/**
* Install predefined page based on $_REQUEST['um_page_slug'] argument.
*/
public function install_predefined_page() {
if ( ! current_user_can( 'manage_options' ) ) {
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
wp_safe_redirect( $url );
exit;
}
$predefined_pages = array_keys( UM()->config()->get( 'predefined_pages' ) );
// phpcs:ignore WordPress.Security.NonceVerification -- early nonce verification based on `um_adm_action`
$page_slug = array_key_exists( 'um_page_slug', $_REQUEST ) ? sanitize_key( $_REQUEST['um_page_slug'] ) : '';
if ( empty( $page_slug ) || ! in_array( $page_slug, $predefined_pages, true ) ) {
$url = add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) );
wp_safe_redirect( $url );
exit;
}
$post_ids = new WP_Query(
array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_um_core',
'value' => $page_slug,
),
),
'posts_per_page' => -1,
'fields' => 'ids',
)
);
$post_ids = $post_ids->get_posts();
if ( ! empty( $post_ids ) ) {
foreach ( $post_ids as $post_id ) {
delete_post_meta( $post_id, '_um_core' );
}
}
UM()->setup()->predefined_page( $page_slug );
// Auto dismiss 'wrong_pages' notice if it's visible
$this->dismiss_wrong_pages();
$url = add_query_arg(
array(
'page' => 'um_options',
'update' => 'um_settings_updated',
),
admin_url( 'admin.php' )
);
wp_safe_redirect( $url );
exit;
}
/**
* Dismiss 'wrong_pages' notice if it's visible.
*/
public function dismiss_wrong_pages() {
// Check empty pages in settings.
$empty_pages = array();
$predefined_pages = array_keys( UM()->config()->get( 'predefined_pages' ) );
foreach ( $predefined_pages as $slug ) {
$page_id = um_get_predefined_page_id( $slug );
if ( ! $page_id ) {
$empty_pages[] = $slug;
continue;
}
$page = get_post( $page_id );
if ( ! $page ) {
$empty_pages[] = $slug;
continue;
}
}
// If there aren't empty pages - then hide pages notice
if ( empty( $empty_pages ) ) {
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
if ( ! is_array( $hidden_notices ) ) {
$hidden_notices = array();
}
$hidden_notices[] = 'wrong_pages';
update_option( 'um_hidden_admin_notices', $hidden_notices );
}
}
/**
* Clear all users cache.
*/
@@ -1826,24 +1904,13 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
* Manual check templates versions.
*/
public function check_templates_version() {
$templates = UM()->admin_settings()->get_override_templates( true );
$out_date = false;
foreach ( $templates as $template ) {
if ( 0 === $template['status_code'] ) {
$out_date = true;
break;
}
}
if ( false === $out_date ) {
delete_option( 'um_override_templates_outdated' );
}
UM()->common()->theme()->flush_transient_templates_data();
$url = add_query_arg(
array(
'page' => 'um_options',
'tab' => 'override_templates',
'page' => 'um_options',
'tab' => 'advanced',
'section' => 'override_templates',
),
admin_url( 'admin.php' )
);
+15 -8
View File
@@ -351,9 +351,10 @@ final class Enqueue extends \um\common\Enqueue {
$forms_data = array(
'successfully_redirect' => add_query_arg(
array(
'page' => 'um_options',
'tab' => 'misc',
'msg' => 'updated',
'page' => 'um_options',
'tab' => 'advanced',
'section' => 'features',
'msg' => 'updated',
),
admin_url( 'admin.php' )
),
@@ -554,7 +555,7 @@ final class Enqueue extends \um\common\Enqueue {
wp_enqueue_style( 'um_admin_common' );
if ( self::$um_cpt_form_screen ) {
if ( defined( 'UM_LEGACY_BUILDER_OFF' ) && UM_LEGACY_BUILDER_OFF ) {
if ( defined( 'UM_DEV_MODE' ) && UM_DEV_MODE && UM()->options()->get( 'enable_new_form_builder' ) ) {
// Do new assets.
} else {
$this->load_builder();
@@ -583,10 +584,16 @@ final class Enqueue extends \um\common\Enqueue {
wp_enqueue_style( 'um_admin_roles' );
} elseif ( 'ultimate-member_page_um_options' === $hook ) {
// phpcs:ignore WordPress.Security.NonceVerification
if ( isset( $_GET['tab'] ) && 'secure' === $_GET['tab'] ) {
wp_register_script( 'um_admin_secure', $js_url . 'admin/secure' . $suffix . '.js', array( 'jquery', 'wp-i18n' ), UM_VERSION, true );
wp_set_script_translations( 'um_admin_secure', 'ultimate-member' );
wp_enqueue_script( 'um_admin_secure' );
if ( isset( $_GET['tab'], $_GET['section'] ) && 'advanced' === $_GET['tab'] && 'security' === $_GET['section'] ) {
wp_register_script( 'um_admin_security', $js_url . 'admin/security' . $suffix . '.js', array( 'jquery', 'wp-i18n' ), UM_VERSION, true );
wp_set_script_translations( 'um_admin_security', 'ultimate-member' );
wp_enqueue_script( 'um_admin_security' );
}
// phpcs:ignore WordPress.Security.NonceVerification
if ( isset( $_GET['tab'] ) && 'appearance' === $_GET['tab'] && empty( $_GET['section'] ) ) {
// Init WP Media Uploader on the UM > Settings > Appearance > Profile screen.
wp_enqueue_media();
}
wp_register_style( 'um_admin_settings', $css_url . 'admin/settings' . $suffix . '.css', array(), UM_VERSION );
+32 -27
View File
@@ -90,12 +90,6 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
*/
public function admin_init() {
global $wpdb;
// Dismiss admin notice after the first visit to Secure settings page.
if ( isset( $_REQUEST['page'] ) && isset( $_REQUEST['tab'] ) &&
'um_options' === sanitize_key( $_REQUEST['page'] ) && 'secure' === sanitize_key( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
UM()->admin()->notices()->dismiss( 'secure_settings' );
}
if ( isset( $_REQUEST['um_secure_expire_all_sessions'] ) && ! wp_doing_ajax() ) {
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'um-secure-expire-session-nonce' ) || ! current_user_can( 'manage_options' ) ) {
// This nonce is not valid or current logged-in user has no administrative rights.
@@ -236,16 +230,18 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
'description' => __( 'Scan your site to check for vulnerabilities prior to Ultimate Member version 2.6.7 and get recommendations to secure your site.', 'ultimate-member' ),
),
array(
'id' => 'lock_register_forms',
'type' => 'checkbox',
'label' => __( 'Lock All Register Forms', 'ultimate-member' ),
'description' => __( 'This prevents all users from registering with Ultimate Member on your site.', 'ultimate-member' ),
'id' => 'lock_register_forms',
'type' => 'checkbox',
'label' => __( 'Lock All Register Forms', 'ultimate-member' ),
'checkbox_label' => __( 'Lock Forms', 'ultimate-member' ),
'description' => __( 'This prevents all users from registering with Ultimate Member on your site.', 'ultimate-member' ),
),
array(
'id' => 'display_login_form_notice',
'type' => 'checkbox',
'label' => __( 'Display Login form notice to reset passwords', 'ultimate-member' ),
'description' => __( 'Enforces users to reset their passwords( one-time ) and prevent from entering old password.', 'ultimate-member' ),
'id' => 'display_login_form_notice',
'type' => 'checkbox',
'label' => __( 'Display Login form notice to reset passwords', 'ultimate-member' ),
'checkbox_label' => __( 'Enable Login form notice', 'ultimate-member' ),
'description' => __( 'Enforces users to reset their passwords (one-time) and prevent from entering old password.', 'ultimate-member' ),
),
);
@@ -265,17 +261,19 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
$secure_fields,
array(
array(
'id' => 'secure_ban_admins_accounts',
'type' => 'checkbox',
'label' => __( 'Enable ban for administrative capabilities', 'ultimate-member' ),
'description' => __( ' When someone tries to inject capabilities to the Account, Profile & Register forms submission, it will be banned.', 'ultimate-member' ),
'id' => 'secure_ban_admins_accounts',
'type' => 'checkbox',
'label' => __( 'Administrative capabilities ban', 'ultimate-member' ),
'checkbox_label' => __( 'Enable ban for administrative capabilities', 'ultimate-member' ),
'description' => __( ' When someone tries to inject capabilities to the Account, Profile & Register forms submission, it will be banned.', 'ultimate-member' ),
),
array(
'id' => 'secure_notify_admins_banned_accounts',
'type' => 'checkbox',
'label' => __( 'Notify Administrators', 'ultimate-member' ),
'description' => __( 'When enabled, All administrators will be notified when someone has suspicious activities in the Account, Profile & Register forms.', 'ultimate-member' ),
'conditional' => array( 'secure_ban_admins_accounts', '=', 1 ),
'id' => 'secure_notify_admins_banned_accounts',
'type' => 'checkbox',
'label' => __( 'Notify Administrators', 'ultimate-member' ),
'checkbox_label' => __( 'Enable notification', 'ultimate-member' ),
'description' => __( 'When enabled, All administrators will be notified when someone has suspicious activities in the Account, Profile & Register forms.', 'ultimate-member' ),
'conditional' => array( 'secure_ban_admins_accounts', '=', 1 ),
),
array(
'id' => 'secure_notify_admins_banned_accounts__interval',
@@ -292,14 +290,21 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
'id' => 'secure_allowed_redirect_hosts',
'type' => 'textarea',
'label' => __( 'Allowed hosts for safe redirect (one host per line)', 'ultimate-member' ),
'description' => __( 'Extend allowed hosts for frontend pages redirects', 'ultimate-member' ),
'description' => __( 'Extend allowed hosts for frontend pages redirects.', 'ultimate-member' ),
),
)
);
$settings['secure'] = array(
'title' => __( 'Secure', 'ultimate-member' ),
'fields' => $secure_fields,
$settings['advanced']['sections'] = UM()->array_insert_before(
$settings['advanced']['sections'],
'developers',
array(
'security' => array(
'title' => __( 'Security', 'ultimate-member' ),
'description' => __( 'This feature scans for suspicious registered accounts, bans the usage of administrative capabilities to site subscribers/members, allows the website administrators to force all users to reset their passwords, preventing users from logging-in using their old passwords that may have been exposed.', 'ultimate-member' ),
'fields' => $secure_fields,
),
)
);
return $settings;
+63 -5
View File
@@ -12,11 +12,69 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class Site_Health {
/**
* String of a badge color.
* Options: blue, green, red, orange, purple and gray.
*
* @see https://make.wordpress.org/core/2019/04/25/site-health-check-in-5-2/
*
* @since 2.8.3
*/
const BADGE_COLOR = 'blue';
/**
* Site_Health constructor.
*/
public function __construct() {
add_filter( 'debug_information', array( $this, 'debug_information' ), 20 );
add_filter( 'site_status_tests', array( $this, 'register_site_status_tests' ) );
}
public function register_site_status_tests( $tests ) {
$custom_templates = UM()->common()->theme()->get_custom_templates_list();
if ( ! empty( $custom_templates ) ) {
$tests['direct']['um_override_templates'] = array(
'label' => esc_html__( 'Are the Ultimate Member templates out of date?', 'ultimate-member' ),
'test' => array( $this, 'override_templates_test' ),
);
}
return $tests;
}
public function override_templates_test() {
$result = array(
'label' => __( 'You have the most recent version of custom Ultimate Member templates', 'ultimate-member' ),
'status' => 'good',
'badge' => array(
'label' => UM_PLUGIN_NAME,
'color' => self::BADGE_COLOR,
),
'description' => sprintf(
'<p>%s</p>',
__( 'Your custom Ultimate Member templates that are situated in the theme have the most recent version and are ready to use.', 'ultimate-member' )
),
'actions' => '',
'test' => 'um_override_templates',
);
if ( UM()->common()->theme()->is_outdated_template_exist() ) {
$result['label'] = __( 'Your custom templates are out of date', 'ultimate-member' );
$result['status'] = 'critical';
$result['badge']['color'] = 'red';
$result['description'] = sprintf(
'<p>%s</p>',
__( 'Your custom Ultimate Member templates that are situated in the theme are out of date and may break the website\'s functionality.', 'ultimate-member' )
);
$result['actions'] = sprintf(
'<p><a href="%s">%s</a></p>',
admin_url( 'admin.php?page=um_options&tab=advanced&section=override_templates' ),
esc_html__( 'Check status and update', 'ultimate-member' )
);
}
return $result;
}
private function get_roles() {
@@ -290,7 +348,7 @@ class Site_Health {
}
$account_settings['um-account_email'] = array(
'label' => __( 'Allow users to change e-mail', 'ultimate-member' ),
'label' => __( 'Allow users to change email', 'ultimate-member' ),
'value' => UM()->options()->get( 'account_email' ) ? $labels['yes'] : $labels['no'],
);
@@ -485,7 +543,7 @@ class Site_Health {
// Email settings
$email_settings = array(
'um-admin_email' => array(
'label' => __( 'Admin E-mail Address', 'ultimate-member' ),
'label' => __( 'Admin Email Address', 'ultimate-member' ),
'value' => UM()->options()->get( 'admin_email' ),
),
'um-mail_from' => array(
@@ -497,7 +555,7 @@ class Site_Health {
'value' => UM()->options()->get( 'mail_from_addr' ),
),
'um-email_html' => array(
'label' => __( 'Use HTML for E-mails?', 'ultimate-member' ),
'label' => __( 'Use HTML for Emails?', 'ultimate-member' ),
'value' => UM()->options()->get( 'email_html' ) ? $labels['yes'] : $labels['no'],
),
);
@@ -1362,7 +1420,7 @@ class Site_Health {
$info[ 'ultimate-member-' . $key ]['fields'],
array(
'um-url_email_activate' => array(
'label' => __( 'URL redirect after e-mail activation', 'ultimate-member' ),
'label' => __( 'URL redirect after email activation', 'ultimate-member' ),
'value' => $rolemeta['_um_url_email_activate'],
),
)
@@ -1788,7 +1846,7 @@ class Site_Health {
'first_name' => __( 'First Name', 'ultimate-member' ),
'last_name' => __( 'Last Name', 'ultimate-member' ),
'nickname' => __( 'Nickname', 'ultimate-member' ),
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
'secondary_user_email' => __( 'Secondary Email Address', 'ultimate-member' ),
'description' => __( 'Biography', 'ultimate-member' ),
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
@@ -1,12 +1,12 @@
<?php
namespace um\admin\core;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'um\admin\core\Admin_Forms_Settings' ) ) {
/**
* Class Admin_Forms_Settings
* @package um\admin\core
@@ -17,41 +17,42 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms_Settings' ) ) {
* Admin_Forms constructor.
* @param bool $form_data
*/
function __construct( $form_data = false ) {
public function __construct( $form_data = false ) {
parent::__construct( $form_data );
}
/**
* Get field value
* Get field value.
*
* @param array $field_data
* @param array $field_data
* @param string $i
*
* @return string|array
*/
function get_field_value( $field_data, $i = '' ) {
$default = isset( $field_data['default' . $i] ) ? $field_data['default' . $i] : UM()->options()->get_default( $field_data['id' . $i] );
public function get_field_value( $field_data, $i = '' ) {
$default_key = 'default' . $i;
$value_key = 'value' . $i;
$id_key = 'id' . $i;
if ( $field_data['type'] == 'checkbox' || $field_data['type'] == 'multi_checkbox' ) {
if ( isset( $field_data['value' . $i] ) ) {
return $field_data['value' . $i];
} else {
$value = UM()->options()->get( $field_data['id' . $i] );
$value = is_string( $value ) ? stripslashes( $value ) : $value;
return '' !== $value ? $value : $default;
}
} else {
if ( isset( $field_data['value' . $i] ) ) {
return $field_data['value'. $i];
} else {
$value = UM()->options()->get( $field_data['id' . $i] );
$value = is_string( $value ) ? stripslashes( $value ) : $value;
return isset( $value ) ? $value : $default;
$default = isset( $field_data[ $default_key ] ) ? $field_data[ $default_key ] : UM()->options()->get_default( $field_data[ $id_key ] );
if ( in_array( $field_data['type'], array( 'checkbox', 'multi_checkbox' ), true ) ) {
if ( isset( $field_data[ $value_key ] ) ) {
return $field_data[ $value_key ];
}
$value = UM()->options()->get( $field_data[ $id_key ] );
$value = is_string( $value ) ? stripslashes( $value ) : $value;
return '' !== $value ? $value : $default;
}
}
if ( isset( $field_data[ $value_key ] ) ) {
return $field_data[ $value_key ];
}
$value = UM()->options()->get( $field_data[ $id_key ] );
$value = is_string( $value ) ? stripslashes( $value ) : $value;
return isset( $value ) ? $value : $default;
}
}
}
+128 -27
View File
@@ -52,7 +52,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
* @param bool $echo
* @return string
*/
function render_form( $echo = true ) {
public function render_form( $echo = true ) {
if ( empty( $this->form_data['fields'] ) ) {
return '';
@@ -64,7 +64,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
ob_start();
foreach ( $this->form_data['fields'] as $field_data ) {
if ( isset( $field_data['type'] ) && 'hidden' == $field_data['type'] ) {
if ( isset( $field_data['type'] ) && 'hidden' === $field_data['type'] ) {
echo $this->render_form_row( $field_data );
}
}
@@ -97,19 +97,18 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
}
/**
* @param array $data
*
* @return string
*/
function render_form_row( $data ) {
public function render_form_row( $data ) {
if ( empty( $data['type'] ) ) {
return '';
}
if ( !empty( $data['value'] ) && $data['type'] != 'email_template' ) {
if ( ! empty( $data['value'] ) && $data['type'] != 'email_template' ) {
$data['value'] = wp_unslash( $data['value'] );
/*for multi_text*/
@@ -169,8 +168,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<p class="description">' . $data['description'] . '</p>';
}
$html .= '</div>';
@@ -190,8 +190,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<p class="description">' . $data['description'] . '</p>';
}
$html .= '</div>';
@@ -209,8 +210,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<p class="description">' . $data['description'] . '</p>';
}
$html .= '</div>';
@@ -233,8 +235,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<div class="clear"></div><p class="description">' . $data['description'] . '</p>';
}
$html .= '</td></tr>';
@@ -255,8 +258,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<div class="clear"></div><p class="description">' . $data['description'] . '</p>';
}
$html .= '</td></tr>';
@@ -276,15 +280,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
}
if ( ! empty( $data['description'] ) )
if ( ! empty( $data['description'] ) ) {
$html .= '<div class="clear"></div><p class="description">' . $data['description'] . '</p>';
}
$html .= '</td></tr>';
}
}
}
} else {
$html .= $this->render_hidden( $data );
}
@@ -927,10 +930,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
*
* @return bool|string
*/
function render_checkbox( $field_data ) {
public function render_checkbox( $field_data ) {
if ( empty( $field_data['id'] ) )
if ( empty( $field_data['id'] ) ) {
return false;
}
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
$id_attr = ' id="' . esc_attr( $id ) . '" ';
@@ -941,7 +945,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
$data = array(
'field_id' => $field_data['id']
'field_id' => $field_data['id'],
);
if ( ! empty( $field_data['data'] ) ) {
@@ -959,20 +963,22 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$value = $this->get_field_value( $field_data );
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
$checkbox_label = ! empty( $field_data['checkbox_label'] ) ? $field_data['checkbox_label'] : '';
return $html;
$field_html = "<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" " . disabled( ! empty( $field_data['disabled'] ), true, false ) . " />";
if ( '' !== $checkbox_label ) {
$field_html = "<label>$field_html $checkbox_label</label>";
}
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" " . disabled( ! empty( $field_data['disabled'] ), true, false ) . " />{$field_html}";
return apply_filters( 'um_admin_render_checkbox_field_html', $html, $field_data );
}
/**
* @param $field_data
*
* @return bool|string
*/
function render_same_page_update( $field_data ) {
public function render_same_page_update( $field_data ) {
if ( empty( $field_data['id'] ) ) {
return false;
@@ -987,7 +993,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$class_attr = ' class="um-forms-field ' . esc_attr( $class ) . '" ';
$data = array(
'field_id' => $field_data['id']
'field_id' => $field_data['id'],
);
if ( ! empty( $field_data['data'] ) ) {
@@ -1009,8 +1015,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
$value = $this->get_field_value( $field_data );
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" />
<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" />";
$checkbox_label = ! empty( $field_data['checkbox_label'] ) ? $field_data['checkbox_label'] : '';
$field_html = "<input type=\"checkbox\" $id_attr $class_attr $name_attr $data_attr " . checked( $value, true, false ) . " value=\"1\" " . disabled( ! empty( $field_data['disabled'] ), true, false ) . " />";
if ( '' !== $checkbox_label ) {
$field_html = "<label>$field_html $checkbox_label</label>";
}
$html = "<input type=\"hidden\" $id_attr_hidden $name_attr value=\"0\" " . disabled( ! empty( $field_data['disabled'] ), true, false ) . " />{$field_html}";
if ( ! empty( $field_data['upgrade_cb'] ) ) {
$html .= '<div class="um-same-page-update-wrapper um-same-page-update-' . esc_attr( $field_data['upgrade_cb'] ) . '"><div class="um-same-page-update-description">' . $field_data['upgrade_description'] . '</div><input type="button" data-upgrade_cb="' . $field_data['upgrade_cb'] . '" class="button button-primary um-admin-form-same-page-update" value="' . esc_attr__( 'Run', 'ultimate-member' ) . '"/>
@@ -1020,7 +1031,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
return $html;
}
/**
* @param $field_data
*
@@ -1083,6 +1093,79 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
return $html;
}
/**
* @param $field_data
*
* @since 2.8.3
*
* @return bool|string
*/
public function render_page_select( $field_data ) {
if ( empty( $field_data['id'] ) ) {
return false;
}
$multiple = ! empty( $field_data['multi'] ) ? 'multiple' : '';
$id = ( ! empty( $this->form_data['prefix_id'] ) ? sanitize_title( $this->form_data['prefix_id'] ) : '' ) . '_' . $field_data['id'];
$id_attr = ' id="' . esc_attr( $id ) . '" ';
$class = ! empty( $field_data['class'] ) ? $field_data['class'] . ' ' : ' ';
$class .= ! empty( $field_data['size'] ) ? 'um-' . $field_data['size'] . '-field' : 'um-long-field';
$class_attr = ' class="um-forms-field um-pages-select2 ' . esc_attr( $class ) . '" ';
$data = array(
'field_id' => $field_data['id'],
);
if ( ! empty( $field_data['placeholder'] ) ) {
$data['placeholder'] = $field_data['placeholder'];
}
$data_attr = '';
foreach ( $data as $key => $value ) {
$data_attr .= ' data-' . $key . '="' . esc_attr( $value ) . '" ';
}
$name = $field_data['id'];
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
$hidden_name_attr = ' name="' . $name . '" ';
$name = $name . ( ! empty( $field_data['multi'] ) ? '[]' : '' );
$name_attr = ' name="' . $name . '" ';
$value = $this->get_field_value( $field_data );
$options = '<option value="">' . esc_html( $data['placeholder'] ) . '</option>';
if ( ! empty( $field_data['options'] ) ) {
foreach ( $field_data['options'] as $key => $option ) {
if ( ! empty( $field_data['multi'] ) ) {
if ( ! is_array( $value ) || empty( $value ) ) {
$value = array();
}
$options .= '<option value="' . $key . '" ' . selected( in_array( $key, $value ), true, false ) . '>' . esc_html( $option ) . '</option>';
} else {
$options .= '<option value="' . $key . '" ' . selected( (string)$key == $value, true, false ) . '>' . esc_html( $option ) . '</option>';
}
}
}
$hidden = '';
if ( ! empty( $multiple ) ) {
$hidden = "<input type=\"hidden\" $hidden_name_attr value=\"\" />";
}
$button = '';
$slug = str_replace( 'core_', '', $field_data['id'] );
if ( ! um_get_predefined_page_id( $slug ) || 'publish' !== get_post_status( um_get_predefined_page_id( $slug ) ) ) {
$button = '&nbsp;<a href="' . esc_url( add_query_arg( array( 'um_adm_action' => 'install_predefined_page', 'um_page_slug' => $slug, '_wpnonce' => wp_create_nonce( 'install_predefined_page' ), ) ) ) . '" class="button button-primary">' . esc_html__( 'Create Default', 'ultimate-member' ) . '</a>';
}
$html = "$hidden<select $multiple $id_attr $name_attr $class_attr $data_attr>$options</select>$button";
return $html;
}
/**
* @param $field_data
@@ -1739,7 +1822,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
return $html;
}
/**
* Get field value
*
@@ -1770,5 +1852,24 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) {
return $value;
}
public function render_external_link( $data ) {
$defaults = array(
'url' => '',
'html' => '',
);
$data = wp_parse_args( $data, $defaults );
if ( empty( $data['url'] ) || empty( $data['html'] ) ) {
return '';
}
ob_start();
?>
<a target="_blank" href="<?php echo esc_url( $data['url'] ); ?>">
<?php echo esc_html( $data['html'] ); ?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" class="um-external-link-icon" aria-hidden="true" focusable="false"><path d="M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"></path></svg>
</a>
<?php
return ob_get_clean();
}
}
}
+44 -6
View File
@@ -16,18 +16,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
*/
class Admin_Menu {
/**
* @var string
*/
var $pagehook;
var $slug = 'ultimatemember';
/**
* Admin_Menu constructor.
*/
function __construct() {
public function __construct() {
add_action( 'admin_menu', array( &$this, 'primary_admin_menu' ), 0 );
add_action( 'admin_menu', array( &$this, 'secondary_menu_items' ), 1000 );
add_action( 'admin_menu', array( &$this, 'extension_menu' ), 9999 );
@@ -35,8 +33,46 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
add_action( 'admin_head', array( $this, 'menu_order_count' ) );
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1000 );
add_action( 'load-ultimate-member_page_um_options', array( &$this, 'maybe_settings_redirect' ) );
}
/**
* Trigger redirect on the Settings screen if there is a wrong tab or section.
*
* @since 2.8.2
*/
public function maybe_settings_redirect() {
$current_tab = empty( $_GET['tab'] ) ? '' : sanitize_key( $_GET['tab'] );
$current_subtab = empty( $_GET['section'] ) ? '' : sanitize_key( $_GET['section'] );
$settings_struct = UM()->admin_settings()->settings_structure[ $current_tab ];
// Remove not option hidden fields.
if ( ! empty( $settings_struct['fields'] ) ) {
foreach ( $settings_struct['fields'] as $field_key => $field_options ) {
if ( isset( $field_options['is_option'] ) && false === $field_options['is_option'] ) {
unset( $settings_struct['fields'][ $field_key ] );
}
}
}
if ( empty( $settings_struct['fields'] ) && empty( $settings_struct['sections'] ) && empty( $settings_struct['form_sections'] ) ) {
wp_safe_redirect( add_query_arg( array( 'page' => 'um_options' ), admin_url( 'admin.php' ) ) );
exit;
}
if ( ! empty( $settings_struct['sections'] ) ) {
if ( empty( $settings_struct['sections'][ $current_subtab ] ) ) {
$args = array( 'page' => 'um_options' );
if ( ! empty( $current_tab ) ) {
$args['tab'] = $current_tab;
}
wp_safe_redirect( add_query_arg( $args, admin_url( 'admin.php' ) ) );
exit;
}
}
}
/**
* Change the admin footer text on UM admin pages
@@ -143,8 +179,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
/**
* Setup admin menu
*/
function primary_admin_menu() {
$this->pagehook = add_menu_page( __( 'Ultimate Member', 'ultimate-member' ), __( 'Ultimate Member', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ), 'dashicons-admin-users', '42.78578');
public function primary_admin_menu() {
$this->pagehook = add_menu_page( __( 'Ultimate Member', 'ultimate-member' ), __( 'Ultimate Member', 'ultimate-member' ), 'manage_options', $this->slug, array( &$this, 'admin_page' ), 'dashicons-admin-users', '42.78578' );
add_action( 'load-' . $this->pagehook, array( &$this, 'on_load_page' ) );
@@ -155,7 +191,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
/**
* Secondary admin menu (after settings)
*/
function secondary_menu_items() {
public function secondary_menu_items() {
add_submenu_page( $this->slug, __( 'Settings', 'ultimate-member' ), __( 'Settings', 'ultimate-member' ), 'manage_options', 'um_options', array( UM()->admin_settings(), 'settings_page' ) );
add_submenu_page( $this->slug, __( 'Forms', 'ultimate-member' ), __( 'Forms', 'ultimate-member' ), 'manage_options', 'edit.php?post_type=um_form', '' );
add_submenu_page( $this->slug, __( 'User Roles', 'ultimate-member' ), __( 'User Roles', 'ultimate-member' ), 'manage_options', 'um_roles', array( &$this, 'um_roles_pages' ) );
+2 -2
View File
@@ -1021,7 +1021,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
public function add_metabox_form() {
add_meta_box( 'submitdiv', __( 'Publish', 'ultimate-member' ), array( $this, 'custom_submitdiv' ), 'um_form', 'side', 'high' );
if ( defined( 'UM_LEGACY_BUILDER_OFF' ) && UM_LEGACY_BUILDER_OFF ) {
if ( defined( 'UM_DEV_MODE' ) && UM_DEV_MODE && UM()->options()->get( 'enable_new_form_builder' ) ) {
// Do new metabox.
} else {
add_meta_box( 'um-admin-form-mode', __( 'Select Form Type', 'ultimate-member' ), array( &$this, 'load_metabox_form' ), 'um_form', 'normal', 'default' );
@@ -1494,7 +1494,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
break;
case '_validate':
if ( array_key_exists( 'mode', $form_data ) && 'login' === $form_data['mode'] && in_array( $field_args['metakey'], array( 'username', 'user_login', 'user_email' ), true ) ) {
if ( array_key_exists( 'mode', $form_data ) && 'login' === $form_data['mode'] && array_key_exists( 'metakey', $field_args ) && in_array( $field_args['metakey'], array( 'username', 'user_login', 'user_email' ), true ) ) {
return;
}
?>
+20 -80
View File
@@ -31,8 +31,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
add_action( 'wp_ajax_um_dismiss_notice', array( &$this, 'dismiss_notice' ) );
add_action( 'admin_init', array( &$this, 'force_dismiss_notice' ) );
add_action( 'current_screen', array( &$this, 'create_list_for_screen' ) );
}
/**
@@ -51,8 +49,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->extensions_page();
$this->template_version();
$this->child_theme_required();
// Removed for now to avoid the bad reviews.
@@ -82,13 +78,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
do_action( 'um_admin_create_notices' );
}
public function create_list_for_screen() {
if ( UM()->admin()->screen()->is_own_screen() ) {
$this->secure_settings();
}
}
/**
* @return array
*/
@@ -587,9 +576,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
}
}
function check_wrong_licenses() {
$invalid_license = 0;
public function check_wrong_licenses() {
$invalid_license = 0;
$arr_inactive_license_keys = array();
if ( empty( UM()->admin_settings()->settings_structure['licenses']['fields'] ) ) {
@@ -599,10 +587,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
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 )
if ( ( is_object( $license ) && isset( $license->license ) && 'valid' === $license->license ) || 'valid' === $license ) {
continue;
}
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) {
if ( ( is_object( $license ) && isset( $license->license ) && 'inactive' === $license->license ) || 'inactive' === $license ) {
$arr_inactive_license_keys[] = $license->item_name;
}
@@ -614,7 +603,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
'license_key',
array(
'class' => 'error',
// translators: %1$s is a inactive license number; %2$s is a plugin name; %3$s is a store link.
// translators: %1$s is an inactive license number; %2$s is a plugin name; %3$s is a store link.
'message' => '<p>' . sprintf( __( 'There are %1$s inactive %2$s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%3$s">www.ultimatemember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ), UM_PLUGIN_NAME, UM()->store_url ) . '</p>',
),
3
@@ -622,12 +611,20 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
}
if ( $invalid_license ) {
$licenses_page_url = add_query_arg(
array(
'page' => 'um_options',
'tab' => 'licenses',
),
admin_url( 'admin.php' )
);
$this->add_notice(
'license_key',
array(
'class' => 'error',
// translators: %1$s is a invalid license; %2$s is a plugin name; %3$s is a license link.
'message' => '<p>' . sprintf( __( 'You have %1$s invalid or expired license keys for %2$s. Please go to the <a href="%3$s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, UM_PLUGIN_NAME, add_query_arg( array( 'page' => 'um_options', 'tab' => 'licenses' ), admin_url( 'admin.php' ) ) ) . '</p>',
// translators: %1$s is an invalid license; %2$s is a plugin name; %3$s is a license link.
'message' => '<p>' . sprintf( __( 'You have %1$s invalid or expired license keys for %2$s. Please go to the <a href="%3$s">Licenses page</a> to correct this issue.', 'ultimate-member' ), $invalid_license, UM_PLUGIN_NAME, $licenses_page_url ) . '</p>',
),
3
);
@@ -775,36 +772,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
), 2 );
}
/**
* Check Templates Versions notice
*/
public function template_version() {
if ( true === (bool) get_option( 'um_override_templates_outdated' ) ) {
$link = admin_url( 'admin.php?page=um_options&tab=override_templates' );
ob_start();
?>
<p>
<?php
// translators: %s override templates page link.
echo wp_kses( sprintf( __( 'Your templates are out of date. Please visit <a href="%s">override templates status page</a> and update templates.', 'ultimate-member' ), $link ), UM()->get_allowed_html( 'admin_notice' ) );
?>
</p>
<?php
$message = ob_get_clean();
UM()->admin()->notices()->add_notice(
'um_override_templates_notice',
array(
'class' => 'error',
'message' => $message,
'dismissible' => false,
),
10
);
}
}
/**
* Check if there isn't installed child-theme. Child theme is required for safely saved customizations.
*/
@@ -820,7 +787,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
<p>
<?php
// translators: %s child-theme article link.
echo wp_kses( sprintf( __( 'We highly recommend using a <a href="%s">child-theme</a> for Ultimate Member customization, which hasn\'t dependencies with the official themes repo, so your custom files cannot be rewritten after a theme upgrade.<br />Otherwise, the customization files may be deleted after every theme upgrade.', 'ultimate-member' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), UM()->get_allowed_html( 'admin_notice' ) );
echo wp_kses( sprintf( __( 'We recommend using a <a href="%s">child-theme</a> for Ultimate Member customization. Unlike official theme repositories, child themes don\'t have dependencies that could lead to your custom files being overwritten during a theme upgrade.<br />Without a child theme, your customization files may be deleted after every theme update.', 'ultimate-member' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), UM()->get_allowed_html( 'admin_notice' ) );
?>
</p>
@@ -838,39 +805,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
}
}
/**
* First time installed Secure settings.
*/
public function secure_settings() {
ob_start();
?>
<p>
<strong><?php esc_html_e( 'Important Update', 'ultimate-member' ); ?></strong><br/>
<?php esc_html_e( 'Ultimate Member has a new additional feature to secure your Ultimate Member forms to prevent attacks from injecting accounts with administrative roles &amp; capabilities.', 'ultimate-member' ); ?>
</p>
<p>
<a class="button button-primary" href="<?php echo esc_attr( admin_url( 'admin.php?page=um_options&tab=secure&um_dismiss_notice=secure_settings&um_admin_nonce=' . wp_create_nonce( 'um-admin-nonce' ) ) ); ?>"><?php esc_html_e( 'Manage Security Settings', 'ultimate-member' ); ?></a>
<a class="button" target="_blank" href="https://docs.ultimatemember.com/article/1869-security-feature"><?php esc_html_e( 'Read the documentation', 'ultimate-member' ); ?></a>
</p>
<?php
$message = ob_get_clean();
$this->add_notice(
'secure_settings',
array(
'class' => 'warning',
'message' => $message,
'dismissible' => true,
),
1
);
}
public function common_secure() {
if ( UM()->options()->get( 'lock_register_forms' ) ) {
ob_start();
?>
<p>
<?php esc_html_e( 'Your Register forms are now locked. You can unlock them in Ultimate Member > Settings > Secure > Lock All Register Forms.', 'ultimate-member' ); ?>
<?php esc_html_e( 'Your Register forms are now locked. You can unlock them in Ultimate Member > Settings > Advanced > Security > Lock All Register Forms.', 'ultimate-member' ); ?>
</p>
<?php
$message = ob_get_clean();
@@ -889,7 +829,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start();
?>
<p>
<?php esc_html_e( 'Mandatory password changes has been enabled. You can disable them in Ultimate Member > Settings > Secure > Display Login form notice to reset passwords.', 'ultimate-member' ); ?>
<?php esc_html_e( 'Mandatory password changes has been enabled. You can disable them in Ultimate Member > Settings > Advanced > Security > Display Login form notice to reset passwords.', 'ultimate-member' ); ?>
</p>
<?php
$message = ob_get_clean();
@@ -908,7 +848,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
ob_start();
?>
<p>
<?php esc_html_e( 'Ban for administrative capabilities is enabled. You can disable them in Ultimate Member > Settings > Secure > Enable ban for administrative capabilities.', 'ultimate-member' ); ?>
<?php esc_html_e( 'Ban for administrative capabilities is enabled. You can disable them in Ultimate Member > Settings > Advanced > Security > Enable ban for administrative capabilities.', 'ultimate-member' ); ?>
</p>
<?php
$message = ob_get_clean();
File diff suppressed because it is too large Load Diff
@@ -85,7 +85,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
}
$old_version = get_option( 'theme_version ' . $theme->get( 'Name' ) );
$version = $theme->get( 'Version' );
$version = $theme->get( 'Version' );
if ( $old_version === $version ) {
return;
}
@@ -98,14 +98,14 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
$um_dir = $theme->get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'ultimate-member';
@mkdir( $um_dir, 0777, true );
$src = realpath( $temp_dir );
$src = realpath( $temp_dir );
$dest = realpath( $um_dir );
if ( $src && $dest ) {
self::recurse_copy( $src, $dest );
error_log( "UM Log. Theme '" . $theme->get( 'template' ) . "' templates restored." );
error_log( "UM Log. Theme '" . $theme->get( 'Name' ) . "' templates restored." );
UM()->files()->remove_dir( $src );
} else {
error_log( "UM Error. Can not restore theme templates." );
error_log( 'UM Error. Can not restore theme templates.' );
}
delete_option( 'theme_version ' . $theme->get( 'Name' ) );
@@ -140,13 +140,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
$temp_dir = UM()->uploader()->get_core_temp_dir() . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $theme->get( 'template' );
@mkdir( $temp_dir, 0777, true );
$src = realpath( $um_dir );
$src = realpath( $um_dir );
$dest = realpath( $temp_dir );
if ( $src && $dest ) {
self::recurse_copy( $src, $dest );
error_log( "UM Log. Theme '" . $theme->get( 'template' ) . "' templates saved." );
error_log( "UM Log. Theme '" . $theme->get( 'Name' ) . "' templates saved." );
} else {
error_log( "UM Error. Can not save theme templates." );
error_log( 'UM Error. Can not save theme templates.' );
}
update_option( 'theme_version ' . $theme->get( 'Name' ), $theme->get( 'Version' ) );
@@ -156,7 +156,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
/**
* Filter: upgrader_package_options
*
*
* @param array $options
* @return array
*/
@@ -170,7 +170,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
/**
* Action: upgrader_process_complete
*
*
* @param \WP_Upgrader $WP_Upgrader
* @param array $options
*/
@@ -184,4 +184,4 @@ if ( ! class_exists( 'um\admin\core\Admin_Theme_Updater' ) ) {
}
}
}
+2 -2
View File
@@ -247,7 +247,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
'label' => __( 'Put as Pending Review', 'ultimate-member' )
),
'um_resend_activation' => array(
'label' => __( 'Resend Activation E-mail', 'ultimate-member' )
'label' => __( 'Resend Activation Email', 'ultimate-member' )
),
'um_deactivate' => array(
'label' => __( 'Deactivate', 'ultimate-member' )
@@ -407,7 +407,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
$status = array(
'approved' => __( 'Approved', 'ultimate-member' ),
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
'awaiting_email_confirmation' => __( 'Waiting e-mail confirmation', 'ultimate-member' ),
'awaiting_email_confirmation' => __( 'Waiting email confirmation', 'ultimate-member' ),
'inactive' => __( 'Inactive', 'ultimate-member' ),
'rejected' => __( 'Rejected', 'ultimate-member' ),
);
@@ -99,6 +99,15 @@ class UM_Emails_List_Table extends WP_List_Table {
$this->_column_headers = array( $columns, $hidden, $sortable );
}
/**
* Generates the table navigation above or below the table
*
* @since 3.1.0
* @param string $which
*/
protected function display_tablenav( $which ) {
// Stop displaying tablenav.
}
/**
* @param object $item
@@ -221,12 +230,14 @@ class UM_Emails_List_Table extends WP_List_Table {
function column_email( $item ) {
$active = UM()->options()->get( $item['key'] . '_on' );
$icon = ! empty( $active ) ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt';
$link = add_query_arg( array( 'email' => $item['key'] ) );
$text = '<span class="dashicons um-notification-status ' . esc_attr( $icon ) . '"></span><a href="' . esc_url( $link ) . '"><strong>' . $item['title'] . '</strong></a>';
$icon = ! empty( $active ) ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt';
$icon_title = ! empty( $active ) ? __( 'Enabled', 'ultimate-member' ) : __( 'Disabled', 'ultimate-member' );
$link = add_query_arg( array( 'email' => $item['key'] ), remove_query_arg( 'paged' ) );
$text = '<span class="dashicons um-notification-status ' . esc_attr( $icon ) . '" title="' . esc_attr( $icon_title ) . '"></span><a href="' . esc_url( $link ) . '"><strong>' . esc_html( $item['title'] ) . '</strong></a>';
if ( ! empty( $item['description'] ) ) {
$text .= ' <span class="um_tooltip dashicons dashicons-editor-help" title="' . esc_attr__( $item['description'], 'ultimate-member' ) . '"></span>';
$text .= ' <span class="um_tooltip dashicons dashicons-editor-help" title="' . esc_attr( $item['description'] ) . '"></span>';
}
return $text;
@@ -239,11 +250,11 @@ class UM_Emails_List_Table extends WP_List_Table {
* @return string
*/
function column_recipients( $item ) {
if ( $item['recipient'] == 'admin' ) {
if ( 'admin' === $item['recipient'] ) {
return UM()->options()->get( 'admin_email' );
} else {
return __( 'Member', 'ultimate-member' );
}
return __( 'Member', 'ultimate-member' );
}
@@ -253,7 +264,8 @@ class UM_Emails_List_Table extends WP_List_Table {
* @return string
*/
function column_configure( $item ) {
return '<a class="button um-email-configure" href="' . add_query_arg( array( 'email' => $item['key'] ) ) . '" title="' . esc_attr__( 'Edit template', 'ultimate-member' ) . '"><span class="dashicons dashicons-admin-generic"></span></a>';
$edit_link = add_query_arg( array( 'email' => $item['key'] ), remove_query_arg( 'paged' ) );
return '<a class="button um-email-configure" href="' . esc_url( $edit_link ) . '" title="' . esc_attr__( 'Manage', 'ultimate-member' ) . '">' . esc_html__( 'Manage', 'ultimate-member' ) . '</a>';
}
@@ -276,13 +288,13 @@ class UM_Emails_List_Table extends WP_List_Table {
}
$ListTable = new UM_Emails_List_Table( array(
'singular' => __( 'Email Notification', 'ultimate-member' ),
'plural' => __( 'Email Notifications', 'ultimate-member' ),
'ajax' => false
'singular' => __( 'Email Notification', 'ultimate-member' ),
'plural' => __( 'Email Notifications', 'ultimate-member' ),
'ajax' => false,
));
$per_page = 20;
$paged = $ListTable->get_pagenum();
$per_page = 999;
$paged = $ListTable->get_pagenum();
/**
* UM hook
@@ -306,9 +318,9 @@ $paged = $ListTable->get_pagenum();
* ?>
*/
$columns = apply_filters( 'um_email_templates_columns', array(
'email' => __( 'Email', 'ultimate-member' ),
'recipients' => __( 'Recipient(s)', 'ultimate-member' ),
'configure' => '',
'email' => __( 'Email', 'ultimate-member' ),
'recipients' => __( 'Recipient(s)', 'ultimate-member' ),
'configure' => '',
) );
$ListTable->set_columns( $columns );
@@ -317,18 +329,21 @@ $emails = UM()->config()->email_notifications;
$ListTable->prepare_items();
$ListTable->items = array_slice( $emails, ( $paged - 1 ) * $per_page, $per_page );
$ListTable->wpc_set_pagination_args( array( 'total_items' => count( $emails ), 'per_page' => $per_page ) ); ?>
$ListTable->wpc_set_pagination_args( array( 'total_items' => count( $emails ), 'per_page' => $per_page ) );
?>
<p class="description" style="margin: 20px 0 0 0;">
<?php
// translators: %s: doc link.
echo wp_kses( sprintf( __( 'You may get more details about email notifications customization <a href="%s">here</a>', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/1335-email-templates' ), UM()->get_allowed_html( 'admin_notice' ) );
?>
<h2 class="title"><?php esc_html_e( 'Email notifications', 'ultimate-member' ); ?></h2>
<p>
<?php esc_html_e( 'Email notifications sent from Ultimate Member are listed below. Click on an email to configure it.', 'ultimate-member' ); ?>
<br />
<?php esc_html_e( 'Emails should be sent from an email using your website\'s domain name. We highly recommend using a SMTP service email delivery.', 'ultimate-member' ); ?>
<?php echo wp_kses( sprintf( __( 'Please see this <a href="%s" target="_blank">doc</a> for more information.', 'ultimate-member' ), 'https://docs.ultimatemember.com/article/116-not-receiving-user-emails-or-admin-notifications' ), UM()->get_allowed_html( 'admin_notice' ) ); ?>
</p>
<div class="clear"></div>
<form action="" method="get" name="um-settings-emails" id="um-settings-emails">
<input type="hidden" name="page" value="um_options" />
<input type="hidden" name="tab" value="email" />
<?php $ListTable->display(); ?>
</form>
<div class="clear"></div>
@@ -58,8 +58,7 @@ class UM_Versions_List_Table extends WP_List_Table {
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, array(), $sortable );
$templates = get_option( 'um_template_statuses', array() );
$templates = is_array( $templates ) ? $templates : array();
$templates = UM()->common()->theme()->build_templates_data();
@uasort(
$templates,
@@ -163,6 +162,16 @@ class UM_Versions_List_Table extends WP_List_Table {
$icon = 1 === $item['status_code'] ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt';
return $item['status'] . ' <span class="dashicons um-notification-status ' . esc_attr( $icon ) . '"></span>';
}
/**
* Generates the table navigation above or below the table
*
* @since 3.1.0
* @param string $which
*/
protected function display_tablenav( $which ) {
// Stop displaying tablenav.
}
}
$list_table = new UM_Versions_List_Table(
@@ -210,6 +219,7 @@ $list_table->prepare_items();
<form action="" method="get" name="um-settings-template-versions" id="um-settings-template-versions">
<input type="hidden" name="page" value="um_options" />
<input type="hidden" name="tab" value="override_templates" />
<input type="hidden" name="tab" value="advanced" />
<input type="hidden" name="section" value="override_templates" />
<?php $list_table->display(); ?>
</form>
+1 -1
View File
@@ -70,7 +70,7 @@
</td>
<td class="last t">
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=awaiting_email_confirmation' ) ); ?>" class="warning">
<?php _e( 'Awaiting E-mail Confirmation', 'ultimate-member' ); ?>
<?php _e( 'Awaiting Email Confirmation', 'ultimate-member' ); ?>
</a>
</td>
</tr>
@@ -43,7 +43,7 @@
'id' => '_um_can_delete_everyone',
'type' => 'checkbox',
'label' => __( 'Can delete other member accounts?', 'ultimate-member' ),
'tooltip' => __( 'Allow this role to edit accounts of other members', 'ultimate-member' ),
'tooltip' => __( 'Allow this role to delete other user accounts.', 'ultimate-member' ),
'value' => ! empty( $role['_um_can_delete_everyone'] ) ? $role['_um_can_delete_everyone'] : 0,
),
array(
@@ -58,4 +58,4 @@
)
)
) )->render_form(); ?>
</div>
</div>
+14 -4
View File
@@ -1,12 +1,14 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$role = $object['data']; ?>
$role = $object['data'];
?>
<div class="um-admin-metabox">
<?php
UM()->admin_forms(
$form = UM()->admin_forms(
array(
'class' => 'um-role-publish um-top-label',
'prefix_id' => 'role',
@@ -20,7 +22,8 @@ $role = $object['data']; ?>
),
),
)
)->render_form();
);
$form->render_form();
?>
</div>
@@ -31,3 +34,10 @@ $role = $object['data']; ?>
<div class="clear"></div>
</div>
</div>
<?php
echo $form->render_external_link(
array(
'html' => __( 'Learn more about role priorities', 'ultimate-member' ),
'url' => 'https://docs.ultimatemember.com/article/1494-how-to-set-role-priority-for-user-roles',
)
);
+2 -2
View File
@@ -76,8 +76,8 @@
array(
'id' => '_um_url_email_activate',
'type' => 'text',
'label' => __( 'URL redirect after e-mail activation', 'ultimate-member' ),
'tooltip' => __( 'If you want users to go to a specific page other than login page after e-mail activation, enter the URL here.', 'ultimate-member' ),
'label' => __( 'URL redirect after email activation', 'ultimate-member' ),
'tooltip' => __( 'If you want users to go to a specific page other than login page after email activation, enter the URL here.', 'ultimate-member' ),
'value' => ! empty( $role['_um_url_email_activate'] ) ? __( $role['_um_url_email_activate'], 'ultimate-member' ) : '',
'conditional' => array( '_um_status', '=', 'checkmail' ),
),
+13
View File
@@ -20,9 +20,22 @@ if ( ! class_exists( 'um\ajax\Init' ) ) {
* @used-by \UM::includes()
*/
public function includes() {
$this->pages();
$this->secure();
}
/**
* @since 2.8.3
*
* @return Pages
*/
public function pages() {
if ( empty( UM()->classes['um\ajax\pages'] ) ) {
UM()->classes['um\ajax\pages'] = new Pages();
}
return UM()->classes['um\ajax\pages'];
}
/**
* @since 2.6.8
*
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace um\ajax;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Pages
*
* @package um\ajax
*/
class Pages {
/**
* Pages constructor.
*/
public function __construct() {
add_action( 'wp_ajax_um_get_pages_list', array( $this, 'get_pages_list' ) );
}
/**
* AJAX callback for getting the pages list
*/
public function get_pages_list() {
UM()->admin()->check_ajax_nonce();
// we will pass post IDs and titles to this array
$return = array();
$pre_result = apply_filters( 'um_admin_settings_get_pages_list', false );
if ( false === $pre_result ) {
$query_args = array(
'post_type' => 'page',
'post_status' => 'publish', // if you don't want drafts to be returned
'ignore_sticky_posts' => 1,
'posts_per_page' => 10, // how much to show at once
'paged' => absint( $_GET['page'] ),
'orderby' => 'title',
'order' => 'asc',
);
if ( ! empty( $_GET['search'] ) ) {
$query_args['s'] = sanitize_text_field( $_GET['search'] ); // the search query
}
$search_results = new \WP_Query( $query_args );
if ( $search_results->have_posts() ) {
while ( $search_results->have_posts() ) {
$search_results->the_post();
// shorten the title a little
$title = ( mb_strlen( $search_results->post->post_title ) > 50 ) ? mb_substr( $search_results->post->post_title, 0, 49 ) . '...' : $search_results->post->post_title;
$title = sprintf( __( '%s (ID: %s)', 'ultimate-member' ), $title, $search_results->post->ID );
$return[] = array( $search_results->post->ID, $title ); // array( Post ID, Post Title )
}
}
$return['total_count'] = $search_results->found_posts;
} else {
// got already calculated posts array from 3rd-party integrations (e.g. WPML, Polylang)
$return = $pre_result;
}
wp_send_json( $return );
}
}
+2 -2
View File
@@ -282,10 +282,10 @@ class Secure {
$content .= $br . '<div style="padding:10px; border:1px solid #ccc;">' . wp_kses( __( '<strong style="color:red">WARNING:</strong> Ensure that you\'ve created a full backup of your site as your restoration point before changing anything on your site with our recommendations.', 'ultimate-member' ), UM()->get_allowed_html( 'admin_notice' ) ) . '</div>';
if ( $suspicious_accounts_count > 0 ) {
$lock_register_forms_url = admin_url( 'admin.php?page=um_options&tab=secure&um_secure_lock_register_forms=1&_wpnonce=' . wp_create_nonce( 'um_secure_lock_register_forms' ) );
$lock_register_forms_url = admin_url( 'admin.php?page=um_options&tab=advanced&section=secure&um_secure_lock_register_forms=1&_wpnonce=' . wp_create_nonce( 'um_secure_lock_register_forms' ) );
$content .= $br . esc_html__( '1. Please temporarily lock all your active Register forms.', 'ultimate-member' );
$content .= ' <a href="' . esc_attr( $lock_register_forms_url ) . '" target="_blank">' . esc_html__( 'Click here to lock them now.', 'ultimate-member' ) . '</a>';
$content .= ' ' . esc_html__( 'You can unblock the Register forms later. Just go to Ultimate Member > Settings > Secure > uncheck the option "Lock All Register Forms".', 'ultimate-member' );
$content .= ' ' . esc_html__( 'You can unblock the Register forms later. Just go to Ultimate Member > Settings > Advanced > Security and uncheck the option "Lock All Register Forms".', 'ultimate-member' );
$content .= $br . $br;
$suspicious_accounts_url = admin_url( 'users.php?um_status=inactive' );
+106 -9
View File
@@ -31,6 +31,13 @@ if ( ! class_exists( 'um\Config' ) ) {
*/
public $core_pages;
/**
* @since 2.8.3
*
* @var array
*/
public $predefined_pages;
/**
* @var array
*/
@@ -275,14 +282,14 @@ if ( ! class_exists( 'um\Config' ) ) {
) );
$this->core_form_meta['register'] = array(
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"E-mail Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
'_um_custom_fields' => 'a:6:{s:10:"user_login";a:15:{s:5:"title";s:8:"Username";s:7:"metakey";s:10:"user_login";s:4:"type";s:4:"text";s:5:"label";s:8:"Username";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:0;s:8:"validate";s:15:"unique_username";s:9:"min_chars";i:3;s:9:"max_chars";i:24;s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"user_email";a:13:{s:5:"title";s:14:"Email Address";s:7:"metakey";s:10:"user_email";s:4:"type";s:4:"text";s:5:"label";s:14:"E-mail Address";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"validate";s:12:"unique_email";s:8:"position";s:1:"4";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"5";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:10:"first_name";a:12:{s:5:"title";s:10:"First Name";s:7:"metakey";s:10:"first_name";s:4:"type";s:4:"text";s:5:"label";s:10:"First Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"last_name";a:12:{s:5:"title";s:9:"Last Name";s:7:"metakey";s:9:"last_name";s:4:"type";s:4:"text";s:5:"label";s:9:"Last Name";s:8:"required";i:0;s:6:"public";i:1;s:8:"editable";b:1;s:8:"position";s:1:"3";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
'_um_mode' => 'register',
'_um_core' => 'register',
'_um_register_use_custom_settings' => 0,
);
$this->core_form_meta['login'] = array(
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or E-mail";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
'_um_custom_fields' => 'a:3:{s:8:"username";a:13:{s:5:"title";s:18:"Username or Email";s:7:"metakey";s:8:"username";s:4:"type";s:4:"text";s:5:"label";s:18:"Username or E-mail";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:0;s:8:"validate";s:24:"unique_username_or_email";s:8:"position";s:1:"1";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:13:"user_password";a:16:{s:5:"title";s:8:"Password";s:7:"metakey";s:13:"user_password";s:4:"type";s:8:"password";s:5:"label";s:8:"Password";s:8:"required";i:1;s:6:"public";i:1;s:8:"editable";b:1;s:9:"min_chars";i:8;s:9:"max_chars";i:30;s:15:"force_good_pass";i:1;s:18:"force_confirm_pass";i:1;s:8:"position";s:1:"2";s:6:"in_row";s:9:"_um_row_1";s:10:"in_sub_row";s:1:"0";s:9:"in_column";s:1:"1";s:8:"in_group";s:0:"";}s:9:"_um_row_1";a:4:{s:4:"type";s:3:"row";s:2:"id";s:9:"_um_row_1";s:8:"sub_rows";s:1:"1";s:4:"cols";s:1:"1";}}',
'_um_mode' => 'login',
'_um_core' => 'login',
'_um_login_use_custom_settings' => 0,
@@ -334,9 +341,9 @@ if ( ! class_exists( 'um\Config' ) ) {
'subject' => 'Welcome to {site_name}!',
'body' => 'Hi {display_name},<br /><br />' .
'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
'To login please visit the following url:<br /><br />' .
'{login_url} <br /><br />' .
'Your account e-mail: {email} <br />' .
'{action_title}:<br /><br />' .
'{action_url} <br /><br />' .
'Your account email: {email} <br />' .
'Your account username: {username} <br /><br />' .
'If you have any problems, please contact us at {admin_email}<br /><br />' .
'Thanks,<br />' .
@@ -355,7 +362,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'If you have any problems, please contact us at {admin_email}<br /><br />' .
'Thanks, <br />' .
'{site_name}',
'description' => __('Whether to send the user an email when his account needs e-mail activation','ultimate-member'),
'description' => __('Whether to send the user an email when his account needs email activation','ultimate-member'),
'recipient' => 'user'
),
'pending_email' => array(
@@ -379,7 +386,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
'To login please visit the following url:<br /><br />' .
'{login_url}<br /><br />' .
'Your account e-mail: {email}<br />' .
'Your account email: {email}<br />' .
'Your account username: {username}<br />' .
'Set your account password: {password_reset_link}<br /><br />' .
'If you have any problems, please contact us at {admin_email}<br /><br />' .
@@ -500,7 +507,7 @@ if ( ! class_exists( 'um\Config' ) ) {
),
'suspicious-activity' => array(
'key' => 'suspicious-activity',
'title' => __( 'Secure: Suspicious Account Activity', 'ultimate-member' ),
'title' => __( 'Security: Suspicious Account Activity', 'ultimate-member' ),
'subject' => __( '[{site_name}] Suspicious Account Activity', 'ultimate-member' ),
'body' => 'This is to inform you that there are suspicious activities with the following accounts: {user_profile_link}',
'description' => __( 'Whether to receive notification when suspicious account activity is detected.', 'ultimate-member' ),
@@ -841,6 +848,96 @@ if ( ! class_exists( 'um\Config' ) ) {
'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
) );
}
//end class
/**
* Get variable from config
*
* @param string $key
*
* @return mixed
*
* @since 2.8.3
*/
public function get( $key ) {
if ( empty( $this->$key ) ) {
$this->{'init_' . $key}();
}
return apply_filters( 'um_config_get', $this->$key, $key );
}
/**
* Init plugin core pages.
*
* @since 2.8.3
*/
public function init_predefined_pages() {
$core_forms = get_option( 'um_core_forms', array() );
$core_directories = get_option( 'um_core_directories', array() );
$setup_shortcodes = array_merge(
array(
'profile' => '',
'login' => '',
'register' => '',
'members' => '',
),
array_merge( $core_forms, $core_directories )
);
$this->predefined_pages = array(
'user' => array(
'title' => __( 'User', 'ultimate-member' ),
'content' => ! empty( $setup_shortcodes['profile'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['profile'] . '"]' : '',
),
'login' => array(
'title' => __( 'Login', 'ultimate-member' ),
'content' => ! empty( $setup_shortcodes['login'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['login'] . '"]' : '',
),
'register' => array(
'title' => __( 'Register', 'ultimate-member' ),
'content' => ! empty( $setup_shortcodes['register'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['register'] . '"]' : '',
),
'members' => array(
'title' => __( 'Members', 'ultimate-member' ),
'content' => ! empty( $setup_shortcodes['members'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['members'] . '"]' : '',
),
'logout' => array(
'title' => __( 'Logout', 'ultimate-member' ),
'content' => '',
),
'account' => array(
'title' => __( 'Account', 'ultimate-member' ),
'content' => '[ultimatemember_account]',
),
'password-reset' => array(
'title' => __( 'Password Reset', 'ultimate-member' ),
'content' => '[ultimatemember_password]',
),
);
/**
* Filters Ultimate Member predefined pages.
*
* @param {array} $pages Predefined pages.
*
* @return {array} Predefined pages.
*
* @since 2.8.3
* @hook um_predefined_pages
*
* @example <caption>Extend UM core pages.</caption>
* function my_predefined_pages( $pages ) {
* // your code here
* $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ), 'content' => 'my-page-predefined-content' );
* return $pages;
* }
* add_filter( 'um_predefined_pages', 'my_predefined_pages' );
*/
$this->predefined_pages = apply_filters( 'um_predefined_pages', $this->predefined_pages );
// since 2.8.3 legacy hook
// @todo remove in 3.0 version
$this->predefined_pages = apply_filters( 'um_core_pages', $this->predefined_pages );
$this->core_pages = $this->predefined_pages;
}
}
}
+4 -3
View File
@@ -228,7 +228,8 @@ if ( ! class_exists( 'UM' ) ) {
// init widgets
add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
//include short non class functions
// Include short non-class functions
require_once 'um-core-functions.php';
require_once 'um-short-functions.php';
require_once 'um-deprecated-functions.php';
}
@@ -585,8 +586,6 @@ if ( ! class_exists( 'UM' ) ) {
$this->theme_updater();
} elseif ( $this->is_request( 'frontend' ) ) {
$this->frontend()->includes();
$this->account();
$this->password();
$this->login();
$this->register();
$this->user_posts();
@@ -594,6 +593,8 @@ if ( ! class_exists( 'UM' ) ) {
}
//common includes
$this->account();
$this->password();
$this->rewrite();
$this->mail();
$this->rest_api();
+13
View File
@@ -24,6 +24,7 @@ if ( ! class_exists( 'um\common\Init' ) ) {
$this->screen();
$this->secure()->hooks();
$this->site_health();
$this->theme()->hooks();
}
/**
@@ -73,5 +74,17 @@ if ( ! class_exists( 'um\common\Init' ) ) {
}
return UM()->classes['um\common\site_health'];
}
/**
* @since 2.8.3
*
* @return Theme
*/
public function theme() {
if ( empty( UM()->classes['um\common\theme'] ) ) {
UM()->classes['um\common\theme'] = new Theme();
}
return UM()->classes['um\common\theme'];
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ if ( ! class_exists( 'um\common\Screen' ) ) {
* Screen constructor.
*/
public function __construct() {
add_filter( 'body_class', array( &$this, 'remove_admin_bar' ), 1000, 1 );
add_filter( 'body_class', array( &$this, 'remove_admin_bar' ), 1000 );
}
/**
+242
View File
@@ -0,0 +1,242 @@
<?php
namespace um\common;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Theme
*
* @package um\common
*/
class Theme {
public function hooks() {
add_action( 'after_switch_theme', array( &$this, 'flush_transient_templates_data' ) );
}
/**
* Find outdated UM templates and notify Administrator.
*
*/
public function flush_transient_templates_data() {
// Flush transient with the custom templates list.
delete_transient( 'um_custom_templates_list' );
}
/**
* Scan the template files.
*
* @param string $template_path Path to the template directory.
* @return array
*/
public static function scan_template_files( $template_path ) {
$files = @scandir( $template_path ); // @codingStandardsIgnoreLine.
$result = array();
if ( ! empty( $files ) ) {
foreach ( $files as $value ) {
if ( ! in_array( $value, array( '.', '..' ), true ) ) {
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
$sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
foreach ( $sub_files as $sub_file ) {
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
}
} else {
$result[] = $value;
}
}
}
}
return $result;
}
public static function get_all_templates() {
$scan_files['um'] = self::scan_template_files( UM_PATH . '/templates/' );
/**
* Filters an array of the template files for scanning versions.
*
* @since 2.6.1
* @hook um_override_templates_scan_files
*
* @param {array} $scan_files Template files for scanning versions.
*
* @return {array} Template files for scanning versions.
*/
return apply_filters( 'um_override_templates_scan_files', $scan_files );
}
/**
* @param $file string
*
* @return string
*/
public static function get_file_version( $file ) {
// Avoid notices if file does not exist.
if ( ! file_exists( $file ) ) {
return '';
}
// We don't need to write to the file, so just open for reading.
$fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine.
// Pull only the first 8kiB of the file in.
$file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine.
// PHP will close a file handle, but we are good citizens.
fclose( $fp ); // @codingStandardsIgnoreLine.
// Make sure we catch CR-only line endings.
$file_data = str_replace( "\r", "\n", $file_data );
$version = '';
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
$version = _cleanup_header_comment( $match[1] );
}
return $version;
}
public function get_custom_templates_list() {
$files_in_theme = array();
$scan_files = self::get_all_templates();
foreach ( $scan_files as $key => $files ) {
foreach ( $files as $file ) {
if ( false === strpos( $file, 'email/' ) ) {
/**
* Filters an array of the template files for scanning versions based on $key.
*
* Note: $key - means um or extension key.
*
* @since 2.6.1
* @hook um_override_templates_get_template_path__{$key}
*
* @param {array} $located Template file paths for scanning versions.
* @param {string} $file Template file name.
*
* @return {array} Template file paths for scanning versions.
*/
$located = apply_filters( "um_override_templates_get_template_path__{$key}", array(), $file );
$exceptions = array(
'members-grid.php',
'members-header.php',
'members-list.php',
'members-pagination.php',
'searchform.php',
'login-to-view.php',
'profile/comments.php',
'profile/comments-single.php',
'profile/posts.php',
'profile/posts-single.php',
'modal/um_upload_single.php',
'modal/um_view_photo.php',
);
$theme_file = false;
if ( ! empty( $located ) ) {
$theme_file = $located['theme'];
} elseif ( in_array( $file, $exceptions, true ) && file_exists( get_stylesheet_directory() . '/ultimate-member/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/ultimate-member/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/ultimate-member/templates/' . $file;
}
if ( ! empty( $theme_file ) ) {
if ( ! empty( $located ) ) {
$core_path = $located['core'];
} else {
$core_path = UM_PATH . 'templates/' . $file;
}
$files_in_theme[] = array(
'core' => $core_path,
'theme' => $theme_file,
);
}
}
}
}
return $files_in_theme;
}
public function is_outdated_template_exist() {
$outdated_exists = false;
$templates = $this->get_custom_templates_list();
foreach ( $templates as $files ) {
if ( ! array_key_exists( 'core', $files ) || ! array_key_exists( 'theme', $files ) ) {
continue;
}
$core_path = $files['core'];
$theme_file = $files['theme'];
$core_version = self::get_file_version( $core_path );
$theme_version = self::get_file_version( $theme_file );
if ( '' === $theme_version || version_compare( $theme_version, $core_version, '<' ) ) {
$outdated_exists = true;
break;
}
}
return $outdated_exists;
}
public function build_templates_data() {
$templates_data = array();
// Get from cache if isn't empty and request isn't force.
$transient = get_transient( 'um_custom_templates_list' );
if ( false !== $transient && array_key_exists( 'data', $transient ) ) {
return $transient['data'];
}
$templates = $this->get_custom_templates_list();
foreach ( $templates as $files ) {
if ( ! array_key_exists( 'core', $files ) || ! array_key_exists( 'theme', $files ) ) {
continue;
}
$core_path = $files['core'];
$theme_file = $files['theme'];
$core_version = self::get_file_version( $core_path );
$theme_version = self::get_file_version( $theme_file );
$status = esc_html__( 'Theme version up to date', 'ultimate-member' );
$status_code = 1;
if ( '' === $theme_version ) {
$status = esc_html__( 'Theme version is empty', 'ultimate-member' );
$status_code = 0;
} elseif ( version_compare( $theme_version, $core_version, '<' ) ) {
$status = esc_html__( 'Theme version is out of date', 'ultimate-member' );
$status_code = 0;
}
$templates_data[] = array(
'core_version' => $core_version,
'theme_version' => $theme_version,
'core_file' => stristr( $core_path, 'wp-content' ),
'theme_file' => stristr( $theme_file, 'wp-content' ),
'status' => $status,
'status_code' => $status_code,
);
}
// Cache results via transient setting.
$transient = array(
'data' => $templates_data,
'time' => time(),
);
set_transient( 'um_custom_templates_list', $transient, 5 * MINUTE_IN_SECONDS );
return $templates_data;
}
}
+11 -11
View File
@@ -273,7 +273,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
),
'tel' => array(
'name' => __( 'Telephone Box', 'ultimate-member' ),
'name' => __( 'Telephone', 'ultimate-member' ),
'col1' => array('_title','_metakey','_help','_default','_min_chars','_visibility'),
'col2' => array('_label','_placeholder','_public','_roles','_validate','_custom_validate','_max_chars'),
'col3' => array('_required','_editable','_icon'),
@@ -782,10 +782,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
),
'username' => array(
'title' => __('Username or E-mail','ultimate-member'),
'title' => __('Username or Email','ultimate-member'),
'metakey' => 'username',
'type' => 'text',
'label' => __('Username or E-mail','ultimate-member'),
'label' => __('Username or Email','ultimate-member'),
'required' => 1,
'public' => 1,
'editable' => false,
@@ -871,10 +871,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
),
'user_email' => array(
'title' => __('E-mail Address','ultimate-member'),
'title' => __('Email Address','ultimate-member'),
'metakey' => 'user_email',
'type' => 'text',
'label' => __('E-mail Address','ultimate-member'),
'label' => __('Email Address','ultimate-member'),
'required' => 0,
'public' => 1,
'validate' => 'unique_email',
@@ -882,10 +882,10 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
),
'secondary_user_email' => array(
'title' => __('Secondary E-mail Address','ultimate-member'),
'title' => __('Secondary Email Address','ultimate-member'),
'metakey' => 'secondary_user_email',
'type' => 'text',
'label' => __('Secondary E-mail Address','ultimate-member'),
'label' => __('Secondary Email Address','ultimate-member'),
'required' => 0,
'public' => 1,
'editable' => true,
@@ -1271,7 +1271,7 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
),
'username_b' => array(
'title' => __('Username or E-mail','ultimate-member'),
'title' => __('Username or Email','ultimate-member'),
'metakey' => 'username_b',
'type' => 'text',
'placeholder' => __('Enter your username or email','ultimate-member'),
@@ -1558,11 +1558,11 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
$array['skype'] = __('Skype ID','ultimate-member');
$array['soundcloud'] = __( 'SoundCloud Profile', 'ultimate-member' );
$array['twitter_url'] = __( 'X (formerly Twitter) URL', 'ultimate-member' );
$array['is_email'] = __('E-mail( Not Unique )','ultimate-member');
$array['unique_email'] = __('Unique E-mail','ultimate-member');
$array['is_email'] = __('Email( Not Unique )','ultimate-member');
$array['unique_email'] = __('Unique Email','ultimate-member');
$array['unique_value'] = __('Unique Metakey value','ultimate-member');
$array['unique_username'] = __('Unique Username','ultimate-member');
$array['unique_username_or_email'] = __('Unique Username/E-mail','ultimate-member');
$array['unique_username_or_email'] = __('Unique Username/Email','ultimate-member');
$array['url'] = __('Website URL','ultimate-member');
$array['youtube_url'] = __('YouTube Profile','ultimate-member');
$array['youtube_video'] = __('YouTube Video','ultimate-member');
+13 -1
View File
@@ -305,7 +305,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* }
* add_filter( 'um_email_template_body_attrs', 'my_email_template_body_attrs', 10, 3 );
*/
$body_attrs = apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug, $args );
$body_attrs = apply_filters( 'um_email_template_body_attrs', 'style="background: #fff;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug, $args );
?>
<body <?php echo $body_attrs; ?>>
@@ -623,6 +623,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
$placeholders[] = '{login_url}';
$placeholders[] = '{password}';
$placeholders[] = '{account_activation_link}';
$placeholders[] = '{action_url}';
$placeholders[] = '{action_title}';
return $placeholders;
}
@@ -641,6 +643,16 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
$replace_placeholders[] = um_get_core_page( 'login' );
$replace_placeholders[] = esc_html__( 'Your set password', 'ultimate-member' );
$replace_placeholders[] = um_user( 'account_activation_link' );
$set_password_required = get_user_meta( um_user( 'ID' ), 'um_set_password_required', true );
if ( empty( $set_password_required ) || 'pending' === um_user( 'status' ) ) {
$replace_placeholders[] = um_get_core_page( 'login' );
$replace_placeholders[] = esc_html__( 'Login to our site', 'ultimate-member' );
} else {
$replace_placeholders[] = um_user( 'password_reset_link' );
$replace_placeholders[] = esc_html__( 'Set your password', 'ultimate-member' );
}
return $replace_placeholders;
}
}
+271 -183
View File
@@ -31,15 +31,32 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
/**
* @var bool
*/
var $roles_in_query = false;
private $roles_in_query = false;
var $general_meta_joined = false;
/**
* @var bool
*/
public $general_meta_joined = false;
var $having = '';
var $select = '';
var $sql_limit = '';
var $sql_order = '';
/**
* @var string
*/
private $having = '';
/**
* @var string
*/
private $select = '';
/**
* @var string
*/
private $sql_limit = '';
/**
* @var string
*/
public $sql_order = '';
/**
* Member_Directory_Meta constructor.
@@ -55,28 +72,27 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
add_action( 'um_delete_custom_field', array( &$this, 'on_delete_custom_field' ), 10, 2 );
}
/**
* Delete custom field and metakey from UM usermeta table
*
* @param $metakey
* @param $args
*/
function on_delete_custom_field( $metakey, $args ) {
public function on_delete_custom_field( $metakey, $args ) {
$metakeys = get_option( 'um_usermeta_fields', array() );
if ( in_array( $metakey, $metakeys ) ) {
unset( $metakeys[ array_search( $metakey, $metakeys ) ] );
if ( in_array( $metakey, $metakeys, true ) ) {
unset( $metakeys[ array_search( $metakey, $metakeys, true ) ] );
global $wpdb;
$wpdb->delete(
"{$wpdb->prefix}um_metadata",
array(
'um_key' => $metakey
'um_key' => $metakey,
),
array(
'%s'
'%s',
)
);
@@ -86,17 +102,16 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
do_action( 'um_metadata_on_delete_custom_field', $metakeys, $metakey, $args );
}
/**
* Add metakey to usermeta fields
*
* @param $metakey
* @param $args
*/
function on_new_field_added( $metakey, $args ) {
public function on_new_field_added( $metakey, $args ) {
$metakeys = get_option( 'um_usermeta_fields', array() );
if ( ! in_array( $metakey, $metakeys ) ) {
if ( ! in_array( $metakey, $metakeys, true ) ) {
$metakeys[] = $metakey;
update_option( 'um_usermeta_fields', array_values( $metakeys ) );
}
@@ -104,7 +119,6 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
do_action( 'um_metadata_on_new_field_added', $metakeys, $metakey, $args );
}
/**
* When you delete usermeta - remove row from um_metadata
*
@@ -113,9 +127,9 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
* @param string $meta_key
* @param mixed $_meta_value
*/
function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
public function on_delete_usermeta( $meta_ids, $object_id, $meta_key, $_meta_value ) {
$metakeys = get_option( 'um_usermeta_fields', array() );
if ( ! in_array( $meta_key, $metakeys ) ) {
if ( ! in_array( $meta_key, $metakeys, true ) ) {
return;
}
@@ -124,17 +138,16 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$wpdb->delete(
"{$wpdb->prefix}um_metadata",
array(
'user_id' => $object_id,
'um_key' => $meta_key
'user_id' => $object_id,
'um_key' => $meta_key,
),
array(
'%d',
'%s'
'%s',
)
);
}
/**
* When you add/update usermeta - add/update row from um_metadata
*
@@ -143,32 +156,33 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
* @param string $meta_key
* @param mixed $_meta_value
*/
function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
public function on_update_usermeta( $meta_id, $object_id, $meta_key, $_meta_value ) {
$metakeys = get_option( 'um_usermeta_fields', array() );
if ( ! in_array( $meta_key, $metakeys ) ) {
if ( ! in_array( $meta_key, $metakeys, true ) ) {
return;
}
global $wpdb;
$result = $wpdb->get_var( $wpdb->prepare(
"SELECT umeta_id
FROM {$wpdb->prefix}um_metadata
WHERE user_id = %d AND
um_key = %s
LIMIT 1",
$object_id,
$meta_key
) );
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT umeta_id
FROM {$wpdb->prefix}um_metadata
WHERE user_id = %d AND
um_key = %s
LIMIT 1",
$object_id,
$meta_key
)
);
if ( empty( $result ) ) {
$wpdb->insert(
"{$wpdb->prefix}um_metadata",
array(
'user_id' => $object_id,
'um_key' => $meta_key,
'um_value' => maybe_serialize( $_meta_value ),
'user_id' => $object_id,
'um_key' => $meta_key,
'um_value' => maybe_serialize( $_meta_value ),
),
array(
'%d',
@@ -180,10 +194,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$wpdb->update(
"{$wpdb->prefix}um_metadata",
array(
'um_value' => maybe_serialize( $_meta_value ),
'um_value' => maybe_serialize( $_meta_value ),
),
array(
'umeta_id' => $result,
'umeta_id' => $result,
),
array(
'%s',
@@ -195,74 +209,100 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
}
}
/**
* @param $directory_data
* @param $field
* @param $value
* @param $i
* @param int $i
* @param bool $is_default
*/
function handle_filter_query( $directory_data, $field, $value, $i, $is_default = false ) {
protected function handle_filter_query( $directory_data, $field, $value, $i, $is_default = false ) {
global $wpdb;
$join_slug = $is_default ? 'ummd' : 'umm' ;
$join_slug = $is_default ? 'ummd' : 'umm';
$join_alias = esc_sql( $join_slug . $i );
$blog_id = get_current_blog_id();
switch ( $field ) {
default:
$filter_type = $this->filter_types[ $field ];
/**
* UM hook
* Filters marker for skipping default filter handle in member directory queries.
* Hook handle filter queries for the custom usermeta table only.
* Note: $field is the field meta key.
*
* @type filter
* @title um_query_args_{$field}__filter
* @description Change field's query for search at Members Directory
* @input_vars
* [{"var":"$field_query","type":"array","desc":"Field query"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_query_args_{$field}__filter_meta', 'function_name', 10, 4 ); ?>
* @example
* <?php
* add_filter( 'um_query_args_{$field}__filter_meta', 'my_query_args_filter', 10, 4 );
* function my_query_args_filter( $field_query ) {
* // your code here
* return $field_query;
* @since 2.1
* @hook um_query_args_{$field}__filter_meta
*
* @param {bool} $skip Skip default filter handler marker.
* @param {object} $member_directory_meta Member_Directory_Meta class instance.
* @param {string} $field Filter's field key.
* @param {mixed} $value Filter value.
* @param {string} $filter_type Filter type.
* @param {bool} $is_default If it's admin filtering option then `true`.
*
* @return {bool} Skip default filter handler marker.
*
* @example <caption>Skip filter by rating default handler and add 3rd-party handlers in callback.</caption>
* function um_custom_query_args_filter_rating__filter_meta( $skip, $member_directory_meta, $field, $value, $filter_type, $is_default ) {
* $skip = true;
* $member_directory_meta->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata ummreviews ON ( ummreviews.user_id = u.ID AND ummreviews.um_key = '_reviews_avg' )";
* return $skip;
* }
* ?>
* add_filter( 'um_query_args_filter_rating__filter_meta', 'um_custom_query_args_filter_rating__filter_meta', 10, 6 );
*/
$skip_default = apply_filters( "um_query_args_{$field}__filter_meta", false, $this, $field, $value, $filter_type, $is_default );
/**
* Filters marker for skipping default filter handle in member directory queries.
* Hook handle filter queries for the custom usermeta table only.
*
* @since 2.1
* @hook um_query_args_filter_global_meta
*
* @param {bool} $skip Skip default filter handler marker.
* @param {object} $member_directory_meta Member_Directory_Meta class instance.
* @param {string} $field Filter's field key.
* @param {mixed} $value Filter value.
* @param {string} $filter_type Filter type.
* @param {bool} $is_default If it's admin filtering option then `true`.
*
* @return {bool} Skip default filter handler marker.
*
* @example <caption>Skip filter by rating default handler and add 3rd-party handlers in callback.</caption>
* function um_custom_query_args_filter_global_meta( $skip, $member_directory_meta, $field, $value, $filter_type, $is_default ) {
* if ( 'filter_rating' === $field ) {
* $skip = true;
* $member_directory_meta->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata ummreviews ON ( ummreviews.user_id = u.ID AND ummreviews.um_key = '_reviews_avg' )";
* }
* return $skip;
* }
* add_filter( 'um_query_args_filter_global_meta', 'um_custom_query_args_filter_global_meta', 10, 6 );
*/
$skip_default = apply_filters( 'um_query_args_filter_global_meta', $skip_default, $this, $field, $value, $filter_type, $is_default );
if ( ! $skip_default ) {
switch ( $filter_type ) {
default:
do_action( "um_query_args_{$field}_{$filter_type}__filter_meta", $field, $value, $filter_type, $i, $is_default );
break;
case 'text':
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
$value = trim( stripslashes( $value ) );
$value = trim( stripslashes( $value ) );
$compare = apply_filters( 'um_members_directory_filter_text', '=', $field );
$value = apply_filters( 'um_members_directory_filter_text_meta_value', $value, $field );
$compare = esc_sql( $compare );
$value = apply_filters( 'um_members_directory_filter_text_meta_value', $value, $field );
$this->where_clauses[] = $wpdb->prepare( "{$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value {$compare} %s", $field, $value );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias and $compare variables are pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "{$join_alias}.um_key = %s AND {$join_alias}.um_value {$compare} %s", $field, $value );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
case 'select':
@@ -270,51 +310,57 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$value = array( $value );
}
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
$values_array = array();
foreach ( $value as $single_val ) {
$single_val = trim( stripslashes( $single_val ) );
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%"' . $single_val . '"%' );
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (string) $single_val ) . '%' );
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value = %s", $single_val );
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias and $compare variables are pre-escaped.
$values_array[] = $wpdb->prepare( "{$join_alias}.um_value LIKE %s", '%"' . $wpdb->esc_like( $single_val ) . '"%' );
$values_array[] = $wpdb->prepare( "{$join_alias}.um_value LIKE %s", '%' . $wpdb->esc_like( maybe_serialize( (string) $single_val ) ) . '%' );
$values_array[] = $wpdb->prepare( "{$join_alias}.um_value = %s", $single_val );
if ( is_numeric( $single_val ) ) {
$values_array[] = $wpdb->prepare( "{$join_slug}{$i}.um_value LIKE %s", '%' . serialize( (int) $single_val ) . '%' );
$values_array[] = $wpdb->prepare( "{$join_alias}.um_value LIKE %s", '%' . $wpdb->esc_like( maybe_serialize( (int) $single_val ) ) . '%' );
}
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
}
$values = implode( ' OR ', $values_array );
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND ( {$values} ) )", $field );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias and $values variables are pre-escaped or $wpdb->prepare.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = %s AND ( {$values} ) )", $field );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
case 'slider':
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
case 'slider':
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
$min = min( $value );
$max = max( $value );
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %d AND %d )", $field, $min, $max );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = %s AND {$join_alias}.um_value BETWEEN %d AND %d )", $field, $min, $max );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
case 'datepicker':
case 'datepicker':
$offset = 0;
if ( ! $is_default ) {
// phpcs:disable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
$offset = (int) $_POST['gmt_offset'];
}
// phpcs:enable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
} else {
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
if ( is_numeric( $gmt_offset ) ) {
@@ -324,103 +370,112 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$from_date = (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ); // client time zone offset
$to_date = (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1; // time 23:59
// @todo: rewrite date() in WP5.3 standards.
$from_date = date( 'Y/m/d', $from_date );
$to_date = date( 'Y/m/d', $to_date );
$to_date = date( 'Y/m/d', $to_date );
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $field, $from_date, $to_date );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = %s AND {$join_alias}.um_value BETWEEN %s AND %s )", $field, $from_date, $to_date );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = array( $from_date, $to_date );
}
break;
case 'timepicker':
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
if ( $value[0] == $value[1] ) {
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND {$join_slug}{$i}.um_value = %s )", $field, $value[0] );
case 'timepicker':
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
if ( $value[0] === $value[1] ) {
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = %s AND {$join_alias}.um_value = %s )", $field, $value[0] );
} else {
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = %s AND CAST( {$join_slug}{$i}.um_value AS TIME ) BETWEEN %s AND %s )", $field, $value[0], $value[1] );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = %s AND CAST( {$join_alias}.um_value AS TIME ) BETWEEN %s AND %s )", $field, $value[0], $value[1] );
}
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
}
}
break;
case 'role':
$value = array_map( 'strtolower', $value );
if ( empty( $this->roles ) && ! is_multisite() ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
$this->roles = $value;
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = %s )", $wpdb->get_blog_prefix( $blog_id ) . 'capabilities' );
$this->roles = $value;
$this->roles_in_query = true;
}
$roles_clauses = array();
foreach ( $value as $role ) {
$roles_clauses[] = $wpdb->prepare( "umm_roles.um_value LIKE %s", '%"' . $role . '"%' );
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $wpdb->esc_like( $role ) . '"%' );
}
// $roles_clauses is pre-prepared.
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
case 'birth_date':
// @todo: rewrite date() in WP5.3 standards.
$from_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ), date( 'Y', time() - min( $value ) * YEAR_IN_SECONDS ) ) );
$to_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ) + 1, date( 'Y', time() - ( max( $value ) + 1 ) * YEAR_IN_SECONDS ) ) );
$to_date = date( 'Y/m/d', mktime( 0,0,0, date( 'm', time() ), date( 'd', time() ) + 1, date( 'Y', time() - ( max( $value ) + 1 ) * YEAR_IN_SECONDS ) ) );
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = 'birth_date' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $to_date, $from_date );
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = 'birth_date' AND {$join_alias}.um_value BETWEEN %s AND %s )", $to_date, $from_date );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = array( $to_date, $from_date );
}
break;
case 'user_registered':
case 'user_registered':
$offset = 0;
if ( ! $is_default ) {
// phpcs:disable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
$offset = (int) $_POST['gmt_offset'];
}
// phpcs:enable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
} else {
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
if ( is_numeric( $gmt_offset ) ) {
$offset = (int) $gmt_offset;
}
}
// @todo: rewrite date() in WP5.3 standards.
$from_date = date( 'Y-m-d H:i:s', strtotime( min( $value ) ) + $offset * HOUR_IN_SECONDS ); // client time zone offset
$to_date = date( 'Y-m-d H:i:s', strtotime( max( $value ) ) + $offset * HOUR_IN_SECONDS + DAY_IN_SECONDS - 1 ); // time 23:59
$to_date = date( 'Y-m-d H:i:s', strtotime( max( $value ) ) + $offset * HOUR_IN_SECONDS + DAY_IN_SECONDS - 1 ); // time 23:59
$this->where_clauses[] = $wpdb->prepare( "u.user_registered BETWEEN %s AND %s", $from_date, $to_date );
$this->where_clauses[] = $wpdb->prepare( 'u.user_registered BETWEEN %s AND %s', $from_date, $to_date );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
case 'last_login':
$offset = 0;
if ( ! $is_default ) {
// phpcs:disable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
if ( isset( $_POST['gmt_offset'] ) && is_numeric( $_POST['gmt_offset'] ) ) {
$offset = (int) $_POST['gmt_offset'];
}
// phpcs:enable WordPress.Security.NonceVerification -- early verified in `ajax_get_members()`.
} else {
$gmt_offset = get_post_meta( $directory_data['form_id'], '_um_search_filters_gmt', true );
if ( is_numeric( $gmt_offset ) ) {
@@ -431,42 +486,42 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$from_date = gmdate( 'Y-m-d H:i:s', (int) min( $value ) + ( $offset * HOUR_IN_SECONDS ) ); // client time zone offset
$to_date = gmdate( 'Y-m-d H:i:s', (int) max( $value ) + ( $offset * HOUR_IN_SECONDS ) + DAY_IN_SECONDS - 1 ); // time 23:59
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_slug}{$i} ON {$join_slug}{$i}.user_id = u.ID";
$this->where_clauses[] = $wpdb->prepare( "( {$join_slug}{$i}.um_key = '_um_last_login' AND {$join_slug}{$i}.um_value BETWEEN %s AND %s )", $from_date, $to_date );
// $join_alias is pre-escaped.
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata {$join_alias} ON {$join_alias}.user_id = u.ID";
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $join_alias is pre-escaped.
$this->where_clauses[] = $wpdb->prepare( "( {$join_alias}.um_key = '_um_last_login' AND {$join_alias}.um_value BETWEEN %s AND %s )", $from_date, $to_date );
if ( ! $is_default ) {
$this->custom_filters_in_query[ $field ] = $value;
}
break;
}
}
/**
* Main Query function for getting members via AJAX
*/
function ajax_get_members() {
public function ajax_get_members() {
UM()->check_ajax_nonce();
global $wpdb;
$blog_id = get_current_blog_id();
// phpcs:disable WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
if ( empty( $_POST['directory_id'] ) ) {
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
}
$directory_id = $this->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
if ( empty( $directory_id ) ) {
wp_send_json_error( __( 'Wrong member directory data', 'ultimate-member' ) );
}
// phpcs:enable WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
$directory_data = UM()->query()->post_data( $directory_id );
//predefined result for user without capabilities to see other members
// Predefined result for user without capabilities to see other members.
$this->predefined_no_caps( $directory_data );
do_action( 'um_member_directory_before_query' );
@@ -474,7 +529,6 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
// Prepare for BIG SELECT query
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
if ( ! empty( $directory_data['show_these_users'] ) ) {
$show_these_users = maybe_unserialize( $directory_data['show_these_users'] );
@@ -482,7 +536,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$users_array = array();
foreach ( $show_these_users as $username ) {
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
$users_array[] = $exists_id;
$users_array[] = absint( $exists_id );
}
}
@@ -499,7 +553,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$users_array = array();
foreach ( $exclude_these_users as $username ) {
if ( false !== ( $exists_id = username_exists( $username ) ) ) {
$users_array[] = $exists_id;
$users_array[] = absint( $exists_id );
}
}
@@ -522,21 +576,24 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
if ( ! UM()->roles()->um_user_can( 'can_edit_everyone' ) ) {
if ( ! $this->general_meta_joined ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
$this->general_meta_joined = true;
}
// $profile_photo_where and $cover_photo_where are static in code.
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data' AND
umm_general.um_value LIKE '%s:14:\"account_status\";s:8:\"approved\";%' AND umm_general.um_value LIKE '%s:15:\"hide_in_members\";b:0;%'{$profile_photo_where}{$cover_photo_where} )";
} else {
if ( ! empty( $cover_photo_where ) || ! empty( $profile_photo_where ) ) {
if ( ! $this->general_meta_joined ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_general ON umm_general.user_id = u.ID";
$this->general_meta_joined = true;
}
// $profile_photo_where and $cover_photo_where are static in code.
$this->where_clauses[] = "( umm_general.um_key = 'um_member_directory_data'{$profile_photo_where}{$cover_photo_where} )";
}
}
//$this->roles = array();
if ( UM()->roles()->um_user_can( 'can_view_all' ) ) {
$view_roles = um_user( 'can_view_roles' );
@@ -560,58 +617,65 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
}
if ( ! empty( $this->roles ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = %s )", $wpdb->get_blog_prefix( $blog_id ) . 'capabilities' );
$roles_clauses = array();
foreach ( $this->roles as $role ) {
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $role . '"%' );
$roles_clauses[] = $wpdb->prepare( 'umm_roles.um_value LIKE %s', '%"' . $wpdb->esc_like( $role ) . '"%' );
}
// $roles_clauses is pre-prepared.
$this->where_clauses[] = '( ' . implode( ' OR ', $roles_clauses ) . ' )';
} else {
if ( ! $this->roles_in_query && is_multisite() ) {
// select users who have capabilities for current blog
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = '" . $wpdb->get_blog_prefix( $blog_id ) . "capabilities' )";
$this->where_clauses[] = "umm_roles.um_value IS NOT NULL";
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_roles ON ( umm_roles.user_id = u.ID AND umm_roles.um_key = %s )", $wpdb->get_blog_prefix( $blog_id ) . 'capabilities' );
$this->where_clauses[] = 'umm_roles.um_value IS NOT NULL';
} elseif ( $this->roles_in_query ) {
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
'users' => array(),
'is_search' => $this->is_search,
), $directory_data );
$member_directory_response = array(
'pagination' => $this->calculate_pagination( $directory_data, 0 ),
'users' => array(),
'is_search' => $this->is_search,
);
$member_directory_response = apply_filters( 'um_ajax_get_members_response', $member_directory_response, $directory_data );
wp_send_json_success( $member_directory_response );
}
}
// phpcs:disable WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
if ( ! empty( $_POST['search'] ) ) {
$search_line = $this->prepare_search( $_POST['search'] );
// phpcs:enable WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
if ( ! empty( $search_line ) ) {
$searches = array();
foreach ( $this->core_search_fields as $field ) {
$searches[] = $wpdb->prepare( "u.{$field} LIKE %s", '%' . $search_line . '%' );
$field = esc_sql( $field );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $field is pre-escaped.
$searches[] = $wpdb->prepare( "u.{$field} LIKE %s", '%' . $wpdb->esc_like( $search_line ) . '%' );
}
$core_search = implode( ' OR ', $searches );
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_search ON umm_search.user_id = u.ID";
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '',$search_line );
$additional_search = apply_filters( 'um_member_directory_meta_general_search_meta_query', '', $search_line );
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $search_line . '%', $search_line );
$search_like_string = apply_filters( 'um_member_directory_meta_search_like_type', '%' . $wpdb->esc_like( $search_line ) . '%', $search_line );
$this->where_clauses[] = $wpdb->prepare( "( umm_search.um_value = %s OR umm_search.um_value LIKE %s OR umm_search.um_value LIKE %s OR {$core_search}{$additional_search})", $search_line, $search_like_string, '%' . serialize( (string) $search_line ) . '%' );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $core_search and $additional_search are pre-prepared.
$this->where_clauses[] = $wpdb->prepare( "( umm_search.um_value = %s OR umm_search.um_value LIKE %s OR umm_search.um_value LIKE %s OR {$core_search}{$additional_search})", $search_line, $search_like_string, '%' . $wpdb->esc_like( maybe_serialize( (string) $search_line ) ) . '%' );
$this->is_search = true;
}
}
//filters
// Filters
$filter_query = array();
if ( ! empty( $directory_data['search_fields'] ) ) {
$search_filters = maybe_unserialize( $directory_data['search_fields'] );
if ( ! empty( $search_filters ) && is_array( $search_filters ) ) {
// phpcs:ignore WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
$filter_query = array_intersect_key( $_POST, array_flip( $search_filters ) );
}
}
@@ -663,15 +727,16 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
//}
$order = 'ASC';
// phpcs:ignore WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
$sortby = ( 'other' === $sortby ) ? $directory_data['sortby_custom'] : $sortby;
$custom_sort = array();
if ( ! empty( $directory_data['sorting_fields'] ) ) {
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
foreach ( $sorting_fields as $field ) {
if ( is_array( $field ) ) {
$field_keys = array_keys( $field );
$field_keys = array_keys( $field );
$custom_sort[] = $field_keys[0];
}
}
@@ -698,10 +763,10 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
// handle sorting options
// sort members by
if ( $sortby == $directory_data['sortby_custom'] || in_array( $sortby, $custom_sort ) ) {
if ( $sortby === $directory_data['sortby_custom'] || in_array( $sortby, $custom_sort, true ) ) {
$custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'ASC';
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby );
$meta_query = new \WP_Meta_Query();
$custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $meta_query->get_cast_for_type( $directory_data['sortby_custom_type'] ) : 'CHAR';
@@ -720,47 +785,60 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
/** This filter is documented in includes/core/class-member-directory.php */
$custom_sort_type = apply_filters( 'um_member_directory_custom_sorting_type', $custom_sort_type, $sortby, $directory_data );
$custom_sort_type = esc_sql( $custom_sort_type );
$custom_sort_type = in_array( strtoupper( $custom_sort_type ), $this->sort_data_types, true ) ? $custom_sort_type : 'CHAR';
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$custom_sort_order} ";
$custom_sort_order = esc_sql( $custom_sort_order );
$custom_sort_order = in_array( strtoupper( $custom_sort_order ), array( 'ASC', 'DESC' ), true ) ? $custom_sort_order : 'ASC';
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS {$custom_sort_type} ) {$custom_sort_order} ";
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys, true ) ) {
if ( strstr( $sortby, '_desc' ) ) {
if ( false !== strpos( $sortby, '_desc' ) ) {
$sortby = str_replace( '_desc', '', $sortby );
$order = 'DESC';
$order = 'DESC';
}
if ( strstr( $sortby, '_asc' ) ) {
if ( false !== strpos( $sortby, '_asc' ) ) {
$sortby = str_replace( '_asc', '', $sortby );
$order = 'ASC';
$order = 'ASC';
}
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby );
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS SIGNED ) {$order}, u.user_registered DESC ";
} elseif ( 'username' == $sortby ) {
} elseif ( 'username' === $sortby ) {
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY u.user_login {$order} ";
} elseif ( 'display_name' == $sortby ) {
} elseif ( 'display_name' === $sortby ) {
$display_name = UM()->options()->get( 'display_name' );
if ( $display_name == 'username' ) {
if ( 'username' === $display_name ) {
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY u.user_login {$order} ";
} else {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'full_name' )";
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order}, u.display_name {$order} ";
}
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ), true ) ) {
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby );
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
} elseif ( 'last_login' === $sortby ) {
@@ -768,20 +846,22 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '_um_last_login' )";
$this->sql_order = ' ORDER BY CAST( umm_sort.um_value AS DATETIME ) DESC ';
} elseif ( $sortby == 'last_first_name' ) {
} elseif ( 'last_first_name' === $sortby ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = 'last_name' )";
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort2 ON ( umm_sort2.user_id = u.ID AND umm_sort2.um_key = 'first_name' )";
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC, CAST( umm_sort2.um_value AS CHAR ) ASC ";
$this->sql_order = ' ORDER BY CAST( umm_sort.um_value AS CHAR ) ASC, CAST( umm_sort2.um_value AS CHAR ) ASC ';
} elseif ( $sortby == 'random' ) {
} elseif ( 'random' === $sortby ) {
if ( um_is_session_started() === false ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
@session_start();
}
// Reset seed on load of initial
// phpcs:ignore WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
if ( empty( $_REQUEST['directory_id'] ) && isset( $_SESSION['um_member_directory_seed'] ) ) {
unset( $_SESSION['um_member_directory_seed'] );
}
@@ -789,34 +869,41 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
// Get seed from session variable if it exists
$seed = false;
if ( isset( $_SESSION['um_member_directory_seed'] ) ) {
$seed = $_SESSION['um_member_directory_seed'];
$seed = (int) $_SESSION['um_member_directory_seed'];
}
// Set new seed if none exists
if ( ! $seed ) {
$seed = rand();
$seed = wp_rand();
$_SESSION['um_member_directory_seed'] = $seed;
}
$seed = esc_sql( $seed );
$this->sql_order = 'ORDER BY RAND(' . $seed . ')';
} else {
if ( strstr( $sortby, '_desc' ) ) {
if ( false !== strpos( $sortby, '_desc' ) ) {
$sortby = str_replace( '_desc', '', $sortby );
$order = 'DESC';
$order = 'DESC';
}
if ( strstr( $sortby, '_asc' ) ) {
if ( false !== strpos( $sortby, '_asc' ) ) {
$sortby = str_replace( '_asc', '', $sortby );
$order = 'ASC';
$order = 'ASC';
}
$metakeys = get_option( 'um_usermeta_fields', array() );
if ( false !== array_search( $sortby, $metakeys ) ) {
$this->joins[] = "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = '{$sortby}' )";
if ( in_array( $sortby, $metakeys, true ) ) {
$this->joins[] = $wpdb->prepare( "LEFT JOIN {$wpdb->prefix}um_metadata umm_sort ON ( umm_sort.user_id = u.ID AND umm_sort.um_key = %s )", $sortby );
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY CAST( umm_sort.um_value AS CHAR ) {$order} ";
} else {
} elseif ( in_array( $sortby, $this->core_users_fields, true ) ) {
$sortby = esc_sql( $sortby );
$order = esc_sql( $order );
$order = in_array( strtoupper( $order ), array( 'ASC', 'DESC' ), true ) ? $order : 'ASC';
$this->sql_order = " ORDER BY u.{$sortby} {$order} ";
}
}
@@ -829,11 +916,11 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
}
$query_number = ( ! empty( $directory_data['max_users'] ) && $directory_data['max_users'] <= $profiles_per_page ) ? $directory_data['max_users'] : $profiles_per_page;
$query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
$query_paged = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification -- verified via `UM()->check_ajax_nonce();`.
$number = $query_number;
if ( ! empty( $directory_data['max_users'] ) && $query_paged*$query_number > $directory_data['max_users'] ) {
$number = ( $query_paged*$query_number - ( $query_paged*$query_number - $directory_data['max_users'] ) ) % $query_number;
if ( ! empty( $directory_data['max_users'] ) && $query_paged * $query_number > $directory_data['max_users'] ) {
$number = ( $query_paged * $query_number - ( $query_paged * $query_number - $directory_data['max_users'] ) ) % $query_number;
}
// limit
@@ -843,11 +930,11 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
do_action( 'um_pre_users_query', $this, $directory_data, $sortby );
$sql_join = implode( ' ', $this->joins );
$sql_where = implode( ' AND ', $this->where_clauses );
$sql_where = ! empty( $sql_where ) ? 'AND ' . $sql_where : '';
global $wpdb;
$sql_select = esc_sql( $this->select );
$sql_having = esc_sql( $this->having );
$sql_join = implode( ' ', $this->joins );
$sql_where = implode( ' AND ', $this->where_clauses );
$sql_where = ! empty( $sql_where ) ? 'AND ' . $sql_where : '';
/*
*
@@ -857,11 +944,11 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
* */
$user_ids = $wpdb->get_col(
"SELECT SQL_CALC_FOUND_ROWS DISTINCT u.ID
{$this->select}
{$sql_select}
FROM {$wpdb->users} AS u
{$sql_join}
WHERE 1=1 {$sql_where}
{$this->having}
{$sql_having}
{$this->sql_order}
{$this->sql_limit}"
);
@@ -901,7 +988,7 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
$this->cover_size = UM()->mobile()->isTablet() ? $sizes[1] : end( $sizes );
$avatar_size = UM()->options()->get( 'profile_photosize' );
$avatar_size = UM()->options()->get( 'profile_photosize' );
$this->avatar_size = str_replace( 'px', '', $avatar_size );
$users = array();
@@ -912,11 +999,12 @@ if ( ! class_exists( 'um\core\Member_Directory_Meta' ) ) {
um_reset_user();
// end of user card
$member_directory_response = apply_filters( 'um_ajax_get_members_response', array(
'pagination' => $pagination_data,
'users' => $users,
'is_search' => $this->is_search,
), $directory_data );
$member_directory_response = array(
'pagination' => $pagination_data,
'users' => $users,
'is_search' => $this->is_search,
);
$member_directory_response = apply_filters( 'um_ajax_get_members_response', $member_directory_response, $directory_data );
wp_send_json_success( $member_directory_response );
}
+38 -17
View File
@@ -58,7 +58,11 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
var $filter_types = array();
/**
* Fields used for searching from wp_users table.
*
* @var string[]
*/
var $core_search_fields = array(
'user_login',
'user_url',
@@ -67,6 +71,19 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
'user_nicename',
);
/**
* Fields used for sorting from wp_users table.
*
* @var string[]
*/
var $core_users_fields = array(
'user_login',
'user_url',
'display_name',
'user_email',
'user_nicename',
'user_registered',
);
/**
* @var
@@ -408,7 +425,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
'first_name' => __( 'First Name', 'ultimate-member' ),
'last_name' => __( 'Last Name', 'ultimate-member' ),
'nickname' => __( 'Nickname', 'ultimate-member' ),
'secondary_user_email' => __( 'Secondary E-mail Address', 'ultimate-member' ),
'secondary_user_email' => __( 'Secondary Email Address', 'ultimate-member' ),
'description' => __( 'Biography', 'ultimate-member' ),
'phone_number' => __( 'Phone Number', 'ultimate-member' ),
'mobile_number' => __( 'Mobile Number', 'ultimate-member' ),
@@ -1314,24 +1331,24 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$this->query_args['paged'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
}
/**
* Add sorting attributes for \WP_Users_Query
*
* @param array $directory_data Member Directory options
*/
function sorting_query( $directory_data ) {
public function sorting_query( $directory_data ) {
// sort members by
$this->query_args['order'] = 'ASC';
$sortby = ! empty( $_POST['sorting'] ) ? sanitize_text_field( $_POST['sorting'] ) : $directory_data['sortby'];
$sortby = ( $sortby == 'other' ) ? $directory_data['sortby_custom'] : $sortby;
$sortby = ( 'other' === $sortby ) ? $directory_data['sortby_custom'] : $sortby;
$custom_sort = array();
if ( ! empty( $directory_data['sorting_fields'] ) ) {
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
foreach ( $sorting_fields as $field ) {
if ( is_array( $field ) ) {
$field_keys = array_keys( $field );
$field_keys = array_keys( $field );
$custom_sort[] = $field_keys[0];
}
}
@@ -1384,7 +1401,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$this->query_args['order'] = 'ASC';
}
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ) ) ) {
} elseif ( in_array( $sortby, array( 'last_name', 'first_name', 'nickname' ), true ) ) {
$this->query_args['meta_query'] = array_merge( $this->query_args['meta_query'], array( $sortby . '_c' => array(
'key' => $sortby,
@@ -1426,7 +1443,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$this->query_args['orderby'] = array( 'last_name_c' => 'ASC', 'first_name_c' => 'ASC' );
unset( $this->query_args['order'] );
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys ) ) {
} elseif ( count( $numeric_sorting_keys ) && in_array( $sortby, $numeric_sorting_keys, true ) ) {
$order = 'DESC';
if ( strstr( $sortby, '_desc' ) ) {
@@ -1458,18 +1475,23 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
)
);
$this->query_args['orderby'] = array( $sortby . '_ns' => $order, 'user_registered' => 'DESC' );
$this->query_args['orderby'] = array(
$sortby . '_ns' => $order,
'user_registered' => 'DESC',
);
unset( $this->query_args['order'] );
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby == $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort ) ) {
} elseif ( ( ! empty( $directory_data['sortby_custom'] ) && $sortby === $directory_data['sortby_custom'] ) || in_array( $sortby, $custom_sort, true ) ) {
$custom_sort_order = ! empty( $directory_data['sortby_custom_order'] ) ? $directory_data['sortby_custom_order'] : 'ASC';
$meta_query = new \WP_Meta_Query();
$custom_sort_type = ! empty( $directory_data['sortby_custom_type'] ) ? $meta_query->get_cast_for_type( $directory_data['sortby_custom_type'] ) : 'CHAR';
if ( ! empty( $directory_data['sorting_fields'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification -- already verified here
$sorting = sanitize_text_field( $_POST['sorting'] );
$sorting_fields = maybe_serialize( $directory_data['sorting_fields'] );
$sorting_fields = maybe_unserialize( $directory_data['sorting_fields'] );
if ( ! empty( $sorting_fields ) && is_array( $sorting_fields ) ) {
foreach ( $sorting_fields as $field ) {
if ( isset( $field[ $sorting ] ) ) {
@@ -2629,14 +2651,13 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
// Prepare default user query values
$this->query_args = array(
'fields' => 'ids',
'number' => 0,
'meta_query' => array(
'relation' => 'AND'
'fields' => 'ids',
'number' => 0,
'meta_query' => array(
'relation' => 'AND',
),
);
// handle different restrictions
$this->restriction_options();
@@ -2770,7 +2791,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$this->cover_size = apply_filters( 'um_member_directory_cover_image_size', $this->cover_size, $directory_data );
$avatar_size = UM()->options()->get( 'profile_photosize' );
$avatar_size = UM()->options()->get( 'profile_photosize' );
$this->avatar_size = str_replace( 'px', '', $avatar_size );
$this->avatar_size = apply_filters( 'um_member_directory_avatar_image_size', $this->avatar_size, $directory_data );
+15 -2
View File
@@ -1,8 +1,9 @@
<?php
namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'um\core\Options' ) ) {
@@ -125,6 +126,18 @@ if ( ! class_exists( 'um\core\Options' ) ) {
return $settings_defaults[ $option_id ];
}
/**
* Get predefined page option key
*
* @since 2.8.3
*
* @param string $slug
*
* @return string
*/
public function get_predefined_page_option_key( $slug ) {
return apply_filters( 'um_predefined_page_option_key', "core_{$slug}" );
}
/**
* Get core page ID
+14
View File
@@ -155,6 +155,7 @@ if ( ! class_exists( 'um\core\Password' ) ) {
if ( false !== $this->change_password ) {
// then COOKIE are valid then get data from them and populate hidden fields for the password reset form
$args['rp_mode'] = 'pw_change';
$args['template'] = 'password-change';
$args['rp_key'] = '';
$rp_cookie = 'wp-resetpass-' . COOKIEHASH;
@@ -163,6 +164,14 @@ if ( ! class_exists( 'um\core\Password' ) ) {
$args['login'] = $rp_login;
$args['rp_key'] = $rp_key;
$rp_user_obj = get_user_by( 'login', $rp_login );
if ( false !== $rp_user_obj ) {
$set_password_required = get_user_meta( $rp_user_obj->ID, 'um_set_password_required', true );
if ( ! empty( $set_password_required ) ) {
$args['rp_mode'] = 'pw_set';
}
}
}
}
@@ -599,6 +608,11 @@ if ( ! class_exists( 'um\core\Password' ) ) {
}
$this->setcookie( $rp_cookie, false );
$set_password_required = get_user_meta( $user->ID, 'um_set_password_required', true );
if ( ! empty( $set_password_required ) ) {
delete_user_meta( $user->ID, 'um_set_password_required' );
}
/**
* UM hook
*
+9 -1
View File
@@ -125,8 +125,14 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
wp_die( __( 'This activation link is expired.', 'ultimate-member' ) );
}
$redirect = um_get_core_page( 'login', 'account_active' );
$set_password_required = get_user_meta( $user_id, 'um_set_password_required', true );
um_fetch_user( $user_id );
UM()->user()->approve();
if ( ! empty( $set_password_required ) ) {
$redirect = um_user( 'password_reset_link' );
}
um_reset_user();
$user_role = UM()->roles()->get_priority_user_role( $user_id );
@@ -167,7 +173,9 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
*/
do_action( 'um_after_email_confirmation', $user_id );
$redirect = empty( $user_role_data['url_email_activate'] ) ? um_get_core_page( 'login', 'account_active' ) : trim( $user_role_data['url_email_activate'] ); // Role setting "URL redirect after e-mail activation"
if ( empty( $set_password_required ) ) {
$redirect = empty( $user_role_data['url_email_activate'] ) ? um_get_core_page( 'login', 'account_active' ) : trim( $user_role_data['url_email_activate'] ); // Role setting "URL redirect after email activation"
}
$redirect = apply_filters( 'um_after_email_confirmation_redirect', $redirect, $user_id, $login );
exit( wp_redirect( $redirect ) );
+7
View File
@@ -162,6 +162,13 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) {
if ( empty( $custom_meta ) ) {
// Set default permalink base if custom meta is empty.
$permalink_base = 'user_login';
} else {
// Ignore username slug if custom meta slug exists.
$user_id = username_exists( um_queried_user() );
$custom_permalink = get_user_meta( $user_id, 'um_user_profile_url_slug_' . $permalink_base, true );
if ( ! empty( $custom_permalink ) && um_queried_user() !== $custom_permalink ) {
return false;
}
}
}
+67 -21
View File
@@ -191,27 +191,7 @@ KEY meta_value_indx (um_value(191))
$content = '[ultimatemember form_id="' . $setup_shortcodes[ $slug ] . '"]';
}
/**
* Filters Ultimate Member predefined pages content when set up the predefined page.
*
* @param {string} $content Predefined page content.
* @param {string} $slug Predefined page slug (key).
*
* @return {string} Predefined page content.
*
* @since 2.1.0
* @hook um_setup_predefined_page_content
*
* @example <caption>Set Ultimate Member predefined pages content with key = 'my_page_key'.</caption>
* function my_um_setup_predefined_page_content( $content, $slug ) {
* // your code here
* if ( 'my_page_key' === $slug ) {
* $content = __( 'My Page content', 'my-translate-key' );
* }
* return $pages;
* }
* add_filter( 'um_setup_predefined_page_content', 'my_um_setup_predefined_page_content' );
*/
/** This filter is documented in includes/core/class-setup.php */
$content = apply_filters( 'um_setup_predefined_page_content', $content, $slug );
$user_page = array(
@@ -243,6 +223,72 @@ KEY meta_value_indx (um_value(191))
UM()->rewrite()->reset_rules();
}
public function predefined_page( $slug, $with_rewrite = true ) {
$page_exists = UM()->query()->find_post_id( 'page', '_um_core', $slug );
if ( $page_exists ) {
return;
}
$predefined_pages = UM()->config()->get( 'predefined_pages' );
if ( empty( $predefined_pages ) || ! array_key_exists( $slug, $predefined_pages ) ) {
return;
}
$data = $predefined_pages[ $slug ];
if ( empty( $data['title'] ) ) {
return;
}
$content = ! empty( $data['content'] ) ? $data['content'] : '';
/**
* Filters Ultimate Member predefined pages content when set up the predefined page.
*
* @param {string} $content Predefined page content.
* @param {string} $slug Predefined page slug (key).
*
* @return {string} Predefined page content.
*
* @since 2.1.0
* @hook um_setup_predefined_page_content
*
* @example <caption>Set Ultimate Member predefined pages content with key = 'my_page_key'.</caption>
* function my_um_setup_predefined_page_content( $content, $slug ) {
* // your code here
* if ( 'my_page_key' === $slug ) {
* $content = __( 'My Page content', 'my-translate-key' );
* }
* return $pages;
* }
* add_filter( 'um_setup_predefined_page_content', 'my_um_setup_predefined_page_content' );
*/
$content = apply_filters( 'um_setup_predefined_page_content', $content, $slug );
$user_page = array(
'post_title' => $data['title'],
'post_content' => $content,
'post_name' => $slug,
'post_type' => 'page',
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'comment_status' => 'closed',
);
$post_id = wp_insert_post( $user_page );
if ( empty( $post_id ) || is_wp_error( $post_id ) ) {
return;
}
update_post_meta( $post_id, '_um_core', $slug );
UM()->options()->update( UM()->options()->get_predefined_page_option_key( $slug ), $post_id );
if ( $with_rewrite ) {
// Reset rewrite rules after page creation and option upgrade.
UM()->rewrite()->reset_rules();
}
}
/**
* Set default UM settings.
*/
+7 -7
View File
@@ -1301,7 +1301,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
}
if ( $this->usermeta['account_status'][0] == 'awaiting_email_confirmation' ) {
$this->usermeta['account_status_name'][0] = __( 'Awaiting E-mail Confirmation', 'ultimate-member' );
$this->usermeta['account_status_name'][0] = __( 'Awaiting Email Confirmation', 'ultimate-member' );
}
if ( $this->usermeta['account_status'][0] == 'awaiting_admin_review' ) {
@@ -1676,7 +1676,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
/**
* This method approves a user membership and sends them an optional welcome/approval e-mail.
* This method approves a user membership and sends them an optional welcome/approval email.
*
* @usage <?php UM()->user()->approve(); ?>
*
@@ -1690,7 +1690,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
?>
*
*/
function approve( $repeat = true ) {
public function approve( $repeat = true ) {
$user_id = um_user( 'ID' );
if ( ! $repeat ) {
@@ -1702,7 +1702,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
delete_option( "um_cache_userdata_{$user_id}" );
if ( um_user( 'account_status' ) == 'awaiting_admin_review' ) {
if ( 'awaiting_admin_review' === um_user( 'account_status' ) ) {
$userdata = get_userdata( $user_id );
$this->maybe_generate_password_reset_key( $userdata );
@@ -1758,7 +1758,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
/**
* This method puts a user under manual review by administrator and sends them an optional e-mail.
* This method puts a user under manual review by administrator and sends them an optional email.
*
* @usage <?php UM()->user()->pending(); ?>
*
@@ -1784,7 +1784,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
/**
* This method rejects a user membership and sends them an optional e-mail.
* This method rejects a user membership and sends them an optional email.
*
* @usage <?php UM()->user()->reject(); ?>
*
@@ -1811,7 +1811,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
/**
* This method deactivates a user membership and sends them an optional e-mail.
* This method deactivates a user membership and sends them an optional email.
*
* @usage <?php UM()->user()->deactivate(); ?>
*
+3 -3
View File
@@ -157,15 +157,15 @@ function um_submit_account_errors_hook( $args ) {
if ( isset( $args['user_email'] ) ) {
if ( strlen( trim( $args['user_email'] ) ) === 0 ) {
UM()->form()->add_error( 'user_email', __( 'You must provide your e-mail', 'ultimate-member' ) );
UM()->form()->add_error( 'user_email', __( 'You must provide your email', 'ultimate-member' ) );
}
if ( ! is_email( $args['user_email'] ) ) {
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
UM()->form()->add_error( 'user_email', __( 'Please provide a valid email', 'ultimate-member' ) );
}
if ( email_exists( $args['user_email'] ) && email_exists( $args['user_email'] ) !== get_current_user_id() ) {
UM()->form()->add_error( 'user_email', __( 'Please provide a valid e-mail', 'ultimate-member' ) );
UM()->form()->add_error( 'user_email', __( 'Please provide a valid email', 'ultimate-member' ) );
}
}
+2 -1
View File
@@ -100,10 +100,11 @@ function um_action_request_process() {
wp_die( esc_html__( 'You do not have permission to make this action.', 'ultimate-member' ) );
}
um_fetch_user( $uid );
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
um_fetch_user( $uid );
UM()->user()->approve();
exit( wp_redirect( UM()->permalinks()->get_current_url( true ) ) );
break;
+51 -52
View File
@@ -821,7 +821,7 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
case 'soundcloud_url':
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'soundcloud.com' ) ) {
// translators: %s: label.
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL','ultimate-member'), $array['label'] ) );
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s username or profile URL', 'ultimate-member' ), $array['label'] ) );
}
break;
@@ -840,7 +840,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
break;
case 'instagram_url':
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'instagram.com' ) ) {
// translators: %s: label.
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
@@ -861,7 +860,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
break;
case 'tiktok_url':
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'tiktok.com' ) ) {
// translators: %s: label.
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
@@ -869,7 +867,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
break;
case 'twitch_url':
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'twitch.tv' ) ) {
// translators: %s: label.
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
@@ -877,7 +874,6 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
break;
case 'reddit_url':
if ( ! UM()->validation()->is_url( $submitted_data[ $key ], 'reddit.com' ) ) {
// translators: %s: label.
UM()->form()->add_error( $key, sprintf( __( 'Please enter a valid %s profile URL', 'ultimate-member' ), $array['label'] ) );
@@ -891,126 +887,126 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
break;
case 'unique_username':
if ( $submitted_data[ $key ] == '' ) {
if ( '' === $submitted_data[ $key ] ) {
UM()->form()->add_error( $key, __( 'You must provide a username', 'ultimate-member' ) );
} elseif ( $mode == 'register' && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
} elseif ( 'register' === $mode && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
} elseif ( is_email( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'Username cannot be an email', 'ultimate-member' ) );
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
}
break;
case 'unique_username_or_email':
if ( $submitted_data[ $key ] == '' ) {
if ( '' === $submitted_data[ $key ] ) {
UM()->form()->add_error( $key, __( 'You must provide a username or email', 'ultimate-member' ) );
} elseif ( $mode == 'register' && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
} elseif ( 'register' === $mode && username_exists( sanitize_user( $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'The username you entered is incorrect', 'ultimate-member' ) );
} elseif ( $mode == 'register' && email_exists( $submitted_data[ $key ] ) ) {
} elseif ( 'register' === $mode && email_exists( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'Your username contains invalid characters', 'ultimate-member' ) );
}
break;
case 'unique_email':
$submitted_data[ $key ] = trim( $submitted_data[ $key ] );
if ( in_array( $key, array( 'user_email' ) ) ) {
if ( ! isset( $submitted_data['user_id'] ) ){
if ( 'user_email' === $key ) {
if ( ! isset( $submitted_data['user_id'] ) ) {
$submitted_data['user_id'] = um_get_requested_user();
}
$email_exists = email_exists( $submitted_data[ $key ] );
if ( $submitted_data[ $key ] == '' && in_array( $key, array( 'user_email' ) ) ) {
if ( '' === $submitted_data[ $key ] ) {
UM()->form()->add_error( $key, __( 'You must provide your email', 'ultimate-member' ) );
} elseif ( in_array( $mode, array( 'register' ) ) && $email_exists ) {
} elseif ( 'register' === $mode && $email_exists ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( in_array( $mode, array( 'profile' ) ) && $email_exists && $email_exists != $submitted_data['user_id'] ) {
} elseif ( 'profile' === $mode && $email_exists && $email_exists !== $submitted_data['user_id'] ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( ! is_email( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member') );
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( ! UM()->validation()->safe_username( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
UM()->form()->add_error( $key, __( 'Your email contains invalid characters', 'ultimate-member' ) );
}
} else {
if ( $submitted_data[ $key ] != '' && ! is_email( $submitted_data[ $key ] ) ) {
if ( '' !== $submitted_data[ $key ] && ! is_email( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( $submitted_data[ $key ] != '' && email_exists( $submitted_data[ $key ] ) ) {
} elseif ( '' !== $submitted_data[ $key ] && email_exists( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
} elseif ( $submitted_data[ $key ] != '' ) {
} elseif ( '' !== $submitted_data[ $key ] ) {
$users = get_users( 'meta_value=' . $submitted_data[ $key ] );
foreach ( $users as $user ) {
if ( $user->ID != $submitted_data['user_id'] ) {
if ( $user->ID !== $submitted_data['user_id'] ) {
UM()->form()->add_error( $key, __( 'The email you entered is incorrect', 'ultimate-member' ) );
}
}
}
}
break;
case 'is_email':
$submitted_data[ $key ] = trim( $submitted_data[ $key ] );
if ( $submitted_data[ $key ] != '' && ! is_email( $submitted_data[ $key ] ) ) {
if ( '' !== $submitted_data[ $key ] && ! is_email( $submitted_data[ $key ] ) ) {
UM()->form()->add_error( $key, __( 'This is not a valid email', 'ultimate-member' ) );
}
break;
case 'unique_value':
if ( '' !== $submitted_data[ $key ] ) {
if ( $submitted_data[ $key ] != '' ) {
if ( ! isset( $submitted_data['user_id'] ) ) {
$submitted_data['user_id'] = um_get_requested_user();
}
$args_unique_meta = array(
'meta_key' => $key,
'meta_value' => $submitted_data[ $key ],
'compare' => '=',
'exclude' => array( $submitted_data['user_id'] ),
'meta_key' => $key,
'meta_value' => $submitted_data[ $key ],
'compare' => '=',
'exclude' => array( $submitted_data['user_id'] ),
);
$meta_key_exists = get_users( $args_unique_meta );
if ( $meta_key_exists ) {
UM()->form()->add_error( $key , __( 'You must provide a unique value', 'ultimate-member' ) );
UM()->form()->add_error( $key, __( 'You must provide a unique value', 'ultimate-member' ) );
}
}
break;
case 'alphabetic':
if ( $submitted_data[ $key ] != '' ) {
if ( '' !== $submitted_data[ $key ] ) {
if ( ! preg_match( '/^\p{L}+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters', 'ultimate-member' ) );
}
}
break;
case 'alpha_numeric':
if ( '' !== $submitted_data[ $key ] ) {
if ( ! preg_match( '/^[\p{L}0-9\s]+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters or numbers', 'ultimate-member' ) );
}
}
break;
case 'lowercase':
if ( '' !== $submitted_data[ $key ] ) {
if ( ! ctype_lower( str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'You must provide lowercase letters.', 'ultimate-member' ) );
}
}
break;
if ( $submitted_data[ $key ] != '' ) {
if ( ! ctype_lower( str_replace(' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key , __( 'You must provide lowercase letters.', 'ultimate-member' ) );
case 'english':
if ( '' !== $submitted_data[ $key ] ) {
if ( ! preg_match( '/^[a-zA-Z]*$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'You must provide English letters.', 'ultimate-member' ) );
}
}
@@ -1076,9 +1072,12 @@ add_action( 'um_submit_form_errors_hook_', 'um_submit_form_errors_hook_', 10, 2
* @return string
*/
function um_invalid_nonce_redirect_url( $url ) {
$url = add_query_arg( [
'um-hash' => substr( md5( rand() ), 0, 6 ),
], remove_query_arg( 'um-hash', $url ) );
$url = add_query_arg(
array(
'um-hash' => substr( md5( rand() ), 0, 6 ),
),
remove_query_arg( 'um-hash', $url )
);
return $url;
}
+1 -1
View File
@@ -168,7 +168,7 @@ function um_add_update_notice( $args ) {
$err = __( 'Your account has not been approved yet.', 'ultimate-member' );
break;
case 'awaiting_email_confirmation':
$err = __( 'Your account is awaiting e-mail verification.', 'ultimate-member' );
$err = __( 'Your account is awaiting email verification.', 'ultimate-member' );
break;
case 'rejected':
$err = __( 'Your membership request has been rejected.', 'ultimate-member' );
+4 -3
View File
@@ -1017,7 +1017,7 @@ function um_profile_header( $args ) {
*/
do_action( 'um_pre_header_editprofile', $args ); ?>
<div class="um-profile-photo" data-user_id="<?php echo esc_attr( um_profile_id() ); ?>" <?php echo esc_html( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( 'profile_photo' ), 'profile_photo' ) ); ?>>
<div class="um-profile-photo" data-user_id="<?php echo esc_attr( um_profile_id() ); ?>" <?php echo wp_kses( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( 'profile_photo' ), 'profile_photo' ), UM()->get_allowed_html( 'templates' ) ); ?>>
<a href="<?php echo esc_url( um_user_profile_url() ); ?>" class="um-profile-photo-img" title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>">
<?php if ( ! $default_size || $default_size == 'original' ) {
@@ -1278,7 +1278,7 @@ function um_profile_header( $args ) {
<textarea id="um-meta-bio" data-html="<?php echo esc_attr( $bio_html ); ?>"
data-character-limit="<?php echo esc_attr( $limit ); ?>"
placeholder="<?php esc_attr_e( 'Tell us a bit about yourself...', 'ultimate-member' ); ?>"
name="<?php echo esc_attr( $description_key ); ?>" <?php echo esc_html( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( $description_key ), 'um-meta-bio' ) ); ?>><?php echo esc_textarea( $description_value ); ?></textarea>
name="<?php echo esc_attr( $description_key ); ?>" <?php echo wp_kses( UM()->fields()->aria_valid_attributes( UM()->fields()->is_error( $description_key ), 'um-meta-bio' ), UM()->get_allowed_html( 'templates' ) ); ?>><?php echo esc_textarea( $description_value ); ?></textarea>
<span class="um-meta-bio-character um-right">
<span class="um-bio-limit"><?php echo esc_html( $limit ); ?></span>
</span>
@@ -1576,7 +1576,8 @@ function um_submit_form_profile( $args, $form_data ) {
* function my_user_edit_profile( $post, $form_data ) {
* // your code here
* }
* add_action( 'um_user_edit_profile', 'my_user_edit_profile', 10, 2 );
* // Don't use priority >= 10 because there is native Ultimate Member handler on it.
* add_action( 'um_user_edit_profile', 'my_user_edit_profile', 9, 2 );
*/
do_action( 'um_user_edit_profile', $args, $form_data );
}
+7 -1
View File
@@ -417,8 +417,10 @@ function um_submit_form_register( $args, $form_data ) {
$user_email = $args['user_email'];
}
$generate_password = false;
if ( ! isset( $args['user_password'] ) ) {
$user_password = UM()->validation()->generate( 8 );
$generate_password = true;
$user_password = UM()->validation()->generate( 8 );
} else {
$user_password = $args['user_password'];
}
@@ -520,6 +522,10 @@ function um_submit_form_register( $args, $form_data ) {
return;
}
if ( true === $generate_password ) {
update_user_meta( $user_id, 'um_set_password_required', true );
}
/**
* Fires after complete UM user registration.
*
+15 -14
View File
@@ -53,45 +53,46 @@ function um_wp_form_errors_hook_ip_test( $user, $username, $password ) {
}
add_filter( 'authenticate', 'um_wp_form_errors_hook_ip_test', 10, 3 );
/**
* Login checks through the WordPress admin login.
*
* @param $user
* @param $username
* @param $password
* @param WP_Error|WP_User $user
*
* @return WP_Error|WP_User
*/
function um_wp_form_errors_hook_logincheck( $user, $username, $password ) {
function um_wp_form_errors_hook_logincheck( $user ) {
if ( is_wp_error( $user ) ) {
return $user;
}
if ( isset( $user->ID ) ) {
um_fetch_user( $user->ID );
$status = um_user( 'account_status' );
switch( $status ) {
$error = null;
switch ( $status ) {
case 'inactive':
return new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
$error = new WP_Error( $status, __( 'Your account has been disabled.', 'ultimate-member' ) );
break;
case 'awaiting_admin_review':
return new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
$error = new WP_Error( $status, __( 'Your account has not been approved yet.', 'ultimate-member' ) );
break;
case 'awaiting_email_confirmation':
return new WP_Error( $status, __( 'Your account is awaiting e-mail verification.', 'ultimate-member' ) );
$error = new WP_Error( $status, __( 'Your account is awaiting email verification.', 'ultimate-member' ) );
break;
case 'rejected':
return new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
$error = new WP_Error( $status, __( 'Your membership request has been rejected.', 'ultimate-member' ) );
break;
}
if ( null !== $error ) {
return $error;
}
}
return $user;
}
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50, 3 );
add_filter( 'authenticate', 'um_wp_form_errors_hook_logincheck', 50 );
/**
* Change lost password url in UM Login form
+1 -1
View File
@@ -34,7 +34,7 @@ function um_admin_user_actions_hook( $actions, $user_id ) {
}
if ( 'awaiting_email_confirmation' === $account_status ) {
$actions['um_resend_activation'] = array( 'label' => __( 'Resend Activation E-mail', 'ultimate-member' ) );
$actions['um_resend_activation'] = array( 'label' => __( 'Resend Activation Email', 'ultimate-member' ) );
}
if ( 'inactive' !== $account_status ) {
File diff suppressed because it is too large Load Diff
+84
View File
@@ -0,0 +1,84 @@
<?php
/**
* Ultimate Member Core Functions
*
* General core functions available on both the front-end and admin.
*
* @version 2.8.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @param string $slug
*
* @return bool
*/
function um_predefined_page_slug_exists( $slug ) {
$predefined_pages = UM()->config()->get( 'predefined_pages' );
return array_key_exists( $slug, $predefined_pages );
}
/**
* @param string $slug
*
* @return false|int
*/
function um_get_predefined_page_id( $slug ) {
if ( ! um_predefined_page_slug_exists( $slug ) ) {
return false;
}
$option_key = UM()->options()->get_predefined_page_option_key( $slug );
return apply_filters( 'um_get_predefined_page_id', UM()->options()->get( $option_key ), $slug );
}
/**
*
* @param string $slug
* @param null|int|\WP_Post $post
*
* @return bool
*/
function um_is_predefined_page( $slug, $post = null ) {
// handle $post inside, just we need make $post as \WP_Post. Otherwise something is wrong and return false
if ( ! $post ) {
global $post;
if ( empty( $post ) ) {
return false;
}
} else {
if ( is_numeric( $post ) ) {
$post = get_post( $post );
if ( empty( $post ) ) {
return false;
}
}
}
if ( empty( $post->ID ) ) {
return false;
}
return um_get_predefined_page_id( $slug ) === $post->ID;
}
/**
* Get predefined page URL
*
* @param string $slug
*
* @return false|string
*/
function um_get_predefined_page_url( $slug ) {
$url = false;
if ( $page_id = um_get_predefined_page_id( $slug ) ) {
$url = get_permalink( $page_id );
}
return $url;
}
+2 -2
View File
@@ -1751,7 +1751,7 @@ function um_can_edit_my_profile() {
/**
* Short for admin e-mail
* Short for admin email
*
* @return mixed|string|void
*/
@@ -1761,7 +1761,7 @@ function um_admin_email() {
/**
* Get admin e-mails
* Get admin emails
*
* @return array
*/
+34 -1
View File
@@ -7,7 +7,7 @@ Tags: community, member, membership, user-profile, user-registration
Requires PHP: 5.6
Requires at least: 5.5
Tested up to: 6.4
Stable tag: 2.8.2
Stable tag: 2.8.3
License: GNU Version 2 or Any Later Version
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -166,6 +166,39 @@ No specific extensions are needed. But we highly recommended keep active these P
IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSION 2.6.7 PATCHES SECURITY PRIVILEGE ESCALATION VULNERABILITY. PLEASE SEE [THIS ARTICLE](https://docs.ultimatemember.com/article/1866-security-incident-update-and-recommended-actions) FOR MORE INFORMATION
= 2.8.3: February 19, 2024 =
* Enhancements:
- Added: Link to the Ultimate Member docs
- Tweak: Ultimate Member > Settings redesign. More details about setting up. Tooltips changed to descriptions.
* Bugfixes:
- Fixed: Member directory queries to custom usermeta table properly escaped and validated
- Fixed: Member directory custom sorting when wp_usermeta table is used
- Fixed: aria-invalid attribute for the user description field
- Fixed: wp_kses protocols for email notifications content
- Fixed: PHP notice while registration form validation
- Fixed: Field validations (English letters, Alpha-numeric types)
- Fixed: Hidden buttons in the modal when uploading profile and cover photo
- Fixed: Theme updater log message
- Fixed: Search line shortcode layout
- Fixed: PHP notice while login form submission
- Fixed: Email notifications HTML layout
- Fixed: Default email notification body color
- Fixed: Ignore username slug when custom meta slug exists when parse user from query
* Templates required update:
- email/notification_deletion.php
- email/notification_new_user.php
- email/notification_review.php
- email/welcome_email.php
- password-change.php
* Cached and optimized/minified assets(JS/CSS) must be flushed/re-generated after upgrade
= 2.8.2: January 15, 2024 =
* Enhancements:
+1 -1
View File
@@ -29,7 +29,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<div style="background: #eee;color: #444;padding: 12px 15px; border-radius: 3px;font-weight: bold;font-size: 16px;">Account Information</div>
<div style="padding: 10px 15px 0 15px;color: #333;"><span style="color:#999">Your account e-mail:</span> <span style="font-weight:bold">{email}</span></div>
<div style="padding: 10px 15px 0 15px;color: #333;"><span style="color:#999">Your account email:</span> <span style="font-weight:bold">{email}</span></div>
<div style="padding: 10px 15px 0 15px;color: #333;"><span style="color:#999">Your account username:</span> <span style="font-weight:bold">{username}</span></div>
<div style="padding: 10px 15px 0 15px;color: #333;"><span style="color:#999">Set your password:</span> <span style="font-weight:bold"><a href="{password_reset_link}" style="color: #3ba1da;text-decoration: none;">{password_reset_link}</a></span></div>
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/**
* Template for the "Account Activation Email".
* Whether to send the user an email when his account needs e-mail activation.
* Whether to send the user an email when his account needs email activation.
*
* This template can be overridden by copying it to {your-theme}/ultimate-member/email/checkmail_email.php
*
+2 -2
View File
@@ -5,7 +5,7 @@
*
* This template can be overridden by copying it to {your-theme}/ultimate-member/email/notification_deletion.php
*
* @version 2.6.1
* @version 2.8.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<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;">{display_name} has just deleted their {site_name} account.</span></div>
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just deleted their {site_name} account.</div>
</div>
+2 -2
View File
@@ -5,7 +5,7 @@
*
* This template can be overridden by copying it to {your-theme}/ultimate-member/email/notification_new_user.php
*
* @version 2.6.1
* @version 2.8.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<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;">{display_name} has just created an account on {site_name}.</span></div>
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just created an account on {site_name}.</div>
<div style="padding: 10px 0 50px 0;text-align: center;">To view their profile click here: <a href="{user_profile_link}" style="color: #3ba1da;text-decoration: none;">{user_profile_link}</a></div>
+2 -2
View File
@@ -5,7 +5,7 @@
*
* This template can be overridden by copying it to {your-theme}/ultimate-member/email/notification_review.php
*
* @version 2.6.1
* @version 2.8.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<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;">{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.</span></div>
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.</div>
<div style="padding: 10px 0 50px 0;text-align: center;">To review this member please click the following link: <a href="{user_profile_link}" style="color: #3ba1da;text-decoration: none;">{user_profile_link}</a></div>
+3 -3
View File
@@ -5,7 +5,7 @@
*
* This template can be overridden by copying it to {your-theme}/ultimate-member/email/welcome_email.php
*
* @version 2.6.1
* @version 2.8.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -21,9 +21,9 @@ if ( ! defined( 'ABSPATH' ) ) {
<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;">Thank you for signing up!<span style="display: block;">Your account is now active.</span></div>
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">Thank you for signing up! <span style="display: block;">Your account is now active.</span></div>
<div style="padding: 10px 0 50px 0;text-align: center;"><a href="{login_url}" style="background: #555555;color: #fff;padding: 12px 30px;text-decoration: none;border-radius: 3px;letter-spacing: 0.3px;">Login to our site</a></div>
<div style="padding: 10px 0 50px 0;text-align: center;"><a href="{action_url}" style="background: #555555;color: #fff;padding: 12px 30px;text-decoration: none;border-radius: 3px;letter-spacing: 0.3px;">{action_title}</a></div>
<div style="padding:20px;">If you have any problems, please contact us at <a href="mailto:{admin_email}" style="color: #3ba1da;text-decoration: none">{admin_email}</a></div>
+34 -41
View File
@@ -6,19 +6,18 @@
*
* Call: function ultimatemember_password()
*
* @version 2.7.0
* @version 2.8.3
*
* @var string $mode
* @var string $rp_key
* @var int $form_id
* @var array $args
* @var string $rp_mode 'pw_set' or 'pw_change' for display it differently.
* @var string $rp_key Reset password key.
* @var array $args Change password arguments
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div class="um <?php echo esc_attr( $this->get_class( $mode ) ); ?> um-<?php echo esc_attr( $form_id ); ?>">
<div class="um <?php echo esc_attr( $this->get_class( 'password' ) ); ?> um-um_password_id">
<div class="um-form">
@@ -29,23 +28,18 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php
/**
* UM hook
* Fires at the start of the password change form. Just after hiddens.
*
* @type action
* @title um_change_password_page_hidden_fields
* @description Password change hidden fields
* @input_vars
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_change_password_page_hidden_fields', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_change_password_page_hidden_fields', 'my_change_password_page_hidden_fields', 10, 1 );
* function my_change_password_page_hidden_fields( $args ) {
* // your code here
* @since 1.3.x
* @hook um_change_password_page_hidden_fields
*
* @param {array} $cp_args Change password form arguments.
*
* @example <caption>Add hidden field at the start of the change password form.</caption>
* function my_custom_change_password_page_hidden_fields( $cp_args ) {
* echo '<input type="hidden" name="my_custom_cp_input" value="1" />'
* }
* ?>
* add_action( 'um_change_password_page_hidden_fields', 'my_custom_change_password_page_hidden_fields' );
*/
do_action( 'um_change_password_page_hidden_fields', $args );
@@ -57,38 +51,37 @@ if ( ! defined( 'ABSPATH' ) ) {
foreach ( $fields as $key => $data ) {
$output .= UM()->fields()->edit_field( $key, $data );
}
echo $output; ?>
if ( $output ) {
echo wp_kses( $output, UM()->get_allowed_html( 'templates' ) );
}
?>
<div class="um-col-alt um-col-alt-b">
<div class="um-center">
<input type="submit" value="<?php esc_attr_e( 'Change password', 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
<?php if ( 'pw_set' === $rp_mode ) { ?>
<input type="submit" value="<?php esc_attr_e( 'Set password', 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
<?php } else { ?>
<input type="submit" value="<?php esc_attr_e( 'Change password', 'ultimate-member' ); ?>" class="um-button" id="um-submit-btn" />
<?php } ?>
</div>
<div class="um-clear"></div>
</div>
<?php
/**
* UM hook
* Fires at the end of the password change form.
*
* @type action
* @title um_change_password_form
* @description Password change form content
* @input_vars
* [{"var":"$args","type":"array","desc":"Password change shortcode arguments"}]
* @change_log
* ["Since: 2.0"]
* @usage add_action( 'um_change_password_form', 'function_name', 10, 1 );
* @example
* <?php
* add_action( 'um_change_password_form', 'my_change_password_form', 10, 1 );
* function my_change_password_form( $args ) {
* // your code here
* @since 1.3.x
* @hook um_change_password_form
*
* @param {array} $cp_args Change password form arguments.
*
* @example <caption>Add hidden field at the start of the change password form.</caption>
* function my_custom_change_password_form( $cp_args ) {
* echo '<input type="hidden" name="my_custom_cp_input" value="1" />'
* }
* ?>
* add_action( 'um_change_password_form', 'my_custom_change_password_form' );
*/
do_action( 'um_change_password_form', $args );
/** This action is documented in includes/core/um-actions-profile.php */
+2 -2
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.8.2
* Version: 2.8.3
* Author: Ultimate Member
* Author URI: http://ultimatemember.com/
* Text Domain: ultimate-member
@@ -32,7 +32,7 @@ define( 'UM_PATH', plugin_dir_path( __FILE__ ) );
define( 'UM_PLUGIN', plugin_basename( __FILE__ ) );
define( 'UM_VERSION', $plugin_data['Version'] );
define( 'UM_PLUGIN_NAME', $plugin_data['Name'] );
// define( 'UM_LEGACY_BUILDER_OFF', true );
// define( 'UM_DEV_MODE', true );
require_once 'includes/class-functions.php';
require_once 'includes/class-init.php';