-
Notifications
You must be signed in to change notification settings - Fork 359
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
Enhancement: pmpro_is_page utility function #761
base: dev
Are you sure you want to change the base?
Conversation
I'm not sure how that utility code helps improve code readability/improves functionality? The As a result, the following costs fewer CPU cycles, is more performant and doesn't obfuscate the code in any way: if ( is_page( $pmpro_pages ) ) { |
Didn't know that, thanks for mentioning it.
I usually avoid using plugin variables directly because their structure may change in future updates. I prefer using documented APIs hence this function for detecting whether a page is handled by Paid Membership Pro or not. For example I prefer using |
As suggested by @eighty20results
Other plugins like bbpress, buddypress, and woocommerce have similar functions. We will take a look at this. |
Couple thoughts. A common issue when checking something like I am not sure if the is_page() function does something similar for I also wonder if we should check pmpro_is_checkout or otherwise check for PMPro blocks/shortcodes on the page and consider pmpro_is_page() true e.g. if there is a checkout block on a page that is not the specified checkout page. It would also be nice to address this issue at the same time. (#1958) Basically allow us to pass in a page key like 'levels' and call pmpro_is_page( 'levels' ) instead of |
I found myself needing this function recently so I assume it could be useful for other people too :-)
Not sure if the naming is ideal. I was tempted to call it
is_pmpro_page
which would make more sense but it would break the convention followed for function names (starting withpmpro_
).