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

Improve options handling #387

Open
jdevalk opened this issue Dec 7, 2023 · 0 comments
Open

Improve options handling #387

jdevalk opened this issue Dec 7, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jdevalk
Copy link
Collaborator

jdevalk commented Dec 7, 2023

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.

@jdevalk jdevalk added the enhancement New feature or request label Dec 7, 2023
@SteveJonesDev SteveJonesDev modified the milestones: v1.12.0, v1.11.0 Mar 28, 2024
@SteveJonesDev SteveJonesDev removed this from the v1.11.0 milestone Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants