Search
 
SCRIPT & CODE EXAMPLE
 

PHP

status messages wordpress settings form

function change( $data ) {
 
    $message = null;
    $type = null;
 
    if ( null != $data ) {
 
        if ( false === get_option( 'myOption' ) ) {
 
            add_option( 'myOption', $data );
            $type = 'updated';
            $message = __( 'Successfully saved', 'my-text-domain' );
 
        } else {
 
            update_option( 'myOption', $data );
            $type = 'updated';
            $message = __( 'Successfully updated', 'my-text-domain' );
 
        }
 
    } else {
 
        $type = 'error';
        $message = __( 'Data can not be empty', 'my-text-domain' );
 
    }
 
    add_settings_error(
        'myUniqueIdentifyer',
        esc_attr( 'settings_updated' ),
        $message,
        $type
    );
 
}
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress if is not page template 
Php :: minishlink/web-push v5.2.5 requires ext-gmp * 
Php :: php array sort by key 
Php :: wordpress widget current year 
Php :: php all date arguments 
Php :: php unit 
Php :: php self referencing form 
Php :: laravel collection forget 
Php :: codeigniter how to know update failed 
Php :: laravel create on model 
Php :: php difference between two dates in seconds 
Php :: wordpress plugin functions exist 
Php :: symfony rabbitMQ 
Php :: carbon add and subtract 
Php :: laravel inline if else if 
Php :: livewire from one component to another 
Php :: drupal get node id from twig 
Php :: php search multidimensional array for multiple values 
Php :: clear session in laravel 
Php :: php contain 
Php :: call api with php 
Php :: php slice array by key 
Php :: laravel tinker insert db record 
Php :: php meta 
Php :: laravel permission 
Php :: laravel function 
Php :: php while loop 
Php :: php kommentar 
Php :: laravel eloquent update multiple records 
Php :: php get country code from country name 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =