ai-generate-titles-and-descriptions-introduction-upsell.php
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Yoast\WP\SEO\Introductions\Application;
use Yoast\WP\SEO\Helpers\Options_Helper;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Introductions\Domain\Introduction_Interface;
/**
* Represents the introduction for the AI generate titles and introduction upsell.
*
* @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
*
* @makePublic
*/
class Ai_Generate_Titles_And_Descriptions_Introduction_Upsell implements Introduction_Interface {
use Current_Page_Trait;
use Version_Trait;
use User_Allowed_Trait;
/**
* Holds the product helper.
*
* @var \Yoast\WP\SEO\Helpers\Product_Helper
*/
private $product_helper;
/**
* Holds the options' helper.
*
* @var \Yoast\WP\SEO\Helpers\Options_Helper
*/
private $options_helper;
/**
* Constructs the introduction.
*
* @param \Yoast\WP\SEO\Helpers\Product_Helper $product_helper The product helper.
* @param \Yoast\WP\SEO\Helpers\Options_Helper $options_helper The options' helper.
*/
public function __construct(
Product_Helper $product_helper,
Options_Helper $options_helper
) {
$this->product_helper = $product_helper;
$this->options_helper = $options_helper;
}
/**
* Returns the unique name.
*
* @return string
*/
public function get_name() {
return 'ai-generate-titles-and-descriptions-upsell';
}
/**
* Returns the requested pagination priority. Lower means earlier.
*
* @return int
*/
public function get_priority() {
return 10;
}
/**
* Returns whether this introduction should show.
*
* @return bool
*/
public function should_show() {
if ( $this->product_helper->is_premium() ) {
return false;
}
if ( $this->options_helper->get( 'previous_version', '' ) === '' ) {
// The current installation is a new one (not upgraded yet).
return false;
}
if ( ! $this->is_version_between( $this->product_helper->get_version(), '20.11-RC4', '21.1-RC0' ) ) {
return false;
}
if ( ! $this->is_user_allowed( [ 'edit_posts' ] ) ) {
return false;
}
return true;
}
}