mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
* manually reviewed #1528;
* also added 'um_restricted_post_content' hook
This commit is contained in:
@@ -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 <caption>Trim restriction message if post_id = 111.</caption>
|
||||
* 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;
|
||||
|
||||
Reference in New Issue
Block a user