-
Notifications
You must be signed in to change notification settings - Fork 882
/
base-site-information.php
129 lines (117 loc) · 4.38 KB
/
base-site-information.php
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
namespace Yoast\WP\SEO\Editors\Framework\Site;
use Exception;
use Yoast\WP\SEO\Actions\Alert_Dismissal_Action;
use Yoast\WP\SEO\Helpers\Product_Helper;
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
use Yoast\WP\SEO\Introductions\Infrastructure\Wistia_Embed_Permission_Repository;
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager;
use Yoast\WP\SEO\Surfaces\Meta_Surface;
/**
* The Base_Site_Information class.
*/
abstract class Base_Site_Information {
/**
* The alert dismissal action.
*
* @var Alert_Dismissal_Action $alert_dismissal_action
*/
protected $alert_dismissal_action;
/**
* The promotion manager.
*
* @var Promotion_Manager $promotion_manager
*/
protected $promotion_manager;
/**
* The short link helper.
*
* @var Short_Link_Helper $shortlink_helper
*/
protected $short_link_helper;
/**
* The wistia embed permission repository.
*
* @var Wistia_Embed_Permission_Repository $wistia_embed_permission_repository
*/
private $wistia_embed_permission_repository;
/**
* The meta surface.
*
* @var Meta_Surface $meta
*/
private $meta;
/**
* The product helper.
*
* @var Product_Helper $product_helper
*/
private $product_helper;
/**
* The constructor.
*
* @param Promotion_Manager $promotion_manager The promotion manager.
* @param Short_Link_Helper $short_link_helper The short link helper.
* @param Wistia_Embed_Permission_Repository $wistia_embed_permission_repository The wistia embed permission
* repository.
* @param Meta_Surface $meta The meta surface.
* @param Product_Helper $product_helper The product helper.
* @param Alert_Dismissal_Action $alert_dismissal_action The alert dismissal action.
*/
public function __construct(
Promotion_Manager $promotion_manager,
Short_Link_Helper $short_link_helper,
Wistia_Embed_Permission_Repository $wistia_embed_permission_repository,
Meta_Surface $meta,
Product_Helper $product_helper,
Alert_Dismissal_Action $alert_dismissal_action
) {
$this->promotion_manager = $promotion_manager;
$this->short_link_helper = $short_link_helper;
$this->wistia_embed_permission_repository = $wistia_embed_permission_repository;
$this->meta = $meta;
$this->product_helper = $product_helper;
$this->alert_dismissal_action = $alert_dismissal_action;
}
/**
* Returns site information that is the
*
* @throws Exception If an invalid user ID is supplied to the wistia repository.
* @return array<string|string,string[]>
*/
public function get_site_information(): array {
return [
'linkParams' => $this->short_link_helper->get_query_params(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'wistiaEmbedPermission' => $this->wistia_embed_permission_repository->get_value_for_user( \get_current_user_id() ),
'site_name' => $this->meta->for_current_page()->site_name,
'contentLocale' => \get_locale(),
'userLocale' => \get_user_locale(),
'isRtl' => \is_rtl(),
'isPremium' => $this->product_helper->is_premium(),
'siteIconUrl' => \get_site_icon_url(),
];
}
/**
* Returns site information that is the
*
* @throws Exception If an invalid user ID is supplied to the wistia repository.
* @return array<string|string,string[]>
*/
public function get_legacy_site_information(): array {
return [
'linkParams' => $this->short_link_helper->get_query_params(),
'pluginUrl' => \plugins_url( '', \WPSEO_FILE ),
'wistiaEmbedPermission' => $this->wistia_embed_permission_repository->get_value_for_user( \get_current_user_id() ),
'metabox' => [
'site_name' => $this->meta->for_current_page()->site_name,
'contentLocale' => \get_locale(),
'userLocale' => \get_user_locale(),
'isRtl' => \is_rtl(),
'isPremium' => $this->product_helper->is_premium(),
'siteIconUrl' => \get_site_icon_url(),
],
];
}
}