1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\services\request\middleware; |
4
|
|
|
|
5
|
|
|
use EventEspresso\core\services\request\RequestInterface; |
6
|
|
|
use EventEspresso\core\services\request\ResponseInterface; |
7
|
|
|
|
8
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class DetectFileEditorRequest |
14
|
|
|
* Detects File Editor requests and executes any logic needing set on those requests. |
15
|
|
|
* ported over from /core/middleware/EE_Detect_File_Editor_Request.core.php |
16
|
|
|
* |
17
|
|
|
* @package EventEspresso\core\services\request\middleware |
18
|
|
|
* @author Darren Ethier |
19
|
|
|
* @since $VID:$ |
20
|
|
|
*/ |
21
|
|
|
class DetectFileEditorRequest extends Middleware |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* converts a Request to a Response |
26
|
|
|
* |
27
|
|
|
* @param RequestInterface $request |
28
|
|
|
* @param ResponseInterface $response |
29
|
|
|
* @return ResponseInterface |
30
|
|
|
*/ |
31
|
|
View Code Duplication |
public function handleRequest(RequestInterface $request, ResponseInterface $response) |
32
|
|
|
{ |
33
|
|
|
$this->request = $request; |
34
|
|
|
$this->response = $response; |
35
|
|
|
if ($this->isFileEditorRequest()) { |
36
|
|
|
$this->setFiltersForRequest(); |
37
|
|
|
} |
38
|
|
|
$this->response = $this->processRequestStack($this->request, $this->response); |
39
|
|
|
return $this->response; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* This sets any filters that need set on this request. |
45
|
|
|
*/ |
46
|
|
|
protected function setFiltersForRequest() |
47
|
|
|
{ |
48
|
|
|
add_filter('FHEE_load_EE_Session', '__return_false', 999); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Conditions for a "file editor request" |
54
|
|
|
* |
55
|
|
|
* @see wp-admin/includes/file.php |
56
|
|
|
* The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
57
|
|
|
* active plugin edits. So these conditions consider that. |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
|
|
protected function isFileEditorRequest() |
61
|
|
|
{ |
62
|
|
|
return $this->request->getRequestParam('wp_scrape_key') |
63
|
|
|
&& $this->request->getRequestParam('wp_scrape_nonce'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|