Skip to content

Instantly share code, notes, and snippets.

@kirillrocks
Created February 7, 2017 08:36
Show Gist options
  • Save kirillrocks/e2bf418da0fe3ee4b44190eb348a6553 to your computer and use it in GitHub Desktop.
Save kirillrocks/e2bf418da0fe3ee4b44190eb348a6553 to your computer and use it in GitHub Desktop.
public static function get_option( $name, $default = false ) {
$option = get_option( 'cjlp' );
if ( false === $option ) {
return $default;
}
if ( isset( $option[ $name ] ) ) {
return $option[ $name ];
} else {
return $default;
}
}
public static function update_option( $name, $value ) {
$option = get_option( 'cjlp' );
$option = ( false === $option ) ? array() : (array) $option;
$option = array_merge( $option, array( $name => $value ) );
update_option( 'cjlp', $option );
}
public static function delete_option( $name ) {
$option = get_option( 'cjlp' );
$option = ( false === $option ) ? array() : (array) $option;
unset( $option[ $name ] );
update_option( 'cjlp', $option );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment