* 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
+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.
*