From cb4f34b041d03e772907349cd8a873c17c0919d9 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 20 Oct 2023 14:22:10 +0100 Subject: [PATCH 1/2] Remove `get_by_key` method Named methods are preferred in case array key names change in the future --- ...s-convertkit-admin-settings-broadcasts.php | 4 +-- .../class-convertkit-settings-broadcasts.php | 25 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/admin/section/class-convertkit-admin-settings-broadcasts.php b/admin/section/class-convertkit-admin-settings-broadcasts.php index 971687564..b931da63e 100644 --- a/admin/section/class-convertkit-admin-settings-broadcasts.php +++ b/admin/section/class-convertkit-admin-settings-broadcasts.php @@ -337,7 +337,7 @@ public function category_callback( $args ) { 'name' => $this->settings_key . '[' . $args['name'] . ']', 'id' => $this->settings_key . '_' . $args['name'], 'class' => 'convertkit-select2 enabled', - 'selected' => $this->settings->get_by_key( $args['name'] ), + 'selected' => $this->settings->category_id(), 'taxonomy' => 'category', 'hide_empty' => false, ) @@ -360,7 +360,7 @@ public function date_callback( $args ) { // Output field. echo $this->get_date_field( // phpcs:ignore WordPress.Security.EscapeOutput $args['name'], - esc_attr( $this->settings->get_by_key( $args['name'] ) ), + esc_attr( $this->settings->g( $args['name'] ) ), $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput array( 'enabled', diff --git a/includes/class-convertkit-settings-broadcasts.php b/includes/class-convertkit-settings-broadcasts.php index f4993da5b..d2fe1057b 100644 --- a/includes/class-convertkit-settings-broadcasts.php +++ b/includes/class-convertkit-settings-broadcasts.php @@ -64,31 +64,6 @@ public function get() { } - /** - * Returns Broadcasts settings value for the given key. - * - * @since 2.2.9 - * - * @param string $key Setting Key. - * @return string Value - */ - public function get_by_key( $key ) { - - // If the setting doesn't exist, bail. - if ( ! array_key_exists( $key, $this->settings ) ) { - return ''; - } - - // If the setting is empty, fallback to the default. - if ( empty( $this->settings[ $key ] ) ) { - $defaults = $this->get_defaults(); - return $defaults[ $key ]; - } - - return $this->settings[ $key ]; - - } - /** * Returns whether Broadcasts are enabled in the Plugin settings. * From dd92078e66ad366fc09782475778dd7d6534d688 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Fri, 20 Oct 2023 14:34:45 +0100 Subject: [PATCH 2/2] Fix syntax error --- admin/section/class-convertkit-admin-settings-broadcasts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/section/class-convertkit-admin-settings-broadcasts.php b/admin/section/class-convertkit-admin-settings-broadcasts.php index b931da63e..08e4705b6 100644 --- a/admin/section/class-convertkit-admin-settings-broadcasts.php +++ b/admin/section/class-convertkit-admin-settings-broadcasts.php @@ -360,7 +360,7 @@ public function date_callback( $args ) { // Output field. echo $this->get_date_field( // phpcs:ignore WordPress.Security.EscapeOutput $args['name'], - esc_attr( $this->settings->g( $args['name'] ) ), + esc_attr( $this->settings->published_at_min_date() ), $args['description'], // phpcs:ignore WordPress.Security.EscapeOutput array( 'enabled',