PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.9
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.9
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 3 years ago front 10 months ago helpers 10 months ago metas 3 years ago multisite 3 years ago palettes 3 years ago provider 3 years ago providers 10 months ago templates 3 years ago update 3 years ago class-hustle-admin-page-abstract.php 10 months ago class-hustle-black-friday-campaign.php 7 months ago class-hustle-condition-factory.php 6 years ago class-hustle-cross-sell.php 10 months ago class-hustle-dashboard-admin.php 3 years ago class-hustle-data.php 3 years 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 10 months ago class-hustle-module-collection.php 3 years ago class-hustle-module-page-abstract.php 2 years ago class-hustle-notifications.php 3 years ago class-hustle-settings-admin.php 3 years ago class-hustle-tutorials-page.php 4 years ago class-hustle-wp-dashboard-page.php 3 years ago hustle-deletion.php 3 years ago hustle-embedded-admin.php 3 years ago hustle-entries-admin.php 3 years ago hustle-entry-model.php 3 years ago hustle-general-data-protection.php 3 years ago hustle-init.php 7 months ago hustle-mail.php 3 years ago hustle-migration.php 3 years ago hustle-model.php 3 years ago hustle-module-model.php 10 months ago hustle-module-widget-legacy.php 3 years ago hustle-module-widget.php 3 years ago hustle-modules-common-admin-ajax.php 10 months ago hustle-popup-admin.php 3 years ago hustle-providers-admin.php 3 years ago hustle-providers.php 3 years ago hustle-settings-admin-ajax.php 3 years ago hustle-settings-page.php 3 years ago hustle-slidein-admin.php 3 years ago hustle-sshare-admin.php 3 years ago hustle-sshare-model.php 3 years ago hustle-tracking-model.php 3 years ago opt-in-geo.php 10 months ago opt-in-utils.php 3 years ago opt-in-wpmudev-api.php 3 years ago
hustle-providers-admin.php
174 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 ( 'external-redirect' === $action && true === $migration ) {
140
141 $nonce = filter_input( INPUT_GET, 'nonce' );
142
143 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_external_redirect' ) ) {
144
145 $slug = esc_html( filter_input( INPUT_GET, 'slug', FILTER_SANITIZE_SPECIAL_CHARS ) );
146
147 $response['migration_notificaiton'] = array(
148 'action' => 'notification',
149 'status' => 'success',
150 'slug' => $slug,
151 );
152
153 if ( 'constantcontact' === $slug ) {
154 $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>' );
155 }
156
157 if ( 'infusionsoft' === $slug ) {
158 $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>' );
159 }
160 } else {
161
162 $response = array(
163 'action' => 'notification',
164 'status' => 'error',
165 'message' => esc_html__( "You're not allowed to do this request.", 'hustle' ),
166 );
167 }
168 }
169
170 return $response;
171 }
172
173 }
174