Skip to content

Instantly share code, notes, and snippets.

@AndreaBarghigiani
Last active August 15, 2018 07:33
Show Gist options
  • Save AndreaBarghigiani/3c548d5f63afa4d127ea0ee5f6fd27c4 to your computer and use it in GitHub Desktop.
Save AndreaBarghigiani/3c548d5f63afa4d127ea0ee5f6fd27c4 to your computer and use it in GitHub Desktop.
This code expand the capability of is_lifterlms() and is able to check if the sale page that is loaded is included in some course or membership.
<?php
// Espandend to use is_sales_page()
if ( ! function_exists( 'is_lifterlms' ) ) {
function is_lifterlms() {
return apply_filters( 'is_lifterlms', ( is_courses() || is_course_taxonomy() || is_course() || is_lesson() || is_membership() || is_memberships() || is_quiz() || is_sales_page() ) );
}
}
/**
* Is Sales Page
* @return bool
* @since 3.0.0
*/
if ( ! function_exists( 'is_sales_page' ) ) {
function is_sales_page() {
$post_id = get_the_ID();
$args = array(
'post_type' => array( 'course', 'llms_membership' ),
'meta_query' => array(
array(
'key' => '_llms_sales_page_content_page_id',
'value' => $post_id,
'compare' => '=',
)
)
);
$query_meta = new WP_Query( $args );
if( $query_meta->post_count > 0 ){
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment