From 9190d93467e8a5d544ff5086c7dac32d4d0e750e Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Tue, 24 Sep 2024 18:21:25 +0300 Subject: [PATCH] * manually reviewed #1528; * also added 'um_restricted_post_content' hook --- includes/core/class-access.php | 29 +++++++++++++++++++++++++++-- readme.txt | 1 + 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/includes/core/class-access.php b/includes/core/class-access.php index 482abc6d..9f1cc02a 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -761,6 +761,8 @@ if ( ! class_exists( 'um\core\Access' ) ) { return $content; } + $original_post_content = $content; + if ( $this->is_restricted( $id ) ) { $restriction = $this->get_post_privacy_settings( $id ); @@ -770,8 +772,31 @@ if ( ! class_exists( 'um\core\Access' ) ) { $content = ! empty( $restriction['_um_restrict_custom_message'] ) ? stripslashes( $restriction['_um_restrict_custom_message'] ) : ''; } - // translators: %s: Restricted post message. - $content = sprintf( __( '%s', 'ultimate-member' ), $content ); + // Because we have a late the_content callback priority here we have to apply shortcodes if faced in restricted message. + $content = apply_shortcodes( $content ); + /** + * Filters the restricted post content. + * Can be used for translations when site is multilingual. + * + * @param {string} $content Post content prepared from restricted message. + * @param {int} $post_id Post ID + * @param {string} $original_post_content Original post content. + * + * @return {string} Maybe changed post content prepared from restricted message. + * + * @since 2.8.7 + * @hook um_restricted_post_content + * + * @example Trim restriction message if post_id = 111. + * function my_restricted_post_content( $content, $post_id, $original_post_content ) { + * if ( 111 === $post_id ) { + * $content = trim( $content ); + * } + * return $content; + * } + * add_filter( 'um_restricted_post_content', 'my_restricted_post_content', 10, 3 ); + */ + $content = apply_filters( 'um_restricted_post_content', $content, $id, $original_post_content ); } return $content; diff --git a/readme.txt b/readme.txt index fbb531b2..aeacf87e 100644 --- a/readme.txt +++ b/readme.txt @@ -174,6 +174,7 @@ IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSI * Updated: User status filter on WP Users list table * Updated: User bulk actions on WP Users list table * Updated: User actions on User Profile and Member Directory card +* Added: Applying shortcodes from the post restriction message **Bugfixes**