PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.54
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.54
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / admin / class-routing.php

class-routing.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.54, at public/admin/class-routing.php

102 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadin\admin;
4
5 use Leadin\utils\QueryParameters;
6
7 /**
8 * Class for helping route around the plugin in OAuth mode.
9 */
10 class Routing {
11
12 const EXPIRED = 'leadin_expired';
13 const JUST_CONNECTED = 'leadin_just_connected';
14 const IS_NEW_PORTAL = 'is_new_portal';
15 const REDIRECT_NONCE = 'leadin_redirect';
16 const REVIEW = 'leadin_review';
17
18 /**
19 * Redirect to the root of the leadin plugin with optional query parameters.
20 * Verified with a redirect nonce.
21 *
22 * @param string $page the WordPress page parameter to redirect to.
23 * @param array $extra_params Associative array of parameters to add to the redirected URL.
24 */
25 public static function redirect( $page, $extra_params = array() ) {
26 $redirect_params = array_merge(
27 array( 'page' => $page ),
28 array( self::REDIRECT_NONCE => wp_create_nonce( self::REDIRECT_NONCE ) ),
29 $extra_params
30 );
31
32 $redirect_url = add_query_arg(
33 urlencode_deep( $redirect_params ),
34 admin_url( 'admin.php' )
35 );
36
37 nocache_headers();
38 wp_safe_redirect( $redirect_url );
39 exit;
40 }
41
42 /**
43 * Return a boolean if the plugin has just been connected.
44 * Signified by query parameter flag `leadin_just_connected`.
45 *
46 * @return bool True if the plugin has just connected.
47 */
48 public static function has_just_connected_with_oauth() {
49 $just_connected_param = QueryParameters::get_param(
50 self::JUST_CONNECTED,
51 self::REDIRECT_NONCE,
52 self::REDIRECT_NONCE
53 );
54
55 return null !== $just_connected_param;
56 }
57
58 /**
59 * Return a boolean if the plugin is being used with a new portal.
60 * Signified by query parameter flag `is_new_portal`.
61 *
62 * @return bool True if the plugin has just connected using a new portal.
63 */
64 public static function is_new_portal_with_oauth() {
65 $just_connected_param = QueryParameters::get_param(
66 self::IS_NEW_PORTAL,
67 self::REDIRECT_NONCE,
68 self::REDIRECT_NONCE
69 );
70
71 return null !== $just_connected_param;
72 }
73
74 /**
75 * Reads query param to see if request has review request query params
76 *
77 * @return bool True if the `leadin_review` query parameter is not empty
78 */
79 public static function has_review_request() {
80 $is_review_request = QueryParameters::get_param(
81 self::REVIEW,
82 'leadin-review'
83 );
84 return ! empty( $is_review_request );
85 }
86
87 /**
88 * Reads query param to see if request has review request query params set to true
89 *
90 * @return bool True if the `leadin_review` query parameter is true
91 */
92 public static function is_review_request() {
93 $is_review_request = QueryParameters::get_param(
94 self::REVIEW,
95 'leadin-review'
96 );
97 return 'true' === $is_review_request;
98 }
99
100
101 }
102