| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Services\Health_Check; |
| 4 |
|
| 5 |
/** |
| 6 |
* Paasses when permalinks are set to contain the post name. |
| 7 |
*/ |
| 8 |
class Postname_Permalink_Check extends Health_Check { |
| 9 |
|
| 10 |
/** |
| 11 |
* Runs the health check. |
| 12 |
* |
| 13 |
* @var Postname_Permalink_Runner |
| 14 |
*/ |
| 15 |
private $runner; |
| 16 |
|
| 17 |
/** |
| 18 |
* Generates WordPress-friendly health check results. |
| 19 |
* |
| 20 |
* @var Postname_Permalink_Reports |
| 21 |
*/ |
| 22 |
private $reports; |
| 23 |
|
| 24 |
/** |
| 25 |
* Constructor. |
| 26 |
* |
| 27 |
* @param Postname_Permalink_Runner $runner The object that implements the actual health check. |
| 28 |
* @param Postname_Permalink_Reports $reports The object that generates WordPress-friendly results. |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
public function __construct( |
| 32 |
Postname_Permalink_Runner $runner, |
| 33 |
Postname_Permalink_Reports $reports |
| 34 |
) { |
| 35 |
$this->runner = $runner; |
| 36 |
$this->reports = $reports; |
| 37 |
$this->reports->set_test_identifier( $this->get_test_identifier() ); |
| 38 |
|
| 39 |
$this->set_runner( $this->runner ); |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Returns a human-readable label for this health check. |
| 44 |
* |
| 45 |
* @return string The human-readable label. |
| 46 |
*/ |
| 47 |
public function get_test_label() { |
| 48 |
return __( 'Postname permalink', 'wordpress-seo' ); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Returns the WordPress-friendly health check result. |
| 53 |
* |
| 54 |
* @return string[] The WordPress-friendly health check result. |
| 55 |
*/ |
| 56 |
protected function get_result() { |
| 57 |
if ( $this->runner->is_successful() ) { |
| 58 |
return $this->reports->get_success_result(); |
| 59 |
} |
| 60 |
|
| 61 |
return $this->reports->get_has_no_postname_in_permalink_result(); |
| 62 |
} |
| 63 |
} |
| 64 |
|