Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
2 deleted 6 characters in body
source | link

Instead of saving the default values to the database, you can retrieve them from the class by using a helper method something like the following:

/**
 * Get the option that is saved or the default.
 *
 * @param string $index. The option we want to get.
 */
public function get_settings( $index = false ) {
        $defaults = [ 'id_number' => 123,'title' => 'my title' ];
        $settings = get_option( 'my_option_name', $this->defaults$defaults );
        $settings = wp_parse_args( $settings, $defaults );

        if ( $index && isset( $settings[ $index ] ) ) {
            return $settings[ $index ];
        }

        return $settings;
    }

Hope this helps!

Instead of saving the default values to the database, you can retrieve them from the class by using a helper method something like the following:

/**
 * Get the option that is saved or the default.
 *
 * @param string $index. The option we want to get.
 */
public function get_settings( $index = false ) {
        $defaults = [ 'id_number' => 123,'title' => 'my title' ];
        $settings = get_option( 'my_option_name', $this->defaults );
        $settings = wp_parse_args( $settings, $defaults );

        if ( $index && isset( $settings[ $index ] ) ) {
            return $settings[ $index ];
        }

        return $settings;
    }

Hope this helps!

Instead of saving the default values to the database, you can retrieve them from the class by using a helper method something like the following:

/**
 * Get the option that is saved or the default.
 *
 * @param string $index. The option we want to get.
 */
public function get_settings( $index = false ) {
        $defaults = [ 'id_number' => 123,'title' => 'my title' ];
        $settings = get_option( 'my_option_name', $defaults );
        $settings = wp_parse_args( $settings, $defaults );

        if ( $index && isset( $settings[ $index ] ) ) {
            return $settings[ $index ];
        }

        return $settings;
    }

Hope this helps!

1
source | link

Instead of saving the default values to the database, you can retrieve them from the class by using a helper method something like the following:

/**
 * Get the option that is saved or the default.
 *
 * @param string $index. The option we want to get.
 */
public function get_settings( $index = false ) {
        $defaults = [ 'id_number' => 123,'title' => 'my title' ];
        $settings = get_option( 'my_option_name', $this->defaults );
        $settings = wp_parse_args( $settings, $defaults );

        if ( $index && isset( $settings[ $index ] ) ) {
            return $settings[ $index ];
        }

        return $settings;
    }

Hope this helps!