Skip to content

Commit

Permalink
Merge pull request #74 from dparker1005/is_page-empty-check
Browse files Browse the repository at this point in the history
Now checking that pages ar not empty before using is_page()
  • Loading branch information
ideadude authored Sep 22, 2021
2 parents e03c608 + 9cf9747 commit 1af1801
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion classes/class-swsales-reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ public static function enqueue_tracking_js() {

wp_register_script( 'swsales_tracking', plugins_url( 'js/swsales-tracking.js', SWSALES_BASENAME ), array( 'jquery', 'utils' ) );

$landing_page_post_id = $active_sitewide_sale->get_landing_page_post_id();
$swsales_data = array(
'landing_page' => is_page( $active_sitewide_sale->get_landing_page_post_id() ),
'landing_page' => ! empty( $landing_page_post_id ) && is_page( $landing_page_post_id ),
'sitewide_sale_id' => $active_sitewide_sale->get_id(),
'ajax_url' => admin_url( 'admin-ajax.php' ),
);
Expand Down
4 changes: 2 additions & 2 deletions modules/class-swsales-module-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public static function is_checkout_page( $is_checkout_page, $sitewide_sale ) {
return $is_checkout_page;
}
$edd_checkout_pages = array( edd_get_option( 'purchase_page' ), edd_get_option( 'success_page' ), edd_get_option( 'failure_page' ) );
return is_page( $edd_checkout_pages ) ? true : $is_checkout_page;
return ( ! empty( $edd_checkout_pages ) && is_page( $edd_checkout_pages ) ) ? true : $is_checkout_page;
}

/**
Expand Down Expand Up @@ -318,7 +318,7 @@ public static function strike_prices( $price, $download_id ) {

// Check if we are on the landing page
$landing_page_post_id = intval( $active_sitewide_sale->get_landing_page_post_id() );
$on_landing_page = is_page( $landing_page_post_id );
$on_landing_page = ! empty( $landing_page_post_id ) && is_page( $landing_page_post_id );
$should_apply_discount_on_landing = ( 'none' !== $active_sitewide_sale->get_automatic_discount() );

// If discount code will be applied or we are on the landing page, strike prices.
Expand Down
2 changes: 1 addition & 1 deletion modules/class-swsales-module-pmpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public static function is_checkout_page( $is_checkout_page, $sitewide_sale ) {
return $is_checkout_page;
}
global $pmpro_pages;
return is_page( $pmpro_pages['checkout'] ) ? true : $is_checkout_page;
return ( ! empty( $pmpro_pages['checkout'] ) && is_page( $pmpro_pages['checkout'] ) ) ? true : $is_checkout_page;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/class-swsales-module-wc.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function is_checkout_page( $is_checkout_page, $sitewide_sale ) {
if ( 'wc' !== $sitewide_sale->get_sale_type() ) {
return $is_checkout_page;
}
return is_page( wc_get_page_id( 'cart' ) ) ? true : $is_checkout_page;
return ( ! empty( wc_get_page_id( 'cart' ) ) && is_page( wc_get_page_id( 'cart' ) ) ) ? true : $is_checkout_page;
}

/**
Expand Down

0 comments on commit 1af1801

Please sign in to comment.