Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lifterlms_membership_link outputting draft or trashed content #2732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
significance: patch
type: fixed
links:
- "#2724"
entry: Avoid outputting lifterlms_membership_link content if the membership is
not published.
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<a href="' . get_permalink( $this->get_attribute( 'id' ) ) . '">' . $this->get_content() . '</a>';
}

Expand All @@ -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();
Loading