| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Introductions\Application; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Helpers\Current_Page_Helper; |
| 6 |
use Yoast\WP\SEO\Helpers\Product_Helper; |
| 7 |
use Yoast\WP\SEO\Introductions\Domain\Introduction_Interface; |
| 8 |
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager; |
| 9 |
|
| 10 |
/** |
| 11 |
* Represents the introduction for the Black Friday announcement. |
| 12 |
*/ |
| 13 |
class Black_Friday_Announcement implements Introduction_Interface { |
| 14 |
|
| 15 |
public const ID = 'black-friday-announcement'; |
| 16 |
|
| 17 |
/** |
| 18 |
* Holds the current page helper. |
| 19 |
* |
| 20 |
* @var Current_Page_Helper |
| 21 |
*/ |
| 22 |
private $current_page_helper; |
| 23 |
|
| 24 |
/** |
| 25 |
* Holds the promotion manager. |
| 26 |
* |
| 27 |
* @var Promotion_Manager |
| 28 |
*/ |
| 29 |
private $promotion_manager; |
| 30 |
|
| 31 |
/** |
| 32 |
* Holds the product helper. |
| 33 |
* |
| 34 |
* @var Product_Helper |
| 35 |
*/ |
| 36 |
private $product_helper; |
| 37 |
|
| 38 |
/** |
| 39 |
* Constructs the introduction. |
| 40 |
* |
| 41 |
* @param Current_Page_Helper $current_page_helper The current page helper. |
| 42 |
* @param Promotion_Manager $promotion_manager The promotion manager. |
| 43 |
* @param Product_Helper $product_helper The product helper. |
| 44 |
*/ |
| 45 |
public function __construct( |
| 46 |
Current_Page_Helper $current_page_helper, |
| 47 |
Promotion_Manager $promotion_manager, |
| 48 |
Product_Helper $product_helper |
| 49 |
) { |
| 50 |
$this->current_page_helper = $current_page_helper; |
| 51 |
$this->promotion_manager = $promotion_manager; |
| 52 |
$this->product_helper = $product_helper; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Returns the ID. |
| 57 |
* |
| 58 |
* @return string The ID. |
| 59 |
*/ |
| 60 |
public function get_id() { |
| 61 |
return self::ID; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Returns the requested pagination priority. Lower means earlier. |
| 66 |
* |
| 67 |
* @return int The priority. |
| 68 |
*/ |
| 69 |
public function get_priority() { |
| 70 |
return 10; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Returns whether this introduction should show. |
| 75 |
* |
| 76 |
* @return bool Whether this introduction should show. |
| 77 |
*/ |
| 78 |
public function should_show() { |
| 79 |
return $this->current_page_helper->is_yoast_seo_page() && ! $this->product_helper->is_premium() && $this->promotion_manager->is( 'black-friday-promotion' ); |
| 80 |
} |
| 81 |
} |
| 82 |
|