Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 默认选项值不自动工作_Php_Jquery_Plugins_Wordpress_Default Value - Fatal编程技术网

Php 默认选项值不自动工作

Php 默认选项值不自动工作,php,jquery,plugins,wordpress,default-value,Php,Jquery,Plugins,Wordpress,Default Value,嗨专家wp插件开发者,我需要帮助。我已应用以下代码,但未使用默认值,并且在单击“保存”按钮后未显示更新的通知。当我在仪表板的选项页面中输入所有值时,一切都正常。但不显示所有更新的通知。请帮帮我 <?php function hkhk_options() { add_menu_page('Scrol Line Admin Settings', 'hk Settings','manage_options', 'hk_settings', 'hk_admin_options'); } add_

嗨专家wp插件开发者,我需要帮助。我已应用以下代码,但未使用默认值,并且在单击“保存”按钮后未显示更新的通知。当我在仪表板的选项页面中输入所有值时,一切都正常。但不显示所有更新的通知。请帮帮我

<?php 
function hkhk_options() {
add_menu_page('Scrol Line Admin Settings', 'hk Settings','manage_options',
'hk_settings', 'hk_admin_options');
}
add_action('admin_menu', 'hkhk_options');


function hk_defaults()
{
$hk_options = array(
    'back_color' => '#ccc',
);

}
if ( is_admin() ) :

function hk_register_settings () {
register_setting('hkhk_options', 'hk_options', 'hk_validate_options');
}
add_action('admin_init', 'hk_register_settings');

function hk_admin_options() {
global $hk_options;

if ( ! isset( $_REQUEST['updated'] ) )
$_REQUEST['updated'] = false; 
?>
    <div class="wrap">
        <h2>Select Scrol Line Option</h2>
        <?php if ( false !== $_REQUEST['updated'] ) : ?>
<div class="update fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
<?php endif; // If the form has just been submitted, this shows the notification ?>


        <form method="post" action="options.php">
        <?php $settings=get_option ( 'hk_options', $hk_options ); ?>
        <?php settings_fields('hkhk_options'); ?>
        <table class="form-table">
            <tr valign="top">
                <th scope="row"><label for="back_color"> Back Color </label></th>
                <td>
                    <input id="back_color" type="text" name="hk_options[back_color]" value="<?php esc_attr_e($settings['back_color']); ?>" class="wp-picker-container" /><p class="description"> Choose any color from here for background color. </p>
                </td>
            </tr>
        </table>
        <p class="submit"><input type="submit" class="button-primary" value="Save Options" /> </p>
        </form>
    </div>
<?php
}
function hk_validate_options( $input ){
   global $hk_options;
   $settings = get_option( 'hk_options', $hk_options );
     $input['back_color'] = wp_filter_post_kses( $input['back_color'] );

    return $input;
}
endif;
function scrol_line_active() {?>
<?php global $hk_options; $hk_settings = get_option ( 'hk_options', $hk_options ); ?>

<script type="text/javascript">
 jQuery(document).ready(function($) {
    jQuery("body") .hk({
        backColor: "<?php echo $hk_settings['back_color']; ?>",

    });
});
</script>
<?php
}
add_action ('wp_head', 'scrol_line_active');
?>

您正在检查错误的请求参数。您需要检查$u请求['settings-updated']。 提交选项页面时,新URL类似于/wp admin/admin.php?page=hk\u settings&settings updated=true


希望这能有所帮助。

谢谢尼兰巴。工作吧。但不能使用默认选项。若我从选项面板中删除了所有值,那个么我的插件就不能工作了。这意味着无法使用默认选项。@InfoBd请解释您的问题。我不明白。