PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14.1
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14.1
7.8.14 7.8.14.1 7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / hustle-providers-admin.php
wordpress-popup / inc Last commit date
display-conditions 5 months ago front 2 days ago helpers 1 month ago metas 3 months ago multisite 5 months ago palettes 3 years ago provider 1 month ago providers 2 days ago templates 3 years ago update 5 months ago class-hustle-admin-page-abstract.php 1 month ago class-hustle-auth-token.php 5 months ago class-hustle-condition-factory.php 6 years ago class-hustle-cross-sell.php 10 months ago class-hustle-dashboard-admin.php 1 month ago class-hustle-data.php 1 month ago class-hustle-db.php 2 years ago class-hustle-installer.php 4 years ago class-hustle-meta.php 3 years ago class-hustle-module-admin.php 1 month ago class-hustle-module-collection.php 5 months ago class-hustle-module-fields.php 3 months ago class-hustle-module-page-abstract.php 1 month ago class-hustle-module-validator.php 3 months ago class-hustle-notifications.php 2 days ago class-hustle-settings-admin.php 1 month ago class-hustle-wp-dashboard-page.php 5 months ago class-opt-in.php 2 days ago hustle-background-conversion-log.php 3 months ago hustle-deletion.php 3 months ago hustle-embedded-admin.php 3 years ago hustle-entries-admin.php 5 months ago hustle-entry-model.php 1 month ago hustle-general-data-protection.php 5 months ago hustle-init.php 1 month ago hustle-mail.php 5 months ago hustle-migration.php 5 months ago hustle-model.php 2 days ago hustle-module-model.php 1 month ago hustle-module-widget-legacy.php 5 months ago hustle-module-widget.php 5 months ago hustle-modules-common-admin-ajax.php 1 month ago hustle-popup-admin.php 3 years ago hustle-providers-admin.php 1 month ago hustle-providers.php 5 months ago hustle-settings-admin-ajax.php 1 month ago hustle-settings-page.php 3 years ago hustle-slidein-admin.php 3 years ago hustle-sshare-admin.php 2 days ago hustle-sshare-model.php 2 days ago hustle-tracking-model.php 3 months ago interface-hustle-auth-provider.php 5 months ago opt-in-geo.php 5 months ago opt-in-utils.php 2 days ago opt-in-wpmudev-api.php 5 months ago
hustle-providers-admin.php
217 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Hustle_Providers_Admin
4 *
5 * @package Hustle
6 */
7
8 /**
9 * Class Hustle_Providers_Admin
10 * This class handles the global "Integrations" page view.
11 *
12 * @since 4.0
13 */
14 class Hustle_Providers_Admin extends Hustle_Admin_Page_Abstract {
15
16 /**
17 * Init
18 */
19 public function init() {
20
21 $this->page = 'hustle_integrations';
22
23 /* translators: Plugin name */
24 $this->page_title = sprintf( __( '%s Integrations', 'hustle' ), Opt_In_Utils::get_plugin_name() );
25
26 $this->page_menu_title = __( 'Integrations', 'hustle' );
27
28 $this->page_capability = 'hustle_edit_integrations';
29
30 $this->page_template_path = 'admin/integrations';
31 }
32
33 /**
34 * Get the arguments used when rendering the main page.
35 *
36 * @since 4.0.1
37 * @return array
38 */
39 public function get_page_template_args() {
40 $accessibility = Hustle_Settings_Admin::get_hustle_settings( 'accessibility' );
41 return array(
42 'accessibility' => $accessibility,
43 'sui' => $this->get_sui_summary_config(),
44 );
45 }
46
47 /**
48 * Register js variables.
49 * Used for when an integration comes back from an external redirect.
50 * For example, when doing oAuth with Hubspot.
51 *
52 * @since 4.3.1
53 *
54 * @return array
55 */
56 protected function get_vars_to_localize() {
57 $current_array = parent::get_vars_to_localize();
58
59 $current_array['integration_redirect'] = $this->grab_integration_external_redirect();
60 $current_array['integrations_url'] = add_query_arg( 'page', Hustle_Data::INTEGRATIONS_PAGE, admin_url( 'admin.php' ) );
61 $current_array['integrations_migrate'] = $this->grab_integration_external_redirect_migration();
62
63 // Also defined wizards.
64 $current_array['providers_action_nonce'] = wp_create_nonce( 'hustle_provider_action' );
65 $current_array['fetching_list'] = esc_html__( 'Fetching integration list…', 'hustle' );
66
67 return $current_array;
68 }
69
70 /**
71 * Attach back the addon after its external redirect.
72 * Return an array provided by the provider for handling
73 * the user's experience after coming back from the redirect.
74 *
75 * @since 4.0.2
76 * @return array
77 */
78 private function grab_integration_external_redirect() {
79
80 $response = array();
81 $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_SPECIAL_CHARS );
82 $migration = filter_input( INPUT_GET, 'migration', FILTER_VALIDATE_BOOLEAN );
83
84 // handle migration elsewhere.
85 if ( 'external-redirect' === $action && true !== $migration ) {
86
87 $nonce = filter_input( INPUT_GET, 'nonce' );
88
89 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_external_redirect' ) ) {
90
91 $slug = filter_input( INPUT_GET, 'slug', FILTER_SANITIZE_SPECIAL_CHARS );
92
93 $provider = Hustle_Provider_Utils::get_provider_by_slug( $slug );
94
95 if ( $provider instanceof Hustle_Provider_Abstract ) {
96
97 $response = $provider->process_external_redirect();
98 if ( ! empty( $response ) ) {
99 $response['slug'] = $slug;
100 }
101 }
102 } else {
103
104 $response = array(
105 'action' => 'notification',
106 'status' => 'error',
107 'message' => esc_html__( "You're not allowed to do this request.", 'hustle' ),
108 );
109 }
110 }
111
112 return $response;
113 }
114
115 /**
116 * Attach back the addon after its external redirect for migration.
117 * Return an array provided by the provider for handling
118 * the user's experience after coming back from the redirect.
119 *
120 * @since 4.0.3
121 * @return array
122 */
123 private function grab_integration_external_redirect_migration() {
124
125 $response = array();
126 $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_SPECIAL_CHARS );
127 $migration = filter_input( INPUT_GET, 'migration', FILTER_VALIDATE_BOOLEAN );
128 $provider = esc_html( filter_input( INPUT_GET, 'show_provider_migration', FILTER_SANITIZE_SPECIAL_CHARS ) );
129 $multi_id = esc_html( filter_input( INPUT_GET, 'integration_id', FILTER_SANITIZE_SPECIAL_CHARS ) );
130
131 if ( ! empty( $provider ) ) {
132 $response['provider_modal'] = $provider;
133 }
134
135 if ( ! empty( $multi_id ) ) {
136 $response['integration_id'] = $multi_id;
137 }
138
139 if ( 'reauth_provider' === $action ) {
140 $response['reauth'] = true;
141 }
142
143 if ( 'migrate_provider_data' === $action && ! empty( $provider ) ) {
144 $nonce = filter_input( INPUT_GET, 'nonce' );
145
146 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_migrate' ) ) {
147
148 $provider_instance = Hustle_Provider_Utils::get_provider_by_slug( $provider );
149
150 if (
151 $provider_instance instanceof Hustle_Provider_Abstract &&
152 method_exists( $provider_instance, 'process_data_migration' )
153 ) {
154 $result = $provider_instance->process_data_migration();
155
156 if ( is_wp_error( $result ) ) {
157 $response['migration_notificaiton'] = array(
158 'action' => 'notification',
159 'status' => 'error',
160 'message' => $result->get_error_message(),
161 );
162 } else {
163 $response['migration_notificaiton'] = array(
164 'action' => 'notification',
165 'status' => 'success',
166 'slug' => $provider,
167 'message' => /* translators: integration type */ sprintf( esc_html__( '%s integration successfully migrated to the new API version.', 'hustle' ), '<strong>' . esc_html( ucfirst( $provider ) ) . '</strong>' ),
168 );
169 }
170 }
171 } else {
172 return array(
173 'action' => 'notification',
174 'status' => 'error',
175 'message' => esc_html__( "You're not allowed to do this request.", 'hustle' ),
176 );
177 }
178 }
179
180 if ( 'external-redirect' === $action && true === $migration ) {
181
182 $nonce = filter_input( INPUT_GET, 'nonce' );
183
184 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_external_redirect' ) ) {
185
186 $slug = esc_html( filter_input( INPUT_GET, 'slug', FILTER_SANITIZE_SPECIAL_CHARS ) );
187
188 $response['migration_notificaiton'] = array(
189 'action' => 'notification',
190 'status' => 'success',
191 'slug' => $slug,
192 );
193
194 if ( 'constantcontact' === $slug ) {
195 $response['migration_notificaiton']['message'] = /* translators: integration type */ sprintf( esc_html__( '%s integration successfully migrated to the v3.0 API version.', 'hustle' ), '<strong>' . esc_html__( 'Constant Contact', 'hustle' ) . '</strong>' );
196 }
197
198 if ( 'infusionsoft' === $slug ) {
199 $response['migration_notificaiton']['message'] = /* translators: integration type */ sprintf( esc_html__( '%s integration successfully migrated to use the REST API.', 'hustle' ), '<strong>' . esc_html__( 'Keap', 'hustle' ) . '</strong>' );
200 }
201 if ( 'convertkit' === $slug ) {
202 $response['migration_notificaiton']['message'] = /* translators: integration type */ sprintf( esc_html__( '%s integration successfully migrated to use the latest API version.', 'hustle' ), '<strong>' . esc_html__( 'ConvertKit', 'hustle' ) . '</strong>' );
203 }
204 } else {
205
206 $response = array(
207 'action' => 'notification',
208 'status' => 'error',
209 'message' => esc_html__( "You're not allowed to do this request.", 'hustle' ),
210 );
211 }
212 }
213
214 return $response;
215 }
216 }
217