Can I fake being in the customizer?

I'm trying to get a list of all theme modsoptions currently registered. The normal way you can do it is to be in

I'm trying to get a list of all theme mods / options currently registered. The normal way you can do it is to be inside the customizer, then $wp_customize->settings().

This will return a k,v pair of all the currenty registered theme mods that can, say, be saved.

If I inspect the global wp_customize outside the customizer itself, it's null, as expected.

Is there a workaround for this?

I'm trying to get a list of all theme mods / options currently registered. The normal way you can do it is to be inside the customizer, then $wp_customize->settings().

This will return a k,v pair of all the currenty registered theme mods that can, say, be saved.

If I inspect the global wp_customize outside the customizer itself, it's null, as expected.

Is there a workaround for this?

Share Improve this question asked Oct 30, 2019 at 13:59 Daniel SmithDaniel Smith 617 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You don't need to fake being in the customizer, just grab the theme mods directly via get_theme_mods. Afterall they're just theme specific options.

Something like this would print out all the theme mods in a definition list:

function tomjn_print_theme_mods() {
    $mods = get_theme_mods();
    if ( empty( $mods ) {
        return;
    }
    echo '<dl>';
    foreach ( $mods as $k => $v ) {
        echo '<dt>'.esc_html( $k ).'</dt>';
        echo '<dd>'.esc_html( $v ).'</dd>';
    }
    echo. '</dl>';
}

https://codex.wordpress/Function_Reference/get_theme_mods

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745043239a4607937.html

相关推荐

  • Can I fake being in the customizer?

    I'm trying to get a list of all theme modsoptions currently registered. The normal way you can do it is to be in

    7小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信