From fce72bbc632a1533cbcf0e533b78a4af467b3b4c Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 31 Jul 2016 18:06:00 -0700 Subject: [PATCH 1/3] don't set array, check value late and set avoids PHP notices --- src/GitHub_Updater/Settings.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/GitHub_Updater/Settings.php b/src/GitHub_Updater/Settings.php index e629f2dec..712788fb8 100644 --- a/src/GitHub_Updater/Settings.php +++ b/src/GitHub_Updater/Settings.php @@ -61,13 +61,6 @@ public function __construct() { &$this, 'plugin_action_links', ) ); - - // Make sure array values exist. - foreach ( array_keys( self::$remote_management ) as $key ) { - if ( empty( parent::$options_remote[ $key ] ) ) { - parent::$options_remote[ $key ] = null; - } - } } /** @@ -656,9 +649,10 @@ public function token_callback_text( $args ) { * @param $args */ public function token_callback_checkbox( $args ) { + $checked = isset( parent::$options[ $args['id'] ] ) ? parent::$options[ $args['id'] ] : null; ?> Date: Sun, 31 Jul 2016 18:07:37 -0700 Subject: [PATCH 2/3] don't merge old options causes problems with checkboxes that aren't present when not checked. --- src/GitHub_Updater/Settings.php | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/GitHub_Updater/Settings.php b/src/GitHub_Updater/Settings.php index 712788fb8..d5cb3870b 100644 --- a/src/GitHub_Updater/Settings.php +++ b/src/GitHub_Updater/Settings.php @@ -356,9 +356,7 @@ public function page_init() { } if ( isset( $_POST['github_updater'] ) && ! is_multisite() ) { - $options = get_site_option( 'github_updater' ); - $options = array_merge( $options, self::sanitize( $_POST['github_updater'] ) ); - update_site_option( 'github_updater', $options ); + update_site_option( 'github_updater', self::sanitize( $_POST['github_updater'] ) ); $this->redirect_on_save(); } } @@ -526,17 +524,13 @@ public function remote_management_page_init() { ); } - if ( isset( $_POST['option_page'] ) && 'github_updater_remote_management' === $_POST['option_page'] ) { - $options = array(); - foreach ( array_keys( self::$remote_management ) as $key ) { - $options[ $key ] = null; - } - if ( isset( $_POST['github_updater_remote_management'] ) ) { - $options = array_replace( $options, (array) self::sanitize( $_POST['github_updater_remote_management'] ) ); - } - update_site_option( 'github_updater_remote_management', $options ); + if ( isset( $_POST['option_page'] ) && + 'github_updater_remote_management' === $_POST['option_page'] && + ! is_multisite() + ) { + update_site_option( 'github_updater_remote_management', (array) self::sanitize( $_POST['github_updater_remote_management'] ) ); + $this->redirect_on_save(); } - $this->redirect_on_save(); } /** @@ -682,21 +676,12 @@ public function token_callback_checkbox_remote( $args ) { * @link http://benohead.com/wordpress-network-wide-plugin-settings/ */ public function update_network_setting() { - if ( 'github_updater' === $_POST['option_page'] ) { update_site_option( 'github_updater', self::sanitize( $_POST['github_updater'] ) ); } if ( 'github_updater_remote_management' === $_POST['option_page'] ) { - $options = array(); - foreach ( array_keys( self::$remote_management ) as $key ) { - $options[ $key ] = null; - } - if ( isset( $_POST['github_updater_remote_management'] ) ) { - $options = array_replace( $options, (array) self::sanitize( $_POST['github_updater_remote_management'] ) ); - } - update_site_option( 'github_updater_remote_management', $options ); + update_site_option( 'github_updater_remote_management', (array) self::sanitize( $_POST['github_updater_remote_management'] ) ); } - $this->redirect_on_save(); } From 41f683a304dccff0abe61eb5ba1325d32b45c9da Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 31 Jul 2016 18:09:58 -0700 Subject: [PATCH 3/3] bump and changes --- CHANGES.md | 1 + github-updater.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 21dc980e6..50c22c299 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ * fixed re-activation of RESTful plugin update, multisite vs single site * when creating Settings page, check current Plugin/Theme class instance, not transient. Fixes issue where remote install of private repo not having private settings saved. * fixed PHP errors in Settings page +* fixed saving issues with checkboxes #### 5.5.0 * better internationalization for changing plugin _View details_ link diff --git a/github-updater.php b/github-updater.php index 35de0199f..cd58f5bcb 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, or GitLab hosted plugins and themes. It also allows for remote installation of plugins or themes into WordPress. - * Version: 5.5.0.9 + * Version: 5.5.0.10 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html