Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

cmb2 loading too late?

$
0
0

Replies: 0

Hey there!

I’m using cmb2 to create an options page as suggested here (https://github.com/CMB2/CMB2-Snippet-Library/blob/master/options-and-settings-pages/theme-options-cmb.php)

I can’t simply use something like this in my functions.php:

if ( myplugin_get_option('my_option') ) {
    // do something
}

I always need to wrap that in a hook and figured that the earliest hook i can use is wp_loaded.

Is there any way to workaround that? I’m using cmb2 inside my plugin/theme instead of making it a dependency, not sure if this matters.

The working example would look something like this:

add_action( 'wp_loaded', 'my_function' );
function my_function () {
    if ( myplugin_get_option('my_option') ) {
        // do something
    }
}

Viewing all articles
Browse latest Browse all 59525

Latest Images

Trending Articles



Latest Images