Skip to content

Adding wpsf_get_option and wpsf_set_options #10

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions