我正在开发一个图库插件。所以我创建了一个自定义帖子类型,在它下面我创建了一个子菜单页面,用于更改图库选项,如边框宽度,边框颜色,边框半径等。当我更新值时,一切正常,但更新通知未显示。 我在这里写主要代码。请告诉我什么是问题。
function gallery_setting_pages() {
add_submenu_page(
'edit.php?post_type=gallary',
'Gallery Settings',
'Settings',
'manage_options',
'gallery-setting',
'gallery_option_page_functions'
);
}
add_action('admin_menu','gallery_setting_pages');
if ( is_admin() ) :
function ppmscrollbar_register_settings() {
register_setting('gallery_plugin_options','rt_gallery_options','rt_gallery_validate_options');
}
add_action('admin_init','ppmscrollbar_register_settings');
function gallery_option_page_functions() {
global $rt_gallery_options;
if ( ! isset ($_REQUEST['updated'] ) )
$_REQUEST['updated']=false;
?>
<?php if ( false !==$_REQUEST['updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e('options saved'); ?></strong></p></div>
<?php endif; // If the form has just been submitted, this show the notification ?>
<form method="post" action="options.php">
<?php $settings=get_option( 'rt_gallery_options', $rt_gallery_options); ?>
<?php settings_fields('gallery_plugin_options'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="cursor_color">Select Gallery Border Color</label></th>
<td>
<input id="cursor_color" type="text" name="rt_gallery_options[cursor_color]" value="<?php echo stripslashes($settings['cursor_color']); ?>" class="my-color-field" /><p class="description">In a few words, explain what is this.</p>
</td>
</tr>
</table>
<p class="submit"><input type="submit" value="Save Changes" class="button button-primary" id="submit" name="submit"></p>
</form>
</div>
<?php
}
function rt_gallery_validate_options( $input ){
global $rt_gallery_options;
$settings = get_option( 'rt_gallery_options', $rt_gallery_options );
//We strip all tags from the text field, to avoid vulnerablilties like XSS
$input['cursor_color']=wp_filter_post_kses( $input['cursor_color']);
return $input;
}
endif; //EndIf is_admin()
答案 0 :(得分:-1)
感谢您在stackoverflow上发布问题以获得答案。我们随时为您提供帮助。请提及您上面使用的页面名称,并告诉我您在页面中更新“已更新”变量的位置。问题可能是,如果您没有设置变量,那么如果条件总是失败,则不会显示通知。