| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Introductions\Application; |
| 4 |
|
| 5 |
trait Current_Page_Trait { |
| 6 |
|
| 7 |
/** |
| 8 |
* Determines whether the current page is applicable. |
| 9 |
* |
| 10 |
* @param string[] $pages The applicable pages. |
| 11 |
* |
| 12 |
* @return bool Whether the current page is applicable. |
| 13 |
*/ |
| 14 |
private function is_on_yoast_page( $pages ) { |
| 15 |
return \in_array( $this->get_page(), $pages, true ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Determines whether the current page is one of our installation pages. |
| 20 |
* |
| 21 |
* @return bool Whether the current page is one of our installation pages. |
| 22 |
*/ |
| 23 |
private function is_on_installation_page() { |
| 24 |
return $this->is_on_yoast_page( [ 'wpseo_installation_successful_free', 'wpseo_installation_successful' ] ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Retrieve the page variable. |
| 29 |
* |
| 30 |
* Note: the result is not safe to use in anything than strict comparisons! |
| 31 |
* |
| 32 |
* @return string The page variable. |
| 33 |
*/ |
| 34 |
private function get_page() { |
| 35 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. |
| 36 |
if ( isset( $_GET['page'] ) && \is_string( $_GET['page'] ) ) { |
| 37 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, only using it in strict comparison. |
| 38 |
return \wp_unslash( $_GET['page'] ); |
| 39 |
} |
| 40 |
|
| 41 |
return ''; |
| 42 |
} |
| 43 |
} |
| 44 |
|