jeudi 2 novembre 2017

how to validate redux framework variable value

I used Redux Framework in my wordpress theme, now i want to use my global variable in my theme, how to validate my global variable if is ok/validated do my codes...

    array(
        'id'       => 'my_id',
        'type'     => 'switch',
        'title'    => __( 'Display Social Icons' , 'txd' ),
        'default'  => false,
    ),

and how to validate it, if its true, do my codes...

when i use var_dump(); i have this

string(1) "1"

now how to validate my variable?

if ( $my_var ) { do something... }
if ( 1 == $my_var ) { do ... }
if ( '1' == $my_var ) { ... }
if ( ! empty( $my_var ) ) { ... }
if ( ! empty( $my_var ) && '1' == $my_var ) { ... }
if ( '1' === $my_var ) { ... }

i am searching most standard and most safe way for doing my way. tnx

Aucun commentaire:

Enregistrer un commentaire