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

Adds Default options in wp_options table to allow manipulating options from WP CLI. #354

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion admin/class-nginx-helper-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,29 @@ public function nginx_helper_default_settings() {
);

}


public function store_default_options() {
$options = get_site_option( 'rt_wp_nginx_helper_options', array() );
$default_settings = $this->nginx_helper_default_settings();

$removable_default_settings = array(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing these settings from the list of settings to be stored in the options table?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SH4LIN These are redis configurations that if stored by default are populating the redis input fields, but on fresh install the nginx_cache purge method is selected which is causing inconsistencies in behaviour.

'redis_port',
'redis_prefix',
'redis_hostname',
'redis_database',
'redis_unix_socket'
);

// Remove all the keys that are not to be stored by default.
foreach ( $removable_default_settings as $removable_key ) {
unset( $default_settings[ $removable_key ] );
}

$diffed_options = wp_parse_args( $options, $default_settings );

add_site_option( 'rt_wp_nginx_helper_options', $diffed_options );
}

/**
* Get settings.
*
Expand Down
4 changes: 4 additions & 0 deletions includes/class-nginx-helper-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public static function activate() {
$role->add_cap( 'Nginx Helper | Purge cache' );

wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' );

if( method_exists( $nginx_helper_admin, 'store_default_options' ) ) {
$nginx_helper_admin->store_default_options();
}

}

Expand Down
Loading