Skip to content

Commit

Permalink
fixes the plugin update function that was removing the "enabled" flag…
Browse files Browse the repository at this point in the history
… under some conditions
  • Loading branch information
erikyo committed Jan 22, 2024
1 parent 833f2ed commit 841f8d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 6 additions & 1 deletion admin/CF7_AntiSpam_Admin_Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ public function cf7a_admin_menu() {
* @return array Modified array of plugin action links.
*/
public function cf7a_plugin_settings_link( array $links ) {
$settings_page_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=cf7-antispam' ), esc_html__( 'Antispam Settings', 'cf7-antispam' ) );
$options = get_option( 'cf7a_options' );
if ( $options['cf7a_enable'] ) {
$settings_page_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=cf7-antispam' ), esc_html__( 'Antispam Settings', 'cf7-antispam' ) );
} else {
$settings_page_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=wpcf7-integration' ), esc_html__( 'Activate Contact Form 7 integration', 'cf7-antispam' ) );
}
array_unshift( $links, $settings_page_link );

return $links;
Expand Down
11 changes: 5 additions & 6 deletions engine/CF7_AntiSpam_Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,12 @@ public static function update_options( $reset_options = false ) {

$options = get_option( 'cf7a_options' );

if ( false !== $options && ! $reset_options ) {
if ( empty( $options ) || $reset_options ) {
/* if the plugin options are missing Init the plugin with the default option + the default settings */
$new_options = array_merge( self::$default_cf7a_options, self::$default_cf7a_options_bootstrap );

add_option( 'cf7a_options', $new_options );
} else {
/* update the plugin options but add the new options automatically */
if ( isset( $options['cf7a_version'] ) ) {
unset( $options['cf7a_version'] );
Expand All @@ -226,11 +230,6 @@ public static function update_options( $reset_options = false ) {
cf7a_log( 'CF7-antispam plugin options updated', 1 );

update_option( 'cf7a_options', $new_options );
} else {
/* if the plugin options are missing Init the plugin with the default option + the default settings */
$new_options = array_merge( self::$default_cf7a_options, self::$default_cf7a_options_bootstrap );

add_option( 'cf7a_options', $new_options );
}

cf7a_log( $new_options, 1 );
Expand Down

0 comments on commit 841f8d9

Please sign in to comment.