From 565a8f074a022b15d1f996a7774c1ab893f2f60c Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Thu, 13 Jul 2023 16:03:28 +0300 Subject: [PATCH] - fixed loading UM forms shortcode twice; --- includes/core/class-shortcodes.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/includes/core/class-shortcodes.php b/includes/core/class-shortcodes.php index 30075de4..6c3f1432 100644 --- a/includes/core/class-shortcodes.php +++ b/includes/core/class-shortcodes.php @@ -602,12 +602,30 @@ 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 ''; + /** + * Filters variable for disable singleton shortcode loading on the same page. + * Note: Set it to `true` if you need to render the same form twice or more on the same page. + * + * @since 2.6.8 + * @hook um_ultimatemember_shortcode_disable_singleton + * + * @param {bool} $disable Disabled singleton. By default, it's `false`. + * @param {array} $args Shortcode arguments. + * + * @return {bool} Disabled singleton or not. + * + * @example Turn on ability to use ultimatemember shortcode twice. + * add_filter( 'um_ultimatemember_shortcode_disable_singleton', '__return_true' ); + */ + $disable_singleton_shortcode = apply_filters( 'um_ultimatemember_shortcode_disable_singleton', false, $args ); + if ( false === $disable_singleton_shortcode ) { + 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; } - $this->forms_exist[ $id ] = true; } return $this->load( $args );