PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
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 / data / class-filters.php

class-filters.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at public/data/class-filters.php

174 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Leadin\data;
3
4 use Leadin\data\Portal_Options;
5
6
7 /**
8 * Class containing all the custom filters defined to be used instead of constants.
9 */
10 class Filters {
11
12 /**
13 * Return the current hublet.
14 */
15 public static function apply_hublet_filters() {
16 return apply_filters( LEADIN_PREFIX . '_hublet', Portal_Options::get_hublet() );
17 }
18
19 /**
20 * Return the prefix for UI urls.
21 */
22 public static function apply_app_prefix_filters() {
23 return self::resolve_hublet( apply_filters( LEADIN_PREFIX . '_app_prefix', 'app' ) );
24 }
25
26 /**
27 * Return the prefix for UI urls.
28 */
29 public static function apply_js_prefix_filters() {
30 return self::resolve_hublet( apply_filters( LEADIN_PREFIX . '_js_prefix', 'js' ) );
31 }
32
33 /**
34 * Return the prefix for API urls.
35 */
36 public static function apply_api_prefix_filters() {
37 return self::resolve_hublet( apply_filters( LEADIN_PREFIX . '_api_prefix', 'api' ) );
38 }
39
40 /**
41 * Return the Hubspot domain.
42 */
43 public static function apply_hubspot_domain_filters() {
44 return apply_filters( LEADIN_PREFIX . '_hubspot_domain', 'hubspot.com' );
45 }
46
47 /**
48 * Apply leadin_base_url filter.
49 *
50 * @param boolean $cross_hublet if false it's use non-hublet specific prefix. For example, "app" instead of "app-eu1".
51 */
52 public static function apply_base_url_filters( $cross_hublet = true ) {
53 $prefix = $cross_hublet ? self::apply_app_prefix_filters() : apply_filters( LEADIN_PREFIX . '_app_prefix', 'app' );
54 $domain = self::apply_hubspot_domain_filters();
55 return apply_filters( LEADIN_PREFIX . '_base_url', "https://$prefix.$domain" );
56 }
57
58 /**
59 * Apply leadin_js_base_url filter.
60 */
61 public static function apply_js_base_url_filters() {
62 $prefix = self::apply_js_prefix_filters();
63 $domain = self::apply_hubspot_domain_filters();
64 return apply_filters( LEADIN_PREFIX . '_js_base_url', "https://$prefix.$domain" );
65 }
66
67 /**
68 * Apply filter to get the base url for the HubSpot api.
69 *
70 * @param boolean $cross_hublet if true it's use non-hublet specific prefix. For example, "api" instead of "api-eu1".
71 */
72 public static function apply_base_api_url_filters( $cross_hublet = false ) {
73 $prefix = $cross_hublet ? 'api' : self::apply_api_prefix_filters();
74 $domain = self::apply_hubspot_domain_filters();
75 return apply_filters( LEADIN_PREFIX . '_base_api_url', "https://$prefix.$domain" );
76 }
77
78 /**
79 * Apply leadin_signup_base_url filter.
80 */
81 public static function apply_signup_base_url_filters() {
82 $domain = self::apply_hubspot_domain_filters();
83 return apply_filters( LEADIN_PREFIX . '_signup_base_url', "https://app.$domain" );
84 }
85
86 /**
87 * Apply leadin_forms_script_url filter.
88 */
89 public static function apply_forms_script_url_filters() {
90 $hublet_domain = self::resolve_hublet( 'js' );
91 return apply_filters( LEADIN_PREFIX . '_forms_script_url', "https://$hublet_domain.hsforms.net/forms/embed/v2.js" );
92 }
93
94 /**
95 * Apply leadin_meetings_script_url filter.
96 */
97 public static function apply_meetings_script_url_filters() {
98 return apply_filters( LEADIN_PREFIX . '_meetings_script_url', 'https://static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js' );
99 }
100
101 /**
102 * Apply leadin_script_loader_domain filter.
103 */
104 public static function apply_script_loader_domain_filters() {
105 $hublet_domain = self::resolve_hublet( 'js' );
106 return apply_filters( LEADIN_PREFIX . '_script_loader_domain', "$hublet_domain.hs-scripts.com" );
107 }
108
109 /**
110 * Apply leadin_forms_payload filter.
111 */
112 public static function apply_forms_payload_filters() {
113 return apply_filters( LEADIN_PREFIX . '_forms_payload', '' );
114 }
115
116 /**
117 * Apply leadin_forms_payload_url filter.
118 */
119 public static function apply_page_content_type_filters() {
120 if ( is_single() ) {
121 $content_type = 'blog-post';
122 } elseif ( is_archive() || is_search() ) {
123 $content_type = 'listing-page';
124 } else {
125 $content_type = 'standard-page';
126 }
127
128 return apply_filters( LEADIN_PREFIX . '_page_content_type', $content_type );
129 }
130
131 /**
132 * Apply leadin_view_plugin_menu_capability filter.
133 */
134 public static function apply_view_plugin_menu_capability_filters() {
135 return apply_filters( LEADIN_PREFIX . '_view_plugin_menu_capability', 'edit_posts' );
136 }
137
138 /**
139 * Apply leadin_connect_plugin_capability filter.
140 */
141 public static function apply_connect_plugin_capability_filters() {
142 return apply_filters( LEADIN_PREFIX . '_connect_plugin_capability', 'manage_options' );
143 }
144
145 /**
146 * Apply leadin_impact_code filter.
147 */
148 public static function apply_impact_code_filters() {
149 return apply_filters( LEADIN_PREFIX . '_impact_code', null );
150 }
151
152 /**
153 * Apply leadin_query_params filter.
154 */
155 public static function apply_query_params_filters() {
156 return apply_filters( LEADIN_PREFIX . '_query_params', '' );
157 }
158
159 /**
160 * Add hublet to the prefix.
161 *
162 * @param String $prefix Prefix to add the hublet to.
163 */
164 private static function resolve_hublet( $prefix ) {
165 $hublet = self::apply_hublet_filters();
166 $result = $prefix;
167 if ( ! empty( $hublet ) && 'na1' !== $hublet ) {
168 $result = "$prefix-$hublet";
169 }
170 return $result;
171 }
172
173 }
174