PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / extra / hub-connector / inc / class-admin.php

class-admin.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at extra/hub-connector/inc/class-admin.php

732 lines 21.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Admin class to process admin side actions.
4 *
5 * @link http://wpmudev.com
6 * @since 1.0.0
7 * @author Joel James <[email protected]>
8 * @package WPMUDEV\Hub\Connector
9 */
10
11 namespace WPMUDEV\Hub\Connector;
12
13 /**
14 * Class Admin
15 */
16 class Admin {
17
18 use Singleton;
19
20 /**
21 * Plugin identifier.
22 *
23 * @var string $plugin
24 */
25 protected $plugin = 'default';
26
27 /**
28 * Admin page screen IDs.
29 *
30 * @var array Screen IDs.
31 */
32 protected $screens = array();
33
34 /**
35 * Extra query arguments for auth URLs.
36 *
37 * @var array Arguments.
38 */
39 protected $extra_args = array();
40
41 /**
42 * Initialize admin class.
43 *
44 * @since 1.0.0
45 */
46 protected function __construct() {
47 // Add required classes to body.
48 add_filter( 'admin_body_class', array( $this, 'add_body_class' ) );
49 // Register UI for a plugin.
50 add_action( 'wpmudev_hub_connector_ui', array( $this, 'render' ) );
51 // Process auth callback from hub.
52 add_action( 'admin_init', array( $this, 'process_auth_callback' ) );
53 // Include WDP ID header.
54 add_filter( 'extra_plugin_headers', array( $this, 'include_wdp_id_header' ) );
55 }
56
57 /**
58 * Get extra query arguments for plugin.
59 *
60 * @since 1.0.0
61 *
62 * @param string $plugin Plugin identifier.
63 *
64 * @return array
65 */
66 public function get_plugin_extra_args( string $plugin ): array {
67 if ( ! empty( $plugin ) && ! empty( $this->extra_args[ $plugin ] ) ) {
68 return $this->extra_args[ $plugin ];
69 }
70
71 return array();
72 }
73
74 /**
75 * Get screen IDs of plugin.
76 *
77 * @since 1.0.0
78 *
79 * @param string $plugin Plugin identifier.
80 *
81 * @return array
82 */
83 public function get_plugin_screens( string $plugin ): array {
84 if ( ! empty( $plugin ) && ! empty( $this->screens[ $plugin ] ) ) {
85 return $this->screens[ $plugin ];
86 }
87
88 return array();
89 }
90
91 /**
92 * Set extra query arguments URL redirects.
93 *
94 * @since 1.0.0
95 *
96 * @param string $plugin Plugin identifier.
97 * @param array $options Options.
98 *
99 * @return void
100 */
101 public function set_plugin_options( string $plugin, array $options = array() ) {
102 if ( empty( $plugin ) ) {
103 return;
104 }
105
106 $options = wp_parse_args(
107 $options,
108 array(
109 'screens' => array(),
110 'extra_args' => array(),
111 )
112 );
113
114 // Set options.
115 $this->set_plugin_screens( $plugin, $options['screens'] );
116 $this->set_plugin_extra_args( $plugin, $options['extra_args'] );
117 }
118
119 /**
120 * Set admin screens to process.
121 *
122 * UI will be rendered only on these screens.
123 *
124 * @since 1.0.0
125 *
126 * @param string $plugin Plugin identifier.
127 * @param array $screens Screen IDs.
128 *
129 * @return void
130 */
131 public function set_plugin_screens( string $plugin, array $screens = array() ) {
132 if ( ! empty( $screens ) ) {
133 foreach ( $screens as $screen ) {
134 $this->screens[ $screen ] = $plugin;
135 }
136 }
137 }
138
139 /**
140 * Set extra query arguments for login and register redirects.
141 *
142 * @since 1.0.0
143 *
144 * @param string $plugin Plugin identifier.
145 * @param array $args Extra arguments.
146 *
147 * @return void
148 */
149 public function set_plugin_extra_args( string $plugin, array $args = array() ) {
150 $this->extra_args[ $plugin ] = $args;
151 }
152
153 /**
154 * Make sure we get WDP ID in plugins data.
155 *
156 * NOTE: We NEED TO keep using WDP ID as the
157 * key, because that's how the WP filter works.
158 *
159 * @since 1.0.0
160 *
161 * @param array $headers Existing headers.
162 *
163 * @return array
164 */
165 public function include_wdp_id_header( $headers ) {
166 // Include WDP ID.
167 $headers[] = 'WDP ID';
168
169 return $headers;
170 }
171
172 /**
173 * Get plugin identifier.
174 *
175 * Get an identifier for plugins to identify if the
176 * module was initialised by their plugin.
177 * If no identifier was being passed from plugin, it will have
178 * a default value "default".
179 *
180 * @since 1.0.0
181 *
182 * @return string
183 */
184 public function get_plugin_id() {
185 return $this->plugin;
186 }
187
188 /**
189 * Render hub connector UI.
190 *
191 * @since 1.0.0
192 *
193 * @param string $plugin Plugin identifier.
194 */
195 public function render( $plugin = 'default' ) {
196 // only render on appropriate capability.
197 if ( ! ( is_multisite() ? current_user_can( 'manage_network_options' ) : current_user_can( 'manage_options' ) ) ) {
198 return;
199 }
200 if ( ! empty( $plugin ) ) {
201 $this->plugin = $plugin;
202 }
203
204 echo '<div id="wpmudev-hub-connector"></div>';
205
206 // Enqueue assets.
207 $this->enqueue_assets();
208 }
209
210 /**
211 * Add required classes to HTML body.
212 *
213 * @since 1.0.0
214 *
215 * @param string $classes Class names.
216 */
217 public function add_body_class( $classes ) {
218 if ( $this->is_allowed_screen() ) {
219 $classes .= ' ' . \WPMUDEV_HUB_CONNECTOR_SUI_VERSION;
220 }
221
222 return $classes;
223 }
224
225 /**
226 * Check if current admin page is one of the allowed pages.
227 *
228 * @since 1.0.0
229 *
230 * @return bool
231 */
232 public function is_allowed_screen() {
233 if ( function_exists( 'get_current_screen' ) ) {
234 $screen = get_current_screen();
235 // Allowed screens.
236 $screens = array_keys( $this->screens );
237
238 // Check if current screen found in list.
239 return ! empty( $screen->id ) && in_array( $screen->id, $screens, true );
240 }
241
242 return false;
243 }
244
245 /**
246 * Enqueue styles and scripts for UI.
247 *
248 * This should be called only when required.
249 *
250 * @since 1.0.0
251 */
252 protected function enqueue_assets() {
253 // SUI and custom styles.
254 wp_enqueue_style(
255 'hub-connector',
256 plugin_dir_url( \WPMUDEV_HUB_CONNECTOR_FILE ) . 'assets/css/hub-connector.min.css',
257 array(),
258 \WPMUDEV_HUB_CONNECTOR_VERSION
259 );
260
261 // Script.
262 wp_enqueue_script(
263 'hub-connector',
264 plugin_dir_url( \WPMUDEV_HUB_CONNECTOR_FILE ) . 'assets/js/hub-connector.min.js',
265 array( 'wp-element', 'wp-i18n' ),
266 \WPMUDEV_HUB_CONNECTOR_VERSION,
267 true
268 );
269
270 // Get current URL.
271 $current_url = remove_query_arg(
272 array(
273 'api_error',
274 'set_apikey',
275 'auth_error',
276 'connection_error',
277 'invalid_key',
278 'site_limit_exceeded',
279 'site_limit',
280 'available_hosting_sites',
281 'hub_connector_callback',
282 'is_multi_auth',
283 'user_apikey',
284 'auth_nonce',
285 'type',
286 ),
287 Data::get()->current_url()
288 );
289
290 // Prepare redirect URL.
291 $redirect_url = add_query_arg( array( 'hub_connector_callback' => 1 ), $current_url );
292
293 // fool-proof, in normal condition this enqueue_assets method won't be called without access.
294 $has_access = is_multisite() ? current_user_can( 'manage_network_options' ) : current_user_can( 'manage_options' );
295 $auth_nonce = $has_access ? wp_create_nonce( 'auth_nonce' ) : '';
296
297 // Extra arguments.
298 $extra_args = $this->get_plugin_extra_args_from_screen();
299
300 // URL arguments for registration URL.
301 $register_args = array(
302 'signup' => 'site-connect',
303 'site_connect_url' => rawurlencode( add_query_arg( 'auth_nonce', $auth_nonce, $redirect_url ) ),
304 );
305 // Include extra args.
306 if ( ! empty( $extra_args['register'] ) ) {
307 $register_args = array_merge( $register_args, $extra_args['register'] );
308 }
309
310 // Vars for javascript.
311 $vars = array(
312 'api_url' => rest_url( 'hub-connector/v1/' ),
313 'nonce' => wp_create_nonce( 'wp_rest' ),
314 'is_syncing' => false,
315 'is_team_selection' => false,
316 'has_access' => $has_access,
317 'is_logged_in' => API::get()->is_logged_in(),
318 // Not being used for literal output / DB insert.
319 // phpcs:disable WordPress.Security.NonceVerification.Recommended
320 'current_tab' => isset( $_GET['hub_connector_callback'] ) ? 'login' : 'register',
321 // phpcs:enable WordPress.Security.NonceVerification.Recommended
322 'login' => array(
323 'hub_auth_url' => add_query_arg(
324 $extra_args['auth'] ?? array(),
325 API::get()->rest_url( 'site-authenticate' )
326 ),
327 'team_auth_url' => add_query_arg(
328 $extra_args['team_auth'] ?? array(),
329 API::get()->rest_url( 'site-authenticate-team' )
330 ),
331 'google_auth_url' => add_query_arg(
332 $extra_args['google_auth'] ?? array(),
333 API::get()->rest_url( 'google-auth' )
334 ),
335 'redirect_url' => $redirect_url,
336 'domain' => Data::get()->network_site_url(),
337 'auth_nonce' => $auth_nonce,
338 'current_url' => $current_url,
339 'forgot_url' => add_query_arg(
340 $extra_args['forgot_password'] ?? array(),
341 Data::get()->server_url( 'forgot-password' )
342 ),
343 'register_url' => add_query_arg(
344 $register_args,
345 Data::get()->server_url( 'register' )
346 ),
347 ),
348 'texts' => $this->text_vars(),
349 );
350
351 /**
352 * Filter hook to modify script vars based on actions.
353 *
354 * @since 1.0.0
355 *
356 * @param array $vars Vars.
357 * @param string $plugin Plugin identifier.
358 */
359 $vars = apply_filters( 'wpmudev_hub_connector_localize_vars', $vars, $this->get_plugin_id() );
360
361 // Localized vars.
362 wp_localize_script( 'hub-connector', 'hubConnectorVars', $vars );
363 }
364
365 /**
366 * Process auth callback from the API.
367 *
368 * This method handles the dynamic script vars required
369 * for the UI.
370 *
371 * @since 1.0.0
372 *
373 * @return bool
374 */
375 public function process_auth_callback() {
376 // we do verify nonce, but we do have more sanity checks to be done first.
377 // phpcs:disable WordPress.Security.NonceVerification.Recommended
378
379 // Only for Hub connector callback.
380 if ( ! isset( $_REQUEST['hub_connector_callback'] ) ) {
381 return false;
382 }
383
384 // Should be capable to perform the actions.
385 if ( ! ( is_multisite() ? current_user_can( 'manage_network_options' ) : current_user_can( 'manage_options' ) ) ) {
386 return $this->update_vars( array( 'has_access' => false ) );
387 }
388
389 // If not logged in.
390 if ( ! API::get()->is_logged_in() ) {
391 // Auth nonce verification.
392 if ( ! $this->verify_nonce() ) {
393 // Failed. So no access.
394 return $this->update_vars( array( 'has_access' => false ) );
395 }
396
397 $error = $this->get_auth_error();
398 if ( ! empty( $error ) ) {
399 // Set auth errors.
400 return $this->update_vars( array( 'auth_error' => $error ) );
401 }
402
403 // Is team selection callback.
404 if ( $this->is_team_selection() ) {
405 $user_api_key = trim( sanitize_key( wp_unslash( $_REQUEST['user_apikey'] ?? '' ) ) );
406 // Get the teams for API key.
407 $teams = API::get()->get_hub_teams( $user_api_key );
408
409 // Set team selection page vars.
410 return $this->update_vars(
411 array(
412 'api_key' => $user_api_key,
413 'hub_teams' => $teams,
414 'is_team_selection' => true,
415 )
416 );
417 }
418
419 // Is the set API key page.
420 if ( ! empty( $_REQUEST['set_apikey'] ) ) {
421 $set_api_key = trim( sanitize_key( wp_unslash( $_REQUEST['set_apikey'] ) ) );
422 // Set API key.
423 API::get()->set_api_key( $set_api_key );
424
425 // Make sure to start syncing.
426 return $this->update_vars(
427 array(
428 'is_syncing' => true,
429 'is_logged_in' => true,
430 )
431 );
432 }
433 }
434
435 // phpcs:enable WordPress.Security.NonceVerification.Recommended
436
437 return false;
438 }
439
440 /**
441 * Get authentication error messages.
442 *
443 * Based on the error code, prepare different error messages.
444 *
445 * @since 1.0.0
446 *
447 * @return string
448 */
449 private function get_auth_error() {
450 /**
451 * Nonce is verified in `process_auth_callback` before this method called.
452 *
453 * @see self::process_auth_callback()
454 */
455 // phpcs:disable WordPress.Security.NonceVerification.Recommended
456
457 $error = '';
458 $reset_url = Data::get()->server_url( 'wp-login.php?action=lostpassword' );
459 $skip_trial_url = Data::get()->server_url( 'hub/account/?skip_trial' );
460 $trial_info_url = Data::get()->server_url( 'docs/getting-started/how-free-trials-work/' );
461 $websites_url = Data::get()->server_url( 'hub2/' );
462 $security_info_url = Data::get()->server_url( 'manuals/hub-security/' );
463 $support_url = Data::get()->server_url( 'hub/support/' );
464 $account_details_url = Data::get()->server_url( 'hub2/account/details/' );
465
466 if ( isset( $_GET['api_error'] ) ) {
467 // Get errors.
468 $api_error = sanitize_key( wp_unslash( $_GET['api_error'] ) );
469 $auth_error = sanitize_key( wp_unslash( $_GET['auth_error'] ?? '' ) );
470
471 if ( 1 === (int) $api_error || 'auth' === $api_error ) {
472 switch ( $auth_error ) {
473 case 'google_linked':
474 $error = sprintf(
475 // translators: %s Account detail URL.
476 __(
477 'You are currently using your Google account as your preferred login method. If you wish to login with your WPMU DEV email & password instead, please change the <strong>Login Method</strong> in <a href="%s" target="_blank">your WPMU DEV account</a>.',
478 'wpmudev'
479 ),
480 $account_details_url
481 );
482 break;
483 case 'google_unlinked':
484 $error = sprintf(
485 // translators: %s Account detail URL.
486 __(
487 'You are currently using your WPMU DEV email & password as your preferred login method. If you wish to login with your Google account instead, please change the <strong>Login Method</strong> in <a href="%s" target="_blank">your WPMU DEV account</a>.',
488 'wpmudev'
489 ),
490 $account_details_url
491 );
492 break;
493 case 'reauth_google':
494 $error = sprintf(
495 // translators: %1$s Account detail URL, %2$s Reset URL.
496 __(
497 'Due to security improvements, you will need to re-link your Google account in the Hub. Please log in with your WPMU DEV email & password for now, then set up your preferred <strong>Login Method</strong> in <a href="%1$s" target="_blank">your WPMU DEV account</a>. Forgot your password? You can <a href="%2$s" target="_blank">reset it here</a>.',
498 'wpmudev'
499 ),
500 $account_details_url,
501 $reset_url
502 );
503 break;
504 default:
505 // Invalid credentials.
506 $error = sprintf(
507 '%s<br><a href="%s" target="_blank">%s</a>',
508 esc_html__( 'Your login details were incorrect. Please make sure you\'re using your WPMU DEV email and password and try again.', 'wpmudev' ),
509 $reset_url,
510 esc_html__( 'Forgot your password?', 'wpmudev' )
511 );
512 break;
513 }
514 } else {
515 switch ( $api_error ) {
516 case 'in_trial':
517 $error = sprintf(
518 '%s<br><a href="%s" target="_blank">%s</a>',
519 sprintf(
520 // translators: %1$s Rest URL, %2$s Upgrade URL, %3$s Trial URL.
521 __(
522 'This domain has previously been registered with us by the user %1$s. To use WPMU DEV on this domain, you can either log in with the original account (you can <a target="_blank" href="%2$s">reset your password</a>) or <a target="_blank" href="%3$s">upgrade your trial</a> to a full membership. Trial accounts can\'t use previously registered domains - <a target="_blank" href="%4$s">here\'s why</a>.',
523 'wpmudev'
524 ),
525 '<strong style="word-break: break-all;">' . esc_html( $_GET['display_name'] ) . '</strong>', // phpcs:ignore
526 $reset_url,
527 $skip_trial_url,
528 $trial_info_url
529 ),
530 $support_url,
531 __( 'Contact support if you need further assistance &raquo;', 'wpmudev' )
532 );
533 break;
534 case 'already_registered':
535 $error = sprintf(
536 // translators: %1$d Account name, %2$s Security info, %3$s Hub URL, %4$s Support URL.
537 __(
538 'This site is currently registered to %1$s. For <a target="_blank" href="%2$s">security reasons</a> they will need to go to the <a target="_blank" href="%3$s">WPMU DEV Hub</a> and remove this domain before you can log in. If you do not have access to that account, and have no way of contacting that user, please <a target="_blank" href="%4$s">contact support for assistance</a>.',
539 'wpmudev'
540 ),
541 '<strong style="word-break: break-all;">' . esc_html( $_GET['display_name'] ) . '</strong>', // phpcs:ignore.
542 $security_info_url,
543 $websites_url,
544 $support_url
545 );
546 break;
547 case 'banned_account':
548 $error = sprintf(
549 // translators: %s Support URL.
550 __( 'This domain cannot be registered to your WPMU DEV account.<br><a href="%s">Contact Accounts & Billing if you need further assistance »</a>', 'wpmudev' ),
551 Data::get()->server_url( 'hub2/#ask-question' )
552 );
553 break;
554 case 'expired_membership':
555 $error = sprintf(
556 // translators: %1$s Hub Account URL, %2$s: Switch to Free URL.
557 __(
558 'Login failed — your WPMU DEV membership has expired. Renew now to regain full access, or switch to our free plan to continue managing all your site in the Hub.<br/><br/><a class="sui-button sui-button-blue" href="%1$s" target="_blank">Renew Membership</a>&nbsp;<a class="sui-button sui-button-ghost" href="%2$s" target="_blank">Switch to Free</a>',
559 'wpmudev'
560 ),
561 Data::get()->server_url( 'hub2/account/ ' ),
562 Data::get()->server_url( 'hub2/?switch-free=1 ' )
563 );
564 break;
565 case 'invalid_nonce':
566 case 'invalid_double_submit_cookie':
567 case 'invalid_google_creds':
568 case '':
569 $error = __( 'Google login failed. Please try again.', 'wpmudev' );
570 break;
571 default:
572 // This in case we add new error types in the future.
573 $error = __( 'Unknown error. Please update the WPMU DEV Dashboard plugin and try again.', 'wpmudev' );
574 break;
575 }
576 }
577 } elseif ( ! empty( $_REQUEST['connection_error'] ) ) {
578 // Variable `$connection_error` is set by the UI function `render_dashboard`.
579 $error = sprintf(
580 '%s<br>%s<br><em>%s</em>',
581 __( 'Your server had a problem connecting to WPMU DEV. Please try again.', 'wpmudev' ),
582 __( 'If this problem continues, please contact your host with this error message and ask:', 'wpmudev' ),
583 sprintf(
584 // translators: url to API.
585 __( '"Is PHP on my server properly configured to be able to contact %s with a POST HTTP request via fsockopen or CURL?"', 'wpmudev' ),
586 Data::get()->server_url()
587 )
588 );
589 } elseif ( ! empty( $_REQUEST['invalid_key'] ) ) {
590 // Invalid API key.
591 $error = __( 'Your API Key was invalid. Please try again.', 'wpmudev' );
592 }
593
594 /**
595 * Filter to modify auth error text.
596 *
597 * @since 1.0.0
598 *
599 * @param string $error Error message.
600 * @param string $plugin Plugin identifier.
601 */
602 return apply_filters( 'wpmudev_hub_connector_get_auth_error', $error, $this->get_plugin_id() );
603 // phpcs:enable WordPress.Security.NonceVerification.Recommended
604 }
605
606 /**
607 * Check if current request is team selection after auth.
608 *
609 * @since 1.0.0
610 *
611 * @return bool
612 */
613 private function is_team_selection() {
614 /**
615 * Nonce is verified in `process_auth_callback` before this method called.
616 *
617 * @see self::process_auth_callback()
618 */
619 // phpcs:disable WordPress.Security.NonceVerification.Recommended
620 return (
621 // Should have multi auth param.
622 isset( $_REQUEST['is_multi_auth'] )
623 && 1 === (int) $_REQUEST['is_multi_auth']
624 // Should have an API key.
625 && ! empty( $_REQUEST['user_apikey'] )
626 );
627
628 // phpcs:enable WordPress.Security.NonceVerification.Recommended
629 }
630
631 /**
632 * Verify auth nonce.
633 *
634 * After or during the hub auth process, we need to make sure
635 * the nonce is valid.
636 *
637 * @since 1.0.0
638 *
639 * @return bool
640 */
641 private function verify_nonce() {
642 return wp_verify_nonce( ( sanitize_text_field( wp_unslash( $_REQUEST['auth_nonce'] ?? '' ) ) ), 'auth_nonce' );
643 }
644
645 /**
646 * Script vars to assign.
647 *
648 * @since 1.0.0
649 *
650 * @param array $data Script vars.
651 *
652 * @return bool
653 */
654 private function update_vars( $data ) {
655 // Update the script vars array.
656 add_filter(
657 'wpmudev_hub_connector_localize_vars',
658 function ( $vars ) use ( $data ) {
659 return array_merge( $vars, $data );
660 }
661 );
662
663 return true;
664 }
665
666 /**
667 * Localized text strings for UI.
668 *
669 * @since 1.0.0
670 *
671 * @return array
672 */
673 private function text_vars() {
674 $strings = array(
675 'login_title' => __( 'Let’s connect your site', 'wpmudev' ),
676 'login_desc' => __( 'To manage your site from The Hub, log in with your WPMU DEV account email and password.', 'wpmudev' ),
677 'sync_error' => __( 'Could not sync with The Hub. Please try again.', 'wpmudev' ),
678 'sync_desc1' => __( 'The Hub connects WPMU DEV to your website and unlocks all the power of our all-in-one platform services.', 'wpmudev' ),
679 'sync_desc2' => __( 'Once your website is connected to The Hub, you will be able to perform updates, manage services - all from one place.', 'wpmudev' ),
680 'sync_loading' => __( 'Please wait a few moments while we connect your website.', 'wpmudev' ),
681 'team_title' => __( 'Choose The Hub Team', 'wpmudev' ),
682 'team_desc' => __( 'We\'ve noticed that you are a member of multiple teams in The Hub. Which team would you like to connect to this site?', 'wpmudev' ),
683 'team_error' => __( 'Unknown API error occurred. Please try again.', 'wpmudev' ),
684 'create_account_desc' => __( "Create a free account to connect your site to WPMU DEV and activate cloud-based link checker. <i>It's fast, seamless, and free.</i>", 'wpmudev' ),
685 'no_access_desc' => __( 'You do not have the permission to view this page.', 'wpmudev' ),
686 'signin_with_google' => __( 'Sign in with Google', 'wpmudev' ),
687 'forgot_password' => __( 'Forgot password?', 'wpmudev' ),
688 'keep_me_logged_in' => __( 'Keep me logged in', 'wpmudev' ),
689 'login' => __( 'Login', 'wpmudev' ),
690 'new_user' => __( 'I am a new user', 'wpmudev' ),
691 'existing_user' => __( 'I am an existing user', 'wpmudev' ),
692 'continue_with_email' => __( 'OR continue with email', 'wpmudev' ),
693 'create_free_account' => __( 'Create a free account', 'wpmudev' ),
694 );
695
696 /**
697 * Filter hook to modify text string vars.
698 *
699 * @since 1.0.0
700 *
701 * @param array $strings Vars.
702 * @param string $plugin Plugin identifier.
703 */
704 return apply_filters( 'wpmudev_hub_connector_localize_text_vars', $strings, $this->get_plugin_id() );
705 }
706
707 /**
708 * Get extra arguments for plugin.
709 *
710 * @return array
711 */
712 private function get_plugin_extra_args_from_screen(): array {
713 $screen = get_current_screen();
714 // We need screen ID.
715 if ( empty( $screen->id ) ) {
716 return array();
717 }
718
719 $screens = $this->screens;
720 // Current screen is not allowed.
721 if ( ! isset( $screens[ $screen->id ] ) ) {
722 return array();
723 }
724
725 // Get plugin ID.
726 $plugin_id = $screens[ $screen->id ];
727
728 // Get plugin's extra args.
729 return $this->get_plugin_extra_args( $plugin_id );
730 }
731 }
732