I am working on a custom WordPress plugin that has
// Callback for setting the if condition where theme should be used instead of Oxygen.
function ote_on_these_views() {
$oxygen_theme_enabler_options = get_option( 'oxygen_theme_enabler_option_name' ); // Array of All Options
$myifcondition = $oxygen_theme_enabler_options['enter_your_if_condition_1'];
if ( is_page( 'contact' ) ) {
return true;
} else {
return false;
}
}
With this in place, everything works fine. I am calling ote_on_these_views() a couple of times in rest of the code.
Now when I replace
if ( is_page( 'contact' ) ) {
with
if ( $myifcondition ) {
it does not work because the if condition is checking to see if the variable is present (and it is) and hence ote_on_these_views() is always returning true.
The current value of $myifcondition is is_page( 'contact' ) and is coming from the plugin's settings page.
So.. is there a way to replace the variable with its value first and then have the if statement check for it or any other workarounds?

Aucun commentaire:
Enregistrer un commentaire