PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
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 years ago front 5 years ago helpers 5 years ago metas 5 years ago palettes 5 years ago provider 5 years ago providers 5 years ago templates 5 years ago update 5 years ago class-hustle-admin-page-abstract.php 5 years ago class-hustle-condition-factory.php 6 years ago class-hustle-dashboard-admin.php 5 years ago class-hustle-data.php 5 years ago class-hustle-db.php 6 years ago class-hustle-module-admin.php 5 years ago class-hustle-module-collection.php 5 years ago class-hustle-module-decorator.php 5 years ago class-hustle-module-page-abstract.php 5 years ago class-hustle-notifications.php 5 years ago class-hustle-settings-admin.php 5 years ago class-hustle-upsell-page.php 5 years ago class-hustle-wp-dashboard-page.php 5 years ago hustle-collection.php 6 years ago hustle-deletion.php 5 years ago hustle-embedded-admin.php 6 years ago hustle-entries-admin.php 5 years ago hustle-entry-model.php 5 years ago hustle-general-data-protection.php 6 years ago hustle-init.php 5 years ago hustle-mail.php 5 years ago hustle-meta.php 5 years ago hustle-migration.php 5 years ago hustle-model.php 5 years ago hustle-module-model.php 5 years ago hustle-module-widget-legacy.php 5 years ago hustle-module-widget.php 5 years ago hustle-modules-common-admin-ajax.php 5 years ago hustle-popup-admin.php 6 years ago hustle-providers-admin.php 5 years ago hustle-providers.php 6 years ago hustle-settings-admin-ajax.php 5 years ago hustle-settings-page.php 5 years ago hustle-slidein-admin.php 6 years ago hustle-sshare-admin.php 5 years ago hustle-sshare-model.php 5 years ago hustle-tracking-model.php 5 years ago opt-in-geo.php 5 years ago opt-in-utils.php 5 years ago opt-in-wpmudev-api.php 6 years ago
hustle-providers-admin.php
164 lines
1 <?php
2 /**
3 * Class Hustle_Providers_Admin
4 * This class handles the global "Integrations" page view.
5 *
6 * @since 4.0
7 */
8 class Hustle_Providers_Admin extends Hustle_Admin_Page_Abstract {
9
10 public function init() {
11
12 $this->page = 'hustle_integrations';
13
14 $this->page_title = __( 'Hustle Integrations', 'hustle' );
15
16 $this->page_menu_title = __( 'Integrations', 'hustle' );
17
18 $this->page_capability = 'hustle_edit_integrations';
19
20 $this->page_template_path = 'admin/integrations';
21 }
22
23 /**
24 * Get the arguments used when rendering the main page.
25 *
26 * @since 4.0.1
27 * @return array
28 */
29 public function get_page_template_args() {
30 $accessibility = Hustle_Settings_Admin::get_hustle_settings( 'accessibility' );
31 return array(
32 'accessibility' => $accessibility,
33 'sui' => $this->get_sui_summary_config(),
34 );
35 }
36
37 /**
38 * Register js variables.
39 * Used for when an integration comes back from an external redirect.
40 * For example, when doing oAuth with Hubspot.
41 *
42 * @since 4.3.1
43 *
44 * @return array
45 */
46 protected function get_vars_to_localize() {
47 $current_array = parent::get_vars_to_localize();
48
49 $current_array['integration_redirect'] = $this->grab_integration_external_redirect();
50 $current_array['integrations_url'] = add_query_arg( 'page', Hustle_Data::INTEGRATIONS_PAGE, admin_url( 'admin.php' ) );
51 $current_array['integrations_migrate'] = $this->grab_integration_external_redirect_migration();
52
53 // Also defined wizards.
54 $current_array['providers_action_nonce'] = wp_create_nonce( 'hustle_provider_action' );
55 $current_array['fetching_list'] = __( 'Fetching integration list…', 'hustle' );
56
57 return $current_array;
58 }
59
60 /**
61 * Attach back the addon after its external redirect.
62 * Return an array provided by the provider for handling
63 * the user's experience after coming back from the redirect.
64 *
65 * @since 4.0.2
66 * @return array
67 */
68 private function grab_integration_external_redirect() {
69
70 $response = array();
71 $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING );
72 $migration = filter_input( INPUT_GET, 'migration', FILTER_VALIDATE_BOOLEAN );
73
74 // handle migration elsewhere
75 if ( 'external-redirect' === $action && true !== $migration ) {
76
77 $nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
78
79 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_external_redirect' ) ) {
80
81 $slug = filter_input( INPUT_GET, 'slug', FILTER_SANITIZE_STRING );
82
83 $provider = Hustle_Provider_Utils::get_provider_by_slug( $slug );
84
85 if ( $provider instanceof Hustle_Provider_Abstract ) {
86
87 $response = $provider->process_external_redirect();
88 if ( ! empty( $response ) ) {
89 $response['slug'] = $slug;
90 }
91 }
92 } else {
93
94 $response = array(
95 'action' => 'notification',
96 'status' => 'error',
97 'message' => __( "You're not allowed to do this request.", 'hustle' ),
98 );
99 }
100 }
101
102 return $response;
103 }
104
105 /**
106 * Attach back the addon after its external redirect for migration.
107 * Return an array provided by the provider for handling
108 * the user's experience after coming back from the redirect.
109 *
110 * @since 4.0.3
111 * @return array
112 */
113 private function grab_integration_external_redirect_migration() {
114
115 $response = array();
116 $action = filter_input( INPUT_GET, 'action', FILTER_SANITIZE_STRING );
117 $migration = filter_input( INPUT_GET, 'migration', FILTER_VALIDATE_BOOLEAN );
118 $provider = filter_input( INPUT_GET, 'show_provider_migration', FILTER_SANITIZE_STRING );
119 $multiID = filter_input( INPUT_GET, 'integration_id', FILTER_SANITIZE_STRING );
120
121 if ( isset( $provider ) && ! empty( $provider ) ) {
122 $response['provider_modal'] = $provider;
123 }
124
125 if ( isset( $multiID ) && ! empty( $multiID ) ) {
126 $response['integration_id'] = $multiID;
127 }
128
129 if ( 'external-redirect' === $action && true === $migration ) {
130
131 $nonce = filter_input( INPUT_GET, 'nonce', FILTER_SANITIZE_STRING );
132
133 if ( $nonce && wp_verify_nonce( $nonce, 'hustle_provider_external_redirect' ) ) {
134
135 $slug = filter_input( INPUT_GET, 'slug', FILTER_SANITIZE_STRING );
136
137 $response['migration_notificaiton'] = array(
138 'action' => 'notification',
139 'status' => 'success',
140 'slug' => $slug,
141 );
142
143 if ( 'constantcontact' === $slug ) {
144 $response['migration_notificaiton']['message'] = sprintf( esc_html__( '%s integration successfully migrated to the v3.0 API version.', 'hustle' ), '<strong>' . esc_html__( 'Constant Contact', 'hustle' ) . '</strong>' );
145 }
146
147 if ( 'infusionsoft' === $slug ) {
148 $response['migration_notificaiton']['message'] = sprintf( esc_html__( '%s integration successfully migrated to use the REST API.', 'hustle' ), '<strong>' . esc_html__( 'InfusionSoft', 'hustle' ) . '</strong>' );
149 }
150 } else {
151
152 $response = array(
153 'action' => 'notification',
154 'status' => 'error',
155 'message' => __( "You're not allowed to do this request.", 'hustle' ),
156 );
157 }
158 }
159
160 return $response;
161 }
162
163 }
164