From d8457350caf61ea36bd84af5adf83300c4ff8c99 Mon Sep 17 00:00:00 2001 From: Rey C Date: Mon, 29 Sep 2025 06:01:46 +0800 Subject: [PATCH] Fix: Translation loading for the wp-user-manager domain was triggered too early. Resolves #405 and https://github.com/WPUserManager/wpum-custom-fields/issues/88 @polevaultweb --- includes/abstracts/class-wpum-field-type.php | 21 ++++++++++++++++++- .../class-wpum-shortcode-generator.php | 11 ++++++++++ includes/admin/class-wpum-options-panel.php | 20 +++++++++++++----- includes/class-wp-user-manager.php | 6 +++++- .../class-wpum-emails-customizer-scripts.php | 13 +++++++++++- .../emails/class-wpum-emails-customizer.php | 13 +++++++++++- includes/fields/class-wpum-field.php | 14 +++++++++++-- includes/fields/class-wpum-fields-editor.php | 2 +- .../fields/types/class-wpum-field-audio.php | 10 ++++++++- .../types/class-wpum-field-checkbox.php | 10 ++++++++- .../types/class-wpum-field-datepicker.php | 11 +++++++++- .../types/class-wpum-field-dropdown.php | 10 ++++++++- .../fields/types/class-wpum-field-email.php | 10 ++++++++- .../fields/types/class-wpum-field-file.php | 10 ++++++++- .../fields/types/class-wpum-field-hidden.php | 10 ++++++++- .../types/class-wpum-field-multicheckbox.php | 10 ++++++++- .../types/class-wpum-field-multiselect.php | 10 ++++++++- .../fields/types/class-wpum-field-number.php | 10 ++++++++- .../types/class-wpum-field-password.php | 10 ++++++++- .../fields/types/class-wpum-field-radio.php | 10 ++++++++- .../types/class-wpum-field-repeater.php | 10 ++++++++- .../types/class-wpum-field-taxonomy.php | 10 ++++++++- .../types/class-wpum-field-telephone.php | 10 ++++++++- .../fields/types/class-wpum-field-text.php | 10 ++++++++- .../types/class-wpum-field-textarea.php | 10 ++++++++- .../fields/types/class-wpum-field-url.php | 10 ++++++++- .../fields/types/class-wpum-field-user.php | 10 ++++++++- .../types/class-wpum-field-userrole.php | 10 ++++++++- .../fields/types/class-wpum-field-video.php | 10 ++++++++- .../fields/types/class-wpum-field-wysiwyg.php | 10 ++++++++- .../class-wpum-shortcode-content-loggedin.php | 10 ++++++++- ...class-wpum-shortcode-content-loggedout.php | 10 ++++++++- .../class-wpum-shortcode-content-roles.php | 10 ++++++++- .../class-wpum-shortcode-content-users.php | 10 ++++++++- .../class-wpum-shortcode-directory.php | 10 ++++++++- .../class-wpum-shortcode-login-link.php | 10 ++++++++- .../shortcodes/class-wpum-shortcode-login.php | 10 ++++++++- .../class-wpum-shortcode-logout-link.php | 10 ++++++++- .../class-wpum-shortcode-my-account.php | 11 ++++++++-- .../class-wpum-shortcode-password.php | 10 ++++++++- .../class-wpum-shortcode-profile-card.php | 10 ++++++++- .../class-wpum-shortcode-profile.php | 11 ++++++++-- ...ass-wpum-shortcode-recently-registered.php | 11 ++++++++-- .../class-wpum-shortcode-registration.php | 11 ++++++++-- 44 files changed, 413 insertions(+), 52 deletions(-) diff --git a/includes/abstracts/class-wpum-field-type.php b/includes/abstracts/class-wpum-field-type.php index 625d0ed1..39de8c68 100644 --- a/includes/abstracts/class-wpum-field-type.php +++ b/includes/abstracts/class-wpum-field-type.php @@ -110,6 +110,22 @@ abstract class WPUM_Field_Type { */ public $min_addon_version = false; + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() {} + + /** + * Get the name of the field. + * + * @return string + */ + public function get_name() { + return $this->name; + } + /** * Register the field * @@ -123,6 +139,9 @@ public function register() { // Add fields tab. add_filter( 'wpum_registered_field_types', array( $this, 'register_field_type' ), 15 ); + + // Set the field name during 'init' to avoid early translation issues. + add_action( 'init', array( $this, 'set_name' ), 0 ); } /** @@ -306,7 +325,7 @@ public function register_field_type( $fields ) { $fields[ $this->group ]['fields'][] = array( 'order' => $this->order, - 'name' => $this->name, + 'name' => $this->get_name(), 'type' => $this->type, 'icon' => $this->icon, 'min_addon_version' => $min_addon_version, diff --git a/includes/abstracts/class-wpum-shortcode-generator.php b/includes/abstracts/class-wpum-shortcode-generator.php index 1b2b18dd..da520c72 100644 --- a/includes/abstracts/class-wpum-shortcode-generator.php +++ b/includes/abstracts/class-wpum-shortcode-generator.php @@ -53,6 +53,13 @@ abstract class WPUM_Shortcode_Generator { */ protected $required; + /** + * Set the label of the shortcode. + * + * @return void + */ + public function set_labels() {} + /** * Get things started. * @@ -60,7 +67,11 @@ abstract class WPUM_Shortcode_Generator { */ public function __construct( $shortcode ) { $this->shortcode_tag = $shortcode; + add_action( 'admin_init', array( $this, 'init' ) ); + + // Set the labels during 'init' to avoid early translation issues. + add_action( 'init', array( $this, 'set_labels' ) ); } /** diff --git a/includes/admin/class-wpum-options-panel.php b/includes/admin/class-wpum-options-panel.php index 5b0c4484..4495a2f7 100644 --- a/includes/admin/class-wpum-options-panel.php +++ b/includes/admin/class-wpum-options-panel.php @@ -28,8 +28,8 @@ class WPUM_Options_Panel { * Get things started. */ public function init() { - // Setup labels for the options panel. - add_filter( 'wpum_labels', array( $this, 'register_labels' ) ); + // Set the option panel labels during 'init' to avoid early translation issues. + add_action( 'init', array( $this, 'init_option_panel_labels' ) ); $this->panel = new \WPUM\TDP\OptionsKit( 'wpum' ); $this->panel->set_page_title( 'WP User Manager Settings' ); @@ -37,9 +37,6 @@ public function init() { // Add a logo to the options panel. $this->panel->add_image( WPUM_PLUGIN_URL . 'assets/images/logo.svg' ); - // Register action buttons for the header. - $this->register_action_buttons(); - // Setup the options panel menu. add_filter( 'wpum_menu', array( $this, 'setup_menu' ) ); @@ -51,6 +48,19 @@ public function init() { add_filter( 'wpum_registered_settings', array( $this, 'register_settings' ) ); } + /** + * Initialize the option panel labels. + * + * @return void + */ + public function init_option_panel_labels() { + // Setup labels for the options panel. + add_filter( 'wpum_labels', array( $this, 'register_labels' ) ); + + // Register action buttons for the header. + $this->register_action_buttons(); + } + /** * Register action buttons for the options panel. */ diff --git a/includes/class-wp-user-manager.php b/includes/class-wp-user-manager.php index 4dbd3e9d..7764f7f1 100644 --- a/includes/class-wp-user-manager.php +++ b/includes/class-wp-user-manager.php @@ -446,7 +446,11 @@ private function setup_database_tables() { */ private function init_hooks() { register_activation_hook( WPUM_PLUGIN_FILE, 'wp_user_manager_install' ); - add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 0 ); + + // Starting WordPress version 6.7, the language translations needs to be loaded on init + // @see https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/#Enhanced-support-for-only-using-PHP-translation-files + add_action( 'init', array( $this, 'load_textdomain' ), 0 ); + add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); ( new WPUM_Plugin_Updates() )->init(); diff --git a/includes/emails/class-wpum-emails-customizer-scripts.php b/includes/emails/class-wpum-emails-customizer-scripts.php index 45942077..45883690 100644 --- a/includes/emails/class-wpum-emails-customizer-scripts.php +++ b/includes/emails/class-wpum-emails-customizer-scripts.php @@ -28,11 +28,22 @@ class WPUM_Emails_Customizer_Scripts { * Get things started. */ public function __construct() { - $this->registered_emails = wpum_get_registered_emails(); + // Set the registered emails during 'init' to avoid early translation issues. + add_action( 'init', array( $this, 'set_registered_emails' ) ); + add_action( 'customize_preview_init', array( $this, 'customize_preview' ) ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_controls' ), 90 ); } + /** + * Initialize the registered emails. + * + * @return void + */ + public function set_registered_emails() { + $this->registered_emails = wpum_get_registered_emails(); + } + /** * Scripts for the live preview. * diff --git a/includes/emails/class-wpum-emails-customizer.php b/includes/emails/class-wpum-emails-customizer.php index f99cd393..e5472352 100644 --- a/includes/emails/class-wpum-emails-customizer.php +++ b/includes/emails/class-wpum-emails-customizer.php @@ -42,12 +42,23 @@ class WPUM_Emails_Customizer { * Get things started. */ public function __construct() { - $this->emails = wpum_get_registered_emails(); + // Set the registered emails during 'init' to avoid early translation issues. + add_action( 'init', array( $this, 'set_registered_emails' ) ); + $this->panel_id = 'wpum_email_customization'; $this->settings_section_id = 'wpum_email_settings'; $this->init(); } + /** + * Set the registered emails. + * + * @return void + */ + public function set_registered_emails() { + $this->emails = wpum_get_registered_emails(); + } + /** * Hook into WordPress. * diff --git a/includes/fields/class-wpum-field.php b/includes/fields/class-wpum-field.php index 14ca5d9b..b6647f7f 100644 --- a/includes/fields/class-wpum-field.php +++ b/includes/fields/class-wpum-field.php @@ -139,6 +139,8 @@ class WPUM_Field { * @param mixed $_id_or_field */ public function __construct( $_id_or_field = false ) { + // Set the type nicename on init to avoid early translation issues + add_action( 'init', array( $this, 'set_type_nicename' ) ); $this->db = new WPUM_DB_Fields(); @@ -161,6 +163,15 @@ public function __construct( $_id_or_field = false ) { } + /** + * Set the type nicename. + * + * @return void + */ + public function set_type_nicename() { + $this->type_nicename = $this->get_field_type_name( $this->type ); + } + /** * Magic __get function to dispatch a call to retrieve a private property. * @@ -208,7 +219,6 @@ private function setup_field( $field = null ) { if ( ! empty( $this->id ) ) { - $this->type_nicename = $this->get_field_type_name( $this->type ); $this->is_primary = $this->set_as_primary_field( $this->type ); $this->required = $this->get_meta( 'required' ); $this->visibility = $this->get_meta( 'visibility' ); @@ -339,7 +349,7 @@ public function get_value() { * * @return string */ - private function get_field_type_name( $type ) { + public function get_field_type_name( $type ) { $registered_types = WPUM()->field_types->get_registered_field_types_names(); $type_name = ''; diff --git a/includes/fields/class-wpum-fields-editor.php b/includes/fields/class-wpum-fields-editor.php index 923fedfb..5314f21c 100644 --- a/includes/fields/class-wpum-fields-editor.php +++ b/includes/fields/class-wpum-fields-editor.php @@ -379,7 +379,7 @@ public function get_fields() { 'group_id' => $field->get_group_id(), 'field_order' => $field->get_field_order(), 'type' => $field->get_type(), - 'type_nicename' => $field->get_type_nicename(), + 'type_nicename' => $field->get_field_type_name( $field->get_type() ), 'name' => $field->get_name(), 'description' => $field->get_description(), 'visibility' => $field->get_visibility(), diff --git a/includes/fields/types/class-wpum-field-audio.php b/includes/fields/types/class-wpum-field-audio.php index 81bc86a0..cde0660f 100644 --- a/includes/fields/types/class-wpum-field-audio.php +++ b/includes/fields/types/class-wpum-field-audio.php @@ -22,7 +22,6 @@ class WPUM_Field_Audio extends WPUM_Field_File { */ public function __construct() { $this->group = 'advanced'; - $this->name = esc_html__( 'Audio', 'wp-user-manager' ); $this->type = 'audio'; $this->template = 'file'; $this->icon = 'dashicons-format-audio'; @@ -30,6 +29,15 @@ public function __construct() { $this->min_addon_version = '2.1'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Audio', 'wp-user-manager' ); + } + /** * @return string */ diff --git a/includes/fields/types/class-wpum-field-checkbox.php b/includes/fields/types/class-wpum-field-checkbox.php index 2a1b208e..b1447c0f 100644 --- a/includes/fields/types/class-wpum-field-checkbox.php +++ b/includes/fields/types/class-wpum-field-checkbox.php @@ -21,7 +21,6 @@ class WPUM_Field_Checkbox extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Single checkbox', 'wp-user-manager' ); $this->type = 'checkbox'; $this->icon = 'dashicons-yes'; $this->order = 3; @@ -29,6 +28,15 @@ public function __construct() { $this->default_type = 'checkbox'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Single checkbox', 'wp-user-manager' ); + } + /** * Format the output onto the profiles for the checkbox field. * diff --git a/includes/fields/types/class-wpum-field-datepicker.php b/includes/fields/types/class-wpum-field-datepicker.php index af49cd3e..49366211 100644 --- a/includes/fields/types/class-wpum-field-datepicker.php +++ b/includes/fields/types/class-wpum-field-datepicker.php @@ -22,10 +22,19 @@ class WPUM_Field_Datepicker extends WPUM_Field_Type { */ public function __construct() { $this->group = 'advanced'; - $this->name = esc_html__( 'Datepicker', 'wp-user-manager' ); $this->type = 'datepicker'; $this->icon = 'dashicons-calendar-alt'; $this->order = 3; + + } + + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Datepicker', 'wp-user-manager' ); } /** diff --git a/includes/fields/types/class-wpum-field-dropdown.php b/includes/fields/types/class-wpum-field-dropdown.php index 6e0f4881..de82576a 100644 --- a/includes/fields/types/class-wpum-field-dropdown.php +++ b/includes/fields/types/class-wpum-field-dropdown.php @@ -21,7 +21,6 @@ class WPUM_Field_Dropdown extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Dropdown', 'wp-user-manager' ); $this->type = 'dropdown'; $this->icon = 'dashicons-editor-ul'; $this->order = 3; @@ -29,6 +28,15 @@ public function __construct() { } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Dropdown', 'wp-user-manager' ); + } + /** * Format the output onto the profiles for the checkbox field. * diff --git a/includes/fields/types/class-wpum-field-email.php b/includes/fields/types/class-wpum-field-email.php index b391262f..336ddae0 100644 --- a/includes/fields/types/class-wpum-field-email.php +++ b/includes/fields/types/class-wpum-field-email.php @@ -21,12 +21,20 @@ class WPUM_Field_Email extends WPUM_Field_Type { * Contruct */ public function __construct() { - $this->name = esc_html__( 'Email', 'wp-user-manager' ); $this->type = 'email'; $this->icon = 'dashicons-email-alt'; $this->order = 3; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Email', 'wp-user-manager' ); + } + /** * Format the output onto the profiles for the email field. * diff --git a/includes/fields/types/class-wpum-field-file.php b/includes/fields/types/class-wpum-field-file.php index cbf97174..d4670e63 100644 --- a/includes/fields/types/class-wpum-field-file.php +++ b/includes/fields/types/class-wpum-field-file.php @@ -22,12 +22,20 @@ class WPUM_Field_File extends WPUM_Field_Type { */ public function __construct() { $this->group = 'advanced'; - $this->name = esc_html__( 'File', 'wp-user-manager' ); $this->type = 'file'; $this->icon = 'dashicons-paperclip'; $this->order = 3; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'File', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-hidden.php b/includes/fields/types/class-wpum-field-hidden.php index 801821d1..6b1b1018 100644 --- a/includes/fields/types/class-wpum-field-hidden.php +++ b/includes/fields/types/class-wpum-field-hidden.php @@ -21,12 +21,20 @@ class WPUM_Field_Hidden extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Hidden', 'wp-user-manager' ); $this->type = 'hidden'; $this->icon = 'dashicons-hidden'; $this->group = 'advanced'; $this->allow_default = true; $this->min_addon_version = '2.2.1'; } + + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Hidden', 'wp-user-manager' ); + } } diff --git a/includes/fields/types/class-wpum-field-multicheckbox.php b/includes/fields/types/class-wpum-field-multicheckbox.php index b9d84376..e4ea8977 100644 --- a/includes/fields/types/class-wpum-field-multicheckbox.php +++ b/includes/fields/types/class-wpum-field-multicheckbox.php @@ -21,12 +21,20 @@ class WPUM_Field_Multicheckbox extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Checkboxes', 'wp-user-manager' ); $this->type = 'multicheckbox'; $this->icon = 'dashicons-editor-ol'; $this->order = 3; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Checkboxes', 'wp-user-manager' ); + } + /** * Determine output of multicheckboxes field onto profile page. * diff --git a/includes/fields/types/class-wpum-field-multiselect.php b/includes/fields/types/class-wpum-field-multiselect.php index 3dabd050..0f49fdca 100644 --- a/includes/fields/types/class-wpum-field-multiselect.php +++ b/includes/fields/types/class-wpum-field-multiselect.php @@ -21,12 +21,20 @@ class WPUM_Field_Multiselect extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Multi Select', 'wp-user-manager' ); $this->type = 'multiselect'; $this->icon = 'dashicons-editor-alignleft'; $this->order = 3; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Multi Select', 'wp-user-manager' ); + } + /** * Gets the value of a posted multiselect field. * diff --git a/includes/fields/types/class-wpum-field-number.php b/includes/fields/types/class-wpum-field-number.php index 879c6337..5444d7b0 100644 --- a/includes/fields/types/class-wpum-field-number.php +++ b/includes/fields/types/class-wpum-field-number.php @@ -21,13 +21,21 @@ class WPUM_Field_Number extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Number', 'wp-user-manager' ); $this->type = 'number'; $this->icon = 'dashicons-leftright'; $this->order = 3; $this->allow_default = true; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Number', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-password.php b/includes/fields/types/class-wpum-field-password.php index a7a8b7dc..fdb38e15 100644 --- a/includes/fields/types/class-wpum-field-password.php +++ b/includes/fields/types/class-wpum-field-password.php @@ -21,12 +21,20 @@ class WPUM_Field_Password extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Password', 'wp-user-manager' ); $this->type = 'password'; $this->icon = 'dashicons-admin-network'; $this->order = 3; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Password', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-radio.php b/includes/fields/types/class-wpum-field-radio.php index 78aa8ba2..863bdd05 100644 --- a/includes/fields/types/class-wpum-field-radio.php +++ b/includes/fields/types/class-wpum-field-radio.php @@ -21,13 +21,21 @@ class WPUM_Field_Radio extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Radio buttons', 'wp-user-manager' ); $this->type = 'radio'; $this->icon = 'dashicons-list-view'; $this->order = 3; $this->allow_default = true; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Radio buttons', 'wp-user-manager' ); + } + /** * Format the output onto the profiles for the radio field. * diff --git a/includes/fields/types/class-wpum-field-repeater.php b/includes/fields/types/class-wpum-field-repeater.php index 8b95c8be..20f54569 100644 --- a/includes/fields/types/class-wpum-field-repeater.php +++ b/includes/fields/types/class-wpum-field-repeater.php @@ -22,7 +22,6 @@ class WPUM_Field_Repeater extends WPUM_Field_Type { */ public function __construct() { $this->group = 'advanced'; - $this->name = esc_html__( 'Repeater', 'wp-user-manager' ); $this->type = 'repeater'; $this->template = 'complex'; $this->icon = 'dashicons-menu-alt'; @@ -34,6 +33,15 @@ public function __construct() { add_filter( 'wpum_registered_parent_field_types', array( $this, 'register_parent_field' ) ); } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Repeater', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-taxonomy.php b/includes/fields/types/class-wpum-field-taxonomy.php index d62d9677..049b9a26 100644 --- a/includes/fields/types/class-wpum-field-taxonomy.php +++ b/includes/fields/types/class-wpum-field-taxonomy.php @@ -21,7 +21,6 @@ class WPUM_Field_Taxonomy extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Taxonomy', 'wp-user-manager' ); $this->type = 'taxonomy'; $this->icon = 'dashicons-tag'; $this->group = 'advanced'; @@ -29,6 +28,15 @@ public function __construct() { $this->min_addon_version = '2.2.1'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Taxonomy', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-telephone.php b/includes/fields/types/class-wpum-field-telephone.php index 35de64c1..2e762307 100644 --- a/includes/fields/types/class-wpum-field-telephone.php +++ b/includes/fields/types/class-wpum-field-telephone.php @@ -21,13 +21,21 @@ class WPUM_Field_Telephone extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Telephone', 'wp-user-manager' ); $this->type = 'telephone'; $this->icon = 'dashicons-phone'; $this->order = 3; $this->min_addon_version = '2.1'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Telephone', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-text.php b/includes/fields/types/class-wpum-field-text.php index afcab6a6..923b27e4 100644 --- a/includes/fields/types/class-wpum-field-text.php +++ b/includes/fields/types/class-wpum-field-text.php @@ -21,13 +21,21 @@ class WPUM_Field_Text extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Single Line Text', 'wp-user-manager' ); $this->type = 'text'; $this->icon = 'dashicons-editor-textcolor'; $this->order = 3; $this->allow_default = true; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Single Line Text', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-textarea.php b/includes/fields/types/class-wpum-field-textarea.php index bbf0470f..7d11e5d8 100644 --- a/includes/fields/types/class-wpum-field-textarea.php +++ b/includes/fields/types/class-wpum-field-textarea.php @@ -21,7 +21,6 @@ class WPUM_Field_Textarea extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'Textarea', 'wp-user-manager' ); $this->type = 'textarea'; $this->icon = 'dashicons-editor-paragraph'; $this->order = 3; @@ -29,6 +28,15 @@ public function __construct() { $this->default_type = 'textArea'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Textarea', 'wp-user-manager' ); + } + /** * Gets the value of a posted textarea field. * diff --git a/includes/fields/types/class-wpum-field-url.php b/includes/fields/types/class-wpum-field-url.php index dc8594b0..f69166ca 100644 --- a/includes/fields/types/class-wpum-field-url.php +++ b/includes/fields/types/class-wpum-field-url.php @@ -21,13 +21,21 @@ class WPUM_Field_Url extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'URL', 'wp-user-manager' ); $this->type = 'url'; $this->icon = 'dashicons-admin-links'; $this->order = 3; $this->allow_default = true; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'URL', 'wp-user-manager' ); + } + /** * Format the output onto the profiles for the url field. * diff --git a/includes/fields/types/class-wpum-field-user.php b/includes/fields/types/class-wpum-field-user.php index df6e5441..b3c292a8 100644 --- a/includes/fields/types/class-wpum-field-user.php +++ b/includes/fields/types/class-wpum-field-user.php @@ -21,7 +21,6 @@ class WPUM_Field_User extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'User', 'wp-user-manager' ); $this->type = 'user'; $this->icon = 'dashicons-admin-users'; $this->group = 'advanced'; @@ -29,6 +28,15 @@ public function __construct() { $this->min_addon_version = '2.3'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'User', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-userrole.php b/includes/fields/types/class-wpum-field-userrole.php index 7c096358..b13e0972 100644 --- a/includes/fields/types/class-wpum-field-userrole.php +++ b/includes/fields/types/class-wpum-field-userrole.php @@ -21,13 +21,21 @@ class WPUM_Field_Userrole extends WPUM_Field_Type { * Construct */ public function __construct() { - $this->name = esc_html__( 'User Role', 'wp-user-manager' ); $this->type = 'userrole'; $this->icon = 'dashicons-admin-generic'; $this->group = 'advanced'; $this->min_addon_version = '2.5'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'User Role', 'wp-user-manager' ); + } + /** * @return array */ diff --git a/includes/fields/types/class-wpum-field-video.php b/includes/fields/types/class-wpum-field-video.php index 4217afe8..c60de5c2 100644 --- a/includes/fields/types/class-wpum-field-video.php +++ b/includes/fields/types/class-wpum-field-video.php @@ -22,7 +22,6 @@ class WPUM_Field_Video extends WPUM_Field_File { */ public function __construct() { $this->group = 'advanced'; - $this->name = esc_html__( 'Video', 'wp-user-manager' ); $this->type = 'video'; $this->template = 'file'; $this->icon = 'dashicons-video-alt2'; @@ -30,6 +29,15 @@ public function __construct() { $this->min_addon_version = '2.1'; } + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'Video', 'wp-user-manager' ); + } + /** * @return string */ diff --git a/includes/fields/types/class-wpum-field-wysiwyg.php b/includes/fields/types/class-wpum-field-wysiwyg.php index 1b61b813..d4675a45 100644 --- a/includes/fields/types/class-wpum-field-wysiwyg.php +++ b/includes/fields/types/class-wpum-field-wysiwyg.php @@ -21,7 +21,6 @@ class WPUM_Field_Wysiwyg extends WPUM_Field_Textarea { * Construct */ public function __construct() { - $this->name = esc_html__( 'WYSIWYG', 'wp-user-manager' ); $this->type = 'wysiwyg'; $this->group = 'advanced'; $this->icon = 'dashicons-align-left'; @@ -29,4 +28,13 @@ public function __construct() { $this->template = 'wysiwyg'; $this->min_addon_version = '2.1'; } + + /** + * Set the name of the field. + * + * @return void + */ + public function set_name() { + $this->name = esc_html__( 'WYSIWYG', 'wp-user-manager' ); + } } diff --git a/includes/shortcodes/class-wpum-shortcode-content-loggedin.php b/includes/shortcodes/class-wpum-shortcode-content-loggedin.php index 50f607d5..c41e0488 100644 --- a/includes/shortcodes/class-wpum-shortcode-content-loggedin.php +++ b/includes/shortcodes/class-wpum-shortcode-content-loggedin.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Content_Loggedin extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_restrict_logged_in' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Members only content', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Members only content', 'wp-user-manager' ); - parent::__construct( 'wpum_restrict_logged_in' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-content-loggedout.php b/includes/shortcodes/class-wpum-shortcode-content-loggedout.php index a6788ea0..68c5b4ca 100644 --- a/includes/shortcodes/class-wpum-shortcode-content-loggedout.php +++ b/includes/shortcodes/class-wpum-shortcode-content-loggedout.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Content_Loggedout extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_restrict_logged_out' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Logged out only user content', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Logged out only user content', 'wp-user-manager' ); - parent::__construct( 'wpum_restrict_logged_out' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-content-roles.php b/includes/shortcodes/class-wpum-shortcode-content-roles.php index d91a59b5..b2ba99b8 100644 --- a/includes/shortcodes/class-wpum-shortcode-content-roles.php +++ b/includes/shortcodes/class-wpum-shortcode-content-roles.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Content_Roles extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_restrict_to_user_roles' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Specific roles only content', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Specific roles only content', 'wp-user-manager' ); - parent::__construct( 'wpum_restrict_to_user_roles' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-content-users.php b/includes/shortcodes/class-wpum-shortcode-content-users.php index f7668101..bf9c6816 100644 --- a/includes/shortcodes/class-wpum-shortcode-content-users.php +++ b/includes/shortcodes/class-wpum-shortcode-content-users.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Content_Users extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_restrict_to_users' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Users specific content', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Users specific content', 'wp-user-manager' ); - parent::__construct( 'wpum_restrict_to_users' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-directory.php b/includes/shortcodes/class-wpum-shortcode-directory.php index 235aaf4b..6e6f66d6 100644 --- a/includes/shortcodes/class-wpum-shortcode-directory.php +++ b/includes/shortcodes/class-wpum-shortcode-directory.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Directory extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_user_directory' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Directory', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Directory', 'wp-user-manager' ); - parent::__construct( 'wpum_user_directory' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-login-link.php b/includes/shortcodes/class-wpum-shortcode-login-link.php index d30c9df1..88451251 100644 --- a/includes/shortcodes/class-wpum-shortcode-login-link.php +++ b/includes/shortcodes/class-wpum-shortcode-login-link.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Login_Link extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_login' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Login link', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Login link', 'wp-user-manager' ); - parent::__construct( 'wpum_login' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-login.php b/includes/shortcodes/class-wpum-shortcode-login.php index dab257f3..eae211ae 100644 --- a/includes/shortcodes/class-wpum-shortcode-login.php +++ b/includes/shortcodes/class-wpum-shortcode-login.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Login extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_login_form' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Login form', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Login form', 'wp-user-manager' ); - parent::__construct( 'wpum_login_form' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-logout-link.php b/includes/shortcodes/class-wpum-shortcode-logout-link.php index 9d6588f4..ae60582b 100644 --- a/includes/shortcodes/class-wpum-shortcode-logout-link.php +++ b/includes/shortcodes/class-wpum-shortcode-logout-link.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Logout_Link extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_logout' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Logout link', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Logout link', 'wp-user-manager' ); - parent::__construct( 'wpum_logout' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-my-account.php b/includes/shortcodes/class-wpum-shortcode-my-account.php index 0482bc8c..effabcc1 100644 --- a/includes/shortcodes/class-wpum-shortcode-my-account.php +++ b/includes/shortcodes/class-wpum-shortcode-my-account.php @@ -21,11 +21,18 @@ class WPUM_Shortcode_My_Account extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { - $this->shortcode['title'] = esc_html__( 'Account page', 'wp-user-manager' ); - $this->shortcode['label'] = esc_html__( 'Account page', 'wp-user-manager' ); parent::__construct( 'wpum_account' ); } + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { + $this->shortcode['title'] = esc_html__( 'Account page', 'wp-user-manager' ); + $this->shortcode['label'] = esc_html__( 'Account page', 'wp-user-manager' ); + } } new WPUM_Shortcode_My_Account(); diff --git a/includes/shortcodes/class-wpum-shortcode-password.php b/includes/shortcodes/class-wpum-shortcode-password.php index 2e543376..ce7d792c 100644 --- a/includes/shortcodes/class-wpum-shortcode-password.php +++ b/includes/shortcodes/class-wpum-shortcode-password.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Password extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_password_recovery' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Password recovery form', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Password recovery form', 'wp-user-manager' ); - parent::__construct( 'wpum_password_recovery' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-profile-card.php b/includes/shortcodes/class-wpum-shortcode-profile-card.php index 0f11beeb..ab3b142c 100644 --- a/includes/shortcodes/class-wpum-shortcode-profile-card.php +++ b/includes/shortcodes/class-wpum-shortcode-profile-card.php @@ -21,9 +21,17 @@ class WPUM_Shortcode_Profile_Card extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { + parent::__construct( 'wpum_profile_card' ); + } + + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { $this->shortcode['title'] = esc_html__( 'Profile card', 'wp-user-manager' ); $this->shortcode['label'] = esc_html__( 'Profile card', 'wp-user-manager' ); - parent::__construct( 'wpum_profile_card' ); } /** diff --git a/includes/shortcodes/class-wpum-shortcode-profile.php b/includes/shortcodes/class-wpum-shortcode-profile.php index dc8c6432..4ce89596 100644 --- a/includes/shortcodes/class-wpum-shortcode-profile.php +++ b/includes/shortcodes/class-wpum-shortcode-profile.php @@ -21,11 +21,18 @@ class WPUM_Shortcode_Profile extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { - $this->shortcode['title'] = esc_html__( 'Profile page', 'wp-user-manager' ); - $this->shortcode['label'] = esc_html__( 'Profiles page', 'wp-user-manager' ); parent::__construct( 'wpum_profile' ); } + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { + $this->shortcode['title'] = esc_html__( 'Profile page', 'wp-user-manager' ); + $this->shortcode['label'] = esc_html__( 'Profiles page', 'wp-user-manager' ); + } } new WPUM_Shortcode_Profile(); diff --git a/includes/shortcodes/class-wpum-shortcode-recently-registered.php b/includes/shortcodes/class-wpum-shortcode-recently-registered.php index ff4aec78..9adcc243 100644 --- a/includes/shortcodes/class-wpum-shortcode-recently-registered.php +++ b/includes/shortcodes/class-wpum-shortcode-recently-registered.php @@ -21,11 +21,18 @@ class WPUM_Shortcode_Recently_Registered extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { - $this->shortcode['title'] = esc_html__( 'Recently registered list', 'wp-user-manager' ); - $this->shortcode['label'] = esc_html__( 'Recently registered list', 'wp-user-manager' ); parent::__construct( 'wpum_recently_registered' ); } + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { + $this->shortcode['title'] = esc_html__( 'Recently registered list', 'wp-user-manager' ); + $this->shortcode['label'] = esc_html__( 'Recently registered list', 'wp-user-manager' ); + } /** * Setup fields for the login shortcode window. * diff --git a/includes/shortcodes/class-wpum-shortcode-registration.php b/includes/shortcodes/class-wpum-shortcode-registration.php index 7027b460..4ce36e7c 100644 --- a/includes/shortcodes/class-wpum-shortcode-registration.php +++ b/includes/shortcodes/class-wpum-shortcode-registration.php @@ -21,11 +21,18 @@ class WPUM_Shortcode_Registration extends WPUM_Shortcode_Generator { * Inject the editor for this shortcode. */ public function __construct() { - $this->shortcode['title'] = esc_html__( 'Registration form', 'wp-user-manager' ); - $this->shortcode['label'] = esc_html__( 'Registration form', 'wp-user-manager' ); parent::__construct( 'wpum_register' ); } + /** + * Set the label and title of the shortcode. + * + * @return void + */ + public function set_labels() { + $this->shortcode['title'] = esc_html__( 'Registration form', 'wp-user-manager' ); + $this->shortcode['label'] = esc_html__( 'Registration form', 'wp-user-manager' ); + } /** * Setup fields for the login shortcode window. *