Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding wpsf_get_option and wpsf_set_options #10

Open
ghost opened this issue Sep 30, 2021 · 0 comments
Open

Adding wpsf_get_option and wpsf_set_options #10

ghost opened this issue Sep 30, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 30, 2021

This framework lacks two important functions.

wpsf_get_option () and wpsf_set_option ()

Here they are:

if ( ! function_exists( 'wpsf_get_option' ) ) {
	/**
	 * Get option.
	 *
	 * @param  string  $option_name
	 * @param  string  $default
	 * @return mixed|string|null
	 */
	function wpsf_get_option( $option_name = '', $default = '' ) {
		$options = apply_filters( 'wpsf_get_option', get_option( WPSF_OPTION ) );

		if ( ! empty( $option_name ) && ! empty( $options[ $option_name ] ) ) {
			return $options[ $option_name ];
		} else {
			return ( ! empty( $default ) ) ? $default : null;
		}
	}
}
if ( ! function_exists( 'wpff_set_option' ) ) {
	/**
	 * Set option.
	 *
	 * @param  string  $option_name
	 * @param  string  $new_value
	 * @return void
	 */
	function wpsf_set_option( $option_name = '', $new_value = '' )  {
		$options = get_option( WPSF_OPTION );

		if ( ! empty( $option_name ) && ! empty( $options[ $option_name ] ) ) {
			$options[ $option_name ] = $new_value;
			update_option( WPSF_OPTION, $options );
		}
	}
}

Put this function in functions/helpers.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants