- fixed dynamically declared variables inside the classes;

This commit is contained in:
Mykyta Synelnikov
2023-04-17 20:16:15 +03:00
parent 1a219ebb24
commit 034d9e8b43
22 changed files with 275 additions and 147 deletions
+27 -7
View File
@@ -34,18 +34,38 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) {
private $custom_nonce_added = false;
var $init_icon = false;
public $init_icon = false;
/**
* @var bool
*/
public $in_edit = false;
/**
* @var null
*/
public $edit_mode_value = null;
/**
* @var array
*/
public $edit_array = array();
/**
* @var array
*/
public $postmeta = array();
/**
* @var bool
*/
public $is_loaded = false;
/**
* Admin_Metabox constructor.
*/
function __construct() {
$this->in_edit = false;
$this->edit_mode_value = null;
$this->edit_array = [];
add_action( 'admin_head', array( &$this, 'admin_head' ), 9);
public function __construct() {
add_action( 'admin_head', array( &$this, 'admin_head' ), 9 );
add_action( 'admin_footer', array( &$this, 'load_modal_content' ), 9 );
add_action( 'load-post.php', array( &$this, 'add_metabox' ), 9 );
+6 -5
View File
@@ -14,14 +14,15 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
*/
class Admin_Users {
/**
* @var string
*/
public $custom_role = 'um_role';
/**
* Admin_Users constructor.
*/
function __construct() {
$this->custom_role = 'um_role';
public function __construct() {
add_action( 'restrict_manage_users', array( &$this, 'restrict_manage_users' ) );
add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
@@ -273,7 +274,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
$submitted = get_user_meta( $user_id, 'submitted', true );
if ( ! empty( $submitted ) ) {
$actions['view_info'] = '<a href="javascript:void(0);" data-modal="UM_preview_registration" data-modal-size="smaller"
$actions['view_info'] = '<a href="javascript:void(0);" data-modal="UM_preview_registration" data-modal-size="smaller"
data-dynamic-content="um_admin_review_registration" data-arg1="' . esc_attr( $user_id ) . '" data-arg2="edit_registration">' . __( 'Info', 'ultimate-member' ) . '</a>';
}
+20 -28
View File
@@ -17,83 +17,75 @@ if ( ! class_exists( 'um\Config' ) ) {
*/
class Config {
/**
* @var array
*/
public $core_forms;
/**
* @var array
*/
var $core_forms;
/**
* @var array
*/
var $core_directories;
public $core_directories;
/**
* @var mixed|void
*/
var $core_pages;
public $core_pages;
/**
* @var array
*/
var $core_directory_meta = array();
public $core_directory_meta = array();
/**
* @var array
*/
var $core_global_meta_all;
public $core_global_meta_all;
/**
* @var mixed|void
*/
var $core_form_meta_all;
public $core_form_meta_all;
/**
* @var array
*/
var $core_form_meta = array();
public $core_form_meta = array();
/**
* @var
*/
var $perms;
public $perms;
/**
* @var
*/
var $nonadmin_perms;
public $nonadmin_perms;
/**
* @var mixed|void
*/
var $email_notifications;
public $email_notifications;
/**
* @var mixed|void
*/
var $settings_defaults;
public $settings_defaults;
/**
* @var array
*/
var $permalinks;
public $permalinks;
/**
* @var array|array[]
*/
public $default_roles_metadata = array();
/**
* Config constructor.
*/
function __construct() {
public function __construct() {
$this->core_forms = array(
'register',
'login',
+5 -1
View File
@@ -71,6 +71,10 @@ if ( ! class_exists( 'UM' ) ) {
*/
public $is_permalinks;
/**
* @var null|string
*/
public $honeypot = null;
/**
* Main UM Instance
@@ -82,7 +86,7 @@ if ( ! class_exists( 'UM' ) ) {
* @see UM()
* @return UM - Main instance
*/
static public function instance() {
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
self::$instance->_um_construct();
+16 -5
View File
@@ -13,29 +13,40 @@ if ( ! class_exists( 'um\core\Builtin' ) ) {
*/
class Builtin {
/**
* @var array
*/
public $predefined_fields = array();
/**
* @var array
*/
public $all_user_fields = array();
/**
* @var array
*/
var $all_user_fields = array();
public $core_fields = array();
/**
* @var array
*/
var $core_fields = array();
public $saved_fields = array();
/**
* @var array
*/
public $custom_fields = array();
/**
* @var array
*/
public $fields_dropdown = array();
/**
* Builtin constructor.
*/
function __construct() {
public function __construct() {
add_action( 'init', array( &$this, 'set_core_fields' ), 1 );
add_action( 'init', array( &$this, 'set_predefined_fields' ), 1 );
add_action( 'init', array( &$this, 'set_custom_fields' ), 1 );
+16 -5
View File
@@ -18,7 +18,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
/**
* @var string
*/
var $set_mode = '';
public $set_mode = '';
/**
@@ -26,17 +26,28 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*/
public $set_id = null;
/**
* @var bool
*/
public $editing = false;
/**
* @var bool
*/
public $viewing = false;
/**
* @var int
*/
public $timestamp = null;
/**
* Fields constructor.
*/
function __construct() {
$this->editing = false;
$this->viewing = false;
public function __construct() {
$this->timestamp = current_time( 'timestamp' );
}
/**
* Standard checkbox field
*
+23 -10
View File
@@ -13,30 +13,45 @@ if ( ! class_exists( 'um\core\Files' ) ) {
*/
class Files {
/**
* @var
*/
public $upload_temp;
/**
* @var
*/
var $upload_temp;
public $upload_baseurl;
/**
* @var
*/
var $upload_baseurl;
public $upload_basedir;
/**
* @var
* @var array|array[]
*/
var $upload_basedir;
public $fonticon = array();
/**
* @var null|string
*/
public $upload_dir = null;
/**
* @var null
*/
public $upload_temp_url = null;
/**
* @var string
*/
public $default_file_fonticon = 'um-faicon-file-o';
/**
* Files constructor.
*/
function __construct() {
public function __construct() {
$this->setup_paths();
add_action( 'template_redirect', array( &$this, 'download_routing' ), 1 );
@@ -63,8 +78,6 @@ if ( ! class_exists( 'um\core\Files' ) ) {
'tif' => array('icon' => 'um-icon-image' ),
'tiff' => array('icon' => 'um-icon-image' ),
);
$this->default_file_fonticon = 'um-faicon-file-o';
}
+21 -17
View File
@@ -13,43 +13,47 @@ if ( ! class_exists( 'um\core\Form' ) ) {
*/
class Form {
/**
* @var null
*/
public $form_suffix;
public $form_suffix = null;
/**
* @var
*/
var $form_id;
public $form_id;
/**
* @var null
*/
var $post_form = null;
public $post_form = null;
/**
* @var null
*/
public $nonce = null;
var $nonce = null;
/**
* @var null
*/
public $errors = null;
/**
* @var null
*/
public $processing = null;
/**
* @var array
*/
public $all_fields = array();
/**
* Form constructor.
*/
function __construct() {
$this->form_suffix = null;
$this->errors = null;
$this->processing = null;
public function __construct() {
add_action( 'template_redirect', array( &$this, 'form_init' ), 2 );
add_action( 'init', array( &$this, 'field_declare' ), 10 );
}
+41 -26
View File
@@ -13,18 +13,35 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
*/
class Shortcodes {
var $profile_role = '';
/**
* @var string
*/
public $profile_role = '';
/**
* @var bool
*/
public $message_mode = false;
/**
* @var string
*/
public $custom_message = '';
/**
* @var array
*/
public $loop = array();
/**
* @var array
*/
public $emoji = array();
/**
* Shortcodes constructor.
*/
function __construct() {
$this->message_mode = false;
$this->custom_message = '';
$this->loop = array();
public function __construct() {
add_shortcode( 'ultimatemember', array( &$this, 'ultimatemember' ) );
add_shortcode( 'ultimatemember_login', array( &$this, 'ultimatemember_login' ) );
@@ -123,10 +140,8 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$this->emoji[':innocent:'] = $base_uri . '72x72/1f607.png';
$this->emoji[':smirk:'] = $base_uri . '72x72/1f60f.png';
$this->emoji[':expressionless:'] = $base_uri . '72x72/1f611.png';
}
/**
* Conditional logout form
*
@@ -430,11 +445,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$args = ! empty( $args ) ? $args : array();
$default_login = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'login' AND
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'login' AND
pm2.meta_value = '1'"
);
@@ -463,11 +478,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$args = ! empty( $args ) ? $args : array();
$default_register = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'register' AND
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'register' AND
pm2.meta_value = '1'"
);
@@ -496,11 +511,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$args = ! empty( $args ) ? $args : array();
$default_profile = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'profile' AND
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'profile' AND
pm2.meta_value = '1'"
);
@@ -530,11 +545,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$args = ! empty( $args ) ? $args : array();
$default_directory = $wpdb->get_var(
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
"SELECT pm.post_id
FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->postmeta} pm2 ON( pm.post_id = pm2.post_id AND pm2.meta_key = '_um_is_default' )
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'directory' AND
WHERE pm.meta_key = '_um_mode' AND
pm.meta_value = 'directory' AND
pm2.meta_value = '1'"
);
+72 -24
View File
@@ -22,35 +22,86 @@ if ( ! class_exists( 'um\core\User' ) ) {
*/
public $previous_data = null;
/**
* @var int
*/
public $id = 0;
/**
* @var null
*/
public $usermeta = null;
/**
* @var null
*/
public $data = null;
/**
* @var null
*/
public $profile = null;
/**
* @var null
*/
public $cannot_edit = null;
/**
* @var null
*/
public $deleted_user_id = null;
/**
* @var array|string[]
*/
public $banned_keys = array();
/**
* @var bool
*/
public $preview = false;
/**
* @var bool
*/
public $send_mail_on_delete = true;
/**
* A list of keys that should never be in wp_usermeta.
* @var array|string[]
*/
public $update_user_keys = array();
/**
* @var null
*/
public $target_id = null;
/**
* User constructor.
*/
function __construct() {
$this->id = 0;
$this->usermeta = null;
$this->data = null;
$this->profile = null;
$this->cannot_edit = null;
$this->deleted_user_id = null;
public function __construct() {
global $wpdb;
$this->banned_keys = array(
'metabox','postbox','meta-box',
'dismissed_wp_pointers', 'session_tokens',
'screen_layout', 'wp_user-', 'dismissed',
'cap_key', $wpdb->get_blog_prefix(). 'capabilities',
'managenav', 'nav_menu', 'user_activation_key',
'level_', $wpdb->get_blog_prefix() . 'user_level'
'metabox',
'postbox',
'meta-box',
'dismissed_wp_pointers',
'session_tokens',
'screen_layout',
'wp_user-',
'dismissed',
'cap_key',
$wpdb->get_blog_prefix() . 'capabilities',
'managenav',
'nav_menu',
'user_activation_key',
'level_',
$wpdb->get_blog_prefix() . 'user_level',
);
add_action( 'init', array( &$this, 'set' ), 1 );
$this->preview = false;
$this->send_mail_on_delete = true;
// a list of keys that should never be in wp_usermeta
$this->update_user_keys = array(
'user_email',
@@ -61,7 +112,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
'role',
);
$this->target_id = null;
add_action( 'init', array( &$this, 'set' ), 1 );
// When the cache should be cleared
add_action( 'um_delete_user', array( &$this, 'remove_cache' ), 10, 1 );
@@ -88,7 +139,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
if ( is_multisite() ) {
add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
@@ -102,13 +152,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
add_action( 'delete_user', array( &$this, 'delete_user_handler' ), 10, 1 );
}
add_action( 'updated_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
add_action( 'added_user_meta', array( &$this, 'on_update_usermeta' ), 10, 4 );
add_action( 'deleted_user_meta', array( &$this, 'on_delete_usermeta' ), 10, 4 );
add_action( 'update_user_meta', array( &$this, 'flush_um_count_users_transient_update' ), 10, 4 );
add_action( 'added_user_meta', array( &$this, 'flush_um_count_users_transient_add' ), 10, 4 );
add_action( 'delete_user_meta', array( &$this, 'flush_um_count_users_transient_delete' ), 10, 4 );
+17 -8
View File
@@ -13,16 +13,25 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
*/
class Validation {
/**
* @var string
*/
public $regex_safe = '/\A[\w\-\.]+\z/';
/**
* @var string
*/
public $regex_username_safe = '|[^a-z0-9 _.\-@]|i';
/**
* @var string
*/
public $regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
/**
* Validation constructor.
*/
function __construct() {
$this->regex_safe = '/\A[\w\-\.]+\z/';
$this->regex_username_safe = '|[^a-z0-9 _.\-@]|i';
$this->regex_phone_number = '/\A[\d\-\.\+\(\)\ ]+\z/';
public function __construct() {
add_filter( 'um_user_pre_updating_files_array', array( $this, 'validate_files' ), 10, 1 );
add_filter( 'um_before_save_filter_submitted', array( $this, 'validate_fields_values' ), 10, 2 );
}
@@ -91,7 +100,7 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
}
// Dropdown options source from callback function
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) &&
if ( in_array( $fields[ $key ]['type'], array( 'select','multiselect' ) ) &&
isset( $fields[ $key ]['custom_dropdown_options_source'] ) &&
! empty( $fields[ $key ]['custom_dropdown_options_source'] ) &&
function_exists( $fields[ $key ]['custom_dropdown_options_source'] ) ) {
@@ -100,7 +109,7 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
$fields[ $key ]['options'] = array_keys( $arr_options );
}
}
// Unset changed value that doesn't match the option list
if ( in_array( $fields[ $key ]['type'], array( 'select' ) ) &&
! empty( $stripslashes ) && ! empty( $fields[ $key ]['options'] ) &&