From 973dd6471309a5696c2b8697ffe1927500fec76a Mon Sep 17 00:00:00 2001 From: ashubawork Date: Wed, 12 Jul 2023 11:46:03 +0300 Subject: [PATCH] - fix user page blocks --- includes/core/class-account.php | 3 +++ includes/core/class-blocks.php | 10 +++++++--- includes/core/class-shortcodes.php | 13 +++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/includes/core/class-account.php b/includes/core/class-account.php index de307f8d..ac2ceda9 100644 --- a/includes/core/class-account.php +++ b/includes/core/class-account.php @@ -15,6 +15,9 @@ if ( ! class_exists( 'um\core\Account' ) ) { */ class Account { + /** + * @var boolean + */ public $account_exist = false; /** diff --git a/includes/core/class-blocks.php b/includes/core/class-blocks.php index cd6b33a3..ce3ed1cb 100644 --- a/includes/core/class-blocks.php +++ b/includes/core/class-blocks.php @@ -167,11 +167,15 @@ if ( ! class_exists( 'um\core\Blocks' ) ) { */ public function forms_render( $atts ) { if ( isset( $atts['form_id'] ) && '' !== $atts['form_id'] ) { - $mode = get_post_meta( $atts['form_id'], '_um_mode', true ); - if ( 'profile' === $mode && ( um_is_core_page( 'account' ) || um_is_core_page( 'user' ) ) ) { - return ''; + if ( um_is_core_page( 'account' ) ) { + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { + return '
' . esc_html__( 'This block cannot be used on this page', 'ultimate-member' ) . '
'; + } else { + return ''; + } } } + $shortcode = '[ultimatemember is_block="1"'; if ( isset( $atts['form_id'] ) && '' !== $atts['form_id'] ) { diff --git a/includes/core/class-shortcodes.php b/includes/core/class-shortcodes.php index f1b6bb78..30075de4 100644 --- a/includes/core/class-shortcodes.php +++ b/includes/core/class-shortcodes.php @@ -13,6 +13,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) { */ class Shortcodes { + /** + * @var array + */ + public $forms_exist = array(); + /** * @var string */ @@ -597,6 +602,14 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) { * @return string */ public function ultimatemember( $args = array() ) { + if ( isset( $args['form_id'] ) ) { + $id = $args['form_id']; + if ( isset( $this->forms_exist[ $id ] ) && true === $this->forms_exist[ $id ] ) { + return ''; + } + $this->forms_exist[ $id ] = true; + } + return $this->load( $args ); }