You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are numerous places in add ons and custom code where we write something like this: global $pmpro_pages; if ( is_page( $pmpro_pages['confirmation'] ) ) { // do something on the confirmation page }
This looks good and works most of the time. The problem is that sometimes the confirmation page may not be set, and so our code there becomes effectively a check for is_page(null) which returns true on ANY page, not just the confirmation page.
A function that returned false if the request page tag/id was empty and otherwise returned true if we were on that specific page would be useful.
We should probably just accept the PMPro page string (confirmation, checkout, billing, etc) and look up the post id from the $pmpro_pages global in the new function.
In the meantime, until we have something like this available, you can write something like this: global $pmpro_pages; if ( ! empty( $pmpro_pages['confirmation'] && is_page( $pmpro_pages['confirmation'] ) ) { // do something on the confirmation page }
The text was updated successfully, but these errors were encountered:
Something to also think about regarding improving this wrapper is to check the page's content for our particular shortcodes or blocks.
This only returns true when the confirmation page is assigned to the PMPro page settings (but having a custom confirmation page that isn't linked to PMPro's page settings will return false in some of our Add Ons).
Maybe two functions or a parameter to check for shortcode could be neat. The possible solutions:
Two functions pmpro_is_page( 'confirmation' ) (checks is_page) and pmpro_maybe_is_page( 'confirmation' ) which checks for is_page and shortcode/block.
OR
pmpro_is_page( 'levels', $shortcode = true ) that way developers can do a 'force check' to see if it's either the PMPro set page or the page contains a shortcode or block.
I'm leaning towards the second one instead, as we usually do force checks in some other methods.
There are numerous places in add ons and custom code where we write something like this:
global $pmpro_pages; if ( is_page( $pmpro_pages['confirmation'] ) ) { // do something on the confirmation page }
This looks good and works most of the time. The problem is that sometimes the confirmation page may not be set, and so our code there becomes effectively a check for
is_page(null)
which returns true on ANY page, not just the confirmation page.A function that returned false if the request page tag/id was empty and otherwise returned true if we were on that specific page would be useful.
We should probably just accept the PMPro page string (confirmation, checkout, billing, etc) and look up the post id from the $pmpro_pages global in the new function.
In the meantime, until we have something like this available, you can write something like this:
global $pmpro_pages; if ( ! empty( $pmpro_pages['confirmation'] && is_page( $pmpro_pages['confirmation'] ) ) { // do something on the confirmation page }
The text was updated successfully, but these errors were encountered: