From c59897f7c03a3e68f73a68483fd3dab896ae33e7 Mon Sep 17 00:00:00 2001 From: Brian Hogg Date: Thu, 15 Aug 2024 16:14:32 -0400 Subject: [PATCH 1/2] Check post status before outputting content. --- .../shortcodes/class.llms.shortcode.membership.link.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/shortcodes/class.llms.shortcode.membership.link.php b/includes/shortcodes/class.llms.shortcode.membership.link.php index bfcc8030c5..f5860f095b 100644 --- a/includes/shortcodes/class.llms.shortcode.membership.link.php +++ b/includes/shortcodes/class.llms.shortcode.membership.link.php @@ -40,6 +40,10 @@ class LLMS_Shortcode_Membership_Link extends LLMS_Shortcode { * @version 3.4.3 */ protected function get_output() { + if ( 'publish' !== get_post_status( $this->get_attribute( 'id' ) ) ) { + return ''; + } + return '' . $this->get_content() . ''; } @@ -65,9 +69,9 @@ protected function get_default_attributes() { * @version 3.4.3 */ protected function get_default_content( $atts = array() ) { - return apply_filters( 'lifterlms_membership_link_text', get_the_title( $this->get_attribute( 'id' ) ), $this->get_attribute( 'id' ) ); + $default_content = 'publish' === get_post_status( $this->get_attribute( 'id' ) ) ? get_the_title( $this->get_attribute( 'id' ) ) : ''; + return apply_filters( 'lifterlms_membership_link_text', $default_content, $this->get_attribute( 'id' ) ); } - } return LLMS_Shortcode_Membership_Link::instance(); From 479c3bcfc9bd469b70b9efaaffa14508b1ae5277 Mon Sep 17 00:00:00 2001 From: Brian Hogg Date: Thu, 15 Aug 2024 16:19:17 -0400 Subject: [PATCH 2/2] Adding changelog. --- ...lms-membership-link-outputs-draft-or-trashed-content.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changelogs/fix_lifterlms-membership-link-outputs-draft-or-trashed-content.yml diff --git a/.changelogs/fix_lifterlms-membership-link-outputs-draft-or-trashed-content.yml b/.changelogs/fix_lifterlms-membership-link-outputs-draft-or-trashed-content.yml new file mode 100644 index 0000000000..a5765cadfc --- /dev/null +++ b/.changelogs/fix_lifterlms-membership-link-outputs-draft-or-trashed-content.yml @@ -0,0 +1,6 @@ +significance: patch +type: fixed +links: + - "#2724" +entry: Avoid outputting lifterlms_membership_link content if the membership is + not published.