Skip to content

Commit

Permalink
fixed set capabilities on update (solves #46)
Browse files Browse the repository at this point in the history
  • Loading branch information
threadi committed Nov 11, 2024
1 parent 7b5a07a commit edd8a0e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
32 changes: 28 additions & 4 deletions app/Plugin/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function_exists( 'wp_is_development_mode' ) && false === wp_is_development_mode(
define( 'EFML_UPDATE_RUNNING', 1 );
}
$this->version200();
$this->version201();

// save new plugin-version in DB.
update_option( 'efmlVersion', $installed_plugin_version );
Expand All @@ -90,13 +91,36 @@ function_exists( 'wp_is_development_mode' ) && false === wp_is_development_mode(
* @return void
*/
private function version200(): void {
// add option for version of this plugin.
add_option( 'efmlVersion', '', '', true );
if ( ! get_option( 'efmlVersion', false ) ) {
// add option for version of this plugin.
add_option( 'efmlVersion', '', '', true );
}

// run the same tasks for all settings as if we activate the plugin.
Settings::get_instance()->activation();
}

/**
* To run on update to version 2.0.1 or newer.
*
* @return void
*/
private function version201(): void {
// get actual capabilities.
$caps = get_option( 'eml_allowed_roles' );

// check for array.
if ( ! is_array( $caps ) ) {
$caps = array();
}

// if list is empty, set the defaults.
if ( empty( $caps ) ) {
$caps = array( 'administrator', 'editor' );
update_option( 'eml_allowed_roles', $caps );
}

// hide GPRD-hint for old installations.
update_option( 'eml_disable_gprd_warning', 1 );
// set capabilities.
Helper::set_capabilities( $caps );
}
}
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,7 @@ Yes, there are many options on WP CLI, see [our documentation](https://github.co

= 2.0.1 =
* Small optimizations on texts for better translations
* GPRD-hint is now also shown for old installations if it is not disabled
* Fixed update handler for WordPress 6.7
* Fixed setting of capabilities for Playground
* Fixed setting of capabilities on update

0 comments on commit edd8a0e

Please sign in to comment.