- fixed CVE ID: CVE-2024-8519

- WPCS;
This commit is contained in:
Mykyta Synelnikov
2024-09-12 16:44:53 +03:00
parent e7c86052ab
commit 6c632a2c68
26 changed files with 71 additions and 104 deletions
+43 -73
View File
@@ -392,21 +392,18 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
return $classes; return $classes;
} }
/** /**
* Logged-in only content * Logged-in only content
* *
* @param array $args * @param array $args
* @param string $content * @param string $content
* *
* @return string * @return string
*/ */
function um_loggedin( $args = array(), $content = "" ) { public function um_loggedin( $args = array(), $content = '' ) {
ob_start();
$args = shortcode_atts( $args = shortcode_atts(
array( array(
'lock_text' => __( 'This content has been restricted to logged in users only. Please <a href="{login_referrer}">login</a> to view this content.', 'ultimate-member' ), 'lock_text' => __( 'This content has been restricted to logged-in users only. Please <a href="{login_referrer}">login</a> to view this content.', 'ultimate-member' ),
'show_lock' => 'yes', 'show_lock' => 'yes',
), ),
$args, $args,
@@ -414,50 +411,32 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
); );
if ( ! is_user_logged_in() ) { if ( ! is_user_logged_in() ) {
// Hide content for not logged-in users. Maybe display locked content notice.
if ( 'no' === $args['show_lock'] ) { if ( 'no' === $args['show_lock'] ) {
echo ''; return '';
} else {
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
UM()->get_template( 'login-to-view.php', '', $args, true );
}
} else {
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
echo do_shortcode( $this->convert_locker_tags( wpautop( $content ) ) );
} else {
echo apply_shortcodes( $this->convert_locker_tags( wpautop( $content ) ) );
} }
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
return UM()->get_template( 'login-to-view.php', '', $args );
} }
$output = ob_get_clean(); return apply_shortcodes( $this->convert_locker_tags( wpautop( $content ) ) );
return htmlspecialchars_decode( $output, ENT_NOQUOTES );
} }
/** /**
* Logged-out only content * Logged-out only content
* *
* @param array $args * @param array $args
* @param string $content * @param string $content
* *
* @return string * @return string
*/ */
function um_loggedout( $args = array(), $content = '' ) { public function um_loggedout( $args = array(), $content = '' ) {
ob_start();
// Hide for logged in users
if ( is_user_logged_in() ) { if ( is_user_logged_in() ) {
echo ''; // Hide for logged-in users
} else { return '';
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) {
echo do_shortcode( wpautop( $content ) );
} else {
echo apply_shortcodes( wpautop( $content ) );
}
} }
return apply_shortcodes( $this->convert_locker_tags( wpautop( $content ) ) );
$output = ob_get_clean();
return $output;
} }
/** /**
@@ -1192,9 +1171,9 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
* *
* @return mixed|string * @return mixed|string
*/ */
function convert_locker_tags( $str ) { public function convert_locker_tags( $str ) {
add_filter( 'um_template_tags_patterns_hook', array( &$this, 'add_placeholder' ), 10, 1 ); add_filter( 'um_template_tags_patterns_hook', array( &$this, 'add_placeholder' ) );
add_filter( 'um_template_tags_replaces_hook', array( &$this, 'add_replace_placeholder' ), 10, 1 ); add_filter( 'um_template_tags_replaces_hook', array( &$this, 'add_replace_placeholder' ) );
return um_convert_tags( $str, array(), false ); return um_convert_tags( $str, array(), false );
} }
@@ -1319,18 +1298,22 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
* @param string $content * @param string $content
* @return string * @return string
*/ */
function um_shortcode_show_content_for_role( $atts = array() , $content = '' ) { public function um_shortcode_show_content_for_role( $atts = array(), $content = '' ) {
global $user_ID; global $user_ID;
if ( ! is_user_logged_in() ) { if ( ! is_user_logged_in() ) {
return; return '';
} }
$a = shortcode_atts( array( $a = shortcode_atts(
'roles' => '', array(
'not' => '', 'roles' => '',
'is_profile' => false, 'not' => '',
), $atts ); 'is_profile' => false,
),
$atts,
'um_show_content'
);
if ( $a['is_profile'] ) { if ( $a['is_profile'] ) {
um_fetch_user( um_profile_id() ); um_fetch_user( um_profile_id() );
@@ -1341,39 +1324,26 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$current_user_roles = um_user( 'roles' ); $current_user_roles = um_user( 'roles' );
if ( ! empty( $a['not'] ) && ! empty( $a['roles'] ) ) { if ( ! empty( $a['not'] ) && ! empty( $a['roles'] ) ) {
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) { return apply_shortcodes( $this->convert_locker_tags( $content ) );
return do_shortcode( $this->convert_locker_tags( $content ) );
} else {
return apply_shortcodes( $this->convert_locker_tags( $content ) );
}
} }
if ( ! empty( $a['not'] ) ) { if ( ! empty( $a['not'] ) ) {
$not_in_roles = explode( ",", $a['not'] ); $not_in_roles = explode( ',', $a['not'] );
if ( is_array( $not_in_roles ) && ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, $not_in_roles ) ) <= 0 ) ) { if ( is_array( $not_in_roles ) && ( empty( $current_user_roles ) || count( array_intersect( $current_user_roles, $not_in_roles ) ) <= 0 ) ) {
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) { return apply_shortcodes( $this->convert_locker_tags( $content ) );
return do_shortcode( $this->convert_locker_tags( $content ) );
} else {
return apply_shortcodes( $this->convert_locker_tags( $content ) );
}
} }
} else { } else {
$roles = explode( ",", $a['roles'] ); $roles = explode( ',', $a['roles'] );
if ( ! empty( $current_user_roles ) && is_array( $roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) { if ( ! empty( $current_user_roles ) && is_array( $roles ) && count( array_intersect( $current_user_roles, $roles ) ) > 0 ) {
if ( version_compare( get_bloginfo('version'),'5.4', '<' ) ) { return apply_shortcodes( $this->convert_locker_tags( $content ) );
return do_shortcode( $this->convert_locker_tags( $content ) );
} else {
return apply_shortcodes( $this->convert_locker_tags( $content ) );
}
} }
} }
return ''; return '';
} }
/** /**
* @param array $args * @param array $args
* @param string $content * @param string $content
@@ -1426,36 +1396,36 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$search_value = array_values( $query ); $search_value = array_values( $query );
$template = UM()->get_template( 'searchform.php', '', array( 'query' => $query, 'search_value' => $search_value[0], 'members_page' => um_get_core_page( 'members' ) ) ); $t_args = array(
'query' => $query,
return $template; 'search_value' => $search_value[0],
'members_page' => um_get_core_page( 'members' ),
);
return UM()->get_template( 'searchform.php', '', $t_args );
} }
/** /**
* UM Placeholders for login referrer * UM Placeholders for login referrer
* *
* @param $placeholders * @param array $placeholders
* *
* @return array * @return array
*/ */
function add_placeholder( $placeholders ) { public function add_placeholder( $placeholders ) {
$placeholders[] = '{login_referrer}'; $placeholders[] = '{login_referrer}';
return $placeholders; return $placeholders;
} }
/** /**
* UM Replace Placeholders for login referrer * UM Replace Placeholders for login referrer
* *
* @param $replace_placeholders * @param array $replace_placeholders
* *
* @return array * @return array
*/ */
function add_replace_placeholder( $replace_placeholders ) { public function add_replace_placeholder( $replace_placeholders ) {
$replace_placeholders[] = um_dynamic_login_page_redirect(); $replace_placeholders[] = um_dynamic_login_page_redirect();
return $replace_placeholders; return $replace_placeholders;
} }
} }
} }
-1
View File
@@ -120,7 +120,6 @@ function um_replace_placeholders() {
'{user_account_link}', '{user_account_link}',
); );
/** /**
* UM hook * UM hook
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the account page * Template for the account page
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/account.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/account.php
* *
* Page: "Account" * Page: "Account"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the GDPR checkbox in register form * Template for the GDPR checkbox in register form
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/gdpr-register.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/gdpr-register.php
* *
* Page: "Register" * Page: "Register"
* Call: function display_option() * Call: function display_option()
+5 -7
View File
@@ -2,20 +2,18 @@
/** /**
* Template for the login only content, locked message * Template for the login only content, locked message
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/login-to-view.php * This template can be overridden by copying it to your-theme/ultimate-member/login-to-view.php
* *
* Call: function um_loggedin() * Call: function um_loggedin()
* *
* @version 2.6.1 * @version 2.8.7
* *
* @var string $lock_text * @var string $lock_text
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} ?> }
?>
<div class="um-locked-content"> <div class="um-locked-content">
<div class="um-locked-content-msg"><?php echo wp_kses( $lock_text, UM()->get_allowed_html( 'templates' ) ); ?></div>
<div class="um-locked-content-msg"><?php echo htmlspecialchars_decode( $lock_text ); ?></div>
</div> </div>
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the login form * Template for the login form
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/login.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/login.php
* *
* Page: "Login" * Page: "Login"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the logout * Template for the logout
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/logout.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/logout.php
* *
* Page: "Logout" * Page: "Logout"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the members directory grid * Template for the members directory grid
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/members-grid.php * This template can be overridden by copying it to your-theme/ultimate-member/members-grid.php
* *
* Page: "Members" * Page: "Members"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the members directory header JS-template * Template for the members directory header JS-template
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/members-header.php * This template can be overridden by copying it to your-theme/ultimate-member/members-header.php
* *
* Page: "Members" * Page: "Members"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the members directory list * Template for the members directory list
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/members-list.php * This template can be overridden by copying it to your-theme/ultimate-member/members-list.php
* *
* Page: "Members" * Page: "Members"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the members directory pagination JS template * Template for the members directory pagination JS template
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/members-pagination.php * This template can be overridden by copying it to your-theme/ultimate-member/members-pagination.php
* *
* Page: "Members" * Page: "Members"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the members directory * Template for the members directory
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/members.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/members.php
* *
* Page: "Members" * Page: "Members"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the message after registration process * Template for the message after registration process
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/message.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/message.php
* *
* Call: function parse_shortcode_args() * Call: function parse_shortcode_args()
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the modal form * Template for the modal form
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/modal/upload-single.php * This template can be overridden by copying it to your-theme/ultimate-member/modal/upload-single.php
* *
* @version 2.8.6 * @version 2.8.6
*/ */
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the modal photo * Template for the modal photo
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/modal/view-photo.php * This template can be overridden by copying it to your-theme/ultimate-member/modal/view-photo.php
* *
* @version 2.8.6 * @version 2.8.6
*/ */
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the password change * Template for the password change
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/password-change.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/password-change.php
* *
* Call: function ultimatemember_password() * Call: function ultimatemember_password()
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the password reset * Template for the password reset
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/password-reset.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/password-reset.php
* *
* Call: function ultimatemember_password() * Call: function ultimatemember_password()
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the profile page * Template for the profile page
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/profile.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/profile.php
* *
* Page: "Profile" * Page: "Profile"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the profile single comments * Template for the profile single comments
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/profile/comments-single.php * This template can be overridden by copying it to your-theme/ultimate-member/profile/comments-single.php
* *
* Page: "Profile" * Page: "Profile"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the profile comments * Template for the profile comments
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/profile/comments.php * This template can be overridden by copying it to your-theme/ultimate-member/profile/comments.php
* *
* Page: "Profile" * Page: "Profile"
* Call: function add_comments(), function load_comments() * Call: function add_comments(), function load_comments()
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the profile single post * Template for the profile single post
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/profile/posts-single.php * This template can be overridden by copying it to your-theme/ultimate-member/profile/posts-single.php
* *
* Page: "Profile" * Page: "Profile"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the profile posts * Template for the profile posts
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/profile/posts.php * This template can be overridden by copying it to your-theme/ultimate-member/profile/posts.php
* *
* Page: "Profile" * Page: "Profile"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the register page * Template for the register page
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/templates/register.php * This template can be overridden by copying it to your-theme/ultimate-member/templates/register.php
* *
* Page: "Register" * Page: "Register"
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the blog restricted message * Template for the blog restricted message
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/restricted-blog.php * This template can be overridden by copying it to your-theme/ultimate-member/restricted-blog.php
* *
* Call: function blog_message() * Call: function blog_message()
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the taxonomy restricted message * Template for the taxonomy restricted message
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/restricted-taxonomy.php * This template can be overridden by copying it to your-theme/ultimate-member/restricted-taxonomy.php
* *
* Call: function taxonomy_message() * Call: function taxonomy_message()
* *
+1 -1
View File
@@ -2,7 +2,7 @@
/** /**
* Template for the search form * Template for the search form
* *
* This template can be overridden by copying it to yourtheme/ultimate-member/searchform.php * This template can be overridden by copying it to your-theme/ultimate-member/searchform.php
* *
* Call: function ultimatemember_searchform() * Call: function ultimatemember_searchform()
* *