| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Imagify\Imagifybeat; |
| 3 | 3 | |
| 4 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 4 | +use Imagify\Traits\InstanceGetterTrait; | |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * Imagifybeat core. |
| 8 | 8 | * |
| @@ -8,10 +8,10 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * @since 1.9.3 |
| 10 | 10 | * @author Grégory Viguier |
| 11 | 11 | */ |
| 12 | -class Core { | |
| 13 | - use \Imagify\Traits\InstanceGetterTrait; | |
| 12 | +final class Core { | |
| 13 | + use InstanceGetterTrait; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Class init: launch hooks. |
| 17 | 17 | * |
| @@ -19,9 +19,9 @@ | ||
| 19 | 19 | * @access public |
| 20 | 20 | * @author Grégory Viguier |
| 21 | 21 | */ |
| 22 | 22 | public function init() { |
| 23 | - add_action( 'wp_ajax_imagifybeat', [ $this, 'core_handler' ], 1 ); | |
| 23 | + add_action( 'wp_ajax_imagifybeat', [ $this, 'core_handler' ], 1 ); | |
| 24 | 24 | add_filter( 'imagifybeat_refresh_nonces', [ $this, 'refresh_imagifybeat_nonces' ] ); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| @@ -39,9 +39,9 @@ | ||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $data = []; |
| 42 | 42 | $response = []; |
| 43 | - $nonce_state = wp_verify_nonce( wp_unslash( $_POST['_nonce'] ), 'imagifybeat-nonce' ); | |
| 43 | + $nonce_state = wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), 'imagifybeat-nonce' ); | |
| 44 | 44 | |
| 45 | 45 | // Screen_id is the same as $current_screen->id and the JS global 'pagenow'. |
| 46 | 46 | if ( ! empty( $_POST['screen_id'] ) ) { |
| 47 | 47 | $screen_id = sanitize_key( $_POST['screen_id'] ); |
| @@ -49,9 +49,9 @@ | ||
| 49 | 49 | $screen_id = 'front'; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | if ( ! empty( $_POST['data'] ) ) { |
| 53 | - $data = wp_unslash( (array) $_POST['data'] ); | |
| 53 | + $data = wp_unslash( (array) $_POST['data'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ( 1 !== $nonce_state ) { |
| 57 | 57 | /** |
| @@ -56,16 +56,15 @@ | ||
| 56 | 56 | if ( 1 !== $nonce_state ) { |
| 57 | 57 | /** |
| 58 | 58 | * Filters the nonces to send. |
| 59 | 59 | * |
| 60 | - * @since 1.9.3 | |
| 61 | - * @author Grégory Viguier | |
| 60 | + * @since 1.9.3 | |
| 62 | 61 | * |
| 63 | 62 | * @param array $response The Imagifybeat response. |
| 64 | 63 | * @param array $data The $_POST data sent. |
| 65 | 64 | * @param string $screen_id The screen id. |
| 66 | 65 | */ |
| 67 | - $response = apply_filters( 'imagifybeat_refresh_nonces', $response, $data, $screen_id ); | |
| 66 | + $response = wpm_apply_filters_typed( 'array', 'imagifybeat_refresh_nonces', $response, $data, $screen_id ); | |
| 68 | 67 | |
| 69 | 68 | if ( false === $nonce_state ) { |
| 70 | 69 | // User is logged in but nonces have expired. |
| 71 | 70 | $response['nonces_expired'] = true; |
| @@ -76,28 +75,26 @@ | ||
| 76 | 75 | if ( ! empty( $data ) ) { |
| 77 | 76 | /** |
| 78 | 77 | * Filters the Imagifybeat response received. |
| 79 | 78 | * |
| 80 | - * @since 1.9.3 | |
| 81 | - * @author Grégory Viguier | |
| 79 | + * @since 1.9.3 | |
| 82 | 80 | * |
| 83 | 81 | * @param array $response The Imagifybeat response. |
| 84 | 82 | * @param array $data The $_POST data sent. |
| 85 | 83 | * @param string $screen_id The screen id. |
| 86 | 84 | */ |
| 87 | - $response = apply_filters( 'imagifybeat_received', $response, $data, $screen_id ); | |
| 85 | + $response = wpm_apply_filters_typed( 'array', 'imagifybeat_received', $response, $data, $screen_id ); | |
| 88 | 86 | } |
| 89 | 87 | |
| 90 | 88 | /** |
| 91 | 89 | * Filters the Imagifybeat response sent. |
| 92 | 90 | * |
| 93 | - * @since 1.9.3 | |
| 94 | - * @author Grégory Viguier | |
| 91 | + * @since 1.9.3 | |
| 95 | 92 | * |
| 96 | 93 | * @param array $response The Imagifybeat response. |
| 97 | 94 | * @param string $screen_id The screen id. |
| 98 | 95 | */ |
| 99 | - $response = apply_filters( 'imagifybeat_send', $response, $screen_id ); | |
| 96 | + $response = wpm_apply_filters_typed( 'array', 'imagifybeat_send', $response, $screen_id ); | |
| 100 | 97 | |
| 101 | 98 | /** |
| 102 | 99 | * Fires when Imagifybeat ticks in logged-in environments. |
| 103 | 100 | * |
| @@ -161,12 +158,11 @@ | ||
| 161 | 158 | |
| 162 | 159 | /** |
| 163 | 160 | * Filters the Imagifybeat settings. |
| 164 | 161 | * |
| 165 | - * @since 1.9.3 | |
| 166 | - * @author Grégory Viguier | |
| 162 | + * @since 1.9.3 | |
| 167 | 163 | * |
| 168 | 164 | * @param array $settings Imagifybeat settings array. |
| 169 | 165 | */ |
| 170 | - return (array) apply_filters( 'imagifybeat_settings', $settings ); | |
| 166 | + return (array) wpm_apply_filters_typed( 'array', 'imagifybeat_settings', $settings ); | |
| 171 | 167 | } |
| 172 | 168 | } |