* changed hook for initialization of email templates paths;

* removed `load_plugin_textdomain` due to (article)[https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/#Enhanced-support-for-only-using-PHP-translation-files]
* deprecated `UM()->localize()` function;
* deprecated `um_language_textdomain` filter hook;
This commit is contained in:
Mykyta Synelnikov
2024-11-29 14:09:23 +02:00
parent f5d81f1a41
commit b892a70756
4 changed files with 47 additions and 64 deletions
+9 -35
View File
@@ -175,7 +175,6 @@ if ( ! class_exists( 'UM' ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'ultimate-member' ), '1.0' );
}
/**
* UM constructor.
*
@@ -185,7 +184,6 @@ if ( ! class_exists( 'UM' ) ) {
parent::__construct();
}
/**
* UM pseudo-constructor.
*
@@ -204,9 +202,6 @@ if ( ! class_exists( 'UM' ) ) {
$this->is_filtering = 0;
$this->honeypot = 'um_request';
// @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();
@@ -215,6 +210,7 @@ if ( ! class_exists( 'UM' ) ) {
// run hook for extensions init
add_action( 'plugins_loaded', array( &$this, 'extensions_init' ), -19 );
// Fallback to avoid fatal errors for users who still have UM extensions compatible with UM 1.3.x and install UM >= 2.0 version before these extensions update.
add_action( 'init', array( &$this, 'old_update_patch' ), 0 );
//run activation
@@ -222,7 +218,7 @@ if ( ! class_exists( 'UM' ) ) {
register_deactivation_hook( UM_PLUGIN, array( &$this, 'deactivation' ) );
if ( is_multisite() && ! defined( 'DOING_AJAX' ) ) {
if ( ! defined( 'DOING_AJAX' ) && is_multisite() ) {
add_action( 'wp_loaded', array( $this, 'maybe_network_activation' ) );
}
@@ -242,39 +238,17 @@ if ( ! class_exists( 'UM' ) ) {
* Note: 'ultimate-member' is a default textdomain.
*
* @since 2.8.5 WordPress native functions are used to make this function clear.
* @deprecated 2.9.2 Ref. https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/#Enhanced-support-for-only-using-PHP-translation-files
*/
// 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() {
_deprecated_function( __METHOD__, '2.9.2', '' );
}
/**
* 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
* Fallback to avoid fatal errors for users who still have UM extensions compatible with UM 1.3.x and install UM >= 2.0 version before these extensions update.
* Doing 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades.
*/
function old_update_patch() {
public function old_update_patch() {
global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified;
if ( is_object( $um_woocommerce ) ) {
+8 -8
View File
@@ -55,12 +55,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
// change the title of the post
add_filter( 'the_title', array( &$this, 'filter_restricted_post_title' ), 10, 2 );
// change the content of the restricted post
add_filter( 'the_content', array( &$this, 'filter_restricted_post_content' ), 999999, 1 );
add_filter( 'the_content', array( &$this, 'filter_restricted_post_content' ), 999999 );
// change the excerpt of the restricted post
add_filter( 'get_the_excerpt', array( &$this, 'filter_restricted_post_excerpt' ), 999999, 2 );
// comments queries
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99, 1 );
add_action( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 99 );
add_filter( 'wp_count_comments', array( &$this, 'custom_comments_count_handler' ), 99, 2 );
// comments RSS
add_filter( 'comment_feed_where', array( &$this, 'exclude_posts_comments_feed' ), 99, 2 );
@@ -97,19 +97,19 @@ if ( ! class_exists( 'um\core\Access' ) ) {
add_filter( 'has_post_thumbnail', array( &$this, 'filter_post_thumbnail' ), 99, 3 );
// Change recent posts widget query.
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99, 1 );
add_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
// Exclude pages displayed by wp_list_pages function.
add_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10, 1 );
add_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ) );
// Archives list change where based on restricted posts.
add_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99, 2 );
// Callbacks for changing posts query.
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
add_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
add_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10, 2 );
add_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99, 3 );
// Callbacks for changing terms query.
add_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99, 1 );
add_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
// there is posts (Posts/Page/CPT) filtration if site is accessible
// there also will be redirects if they need
@@ -124,12 +124,12 @@ if ( ! class_exists( 'um\core\Access' ) ) {
remove_action( 'pre_get_terms', array( &$this, 'exclude_hidden_terms_query' ), 99 );
remove_filter( 'widget_posts_args', array( &$this, 'exclude_restricted_posts_widget' ), 99 );
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ), 10 );
remove_filter( 'wp_list_pages_excludes', array( &$this, 'exclude_restricted_pages' ) );
remove_filter( 'getarchives_where', array( &$this, 'exclude_restricted_posts_archives_widget' ), 99 );
remove_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
remove_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99 );
remove_action( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99 );
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ), 10 );
remove_filter( 'posts_where', array( &$this, 'exclude_posts_where' ) );
remove_filter( 'wp_count_posts', array( &$this, 'custom_count_posts_handler' ), 99 );
}
+16 -19
View File
@@ -47,25 +47,8 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* Mail constructor.
*/
public function __construct() {
//mandrill compatibility
add_action( 'init', array( &$this, 'init_paths' ), 0 ); // init class variables on zero-priority.
add_filter( 'mandrill_nl2br', array( &$this, 'mandrill_nl2br' ) );
add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 ); // @todo change to init.
}
/**
* Mandrill compatibility
*
* @param $nl2br
* @param string $message
* @return bool
*/
public function mandrill_nl2br( $nl2br, $message = '' ) {
// text emails
if ( ! UM()->options()->get( 'email_html' ) ) {
$nl2br = true;
}
return $nl2br;
}
/**
@@ -85,7 +68,7 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
* @example <caption>Extends email templates path.</caption>
* function my_email_templates_path_by_slug( $paths ) {
* // your code here
* $paths['{template_name}'] = '{template_path}';
* $paths['template_name'] = 'template_path';
* return $paths;
* }
* add_filter( 'um_email_templates_path_by_slug', 'my_email_templates_path_by_slug' );
@@ -93,6 +76,20 @@ if ( ! class_exists( 'um\core\Mail' ) ) {
$this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', $this->path_by_slug );
}
/**
* Mandrill compatibility
*
* @param $nl2br
* @return bool
*/
public function mandrill_nl2br( $nl2br ) {
if ( ! UM()->options()->get( 'email_html' ) ) {
$nl2br = true; // nl2br for text emails
}
return $nl2br;
}
/**
* Check blog ID on multisite, return '' if single site.
*
+12
View File
@@ -109,3 +109,15 @@ if ( ! defined( 'ABSPATH' ) ) {
* @depecated 2.8.7 Fully deprecated because there is used dropdown with statuses instead of list table views.
* @hook um_admin_views_users
*/
/**
* Filters the plugin's textdomain.
*
* @param {string} $domain Plugin's textdomain.
*
* @return {string} Maybe changed plugin's textdomain.
*
* @since 1.3.x
* @depecated 2.9.2 Fully deprecated because minimum required WP version is 5.5, but we cannot use `load_plugin_textdomain()` function since 4.6.0 if the plugin is situated in wp.org plugins directory.
* @hook um_language_textdomain
*/