• Hi,

    I’ve created a new options page called MSP Settings in my plugin. Everything saves fine, but, I don’t get the admin notification at the top of the option page that tells me “Options Saved”. If my validation function fails it also doesn’t display a “Saved failed” notification. Is this notification something I have to build in manually or its supported out of the box for options pages?

    I am running WordPress on a Windows local machine.

    My plugin code is below:

    function msp_general_options_page() {
    	?>
    
    		 <div class="wrap">
    			<?php screen_icon(); ?>
    			<h2><?php _e( 'MSP UltimatePlugin', 'msp-ult' ); ?></h2>
    			<p><?php _e( 'This is an options page you can use to control settings in your MSP website. Example, configure services, products, etc.' ); ?></p>
    			<form method="POST" action="options.php">
    				<?php
    					settings_fields( 'msp_general_settings' );
    				?>
    				<table class="form-table">
    					<?php msp_general_do_options(); ?>
    				</table>
    				<input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'msp-ult'); ?>" />
    				<input type="hidden" name="msp-general-options-submit" value="Y" />
    			</form>
    		</div>
    
    	<?php
     }
    
     function create_msp_menus() {
    	add_menu_page( __( 'MSP Settings', 'msp-ult'  ), __( 'MSP Settings', 'msp-ult'  ), 'manage_options', 'msp_general_options', 'msp_general_options_page' );
    	add_submenu_page( 'msp_general_options', __( 'General Options', 'msp-ult'  ), __( 'General Options' , 'msp-ult' ), 'manage_options', 'msp_general_options' );
    
     }
     add_action( 'admin_menu', 'create_msp_menus');
    
     function msp_pluginsettings_init() {
    	register_setting( 'msp_general_settings', 'msp_general_options', 'msp_validate_general_settings');
    	/* register addditional settings here */
     }
     add_action( 'admin_init', 'msp_pluginsettings_init' );
    
     function msp_general_do_options() {
    
    	$options = get_option( 'msp_general_options' );
    	?>
    		<tr valign="top"><th scope="row"><?php _e( 'MSP API Token','msp-ult' ); ?></th>
    			<td>
    				<?php
    					if ( $options['msp-api-token'] ) {
    						$options['msp-api-token'] = wp_kses( $options['msp-api-token'] );
    					} else {
    						$options['msp-api-token'] = _( '' );
    					}
    				?>
    
    				<input type="text" id="msp-api-token" name="msp_general_options[msp-api-token]" width="300" value="<?php echo $options['msp-api-token']; ?>" /><br/>
    				<label class="description" for="msp_general_options[msp-api-token]"><?php _e( 'A key to authenticate that the WordPress site using this plugin has permission to do so.' )?></label>
    			</td>
    		</tr>
    	<?php
    }
    
    function msp_validate_general_settings( $input ){
    	if( ! is_numeric( $input['msp-api-token'] ) ) {
    		$input = null;
    	}
    	return $input;
    }

    Thank you,

    Tin

  • The topic ‘admin notification not showing up when save plugin options’ is closed to new replies.