PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / conditionals / third-party / elementor-edit-conditional.php

elementor-edit-conditional.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/conditionals/third-party/elementor-edit-conditional.php

70 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Conditionals\Third_Party;
4
5 use Yoast\WP\SEO\Conditionals\Conditional;
6
7 /**
8 * Conditional that is only met when on an Elementor edit page or when the current
9 * request is an ajax request for saving our post meta data.
10 */
11 class Elementor_Edit_Conditional implements Conditional {
12
13 /**
14 * Returns whether this conditional is met.
15 *
16 * @return bool Whether the conditional is met.
17 */
18 public function is_met() {
19 global $pagenow;
20
21 // Editing a post/page in Elementor.
22 if ( $pagenow === 'post.php' && $this->is_elementor_get_action() ) {
23 return true;
24 }
25
26 // Request for us saving a post/page in Elementor (submits our form via AJAX).
27 return \wp_doing_ajax() && $this->is_yoast_save_post_action();
28 }
29
30 /**
31 * Checks if the current request' GET action is 'elementor'.
32 *
33 * @return bool True when the GET action is 'elementor'.
34 */
35 private function is_elementor_get_action(): bool {
36 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
37 if ( ! isset( $_GET['action'] ) ) {
38 return false;
39 }
40
41 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
42 if ( ! \is_string( $_GET['action'] ) ) {
43 return false;
44 }
45
46 // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, we are only strictly comparing.
47 return \wp_unslash( $_GET['action'] ) === 'elementor';
48 }
49
50 /**
51 * Checks if the current request' POST action is 'wpseo_elementor_save'.
52 *
53 * @return bool True when the POST action is 'wpseo_elementor_save'.
54 */
55 private function is_yoast_save_post_action(): bool {
56 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information.
57 if ( ! isset( $_POST['action'] ) ) {
58 return false;
59 }
60
61 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information.
62 if ( ! \is_string( $_POST['action'] ) ) {
63 return false;
64 }
65
66 // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, we are only strictly comparing.
67 return \wp_unslash( $_POST['action'] ) === 'wpseo_elementor_save';
68 }
69 }
70