PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | extensions/blocks/mailchimp/mailchimp.php +2 -37 16.2-beta → 16.3-beta View file →
@@ -10,12 +10,9 @@
10 10 namespace Automattic\Jetpack\Extensions\Mailchimp;
11 11
12 12 use Automattic\Jetpack\Assets;
13 13 use Automattic\Jetpack\Blocks;
14 -use Automattic\Jetpack\Connection\Client;
15 -use Automattic\Jetpack\Connection\Manager as Connection_Manager;
16 14 use Automattic\Jetpack\External_Connections;
17 -use Automattic\Jetpack\Status\Host;
18 15 use Jetpack;
19 16 use Jetpack_Gutenberg;
20 17
21 18 if ( ! defined( 'ABSPATH' ) ) {
@@ -103,41 +100,9 @@
103 100 }
104 101
105 102 check_admin_referer( 'writing-options' );
106 103
107 - $site_id = Connection_Manager::get_site_id();
108 - if ( is_wp_error( $site_id ) ) {
109 - return;
110 - }
111 -
112 - if ( $audience === 'none' ) {
113 - $data = array(
114 - 'follower_list_id' => '0',
115 - 'keyring_id' => '0',
116 - );
117 - } else {
118 - $connection = External_Connections::get_connection( 'mailchimp' );
119 - if ( empty( $connection ) ) {
120 - return;
121 - }
122 - $data = array(
123 - 'follower_list_id' => $audience,
124 - 'keyring_id' => $connection['ID'],
125 - );
126 - }
127 -
128 - if ( ( new Host() )->is_wpcom_simple() ) {
129 - require_lib( 'mailchimp' );
130 - $response = \MailchimpApi::save_settings( $site_id, $data );
131 - } else {
132 - $response = Client::wpcom_json_api_request_as_user(
133 - sprintf( '/sites/%d/mailchimp/settings', $site_id ),
134 - '1.1',
135 - array( 'method' => 'POST' ),
136 - $data,
137 - 'rest'
138 - );
139 - }
140 - if ( is_wp_error( $response ) ) {
104 + require_once JETPACK__PLUGIN_DIR . '_inc/lib/class-jetpack-mailchimp-helper.php';
105 + if ( is_wp_error( \Jetpack_Mailchimp_Helper::save_audience( $audience ) ) ) {
141 106 add_settings_error( 'general', 'settings_updated', __( 'Settings save failed.', 'jetpack' ), 'error' );
142 107 }
143 108 }