@@ -15,125 +15,125 @@ |
||
15 | 15 | interface LegacyRequestInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return array |
|
20 | - */ |
|
21 | - public function get_params(); |
|
18 | + /** |
|
19 | + * @return array |
|
20 | + */ |
|
21 | + public function get_params(); |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - public function post_params(); |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + public function post_params(); |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function cookie_params(); |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function cookie_params(); |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public function server_params(); |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public function server_params(); |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * returns contents of $_REQUEST |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function params(); |
|
42 | + /** |
|
43 | + * returns contents of $_REQUEST |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function params(); |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $key |
|
52 | - * @param $value |
|
53 | - * @param bool $override_ee |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function set($key, $value, $override_ee = false); |
|
50 | + /** |
|
51 | + * @param $key |
|
52 | + * @param $value |
|
53 | + * @param bool $override_ee |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function set($key, $value, $override_ee = false); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * returns the value for a request param if the given key exists |
|
61 | - * |
|
62 | - * @param $key |
|
63 | - * @param null $default |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function get($key, $default = null); |
|
59 | + /** |
|
60 | + * returns the value for a request param if the given key exists |
|
61 | + * |
|
62 | + * @param $key |
|
63 | + * @param null $default |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function get($key, $default = null); |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * check if param exists |
|
71 | - * |
|
72 | - * @param $key |
|
73 | - * @return bool |
|
74 | - */ |
|
75 | - public function is_set($key); |
|
69 | + /** |
|
70 | + * check if param exists |
|
71 | + * |
|
72 | + * @param $key |
|
73 | + * @return bool |
|
74 | + */ |
|
75 | + public function is_set($key); |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * remove param |
|
80 | - * |
|
81 | - * @param $key |
|
82 | - * @param bool $unset_from_global_too |
|
83 | - */ |
|
84 | - public function un_set($key, $unset_from_global_too = false); |
|
78 | + /** |
|
79 | + * remove param |
|
80 | + * |
|
81 | + * @param $key |
|
82 | + * @param bool $unset_from_global_too |
|
83 | + */ |
|
84 | + public function un_set($key, $unset_from_global_too = false); |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function ip_address(); |
|
87 | + /** |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function ip_address(); |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - public function isAdmin(); |
|
93 | + /** |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + public function isAdmin(); |
|
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * @return mixed |
|
101 | - */ |
|
102 | - public function isAjax(); |
|
99 | + /** |
|
100 | + * @return mixed |
|
101 | + */ |
|
102 | + public function isAjax(); |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return mixed |
|
107 | - */ |
|
108 | - public function isFrontAjax(); |
|
105 | + /** |
|
106 | + * @return mixed |
|
107 | + */ |
|
108 | + public function isFrontAjax(); |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * @return mixed|string |
|
113 | - */ |
|
114 | - public function requestUri(); |
|
111 | + /** |
|
112 | + * @return mixed|string |
|
113 | + */ |
|
114 | + public function requestUri(); |
|
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function userAgent(); |
|
117 | + /** |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function userAgent(); |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * @param string $user_agent |
|
125 | - */ |
|
126 | - public function setUserAgent($user_agent = ''); |
|
123 | + /** |
|
124 | + * @param string $user_agent |
|
125 | + */ |
|
126 | + public function setUserAgent($user_agent = ''); |
|
127 | 127 | |
128 | 128 | |
129 | - /** |
|
130 | - * @return bool |
|
131 | - */ |
|
132 | - public function isBot(); |
|
129 | + /** |
|
130 | + * @return bool |
|
131 | + */ |
|
132 | + public function isBot(); |
|
133 | 133 | |
134 | 134 | |
135 | - /** |
|
136 | - * @param bool $is_bot |
|
137 | - */ |
|
138 | - public function setIsBot($is_bot); |
|
135 | + /** |
|
136 | + * @param bool $is_bot |
|
137 | + */ |
|
138 | + public function setIsBot($is_bot); |
|
139 | 139 | } |
@@ -18,130 +18,130 @@ |
||
18 | 18 | class Response implements ResponseInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var array $notice |
|
23 | - */ |
|
24 | - protected $notice = array(); |
|
21 | + /** |
|
22 | + * @var array $notice |
|
23 | + */ |
|
24 | + protected $notice = array(); |
|
25 | 25 | |
26 | - /** |
|
27 | - * rendered output to be returned to WP |
|
28 | - * |
|
29 | - * @var string $output |
|
30 | - */ |
|
31 | - protected $output = ''; |
|
26 | + /** |
|
27 | + * rendered output to be returned to WP |
|
28 | + * |
|
29 | + * @var string $output |
|
30 | + */ |
|
31 | + protected $output = ''; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var bool |
|
35 | - */ |
|
36 | - protected $request_terminated = false; |
|
33 | + /** |
|
34 | + * @var bool |
|
35 | + */ |
|
36 | + protected $request_terminated = false; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @var bool $deactivate_plugin |
|
40 | - */ |
|
41 | - protected $deactivate_plugin = false; |
|
38 | + /** |
|
39 | + * @var bool $deactivate_plugin |
|
40 | + */ |
|
41 | + protected $deactivate_plugin = false; |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * EE_Response constructor. |
|
46 | - */ |
|
47 | - public function __construct() |
|
48 | - { |
|
49 | - $this->terminateRequest(false); |
|
50 | - } |
|
44 | + /** |
|
45 | + * EE_Response constructor. |
|
46 | + */ |
|
47 | + public function __construct() |
|
48 | + { |
|
49 | + $this->terminateRequest(false); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @param $key |
|
56 | - * @param $value |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function setNotice($key, $value) |
|
60 | - { |
|
61 | - $this->notice[ $key ] = $value; |
|
62 | - } |
|
54 | + /** |
|
55 | + * @param $key |
|
56 | + * @param $value |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function setNotice($key, $value) |
|
60 | + { |
|
61 | + $this->notice[ $key ] = $value; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param $key |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - public function getNotice($key) |
|
71 | - { |
|
72 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
73 | - } |
|
66 | + /** |
|
67 | + * @param $key |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + public function getNotice($key) |
|
71 | + { |
|
72 | + return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - public function getNotices() |
|
81 | - { |
|
82 | - return $this->notice; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + public function getNotices() |
|
81 | + { |
|
82 | + return $this->notice; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @param string $string |
|
89 | - * @param bool $append |
|
90 | - */ |
|
91 | - public function addOutput($string, $append = true) |
|
92 | - { |
|
93 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
94 | - } |
|
87 | + /** |
|
88 | + * @param string $string |
|
89 | + * @param bool $append |
|
90 | + */ |
|
91 | + public function addOutput($string, $append = true) |
|
92 | + { |
|
93 | + $this->output = $append ? $this->output . $string : $string . $this->output; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function getOutput() |
|
102 | - { |
|
103 | - return $this->output; |
|
104 | - } |
|
98 | + /** |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function getOutput() |
|
102 | + { |
|
103 | + return $this->output; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * @return boolean |
|
110 | - */ |
|
111 | - public function requestTerminated() |
|
112 | - { |
|
113 | - return $this->request_terminated; |
|
114 | - } |
|
108 | + /** |
|
109 | + * @return boolean |
|
110 | + */ |
|
111 | + public function requestTerminated() |
|
112 | + { |
|
113 | + return $this->request_terminated; |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * @param boolean $request_terminated |
|
120 | - */ |
|
121 | - public function terminateRequest($request_terminated = true) |
|
122 | - { |
|
123 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
124 | - } |
|
118 | + /** |
|
119 | + * @param boolean $request_terminated |
|
120 | + */ |
|
121 | + public function terminateRequest($request_terminated = true) |
|
122 | + { |
|
123 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | 127 | |
128 | - /** |
|
129 | - * @return boolean |
|
130 | - */ |
|
131 | - public function pluginDeactivated() |
|
132 | - { |
|
133 | - return $this->deactivate_plugin; |
|
134 | - } |
|
128 | + /** |
|
129 | + * @return boolean |
|
130 | + */ |
|
131 | + public function pluginDeactivated() |
|
132 | + { |
|
133 | + return $this->deactivate_plugin; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | 137 | |
138 | - /** |
|
139 | - * sets $deactivate_plugin to true |
|
140 | - */ |
|
141 | - public function deactivatePlugin() |
|
142 | - { |
|
143 | - $this->deactivate_plugin = true; |
|
144 | - } |
|
138 | + /** |
|
139 | + * sets $deactivate_plugin to true |
|
140 | + */ |
|
141 | + public function deactivatePlugin() |
|
142 | + { |
|
143 | + $this->deactivate_plugin = true; |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | 147 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function setNotice($key, $value) |
60 | 60 | { |
61 | - $this->notice[ $key ] = $value; |
|
61 | + $this->notice[$key] = $value; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function getNotice($key) |
71 | 71 | { |
72 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
72 | + return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function addOutput($string, $append = true) |
92 | 92 | { |
93 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
93 | + $this->output = $append ? $this->output.$string : $string.$this->output; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 |
@@ -16,13 +16,13 @@ |
||
16 | 16 | interface RequestStackCoreAppInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * gives the core app a chance to handle the response after the request stack has fully processed |
|
21 | - * |
|
22 | - * @param RequestInterface $request |
|
23 | - * @param ResponseInterface $response |
|
24 | - */ |
|
25 | - public function handleResponse(RequestInterface $request, ResponseInterface $response); |
|
19 | + /** |
|
20 | + * gives the core app a chance to handle the response after the request stack has fully processed |
|
21 | + * |
|
22 | + * @param RequestInterface $request |
|
23 | + * @param ResponseInterface $response |
|
24 | + */ |
|
25 | + public function handleResponse(RequestInterface $request, ResponseInterface $response); |
|
26 | 26 | |
27 | 27 | } |
28 | 28 | // Location: RequestStackCoreApp.php |
@@ -21,25 +21,25 @@ |
||
21 | 21 | class BotDetector extends Middleware |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * converts a Request to a Response |
|
26 | - * |
|
27 | - * @param RequestInterface $request |
|
28 | - * @param ResponseInterface $response |
|
29 | - * @return ResponseInterface |
|
30 | - */ |
|
31 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
32 | - { |
|
33 | - $this->request = $request; |
|
34 | - $this->response = $response; |
|
35 | - /** @var CrawlerDetect $CrawlerDetect */ |
|
36 | - $CrawlerDetect = $this->loader->getShared('EventEspressoVendor\Jaybizzle\CrawlerDetect\CrawlerDetect'); |
|
37 | - // Check and record the user agent of the current 'visitor' |
|
38 | - $this->request->setIsBot($CrawlerDetect->isCrawler()); |
|
39 | - $this->request->setUserAgent($CrawlerDetect->userAgent()); |
|
40 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
41 | - return $this->response; |
|
42 | - } |
|
24 | + /** |
|
25 | + * converts a Request to a Response |
|
26 | + * |
|
27 | + * @param RequestInterface $request |
|
28 | + * @param ResponseInterface $response |
|
29 | + * @return ResponseInterface |
|
30 | + */ |
|
31 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
32 | + { |
|
33 | + $this->request = $request; |
|
34 | + $this->response = $response; |
|
35 | + /** @var CrawlerDetect $CrawlerDetect */ |
|
36 | + $CrawlerDetect = $this->loader->getShared('EventEspressoVendor\Jaybizzle\CrawlerDetect\CrawlerDetect'); |
|
37 | + // Check and record the user agent of the current 'visitor' |
|
38 | + $this->request->setIsBot($CrawlerDetect->isCrawler()); |
|
39 | + $this->request->setUserAgent($CrawlerDetect->userAgent()); |
|
40 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
41 | + return $this->response; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | // Location: BotDetector.php |
@@ -22,95 +22,95 @@ |
||
22 | 22 | class PreProductionVersionWarning extends Middleware |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * converts a Request to a Response |
|
27 | - * |
|
28 | - * @param RequestInterface $request |
|
29 | - * @param ResponseInterface $response |
|
30 | - * @return ResponseInterface |
|
31 | - */ |
|
32 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
33 | - { |
|
34 | - $this->request = $request; |
|
35 | - $this->response = $response; |
|
36 | - $this->displayPreProductionVersionWarning(); |
|
37 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
38 | - return $this->response; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
45 | - * |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public function displayPreProductionVersionWarning() |
|
49 | - { |
|
50 | - // skip AJAX requests |
|
51 | - if ($this->request->isAjax()) { |
|
52 | - return; |
|
53 | - } |
|
54 | - // skip stable releases |
|
55 | - if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
56 | - return; |
|
57 | - } |
|
58 | - // site admin has authorized use of non-stable release candidate for production |
|
59 | - if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
60 | - return; |
|
61 | - } |
|
62 | - // post release candidate warning |
|
63 | - if ($this->request->isAdmin()) { |
|
64 | - add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
65 | - } else { |
|
66 | - add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * displays admin notice that current version of EE is not a stable release |
|
74 | - * |
|
75 | - * @return void |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - */ |
|
78 | - public function preProductionVersionAdminNotice() |
|
79 | - { |
|
80 | - new PersistentAdminNotice( |
|
81 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
82 | - $this->warningNotice() |
|
83 | - ); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
89 | - * |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public function preProductionVersionWarningNotice() |
|
93 | - { |
|
94 | - echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
95 | - echo $this->warningNotice(); |
|
96 | - echo '</p></div>'; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - private function warningNotice() |
|
104 | - { |
|
105 | - return sprintf( |
|
106 | - esc_html__( |
|
107 | - 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
108 | - 'event_espresso' |
|
109 | - ), |
|
110 | - '<strong>', |
|
111 | - '</strong>' |
|
112 | - ); |
|
113 | - } |
|
25 | + /** |
|
26 | + * converts a Request to a Response |
|
27 | + * |
|
28 | + * @param RequestInterface $request |
|
29 | + * @param ResponseInterface $response |
|
30 | + * @return ResponseInterface |
|
31 | + */ |
|
32 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
33 | + { |
|
34 | + $this->request = $request; |
|
35 | + $this->response = $response; |
|
36 | + $this->displayPreProductionVersionWarning(); |
|
37 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
38 | + return $this->response; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
45 | + * |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public function displayPreProductionVersionWarning() |
|
49 | + { |
|
50 | + // skip AJAX requests |
|
51 | + if ($this->request->isAjax()) { |
|
52 | + return; |
|
53 | + } |
|
54 | + // skip stable releases |
|
55 | + if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
56 | + return; |
|
57 | + } |
|
58 | + // site admin has authorized use of non-stable release candidate for production |
|
59 | + if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
60 | + return; |
|
61 | + } |
|
62 | + // post release candidate warning |
|
63 | + if ($this->request->isAdmin()) { |
|
64 | + add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
65 | + } else { |
|
66 | + add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * displays admin notice that current version of EE is not a stable release |
|
74 | + * |
|
75 | + * @return void |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + */ |
|
78 | + public function preProductionVersionAdminNotice() |
|
79 | + { |
|
80 | + new PersistentAdminNotice( |
|
81 | + 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
82 | + $this->warningNotice() |
|
83 | + ); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
89 | + * |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public function preProductionVersionWarningNotice() |
|
93 | + { |
|
94 | + echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
95 | + echo $this->warningNotice(); |
|
96 | + echo '</p></div>'; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + private function warningNotice() |
|
104 | + { |
|
105 | + return sprintf( |
|
106 | + esc_html__( |
|
107 | + 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
108 | + 'event_espresso' |
|
109 | + ), |
|
110 | + '<strong>', |
|
111 | + '</strong>' |
|
112 | + ); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | // Location: NonProductionReadyVersionWarning.php |
@@ -78,7 +78,7 @@ |
||
78 | 78 | public function preProductionVersionAdminNotice() |
79 | 79 | { |
80 | 80 | new PersistentAdminNotice( |
81 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
81 | + 'preProductionVersionAdminNotice_'.EVENT_ESPRESSO_VERSION, |
|
82 | 82 | $this->warningNotice() |
83 | 83 | ); |
84 | 84 | } |
@@ -16,69 +16,69 @@ |
||
16 | 16 | interface ResponseInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * set_notice |
|
21 | - * |
|
22 | - * @access public |
|
23 | - * @param $key |
|
24 | - * @param $value |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function setNotice($key, $value); |
|
19 | + /** |
|
20 | + * set_notice |
|
21 | + * |
|
22 | + * @access public |
|
23 | + * @param $key |
|
24 | + * @param $value |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function setNotice($key, $value); |
|
28 | 28 | |
29 | - /** |
|
30 | - * get_notice |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @param $key |
|
34 | - * @return mixed |
|
35 | - */ |
|
36 | - public function getNotice($key); |
|
29 | + /** |
|
30 | + * get_notice |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @param $key |
|
34 | + * @return mixed |
|
35 | + */ |
|
36 | + public function getNotice($key); |
|
37 | 37 | |
38 | - /** |
|
39 | - * get_notices |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - public function getNotices(); |
|
38 | + /** |
|
39 | + * get_notices |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + public function getNotices(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * add_output |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @param $string |
|
51 | - * @param bool $append |
|
52 | - */ |
|
53 | - public function addOutput($string, $append = true); |
|
46 | + /** |
|
47 | + * add_output |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @param $string |
|
51 | + * @param bool $append |
|
52 | + */ |
|
53 | + public function addOutput($string, $append = true); |
|
54 | 54 | |
55 | - /** |
|
56 | - * get_output |
|
57 | - * |
|
58 | - * @access public |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function getOutput(); |
|
55 | + /** |
|
56 | + * get_output |
|
57 | + * |
|
58 | + * @access public |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function getOutput(); |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function requestTerminated(); |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function requestTerminated(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param boolean $request_terminated |
|
70 | - */ |
|
71 | - public function terminateRequest($request_terminated = true); |
|
68 | + /** |
|
69 | + * @param boolean $request_terminated |
|
70 | + */ |
|
71 | + public function terminateRequest($request_terminated = true); |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return boolean |
|
75 | - */ |
|
76 | - public function pluginDeactivated(); |
|
73 | + /** |
|
74 | + * @return boolean |
|
75 | + */ |
|
76 | + public function pluginDeactivated(); |
|
77 | 77 | |
78 | - /** |
|
79 | - * sets $deactivate_plugin to true |
|
80 | - */ |
|
81 | - public function deactivatePlugin(); |
|
78 | + /** |
|
79 | + * sets $deactivate_plugin to true |
|
80 | + */ |
|
81 | + public function deactivatePlugin(); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | // Location: ResponseInterface.php |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | || ($key === 'ee' && empty($this->request['ee'])) |
175 | 175 | || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
176 | 176 | ) { |
177 | - $this->request[ $key ] = $value; |
|
177 | + $this->request[$key] = $value; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -246,26 +246,26 @@ discard block |
||
246 | 246 | $keys = explode('[', $key); |
247 | 247 | $key = array_shift($keys); |
248 | 248 | // check if top level key exists |
249 | - if (isset($request_params[ $key ])) { |
|
249 | + if (isset($request_params[$key])) { |
|
250 | 250 | // build a new key to pass along like: 'second[third]' |
251 | 251 | // or just 'second' depending on depth of keys |
252 | 252 | $key_string = array_shift($keys); |
253 | - if (! empty($keys)) { |
|
254 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
253 | + if ( ! empty($keys)) { |
|
254 | + $key_string .= '['.implode('][', $keys).']'; |
|
255 | 255 | } |
256 | 256 | return $this->requestParameterDrillDown( |
257 | 257 | $key_string, |
258 | 258 | $default, |
259 | 259 | $is_set_or_get, |
260 | - $request_params[ $key ] |
|
260 | + $request_params[$key] |
|
261 | 261 | ); |
262 | 262 | } |
263 | 263 | } |
264 | 264 | if ($is_set_or_get === 'is_set') { |
265 | - return isset($request_params[ $key ]); |
|
265 | + return isset($request_params[$key]); |
|
266 | 266 | } |
267 | - return isset($request_params[ $key ]) |
|
268 | - ? $request_params[ $key ] |
|
267 | + return isset($request_params[$key]) |
|
268 | + ? $request_params[$key] |
|
269 | 269 | : $default; |
270 | 270 | } |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function unSetRequestParam($key, $unset_from_global_too = false) |
281 | 281 | { |
282 | - unset($this->request[ $key ]); |
|
282 | + unset($this->request[$key]); |
|
283 | 283 | if ($unset_from_global_too) { |
284 | - unset($_REQUEST[ $key ]); |
|
284 | + unset($_REQUEST[$key]); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | 'REMOTE_ADDR', |
318 | 318 | ); |
319 | 319 | foreach ($server_keys as $key) { |
320 | - if (isset($this->server[ $key ])) { |
|
321 | - foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
320 | + if (isset($this->server[$key])) { |
|
321 | + foreach (array_map('trim', explode(',', $this->server[$key])) as $ip) { |
|
322 | 322 | if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
323 | 323 | $visitor_ip = $ip; |
324 | 324 | } |
@@ -20,507 +20,507 @@ |
||
20 | 20 | class Request implements InterminableInterface, RequestInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * $_GET parameters |
|
25 | - * |
|
26 | - * @var array $get |
|
27 | - */ |
|
28 | - private $get; |
|
29 | - |
|
30 | - /** |
|
31 | - * $_POST parameters |
|
32 | - * |
|
33 | - * @var array $post |
|
34 | - */ |
|
35 | - private $post; |
|
36 | - |
|
37 | - /** |
|
38 | - * $_COOKIE parameters |
|
39 | - * |
|
40 | - * @var array $cookie |
|
41 | - */ |
|
42 | - private $cookie; |
|
43 | - |
|
44 | - /** |
|
45 | - * $_SERVER parameters |
|
46 | - * |
|
47 | - * @var array $server |
|
48 | - */ |
|
49 | - private $server; |
|
50 | - |
|
51 | - /** |
|
52 | - * $_REQUEST parameters |
|
53 | - * |
|
54 | - * @var array $request |
|
55 | - */ |
|
56 | - private $request; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var RequestTypeContextCheckerInterface |
|
60 | - */ |
|
61 | - private $request_type; |
|
62 | - |
|
63 | - /** |
|
64 | - * IP address for request |
|
65 | - * |
|
66 | - * @var string $ip_address |
|
67 | - */ |
|
68 | - private $ip_address; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var string $user_agent |
|
72 | - */ |
|
73 | - private $user_agent; |
|
74 | - |
|
75 | - /** |
|
76 | - * true if current user appears to be some kind of bot |
|
77 | - * |
|
78 | - * @var bool $is_bot |
|
79 | - */ |
|
80 | - private $is_bot; |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param array $get |
|
86 | - * @param array $post |
|
87 | - * @param array $cookie |
|
88 | - * @param array $server |
|
89 | - */ |
|
90 | - public function __construct(array $get, array $post, array $cookie, array $server) |
|
91 | - { |
|
92 | - // grab request vars |
|
93 | - $this->get = $get; |
|
94 | - $this->post = $post; |
|
95 | - $this->cookie = $cookie; |
|
96 | - $this->server = $server; |
|
97 | - $this->request = array_merge($this->get, $this->post); |
|
98 | - $this->ip_address = $this->visitorIp(); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @param RequestTypeContextCheckerInterface $type |
|
104 | - */ |
|
105 | - public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
106 | - { |
|
107 | - $this->request_type = $type; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @return array |
|
114 | - */ |
|
115 | - public function getParams() |
|
116 | - { |
|
117 | - return $this->get; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function postParams() |
|
126 | - { |
|
127 | - return $this->post; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @return array |
|
134 | - */ |
|
135 | - public function cookieParams() |
|
136 | - { |
|
137 | - return $this->cookie; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return array |
|
143 | - */ |
|
144 | - public function serverParams() |
|
145 | - { |
|
146 | - return $this->server; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * returns contents of $_REQUEST |
|
153 | - * |
|
154 | - * @return array |
|
155 | - */ |
|
156 | - public function requestParams() |
|
157 | - { |
|
158 | - return $this->request; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @param $key |
|
165 | - * @param $value |
|
166 | - * @param bool $override_ee |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - public function setRequestParam($key, $value, $override_ee = false) |
|
170 | - { |
|
171 | - // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
172 | - if ( |
|
173 | - $key !== 'ee' |
|
174 | - || ($key === 'ee' && empty($this->request['ee'])) |
|
175 | - || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
|
176 | - ) { |
|
177 | - $this->request[ $key ] = $value; |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * returns the value for a request param if the given key exists |
|
185 | - * |
|
186 | - * @param $key |
|
187 | - * @param null $default |
|
188 | - * @return mixed |
|
189 | - */ |
|
190 | - public function getRequestParam($key, $default = null) |
|
191 | - { |
|
192 | - return $this->requestParameterDrillDown($key, $default, 'get'); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * check if param exists |
|
199 | - * |
|
200 | - * @param $key |
|
201 | - * @return bool |
|
202 | - */ |
|
203 | - public function requestParamIsSet($key) |
|
204 | - { |
|
205 | - return $this->requestParameterDrillDown($key); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * the supplied key can be a simple string to represent a "top-level" request parameter |
|
212 | - * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
213 | - * by using square brackets to surround keys for deeper array elements. |
|
214 | - * For example : |
|
215 | - * if the supplied $key was: "first[second][third]" |
|
216 | - * then this will attempt to drill down into the request parameter array to find a value. |
|
217 | - * Given the following request parameters: |
|
218 | - * array( |
|
219 | - * 'first' => array( |
|
220 | - * 'second' => array( |
|
221 | - * 'third' => 'has a value' |
|
222 | - * ) |
|
223 | - * ) |
|
224 | - * ) |
|
225 | - * would return true |
|
226 | - * |
|
227 | - * @param $key |
|
228 | - * @param null $default |
|
229 | - * @param string $is_set_or_get |
|
230 | - * @param array $request_params |
|
231 | - * @return bool|mixed|null |
|
232 | - */ |
|
233 | - private function requestParameterDrillDown( |
|
234 | - $key, |
|
235 | - $default = null, |
|
236 | - $is_set_or_get = 'is_set', |
|
237 | - array $request_params = array() |
|
238 | - ) { |
|
239 | - $request_params = ! empty($request_params) |
|
240 | - ? $request_params |
|
241 | - : $this->request; |
|
242 | - // does incoming key represent an array like 'first[second][third]' ? |
|
243 | - if (strpos($key, '[') !== false) { |
|
244 | - // turn it into an actual array |
|
245 | - $key = str_replace(']', '', $key); |
|
246 | - $keys = explode('[', $key); |
|
247 | - $key = array_shift($keys); |
|
248 | - // check if top level key exists |
|
249 | - if (isset($request_params[ $key ])) { |
|
250 | - // build a new key to pass along like: 'second[third]' |
|
251 | - // or just 'second' depending on depth of keys |
|
252 | - $key_string = array_shift($keys); |
|
253 | - if (! empty($keys)) { |
|
254 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
255 | - } |
|
256 | - return $this->requestParameterDrillDown( |
|
257 | - $key_string, |
|
258 | - $default, |
|
259 | - $is_set_or_get, |
|
260 | - $request_params[ $key ] |
|
261 | - ); |
|
262 | - } |
|
263 | - } |
|
264 | - if ($is_set_or_get === 'is_set') { |
|
265 | - return isset($request_params[ $key ]); |
|
266 | - } |
|
267 | - return isset($request_params[ $key ]) |
|
268 | - ? $request_params[ $key ] |
|
269 | - : $default; |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * remove param |
|
276 | - * |
|
277 | - * @param $key |
|
278 | - * @param bool $unset_from_global_too |
|
279 | - */ |
|
280 | - public function unSetRequestParam($key, $unset_from_global_too = false) |
|
281 | - { |
|
282 | - unset($this->request[ $key ]); |
|
283 | - if ($unset_from_global_too) { |
|
284 | - unset($_REQUEST[ $key ]); |
|
285 | - } |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function ipAddress() |
|
294 | - { |
|
295 | - return $this->ip_address; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * attempt to get IP address of current visitor from server |
|
301 | - * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
302 | - * |
|
303 | - * @access public |
|
304 | - * @return string |
|
305 | - */ |
|
306 | - private function visitorIp() |
|
307 | - { |
|
308 | - $visitor_ip = '0.0.0.0'; |
|
309 | - $server_keys = array( |
|
310 | - 'HTTP_CLIENT_IP', |
|
311 | - 'HTTP_X_FORWARDED_FOR', |
|
312 | - 'HTTP_X_FORWARDED', |
|
313 | - 'HTTP_X_CLUSTER_CLIENT_IP', |
|
314 | - 'HTTP_FORWARDED_FOR', |
|
315 | - 'HTTP_FORWARDED', |
|
316 | - 'REMOTE_ADDR', |
|
317 | - ); |
|
318 | - foreach ($server_keys as $key) { |
|
319 | - if (isset($this->server[ $key ])) { |
|
320 | - foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
321 | - if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
322 | - $visitor_ip = $ip; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - } |
|
327 | - return $visitor_ip; |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * @return string |
|
333 | - */ |
|
334 | - public function requestUri() |
|
335 | - { |
|
336 | - $request_uri = filter_input( |
|
337 | - INPUT_SERVER, |
|
338 | - 'REQUEST_URI', |
|
339 | - FILTER_SANITIZE_URL, |
|
340 | - FILTER_NULL_ON_FAILURE |
|
341 | - ); |
|
342 | - if (empty($request_uri)) { |
|
343 | - // fallback sanitization if the above fails |
|
344 | - $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']); |
|
345 | - } |
|
346 | - return $request_uri; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * @return string |
|
352 | - */ |
|
353 | - public function userAgent() |
|
354 | - { |
|
355 | - return $this->user_agent; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * @param string $user_agent |
|
361 | - */ |
|
362 | - public function setUserAgent($user_agent = '') |
|
363 | - { |
|
364 | - if ($user_agent === '' || ! is_string($user_agent)) { |
|
365 | - $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : ''; |
|
366 | - } |
|
367 | - $this->user_agent = $user_agent; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * @return bool |
|
373 | - */ |
|
374 | - public function isBot() |
|
375 | - { |
|
376 | - return $this->is_bot; |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * @param bool $is_bot |
|
382 | - */ |
|
383 | - public function setIsBot($is_bot) |
|
384 | - { |
|
385 | - $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * @return bool |
|
391 | - */ |
|
392 | - public function isActivation() |
|
393 | - { |
|
394 | - return $this->request_type->isActivation(); |
|
395 | - } |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * @param $is_activation |
|
400 | - * @return bool |
|
401 | - */ |
|
402 | - public function setIsActivation($is_activation) |
|
403 | - { |
|
404 | - return $this->request_type->setIsActivation($is_activation); |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * @return bool |
|
410 | - */ |
|
411 | - public function isAdmin() |
|
412 | - { |
|
413 | - return $this->request_type->isAdmin(); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * @return bool |
|
419 | - */ |
|
420 | - public function isAdminAjax() |
|
421 | - { |
|
422 | - return $this->request_type->isAdminAjax(); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * @return bool |
|
428 | - */ |
|
429 | - public function isAjax() |
|
430 | - { |
|
431 | - return $this->request_type->isAjax(); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * @return bool |
|
437 | - */ |
|
438 | - public function isEeAjax() |
|
439 | - { |
|
440 | - return $this->request_type->isEeAjax(); |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * @return bool |
|
446 | - */ |
|
447 | - public function isOtherAjax() |
|
448 | - { |
|
449 | - return $this->request_type->isOtherAjax(); |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * @return bool |
|
455 | - */ |
|
456 | - public function isApi() |
|
457 | - { |
|
458 | - return $this->request_type->isApi(); |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - /** |
|
463 | - * @return bool |
|
464 | - */ |
|
465 | - public function isCli() |
|
466 | - { |
|
467 | - return $this->request_type->isCli(); |
|
468 | - } |
|
469 | - |
|
470 | - |
|
471 | - /** |
|
472 | - * @return bool |
|
473 | - */ |
|
474 | - public function isCron() |
|
475 | - { |
|
476 | - return $this->request_type->isCron(); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * @return bool |
|
482 | - */ |
|
483 | - public function isFeed() |
|
484 | - { |
|
485 | - return $this->request_type->isFeed(); |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * @return bool |
|
491 | - */ |
|
492 | - public function isFrontend() |
|
493 | - { |
|
494 | - return $this->request_type->isFrontend(); |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * @return bool |
|
500 | - */ |
|
501 | - public function isFrontAjax() |
|
502 | - { |
|
503 | - return $this->request_type->isFrontAjax(); |
|
504 | - } |
|
505 | - |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * @return bool |
|
510 | - */ |
|
511 | - public function isIframe() |
|
512 | - { |
|
513 | - return $this->request_type->isIframe(); |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * @return string |
|
519 | - */ |
|
520 | - public function slug() |
|
521 | - { |
|
522 | - return $this->request_type->slug(); |
|
523 | - } |
|
23 | + /** |
|
24 | + * $_GET parameters |
|
25 | + * |
|
26 | + * @var array $get |
|
27 | + */ |
|
28 | + private $get; |
|
29 | + |
|
30 | + /** |
|
31 | + * $_POST parameters |
|
32 | + * |
|
33 | + * @var array $post |
|
34 | + */ |
|
35 | + private $post; |
|
36 | + |
|
37 | + /** |
|
38 | + * $_COOKIE parameters |
|
39 | + * |
|
40 | + * @var array $cookie |
|
41 | + */ |
|
42 | + private $cookie; |
|
43 | + |
|
44 | + /** |
|
45 | + * $_SERVER parameters |
|
46 | + * |
|
47 | + * @var array $server |
|
48 | + */ |
|
49 | + private $server; |
|
50 | + |
|
51 | + /** |
|
52 | + * $_REQUEST parameters |
|
53 | + * |
|
54 | + * @var array $request |
|
55 | + */ |
|
56 | + private $request; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var RequestTypeContextCheckerInterface |
|
60 | + */ |
|
61 | + private $request_type; |
|
62 | + |
|
63 | + /** |
|
64 | + * IP address for request |
|
65 | + * |
|
66 | + * @var string $ip_address |
|
67 | + */ |
|
68 | + private $ip_address; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var string $user_agent |
|
72 | + */ |
|
73 | + private $user_agent; |
|
74 | + |
|
75 | + /** |
|
76 | + * true if current user appears to be some kind of bot |
|
77 | + * |
|
78 | + * @var bool $is_bot |
|
79 | + */ |
|
80 | + private $is_bot; |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param array $get |
|
86 | + * @param array $post |
|
87 | + * @param array $cookie |
|
88 | + * @param array $server |
|
89 | + */ |
|
90 | + public function __construct(array $get, array $post, array $cookie, array $server) |
|
91 | + { |
|
92 | + // grab request vars |
|
93 | + $this->get = $get; |
|
94 | + $this->post = $post; |
|
95 | + $this->cookie = $cookie; |
|
96 | + $this->server = $server; |
|
97 | + $this->request = array_merge($this->get, $this->post); |
|
98 | + $this->ip_address = $this->visitorIp(); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @param RequestTypeContextCheckerInterface $type |
|
104 | + */ |
|
105 | + public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type) |
|
106 | + { |
|
107 | + $this->request_type = $type; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @return array |
|
114 | + */ |
|
115 | + public function getParams() |
|
116 | + { |
|
117 | + return $this->get; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function postParams() |
|
126 | + { |
|
127 | + return $this->post; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @return array |
|
134 | + */ |
|
135 | + public function cookieParams() |
|
136 | + { |
|
137 | + return $this->cookie; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return array |
|
143 | + */ |
|
144 | + public function serverParams() |
|
145 | + { |
|
146 | + return $this->server; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * returns contents of $_REQUEST |
|
153 | + * |
|
154 | + * @return array |
|
155 | + */ |
|
156 | + public function requestParams() |
|
157 | + { |
|
158 | + return $this->request; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @param $key |
|
165 | + * @param $value |
|
166 | + * @param bool $override_ee |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + public function setRequestParam($key, $value, $override_ee = false) |
|
170 | + { |
|
171 | + // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
172 | + if ( |
|
173 | + $key !== 'ee' |
|
174 | + || ($key === 'ee' && empty($this->request['ee'])) |
|
175 | + || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee) |
|
176 | + ) { |
|
177 | + $this->request[ $key ] = $value; |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * returns the value for a request param if the given key exists |
|
185 | + * |
|
186 | + * @param $key |
|
187 | + * @param null $default |
|
188 | + * @return mixed |
|
189 | + */ |
|
190 | + public function getRequestParam($key, $default = null) |
|
191 | + { |
|
192 | + return $this->requestParameterDrillDown($key, $default, 'get'); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * check if param exists |
|
199 | + * |
|
200 | + * @param $key |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | + public function requestParamIsSet($key) |
|
204 | + { |
|
205 | + return $this->requestParameterDrillDown($key); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * the supplied key can be a simple string to represent a "top-level" request parameter |
|
212 | + * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
213 | + * by using square brackets to surround keys for deeper array elements. |
|
214 | + * For example : |
|
215 | + * if the supplied $key was: "first[second][third]" |
|
216 | + * then this will attempt to drill down into the request parameter array to find a value. |
|
217 | + * Given the following request parameters: |
|
218 | + * array( |
|
219 | + * 'first' => array( |
|
220 | + * 'second' => array( |
|
221 | + * 'third' => 'has a value' |
|
222 | + * ) |
|
223 | + * ) |
|
224 | + * ) |
|
225 | + * would return true |
|
226 | + * |
|
227 | + * @param $key |
|
228 | + * @param null $default |
|
229 | + * @param string $is_set_or_get |
|
230 | + * @param array $request_params |
|
231 | + * @return bool|mixed|null |
|
232 | + */ |
|
233 | + private function requestParameterDrillDown( |
|
234 | + $key, |
|
235 | + $default = null, |
|
236 | + $is_set_or_get = 'is_set', |
|
237 | + array $request_params = array() |
|
238 | + ) { |
|
239 | + $request_params = ! empty($request_params) |
|
240 | + ? $request_params |
|
241 | + : $this->request; |
|
242 | + // does incoming key represent an array like 'first[second][third]' ? |
|
243 | + if (strpos($key, '[') !== false) { |
|
244 | + // turn it into an actual array |
|
245 | + $key = str_replace(']', '', $key); |
|
246 | + $keys = explode('[', $key); |
|
247 | + $key = array_shift($keys); |
|
248 | + // check if top level key exists |
|
249 | + if (isset($request_params[ $key ])) { |
|
250 | + // build a new key to pass along like: 'second[third]' |
|
251 | + // or just 'second' depending on depth of keys |
|
252 | + $key_string = array_shift($keys); |
|
253 | + if (! empty($keys)) { |
|
254 | + $key_string .= '[' . implode('][', $keys) . ']'; |
|
255 | + } |
|
256 | + return $this->requestParameterDrillDown( |
|
257 | + $key_string, |
|
258 | + $default, |
|
259 | + $is_set_or_get, |
|
260 | + $request_params[ $key ] |
|
261 | + ); |
|
262 | + } |
|
263 | + } |
|
264 | + if ($is_set_or_get === 'is_set') { |
|
265 | + return isset($request_params[ $key ]); |
|
266 | + } |
|
267 | + return isset($request_params[ $key ]) |
|
268 | + ? $request_params[ $key ] |
|
269 | + : $default; |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * remove param |
|
276 | + * |
|
277 | + * @param $key |
|
278 | + * @param bool $unset_from_global_too |
|
279 | + */ |
|
280 | + public function unSetRequestParam($key, $unset_from_global_too = false) |
|
281 | + { |
|
282 | + unset($this->request[ $key ]); |
|
283 | + if ($unset_from_global_too) { |
|
284 | + unset($_REQUEST[ $key ]); |
|
285 | + } |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function ipAddress() |
|
294 | + { |
|
295 | + return $this->ip_address; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * attempt to get IP address of current visitor from server |
|
301 | + * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
302 | + * |
|
303 | + * @access public |
|
304 | + * @return string |
|
305 | + */ |
|
306 | + private function visitorIp() |
|
307 | + { |
|
308 | + $visitor_ip = '0.0.0.0'; |
|
309 | + $server_keys = array( |
|
310 | + 'HTTP_CLIENT_IP', |
|
311 | + 'HTTP_X_FORWARDED_FOR', |
|
312 | + 'HTTP_X_FORWARDED', |
|
313 | + 'HTTP_X_CLUSTER_CLIENT_IP', |
|
314 | + 'HTTP_FORWARDED_FOR', |
|
315 | + 'HTTP_FORWARDED', |
|
316 | + 'REMOTE_ADDR', |
|
317 | + ); |
|
318 | + foreach ($server_keys as $key) { |
|
319 | + if (isset($this->server[ $key ])) { |
|
320 | + foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) { |
|
321 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
322 | + $visitor_ip = $ip; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + } |
|
327 | + return $visitor_ip; |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * @return string |
|
333 | + */ |
|
334 | + public function requestUri() |
|
335 | + { |
|
336 | + $request_uri = filter_input( |
|
337 | + INPUT_SERVER, |
|
338 | + 'REQUEST_URI', |
|
339 | + FILTER_SANITIZE_URL, |
|
340 | + FILTER_NULL_ON_FAILURE |
|
341 | + ); |
|
342 | + if (empty($request_uri)) { |
|
343 | + // fallback sanitization if the above fails |
|
344 | + $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']); |
|
345 | + } |
|
346 | + return $request_uri; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * @return string |
|
352 | + */ |
|
353 | + public function userAgent() |
|
354 | + { |
|
355 | + return $this->user_agent; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * @param string $user_agent |
|
361 | + */ |
|
362 | + public function setUserAgent($user_agent = '') |
|
363 | + { |
|
364 | + if ($user_agent === '' || ! is_string($user_agent)) { |
|
365 | + $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : ''; |
|
366 | + } |
|
367 | + $this->user_agent = $user_agent; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * @return bool |
|
373 | + */ |
|
374 | + public function isBot() |
|
375 | + { |
|
376 | + return $this->is_bot; |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * @param bool $is_bot |
|
382 | + */ |
|
383 | + public function setIsBot($is_bot) |
|
384 | + { |
|
385 | + $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * @return bool |
|
391 | + */ |
|
392 | + public function isActivation() |
|
393 | + { |
|
394 | + return $this->request_type->isActivation(); |
|
395 | + } |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * @param $is_activation |
|
400 | + * @return bool |
|
401 | + */ |
|
402 | + public function setIsActivation($is_activation) |
|
403 | + { |
|
404 | + return $this->request_type->setIsActivation($is_activation); |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * @return bool |
|
410 | + */ |
|
411 | + public function isAdmin() |
|
412 | + { |
|
413 | + return $this->request_type->isAdmin(); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * @return bool |
|
419 | + */ |
|
420 | + public function isAdminAjax() |
|
421 | + { |
|
422 | + return $this->request_type->isAdminAjax(); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * @return bool |
|
428 | + */ |
|
429 | + public function isAjax() |
|
430 | + { |
|
431 | + return $this->request_type->isAjax(); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * @return bool |
|
437 | + */ |
|
438 | + public function isEeAjax() |
|
439 | + { |
|
440 | + return $this->request_type->isEeAjax(); |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * @return bool |
|
446 | + */ |
|
447 | + public function isOtherAjax() |
|
448 | + { |
|
449 | + return $this->request_type->isOtherAjax(); |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * @return bool |
|
455 | + */ |
|
456 | + public function isApi() |
|
457 | + { |
|
458 | + return $this->request_type->isApi(); |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + /** |
|
463 | + * @return bool |
|
464 | + */ |
|
465 | + public function isCli() |
|
466 | + { |
|
467 | + return $this->request_type->isCli(); |
|
468 | + } |
|
469 | + |
|
470 | + |
|
471 | + /** |
|
472 | + * @return bool |
|
473 | + */ |
|
474 | + public function isCron() |
|
475 | + { |
|
476 | + return $this->request_type->isCron(); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * @return bool |
|
482 | + */ |
|
483 | + public function isFeed() |
|
484 | + { |
|
485 | + return $this->request_type->isFeed(); |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * @return bool |
|
491 | + */ |
|
492 | + public function isFrontend() |
|
493 | + { |
|
494 | + return $this->request_type->isFrontend(); |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * @return bool |
|
500 | + */ |
|
501 | + public function isFrontAjax() |
|
502 | + { |
|
503 | + return $this->request_type->isFrontAjax(); |
|
504 | + } |
|
505 | + |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * @return bool |
|
510 | + */ |
|
511 | + public function isIframe() |
|
512 | + { |
|
513 | + return $this->request_type->isIframe(); |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * @return string |
|
519 | + */ |
|
520 | + public function slug() |
|
521 | + { |
|
522 | + return $this->request_type->slug(); |
|
523 | + } |
|
524 | 524 | |
525 | 525 | |
526 | 526 | } |
@@ -11,49 +11,49 @@ |
||
11 | 11 | interface LoaderInterface |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Can be for instantiating a new instance of a class, |
|
16 | - * or for getting a shared instance of a class (default) |
|
17 | - * |
|
18 | - * @param string $fqcn |
|
19 | - * @param array $arguments |
|
20 | - * @param bool $shared |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function load($fqcn, $arguments = array(), $shared = true); |
|
24 | - |
|
25 | - /** |
|
26 | - * Used for instantiating a new instance of a class |
|
27 | - * |
|
28 | - * @param string $fqcn |
|
29 | - * @param array $arguments |
|
30 | - * @return mixed |
|
31 | - */ |
|
32 | - public function getNew($fqcn, $arguments = array()); |
|
33 | - |
|
34 | - /** |
|
35 | - * Used for getting a shared instance of a class |
|
36 | - * |
|
37 | - * @param string $fqcn |
|
38 | - * @param array $arguments |
|
39 | - * @return mixed |
|
40 | - */ |
|
41 | - public function getShared($fqcn, $arguments = array()); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @param string $fqcn |
|
46 | - * @param mixed $object |
|
47 | - * @return bool |
|
48 | - * @throws InvalidArgumentException |
|
49 | - */ |
|
50 | - public function share($fqcn, $object); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * calls reset() on loader if method exists |
|
55 | - */ |
|
56 | - public function reset(); |
|
14 | + /** |
|
15 | + * Can be for instantiating a new instance of a class, |
|
16 | + * or for getting a shared instance of a class (default) |
|
17 | + * |
|
18 | + * @param string $fqcn |
|
19 | + * @param array $arguments |
|
20 | + * @param bool $shared |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function load($fqcn, $arguments = array(), $shared = true); |
|
24 | + |
|
25 | + /** |
|
26 | + * Used for instantiating a new instance of a class |
|
27 | + * |
|
28 | + * @param string $fqcn |
|
29 | + * @param array $arguments |
|
30 | + * @return mixed |
|
31 | + */ |
|
32 | + public function getNew($fqcn, $arguments = array()); |
|
33 | + |
|
34 | + /** |
|
35 | + * Used for getting a shared instance of a class |
|
36 | + * |
|
37 | + * @param string $fqcn |
|
38 | + * @param array $arguments |
|
39 | + * @return mixed |
|
40 | + */ |
|
41 | + public function getShared($fqcn, $arguments = array()); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @param string $fqcn |
|
46 | + * @param mixed $object |
|
47 | + * @return bool |
|
48 | + * @throws InvalidArgumentException |
|
49 | + */ |
|
50 | + public function share($fqcn, $object); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * calls reset() on loader if method exists |
|
55 | + */ |
|
56 | + public function reset(); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | // End of file LoaderInterface.php |
@@ -14,13 +14,13 @@ |
||
14 | 14 | interface CachingLoaderDecoratorInterface extends LoaderDecoratorInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @param string $fqcn |
|
19 | - * @param mixed $object |
|
20 | - * @return bool |
|
21 | - * @throws InvalidArgumentException |
|
22 | - */ |
|
23 | - public function share($fqcn, $object); |
|
17 | + /** |
|
18 | + * @param string $fqcn |
|
19 | + * @param mixed $object |
|
20 | + * @return bool |
|
21 | + * @throws InvalidArgumentException |
|
22 | + */ |
|
23 | + public function share($fqcn, $object); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | // End of file LoaderInterface.php |