首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress主题开发

Wordpress主题开发
EN

Stack Overflow用户
提问于 2014-08-25 22:53:54
回答 1查看 98关注 0票数 0

我目前正在尝试实现的是一些简单的主题选项。我想要做的是;

在Wordpress GUI的主题选项部分,我目前有一些设置(没有后面的操作),就是简单地“点击一个将禁用首页窗口小部件的复选框,如果它是打开的,则显示它们,如果它是关闭的,则禁用它们”

我理解背后的逻辑,但我不知道如何创建一些东西将返回一个简单的真或假,从主题-options.php,链接到前面-page.php,并使用从主题-选项的结果作为条件来显示所说的区域。

这方面的任何帮助都将是令人惊叹的。

代码语言:javascript
复制
<?php $options = get_option( 'SV_theme_options' ); ?>

<input id="SV_theme_options[option1]" name="SV_theme_options[option1]" type="checkbox" value="1" <?php checked( '1', $options['option1'] ); ?> />


/**
 * Sanitize and validate input. Accepts an array, return a sanitized array.
 */
function theme_options_validate( $input ) {
    global $select_options, $radio_options;

    // Our checkbox value is either 0 or 1
    if ( ! isset( $input['option1'] ) )
        $input['option1'] = null;
    $input['option1'] = ( $input['option1'] == 1 ? 1 : 0 );

    // Say our text option must be safe text with no HTML tags
    $input['sometext'] = wp_filter_nohtml_kses( $input['sometext'] );

    // Our select option must actually be in our array of select options
    if ( ! array_key_exists( $input['selectinput'], $select_options ) )
        $input['selectinput'] = null;

    // Our radio option must actually be in our array of radio options
    if ( ! isset( $input['radioinput'] ) )
        $input['radioinput'] = null;
    if ( ! array_key_exists( $input['radioinput'], $radio_options ) )
        $input['radioinput'] = null;

    // Say our textarea option must be safe text with the allowed tags for posts
    $input['sometextarea'] = wp_filter_post_kses( $input['sometextarea'] );

    return $input;
}

同样在前面的-page.php中,我已经对这个文件执行了required_once,尝试通过执行以下操作来调用:

echo theme_options_validate( $input['option1' );

但是,我得到的只是返回的单词Array。

问候你,本

EN

回答 1

Stack Overflow用户

发布于 2014-08-25 22:56:39

也许那是因为你打错了字。

您没有关闭括号

代码语言:javascript
复制
echo theme_options_validate( $input['option1' );

应该是:

代码语言:javascript
复制
echo theme_options_validate( $input['option1'] );
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25488689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档