mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Merge pull request #1584 from ultimatemember/fix/_load_textdomain_just_in_time
Fixes load textdomain just in time
This commit is contained in:
@@ -42,14 +42,7 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) {
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( ! $this->can_be_active() ) {
|
||||
UM()->admin()->notices()->add_notice(
|
||||
'um-action-scheduler',
|
||||
array(
|
||||
'class' => 'notice-warning is-dismissible',
|
||||
// translators: %1$s - Plugin name, %1$s - Plugin Version
|
||||
'message' => '<p>' . sprintf( __( '<strong>%1$s %2$s</strong> The file needed to enable the Action Scheduler is missing. The plugin will continue to function as it did before, but without the new benefits offered by the Action Scheduler.', 'ultimate-member' ), UM_PLUGIN_NAME, UM_VERSION ) . '</p>',
|
||||
)
|
||||
);
|
||||
add_action( 'init', array( $this, 'add_notice' ) );
|
||||
} else {
|
||||
add_filter( 'um_settings_structure', array( $this, 'add_setting' ) );
|
||||
|
||||
@@ -60,6 +53,17 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
public function add_notice() {
|
||||
UM()->admin()->notices()->add_notice(
|
||||
'um-action-scheduler',
|
||||
array(
|
||||
'class' => 'notice-warning is-dismissible',
|
||||
// translators: %1$s - Plugin name, %1$s - Plugin Version
|
||||
'message' => '<p>' . sprintf( __( '<strong>%1$s %2$s</strong> The file needed to enable the Action Scheduler is missing. The plugin will continue to function as it did before, but without the new benefits offered by the Action Scheduler.', 'ultimate-member' ), UM_PLUGIN_NAME, UM_VERSION ) . '</p>',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the Action Scheduler setting to Ultimate Member feature settings
|
||||
*
|
||||
|
||||
@@ -23,10 +23,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
|
||||
* Admin_Navmenu constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::$fields = array(
|
||||
'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
|
||||
'um_nav_roles' => __( 'By Role', 'ultimate-member' ),
|
||||
);
|
||||
add_action( 'init', array( &$this, 'set_variables' ) );
|
||||
|
||||
add_action( 'customize_controls_print_footer_scripts', array( &$this, '_wp_template' ) );
|
||||
add_action( 'wp_update_nav_menu_item', array( &$this, '_save' ), 10, 3 );
|
||||
@@ -36,6 +33,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Navmenu' ) ) {
|
||||
// add_action( 'wp_nav_menu_item_custom_fields_customize_template', array( $this, 'wp_nav_menu_item_custom_fields_customize_template' ), 20, 5 );
|
||||
}
|
||||
|
||||
public function set_variables() {
|
||||
self::$fields = array(
|
||||
'um_nav_public' => __( 'Display Mode', 'ultimate-member' ),
|
||||
'um_nav_roles' => __( 'By Role', 'ultimate-member' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires just before the move buttons of a nav menu item in the menu editor.
|
||||
|
||||
+29
-29
@@ -204,8 +204,8 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
$this->is_filtering = 0;
|
||||
$this->honeypot = 'um_request';
|
||||
|
||||
// textdomain loading
|
||||
add_action( 'init', array( &$this, 'localize' ), 0 );
|
||||
// @todo investigate permanently delete 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, 'localize' ), 0 ); // textdomain loading
|
||||
|
||||
// include UM classes
|
||||
$this->includes();
|
||||
@@ -243,33 +243,33 @@ if ( ! class_exists( 'UM' ) ) {
|
||||
*
|
||||
* @since 2.8.5 WordPress native functions are used to make this function clear.
|
||||
*/
|
||||
public function localize() {
|
||||
$default_domain = dirname( plugin_basename( UM_PLUGIN ) );
|
||||
/**
|
||||
* Filters the plugin's textdomain.
|
||||
*
|
||||
* @param {string} $domain Plugin's textdomain.
|
||||
*
|
||||
* @return {string} Maybe changed plugin's textdomain.
|
||||
*
|
||||
* @since 1.3.x
|
||||
* @hook um_language_textdomain
|
||||
*
|
||||
* @example <caption>Change UM language locale.</caption>
|
||||
* function my_um_language_textdomain( $domain ) {
|
||||
* $domain = 'ultimate-member-custom';
|
||||
* return $domain;
|
||||
* }
|
||||
* add_filter( 'um_language_textdomain', 'my_um_language_textdomain' );
|
||||
*/
|
||||
$domain = apply_filters( 'um_language_textdomain', $default_domain );
|
||||
|
||||
// Unload textdomain if it has already loaded.
|
||||
if ( is_textdomain_loaded( $domain ) ) {
|
||||
unload_textdomain( $domain, true );
|
||||
}
|
||||
load_plugin_textdomain( $domain, false, $default_domain . '/languages' );
|
||||
}
|
||||
// public function localize() {
|
||||
// $default_domain = dirname( plugin_basename( UM_PLUGIN ) );
|
||||
// /**
|
||||
// * Filters the plugin's textdomain.
|
||||
// *
|
||||
// * @param {string} $domain Plugin's textdomain.
|
||||
// *
|
||||
// * @return {string} Maybe changed plugin's textdomain.
|
||||
// *
|
||||
// * @since 1.3.x
|
||||
// * @hook um_language_textdomain
|
||||
// *
|
||||
// * @example <caption>Change UM language locale.</caption>
|
||||
// * function my_um_language_textdomain( $domain ) {
|
||||
// * $domain = 'ultimate-member-custom';
|
||||
// * return $domain;
|
||||
// * }
|
||||
// * add_filter( 'um_language_textdomain', 'my_um_language_textdomain' );
|
||||
// */
|
||||
// $domain = apply_filters( 'um_language_textdomain', $default_domain );
|
||||
//
|
||||
// // Unload textdomain if it has already loaded.
|
||||
// if ( is_textdomain_loaded( $domain ) ) {
|
||||
// unload_textdomain( $domain, true );
|
||||
// }
|
||||
// load_plugin_textdomain( $domain, false, $default_domain . '/languages' );
|
||||
// }
|
||||
|
||||
/**
|
||||
* 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
|
||||
|
||||
Reference in New Issue
Block a user