Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/Common/Ajax/AjaxHandler.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
namespace WP_Rocket\Engine\Common\Ajax;
4
+
5
+
class AjaxHandler {
6
+
7
+
/**
8
+
* Validate the referer before going further.
9
+
*
10
+
* @param string $action Action to validate.
11
+
* @param string $capacities User capacity to verify.
12
+
* @return bool
13
+
*/
14
+
public function validate_referer( string $action, string $capacities ) {
15
+
16
+
check_admin_referer( $action );
17
+
18
+
if ( ! current_user_can( $capacities ) ) {
19
+
return false;
20
+
}
21
+
22
+
return true;
23
+
}
24
+
25
+
/**
26
+
* Redirect the page at the end of the logic.
27
+
*
28
+
* @param string $url URl to redirect to (by default referrer).
29
+
* @return void
30
+
*/
31
+
public function redirect( string $url = '' ) {
32
+
wp_safe_redirect( '' === $url ? wp_get_referer() : $url );
33
+
rocket_get_constant( 'WP_ROCKET_IS_TESTING', false ) ? wp_die() : exit;
34
+
}
35
+
}
36
+