Skip to content

Improve options handling #387

@jdevalk

Description

@jdevalk

Use one option instead of multiple

We should have one edac option which is an array with keys for all the things we need to store. No need for the many different options we have right now.

Instead of this:

add_option( 'edac_activation_date', gmdate( 'Y-m-d H:i:s' ) );
add_option( 'edac_post_types', array( 'post', 'page' ) );
add_option( 'edac_simplified_summary_position', 'after' );

We should be doing:

add_option( 'edac', [
  'activation_date'             => gmdate( 'Y-m-d H:i:s' ),
  'post_types'                  => [ 'post', 'page' ],
  'simplified_summary_position' => 'after',
] );

Ideally, we'd make a single options class which we use for all interactions with our single option. For example, something like this.

No need to add_option

This code:

if ( get_option( $option_name ) !== false ) {
    update_option( $option_name, $new_value );
} else {
    add_option( $option_name, $new_value );
}

can simply be

update_option( $option_name, $new_value );

If the option doesn't exist, it will be created. WP already takes care of these things.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions