Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion includes/abstracts/class-wpum-field-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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 );
}

/**
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions includes/abstracts/class-wpum-shortcode-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,25 @@ abstract class WPUM_Shortcode_Generator {
*/
protected $required;

/**
* Set the label of the shortcode.
*
* @return void
*/
public function set_labels() {}

/**
* Get things started.
*
* @param string $shortcode
*/
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' ) );
}

/**
Expand Down
20 changes: 15 additions & 5 deletions includes/admin/class-wpum-options-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ 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' );

// 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' ) );

Expand All @@ -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.
*/
Expand Down
6 changes: 5 additions & 1 deletion includes/class-wp-user-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion includes/emails/class-wpum-emails-customizer-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 12 additions & 1 deletion includes/emails/class-wpum-emails-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
14 changes: 12 additions & 2 deletions includes/fields/class-wpum-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@
* @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();

Expand All @@ -161,6 +163,15 @@

}

/**
* 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.
*
Expand Down Expand Up @@ -208,12 +219,11 @@

if ( ! empty( $this->id ) ) {

$this->type_nicename = $this->get_field_type_name( $this->type );
$this->is_primary = $this->set_as_primary_field( $this->type );

Check warning on line 222 in includes/fields/class-wpum-field.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 1 space but found 4 spaces
$this->required = $this->get_meta( 'required' );

Check warning on line 223 in includes/fields/class-wpum-field.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 6 spaces
$this->visibility = $this->get_meta( 'visibility' );

Check warning on line 224 in includes/fields/class-wpum-field.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 1 space but found 4 spaces
$this->editable = $this->get_meta( 'editing' );

Check warning on line 225 in includes/fields/class-wpum-field.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 3 spaces but found 6 spaces
$this->parent_id = max( 0, (int) $this->get_meta( 'parent_id' ) );

Check warning on line 226 in includes/fields/class-wpum-field.php

View workflow job for this annotation

GitHub Actions / phpcs

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 5 spaces

$class = 'WPUM_Field_' . ucfirst( $this->get_type() );
if ( class_exists( $class ) ) {
Expand Down Expand Up @@ -339,7 +349,7 @@
*
* @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 = '';
Expand Down
2 changes: 1 addition & 1 deletion includes/fields/class-wpum-fields-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ 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';
$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__( 'Audio', 'wp-user-manager' );
}

/**
* @return string
*/
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ 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;
$this->allow_default = true;
$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.
*
Expand Down
11 changes: 10 additions & 1 deletion includes/fields/types/class-wpum-field-datepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}

/**
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ 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;
$this->allow_default = true;
}


/**
* 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.
*
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
10 changes: 9 additions & 1 deletion includes/fields/types/class-wpum-field-hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}

Loading
Loading