From cbb4d8e9b48e40b925f5fda5d0f300f8bcdb3dc7 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 14 Nov 2023 16:50:26 +0000 Subject: [PATCH 1/4] Added Author setting to Broadcasts Importer --- ...s-convertkit-admin-settings-broadcasts.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/admin/section/class-convertkit-admin-settings-broadcasts.php b/admin/section/class-convertkit-admin-settings-broadcasts.php index 9eb31ea49..01c1413b0 100644 --- a/admin/section/class-convertkit-admin-settings-broadcasts.php +++ b/admin/section/class-convertkit-admin-settings-broadcasts.php @@ -209,6 +209,19 @@ public function register_fields() { ) ); + add_settings_field( + 'author_id', + __( 'Author', 'convertkit' ), + array( $this, 'author_id_callback' ), + $this->settings_key, + $this->name, + array( + 'name' => 'author_id', + 'label_for' => 'author_id', + 'description' => __( 'The WordPress User to set as the author for WordPress Posts created from imported broadcasts.', 'convertkit' ), + ) + ); + add_settings_field( 'category_id', __( 'Category', 'convertkit' ), @@ -358,6 +371,32 @@ public function post_status_callback( $args ) { } + /** + * Renders the input for the author setting. + * + * @since 2.3.9 + * + * @param array $args Setting field arguments (name,description). + */ + public function author_id_callback( $args ) { + + // Build field. + $select_field = wp_dropdown_users( + array( + 'echo' => false, + 'selected' => $this->settings->author_id(), + 'include_selected' => true, + 'name' => $this->settings_key . '[' . $args['name'] . ']', + 'id' => $args['name'], + 'class' => 'enabled convertkit-select2', + ) + ); + + // Output field. + echo '
' . $select_field . '
' . $this->get_description( $args['description'] ); // phpcs:ignore WordPress.Security.EscapeOutput + + } + /** * Renders the input for the category setting. * From 982e24b34f2d8aa9b6904dc57d182677785da3bf Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Wed, 15 Nov 2023 13:45:42 -0500 Subject: [PATCH 2/4] Started tests --- .../broadcasts/import/BroadcastsToPostsSettingsCest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php b/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php index 9db84497f..8a514851f 100644 --- a/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php +++ b/tests/acceptance/broadcasts/import/BroadcastsToPostsSettingsCest.php @@ -38,6 +38,7 @@ public function testAccessibility(AcceptanceTester $I) // Confirm that settings have label[for] attributes. $I->seeInSource('