我目前正在尝试实现的是一些简单的主题选项。我想要做的是;
在Wordpress GUI的主题选项部分,我目前有一些设置(没有后面的操作),就是简单地“点击一个将禁用首页窗口小部件的复选框,如果它是打开的,则显示它们,如果它是关闭的,则禁用它们”
我理解背后的逻辑,但我不知道如何创建一些东西将返回一个简单的真或假,从主题-options.php,链接到前面-page.php,并使用从主题-选项的结果作为条件来显示所说的区域。
这方面的任何帮助都将是令人惊叹的。
<?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。
问候你,本
发布于 2014-08-25 22:56:39
也许那是因为你打错了字。
您没有关闭括号
echo theme_options_validate( $input['option1' );应该是:
echo theme_options_validate( $input['option1'] );https://stackoverflow.com/questions/25488689
复制相似问题