Last active
March 27, 2023 23:12
-
-
Save WillBrubaker/5d69293d0b31a78c275a to your computer and use it in GitHub Desktop.
An example of the use of the pre_option_ WordPress filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'pre_get_posts', 'wwm_pre_get_posts', 10, 0 ); | |
function wwm_pre_get_posts() { | |
/** | |
* For this example, the plugin that would be altered is the 'featured video plus' plugin | |
* The task is to show the featured video on single pages, but not on archives | |
* apply the filter on singlular pages that aren't the admin interface. | |
*/ | |
if ( ! is_singular() && ! is_admin() ) { | |
add_filter( 'pre_option_fvp-settings', 'wwm_fvp_settings', 10, 1 ) | |
} | |
} | |
function wwm_fvp_settings( $options = array() ) { | |
$options['usage'] = 'manual'; | |
return $options; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment