Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // mu-plugins/theme-features.php
- require_once( FEATURES_DIR . '/myfeature.php' );
- // mu-plugins/theme-features/myfeature.php
- function features_myfeature_init() {
- if ( current_theme_supports( 'myfeature' ) ) {
- add_action( 'some_hook', 'features_myfeature' );
- }
- }
- add_action( 'wp_loaded', 'features_myfeature_init' );
- function features_myfeature() {
- $defaults = [ 'type' => 'foobar'];
- $options = (array) get_theme_support( 'myfeature' );
- $options = wp_parse_args( $options, $defaults);
- // do stuff
- echo ($options['type']); // qwerty
- }
- // theme/functions.php
- function mytheme_setup() {
- add_theme_support( 'myfeature', ['type' => 'qwerty'] );
- }
- add_action( 'after_setup_theme', 'mytheme_setup' );
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement