@@ -17,47 +17,47 @@ discard block |
||
17 | 17 | class PluginUpsells |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var DomainInterface |
|
22 | - */ |
|
23 | - private $domain; |
|
20 | + /** |
|
21 | + * @var DomainInterface |
|
22 | + */ |
|
23 | + private $domain; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * PluginUpsells constructor. |
|
28 | - * |
|
29 | - * @param DomainInterface $domain |
|
30 | - */ |
|
31 | - public function __construct(DomainInterface $domain) |
|
32 | - { |
|
33 | - $this->domain = $domain; |
|
34 | - } |
|
26 | + /** |
|
27 | + * PluginUpsells constructor. |
|
28 | + * |
|
29 | + * @param DomainInterface $domain |
|
30 | + */ |
|
31 | + public function __construct(DomainInterface $domain) |
|
32 | + { |
|
33 | + $this->domain = $domain; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Hook in various upsells for the decaf version of EE. |
|
39 | - */ |
|
40 | - public function decafUpsells() |
|
41 | - { |
|
42 | - if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) { |
|
43 | - add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3); |
|
44 | - } |
|
45 | - } |
|
37 | + /** |
|
38 | + * Hook in various upsells for the decaf version of EE. |
|
39 | + */ |
|
40 | + public function decafUpsells() |
|
41 | + { |
|
42 | + if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) { |
|
43 | + add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Callback for `after_plugin_row` to add upsell info |
|
50 | - * |
|
51 | - * @param string $plugin_file |
|
52 | - * @param array $plugin_data |
|
53 | - * @param string $status |
|
54 | - * @throws DomainException |
|
55 | - */ |
|
56 | - public function doPremiumUpsell($plugin_file, $plugin_data, $status) |
|
57 | - { |
|
58 | - if ($plugin_file === $this->domain->pluginBasename()) { |
|
59 | - list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails(); |
|
60 | - echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active"> |
|
48 | + /** |
|
49 | + * Callback for `after_plugin_row` to add upsell info |
|
50 | + * |
|
51 | + * @param string $plugin_file |
|
52 | + * @param array $plugin_data |
|
53 | + * @param string $status |
|
54 | + * @throws DomainException |
|
55 | + */ |
|
56 | + public function doPremiumUpsell($plugin_file, $plugin_data, $status) |
|
57 | + { |
|
58 | + if ($plugin_file === $this->domain->pluginBasename()) { |
|
59 | + list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails(); |
|
60 | + echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active"> |
|
61 | 61 | <td colspan="3" class="plugin-update colspanchange"> |
62 | 62 | <div class="notice inline notice-alt"> |
63 | 63 | <div class="ee-upsell-container"> |
@@ -74,27 +74,27 @@ discard block |
||
74 | 74 | </div> |
75 | 75 | </td> |
76 | 76 | </tr>'; |
77 | - } |
|
78 | - } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Provide the details used for the upsell container. |
|
82 | - * |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - protected function getAfterPluginRowDetails() |
|
86 | - { |
|
87 | - return array( |
|
88 | - esc_html__('Upgrade for Support', 'event_espresso'), |
|
89 | - 'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary', |
|
90 | - sprintf( |
|
91 | - esc_html__( |
|
92 | - 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
93 | - 'event_espresso' |
|
94 | - ), |
|
95 | - '<strong>', |
|
96 | - '</strong>' |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
80 | + /** |
|
81 | + * Provide the details used for the upsell container. |
|
82 | + * |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + protected function getAfterPluginRowDetails() |
|
86 | + { |
|
87 | + return array( |
|
88 | + esc_html__('Upgrade for Support', 'event_espresso'), |
|
89 | + 'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary', |
|
90 | + sprintf( |
|
91 | + esc_html__( |
|
92 | + 'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!', |
|
93 | + 'event_espresso' |
|
94 | + ), |
|
95 | + '<strong>', |
|
96 | + '</strong>' |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | } |
@@ -18,68 +18,68 @@ |
||
18 | 18 | class ExitModal |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var Registry |
|
23 | - */ |
|
24 | - private $assets_registry; |
|
21 | + /** |
|
22 | + * @var Registry |
|
23 | + */ |
|
24 | + private $assets_registry; |
|
25 | 25 | |
26 | - /** |
|
27 | - * ExitModal constructor. |
|
28 | - * |
|
29 | - * @param Registry $assets_registry |
|
30 | - */ |
|
31 | - public function __construct(Registry $assets_registry) |
|
32 | - { |
|
33 | - $this->assets_registry = $assets_registry; |
|
34 | - add_action('in_admin_footer', array($this, 'modalContainer')); |
|
35 | - add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
36 | - } |
|
26 | + /** |
|
27 | + * ExitModal constructor. |
|
28 | + * |
|
29 | + * @param Registry $assets_registry |
|
30 | + */ |
|
31 | + public function __construct(Registry $assets_registry) |
|
32 | + { |
|
33 | + $this->assets_registry = $assets_registry; |
|
34 | + add_action('in_admin_footer', array($this, 'modalContainer')); |
|
35 | + add_action('admin_enqueue_scripts', array($this, 'enqueues')); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Callback on in_admin_footer that is used to output the exit modal container. |
|
41 | - */ |
|
42 | - public function modalContainer() |
|
43 | - { |
|
44 | - echo '<div id="ee-exit-survey-modal"></div>'; |
|
45 | - } |
|
39 | + /** |
|
40 | + * Callback on in_admin_footer that is used to output the exit modal container. |
|
41 | + */ |
|
42 | + public function modalContainer() |
|
43 | + { |
|
44 | + echo '<div id="ee-exit-survey-modal"></div>'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
50 | - * |
|
51 | - * @throws InvalidArgumentException |
|
52 | - */ |
|
53 | - public function enqueues() |
|
54 | - { |
|
55 | - $current_user = new WP_User(get_current_user_id()); |
|
56 | - $this->assets_registry->addData( |
|
57 | - 'exitModalInfo', |
|
58 | - array( |
|
59 | - 'firstname' => htmlspecialchars($current_user->user_firstname), |
|
60 | - 'emailaddress' => htmlspecialchars($current_user->user_email), |
|
61 | - 'website' => htmlspecialchars(site_url()), |
|
62 | - 'isModalActive' => $this->isModalActive() |
|
63 | - ) |
|
64 | - ); |
|
48 | + /** |
|
49 | + * Callback for `admin_enqueue_scripts` to take care of enqueueing scripts and styles specific to the modal. |
|
50 | + * |
|
51 | + * @throws InvalidArgumentException |
|
52 | + */ |
|
53 | + public function enqueues() |
|
54 | + { |
|
55 | + $current_user = new WP_User(get_current_user_id()); |
|
56 | + $this->assets_registry->addData( |
|
57 | + 'exitModalInfo', |
|
58 | + array( |
|
59 | + 'firstname' => htmlspecialchars($current_user->user_firstname), |
|
60 | + 'emailaddress' => htmlspecialchars($current_user->user_email), |
|
61 | + 'website' => htmlspecialchars(site_url()), |
|
62 | + 'isModalActive' => $this->isModalActive() |
|
63 | + ) |
|
64 | + ); |
|
65 | 65 | |
66 | - wp_enqueue_script('ee-wp-plugins-page'); |
|
67 | - wp_enqueue_style('ee-wp-plugins-page'); |
|
68 | - } |
|
66 | + wp_enqueue_script('ee-wp-plugins-page'); |
|
67 | + wp_enqueue_style('ee-wp-plugins-page'); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
73 | - * @return bool |
|
74 | - */ |
|
75 | - private function isModalActive() |
|
76 | - { |
|
77 | - return filter_var( |
|
78 | - apply_filters( |
|
79 | - 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
80 | - true |
|
81 | - ), |
|
82 | - FILTER_VALIDATE_BOOLEAN |
|
83 | - ); |
|
84 | - } |
|
71 | + /** |
|
72 | + * Exposes a filter switch for turning off the enqueueing of the modal script. |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | + private function isModalActive() |
|
76 | + { |
|
77 | + return filter_var( |
|
78 | + apply_filters( |
|
79 | + 'FHEE__EventEspresso_core_domain_services_admin_ExitModal__isModalActive', |
|
80 | + true |
|
81 | + ), |
|
82 | + FILTER_VALIDATE_BOOLEAN |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | } |
@@ -4,31 +4,31 @@ |
||
4 | 4 | interface SetHooksInterface |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * a place to add action and filter hooks for regular frontend requests |
|
9 | - * |
|
10 | - * @return void |
|
11 | - */ |
|
12 | - public function setHooks(); |
|
7 | + /** |
|
8 | + * a place to add action and filter hooks for regular frontend requests |
|
9 | + * |
|
10 | + * @return void |
|
11 | + */ |
|
12 | + public function setHooks(); |
|
13 | 13 | |
14 | - /** |
|
15 | - * a place to add action and filter hooks for regular WP admin requests |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function setAdminHooks(); |
|
14 | + /** |
|
15 | + * a place to add action and filter hooks for regular WP admin requests |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function setAdminHooks(); |
|
20 | 20 | |
21 | - /** |
|
22 | - * a place to add action and filter hooks for AJAX requests |
|
23 | - * |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function setAjaxHooks(); |
|
21 | + /** |
|
22 | + * a place to add action and filter hooks for AJAX requests |
|
23 | + * |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function setAjaxHooks(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * a place to add action and filter hooks for REST API requests |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function setApiHooks(); |
|
28 | + /** |
|
29 | + * a place to add action and filter hooks for REST API requests |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function setApiHooks(); |
|
34 | 34 | } |
@@ -16,13 +16,13 @@ |
||
16 | 16 | interface RequiresDependencyMapInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param EE_Dependency_Map $dependency_map |
|
21 | - */ |
|
22 | - public function setDependencyMap($dependency_map); |
|
19 | + /** |
|
20 | + * @param EE_Dependency_Map $dependency_map |
|
21 | + */ |
|
22 | + public function setDependencyMap($dependency_map); |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return EE_Dependency_Map |
|
26 | - */ |
|
27 | - public function dependencyMap(); |
|
24 | + /** |
|
25 | + * @return EE_Dependency_Map |
|
26 | + */ |
|
27 | + public function dependencyMap(); |
|
28 | 28 | } |
@@ -13,14 +13,14 @@ |
||
13 | 13 | interface RequiresDomainInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param DomainInterface $domain |
|
18 | - */ |
|
19 | - public function setDomain(DomainInterface $domain); |
|
16 | + /** |
|
17 | + * @param DomainInterface $domain |
|
18 | + */ |
|
19 | + public function setDomain(DomainInterface $domain); |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @return DomainInterface |
|
24 | - */ |
|
25 | - public function domain(); |
|
22 | + /** |
|
23 | + * @return DomainInterface |
|
24 | + */ |
|
25 | + public function domain(); |
|
26 | 26 | } |
@@ -14,34 +14,34 @@ |
||
14 | 14 | */ |
15 | 15 | interface CapabilitiesActionRestrictionInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Return whether the item can be edited for the given context. |
|
19 | - * @param Context $context |
|
20 | - * @return bool |
|
21 | - */ |
|
22 | - public function canEdit(Context $context); |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Return whether the item can be read for the given context. |
|
27 | - * @param Context $context |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - public function canRead(Context $context); |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Return whether the item can be deleted for the given context. |
|
35 | - * @param Context $context |
|
36 | - * @return bool |
|
37 | - */ |
|
38 | - public function canDelete(Context $context); |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Return whether the item can be created for the given context |
|
43 | - * @param Context $context |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public function canCreate(Context $context); |
|
17 | + /** |
|
18 | + * Return whether the item can be edited for the given context. |
|
19 | + * @param Context $context |
|
20 | + * @return bool |
|
21 | + */ |
|
22 | + public function canEdit(Context $context); |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Return whether the item can be read for the given context. |
|
27 | + * @param Context $context |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + public function canRead(Context $context); |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Return whether the item can be deleted for the given context. |
|
35 | + * @param Context $context |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | + public function canDelete(Context $context); |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Return whether the item can be created for the given context |
|
43 | + * @param Context $context |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public function canCreate(Context $context); |
|
47 | 47 | } |
@@ -17,44 +17,44 @@ |
||
17 | 17 | class FullyQualifiedName |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $fully_qualified_name |
|
22 | - */ |
|
23 | - private $fully_qualified_name; |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * FullyQualifiedName constructor. |
|
28 | - * |
|
29 | - * @param string $fully_qualified_name |
|
30 | - * @throws InvalidClassException |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - * @throws InvalidDataTypeException |
|
33 | - */ |
|
34 | - public function __construct($fully_qualified_name) |
|
35 | - { |
|
36 | - if (! is_string($fully_qualified_name)) { |
|
37 | - throw new InvalidDataTypeException( |
|
38 | - '$fully_qualified_name', |
|
39 | - $fully_qualified_name, |
|
40 | - 'string' |
|
41 | - ); |
|
42 | - } |
|
43 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
44 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
45 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
46 | - } |
|
47 | - throw new InvalidClassException($fully_qualified_name); |
|
48 | - } |
|
49 | - $this->fully_qualified_name = $fully_qualified_name; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function __toString() |
|
57 | - { |
|
58 | - return $this->fully_qualified_name; |
|
59 | - } |
|
20 | + /** |
|
21 | + * @var string $fully_qualified_name |
|
22 | + */ |
|
23 | + private $fully_qualified_name; |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * FullyQualifiedName constructor. |
|
28 | + * |
|
29 | + * @param string $fully_qualified_name |
|
30 | + * @throws InvalidClassException |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + * @throws InvalidDataTypeException |
|
33 | + */ |
|
34 | + public function __construct($fully_qualified_name) |
|
35 | + { |
|
36 | + if (! is_string($fully_qualified_name)) { |
|
37 | + throw new InvalidDataTypeException( |
|
38 | + '$fully_qualified_name', |
|
39 | + $fully_qualified_name, |
|
40 | + 'string' |
|
41 | + ); |
|
42 | + } |
|
43 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
44 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
45 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
46 | + } |
|
47 | + throw new InvalidClassException($fully_qualified_name); |
|
48 | + } |
|
49 | + $this->fully_qualified_name = $fully_qualified_name; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function __toString() |
|
57 | + { |
|
58 | + return $this->fully_qualified_name; |
|
59 | + } |
|
60 | 60 | } |
@@ -17,198 +17,198 @@ |
||
17 | 17 | class Url |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $scheme |
|
22 | - */ |
|
23 | - private $scheme; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $host |
|
27 | - */ |
|
28 | - private $host; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $path |
|
32 | - */ |
|
33 | - private $path; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $query |
|
37 | - */ |
|
38 | - private $query; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $fragment |
|
42 | - */ |
|
43 | - private $fragment; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * Url constructor. |
|
48 | - * |
|
49 | - * @param $url |
|
50 | - * @throws InvalidArgumentException |
|
51 | - */ |
|
52 | - public function __construct($url) |
|
53 | - { |
|
54 | - if (! filter_var( |
|
55 | - $url, |
|
56 | - FILTER_VALIDATE_URL, |
|
57 | - array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED) |
|
58 | - )) { |
|
59 | - throw new InvalidArgumentException( |
|
60 | - esc_html__( |
|
61 | - 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
62 | - 'event_espresso' |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
66 | - $url = parse_url($url); |
|
67 | - $this->setScheme($url); |
|
68 | - $this->setHost($url); |
|
69 | - $this->setPath($url); |
|
70 | - $this->setQuery($url); |
|
71 | - $this->setFragment($url); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
77 | - * will return a string like: 'abc://' |
|
78 | - * |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function scheme() |
|
82 | - { |
|
83 | - return $this->scheme; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param array $url |
|
89 | - */ |
|
90 | - private function setScheme($url) |
|
91 | - { |
|
92 | - $this->scheme = $url['scheme'] . '://'; |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
98 | - * will return a string like: 'example.com' |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function host() |
|
103 | - { |
|
104 | - return $this->host; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @param array $url |
|
110 | - */ |
|
111 | - private function setHost($url) |
|
112 | - { |
|
113 | - $this->host = $url['host']; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
119 | - * will return a string like: '/path/data' |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function path() |
|
124 | - { |
|
125 | - return $this->path; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @param array $url |
|
131 | - */ |
|
132 | - private function setPath($url) |
|
133 | - { |
|
134 | - $this->path = isset($url['path']) ? $url['path'] : ''; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
140 | - * will return a string like: '?key=value' |
|
141 | - * |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function queryString() |
|
145 | - { |
|
146 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
152 | - * will return an array like: array('key' => 'value') |
|
153 | - * |
|
154 | - * @return array |
|
155 | - */ |
|
156 | - public function queryParams() |
|
157 | - { |
|
158 | - return wp_parse_args($this->query); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param array $url |
|
164 | - */ |
|
165 | - private function setQuery($url) |
|
166 | - { |
|
167 | - $this->query = isset($url['query']) ? $url['query'] : ''; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
173 | - * will return a string like: '#id' |
|
174 | - * |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function fragment() |
|
178 | - { |
|
179 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * @param array $url |
|
185 | - */ |
|
186 | - private function setFragment($url) |
|
187 | - { |
|
188 | - $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
194 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - public function getFullUrl() |
|
199 | - { |
|
200 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
206 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
207 | - * |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - public function __toString() |
|
211 | - { |
|
212 | - return $this->getFullUrl(); |
|
213 | - } |
|
20 | + /** |
|
21 | + * @var string $scheme |
|
22 | + */ |
|
23 | + private $scheme; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $host |
|
27 | + */ |
|
28 | + private $host; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $path |
|
32 | + */ |
|
33 | + private $path; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $query |
|
37 | + */ |
|
38 | + private $query; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $fragment |
|
42 | + */ |
|
43 | + private $fragment; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * Url constructor. |
|
48 | + * |
|
49 | + * @param $url |
|
50 | + * @throws InvalidArgumentException |
|
51 | + */ |
|
52 | + public function __construct($url) |
|
53 | + { |
|
54 | + if (! filter_var( |
|
55 | + $url, |
|
56 | + FILTER_VALIDATE_URL, |
|
57 | + array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED) |
|
58 | + )) { |
|
59 | + throw new InvalidArgumentException( |
|
60 | + esc_html__( |
|
61 | + 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
62 | + 'event_espresso' |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | + $url = parse_url($url); |
|
67 | + $this->setScheme($url); |
|
68 | + $this->setHost($url); |
|
69 | + $this->setPath($url); |
|
70 | + $this->setQuery($url); |
|
71 | + $this->setFragment($url); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
77 | + * will return a string like: 'abc://' |
|
78 | + * |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function scheme() |
|
82 | + { |
|
83 | + return $this->scheme; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param array $url |
|
89 | + */ |
|
90 | + private function setScheme($url) |
|
91 | + { |
|
92 | + $this->scheme = $url['scheme'] . '://'; |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
98 | + * will return a string like: 'example.com' |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function host() |
|
103 | + { |
|
104 | + return $this->host; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @param array $url |
|
110 | + */ |
|
111 | + private function setHost($url) |
|
112 | + { |
|
113 | + $this->host = $url['host']; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
119 | + * will return a string like: '/path/data' |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function path() |
|
124 | + { |
|
125 | + return $this->path; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @param array $url |
|
131 | + */ |
|
132 | + private function setPath($url) |
|
133 | + { |
|
134 | + $this->path = isset($url['path']) ? $url['path'] : ''; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
140 | + * will return a string like: '?key=value' |
|
141 | + * |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function queryString() |
|
145 | + { |
|
146 | + return $this->query !== '' ? '?' . $this->query : ''; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
152 | + * will return an array like: array('key' => 'value') |
|
153 | + * |
|
154 | + * @return array |
|
155 | + */ |
|
156 | + public function queryParams() |
|
157 | + { |
|
158 | + return wp_parse_args($this->query); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param array $url |
|
164 | + */ |
|
165 | + private function setQuery($url) |
|
166 | + { |
|
167 | + $this->query = isset($url['query']) ? $url['query'] : ''; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
173 | + * will return a string like: '#id' |
|
174 | + * |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function fragment() |
|
178 | + { |
|
179 | + return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * @param array $url |
|
185 | + */ |
|
186 | + private function setFragment($url) |
|
187 | + { |
|
188 | + $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
194 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + public function getFullUrl() |
|
199 | + { |
|
200 | + return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
206 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
207 | + * |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + public function __toString() |
|
211 | + { |
|
212 | + return $this->getFullUrl(); |
|
213 | + } |
|
214 | 214 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function __construct($url) |
53 | 53 | { |
54 | - if (! filter_var( |
|
54 | + if ( ! filter_var( |
|
55 | 55 | $url, |
56 | 56 | FILTER_VALIDATE_URL, |
57 | 57 | array(FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED) |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private function setScheme($url) |
91 | 91 | { |
92 | - $this->scheme = $url['scheme'] . '://'; |
|
92 | + $this->scheme = $url['scheme'].'://'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function queryString() |
145 | 145 | { |
146 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
146 | + return $this->query !== '' ? '?'.$this->query : ''; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function fragment() |
178 | 178 | { |
179 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
179 | + return $this->fragment !== '' ? '#'.$this->fragment : ''; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function getFullUrl() |
199 | 199 | { |
200 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
200 | + return $this->scheme().$this->host().$this->path().$this->queryString().$this->fragment(); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 |
@@ -20,98 +20,98 @@ |
||
20 | 20 | class SessionLifespan |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * how long an EE session lasts in seconds |
|
25 | - * default session lifespan of 1 hour (for not so instant IPNs) |
|
26 | - * |
|
27 | - * @var int $lifespan |
|
28 | - */ |
|
29 | - private $lifespan; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * SessionLifespan constructor. |
|
34 | - * |
|
35 | - * @param int $lifespan |
|
36 | - * @throws DomainException |
|
37 | - */ |
|
38 | - public function __construct($lifespan = 0) |
|
39 | - { |
|
40 | - $lifespan = absint($lifespan); |
|
41 | - $lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS; |
|
42 | - $this->setLifespan($lifespan); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @param int $lifespan |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - protected function setLifespan($lifespan) |
|
51 | - { |
|
52 | - if ($lifespan < 60) { |
|
53 | - throw new DomainException( |
|
54 | - esc_html__( |
|
55 | - 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
56 | - 'event_espresso' |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
60 | - $this->lifespan = apply_filters( |
|
61 | - 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
62 | - // apply legacy filter for now but add doing it wrong notice in future |
|
63 | - apply_filters( |
|
64 | - 'FHEE__EE_Session__construct___lifespan', |
|
65 | - $lifespan |
|
66 | - ) |
|
67 | - ) + 1; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - public function inSeconds() |
|
75 | - { |
|
76 | - return $this->lifespan; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $separator |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function inHoursMinutesSeconds($separator = ':') |
|
85 | - { |
|
86 | - return sprintf( |
|
87 | - '%02d%s%02d%s%02d', |
|
88 | - floor($this->lifespan / 3600), |
|
89 | - $separator, |
|
90 | - ($this->lifespan / 60) % 60, |
|
91 | - $separator, |
|
92 | - $this->lifespan % 60 |
|
93 | - ); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * Returns a timestamp for when the session would expire based on this lifespan |
|
99 | - * |
|
100 | - * @param bool $utc If true, displays expiration in UTC |
|
101 | - * If false, displays expiration in local time |
|
102 | - * @return int |
|
103 | - */ |
|
104 | - public function expiration($utc = true) |
|
105 | - { |
|
106 | - return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function __toString() |
|
114 | - { |
|
115 | - return (string) $this->inSeconds(); |
|
116 | - } |
|
23 | + /** |
|
24 | + * how long an EE session lasts in seconds |
|
25 | + * default session lifespan of 1 hour (for not so instant IPNs) |
|
26 | + * |
|
27 | + * @var int $lifespan |
|
28 | + */ |
|
29 | + private $lifespan; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * SessionLifespan constructor. |
|
34 | + * |
|
35 | + * @param int $lifespan |
|
36 | + * @throws DomainException |
|
37 | + */ |
|
38 | + public function __construct($lifespan = 0) |
|
39 | + { |
|
40 | + $lifespan = absint($lifespan); |
|
41 | + $lifespan = $lifespan > 0 ? $lifespan : (int) HOUR_IN_SECONDS; |
|
42 | + $this->setLifespan($lifespan); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @param int $lifespan |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + protected function setLifespan($lifespan) |
|
51 | + { |
|
52 | + if ($lifespan < 60) { |
|
53 | + throw new DomainException( |
|
54 | + esc_html__( |
|
55 | + 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
56 | + 'event_espresso' |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | + $this->lifespan = apply_filters( |
|
61 | + 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
62 | + // apply legacy filter for now but add doing it wrong notice in future |
|
63 | + apply_filters( |
|
64 | + 'FHEE__EE_Session__construct___lifespan', |
|
65 | + $lifespan |
|
66 | + ) |
|
67 | + ) + 1; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return int |
|
73 | + */ |
|
74 | + public function inSeconds() |
|
75 | + { |
|
76 | + return $this->lifespan; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $separator |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function inHoursMinutesSeconds($separator = ':') |
|
85 | + { |
|
86 | + return sprintf( |
|
87 | + '%02d%s%02d%s%02d', |
|
88 | + floor($this->lifespan / 3600), |
|
89 | + $separator, |
|
90 | + ($this->lifespan / 60) % 60, |
|
91 | + $separator, |
|
92 | + $this->lifespan % 60 |
|
93 | + ); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns a timestamp for when the session would expire based on this lifespan |
|
99 | + * |
|
100 | + * @param bool $utc If true, displays expiration in UTC |
|
101 | + * If false, displays expiration in local time |
|
102 | + * @return int |
|
103 | + */ |
|
104 | + public function expiration($utc = true) |
|
105 | + { |
|
106 | + return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function __toString() |
|
114 | + { |
|
115 | + return (string) $this->inSeconds(); |
|
116 | + } |
|
117 | 117 | } |