Integration.php
2.27 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
namespace AC;
use AC\Type\Url;
abstract class Integration {
/** @var string */
private $basename;
/** @var string */
private $title;
/** @var string */
private $logo;
/** @var Url */
private $url;
/** @var string */
private $plugin_link;
/**
* @var string
*/
private $description;
/**
* @param string $basename
* @param string $title
* @param string $logo
* @param string $description
* @param string $plugin_link
* @param string $page
*/
public function __construct( $basename, $title, $logo, $description, $plugin_link = null, Url $url = null ) {
if ( null === $plugin_link ) {
$plugin_link = $this->search_plugin( $title );
}
if ( null === $url ) {
$url = new Url\Site( Url\Site::PAGE_PRICING );
}
$this->basename = $basename;
$this->title = $title;
$this->logo = $logo;
$this->description = $description;
$this->plugin_link = $plugin_link;
$this->url = $url;
}
/**
* @return bool
*/
abstract public function is_plugin_active();
/**
* @param Screen $screen
*
* @return bool
*/
abstract public function show_notice( Screen $screen );
/**
* @param string $name
*
* @return string
*/
private function search_plugin( $name ) {
return add_query_arg(
[
'tab' => 'search',
'type' => 'term',
's' => $name,
],
admin_url( 'plugin-install.php' )
);
}
/**
* @return string
*/
public function get_basename() {
return $this->basename;
}
/**
* @return string
*/
public function get_slug() {
return dirname( $this->basename );
}
/**
* @return string
*/
public function get_title() {
return $this->title;
}
/**
* @return string
*/
public function get_logo() {
return $this->logo;
}
/**
* @return string
*/
public function get_description() {
return $this->description;
}
/**
* @return string
*/
public function get_link() {
return ( new Url\UtmTags( $this->url, 'addon', $this->get_slug() ) )->get_url();
}
/**
* @return string
*/
public function get_plugin_link() {
return $this->plugin_link;
}
/**
* Determines when the placeholder column is shown for a particular list screen.
*
* @param ListScreen $list_screen
*
* @return bool
*/
public function show_placeholder( ListScreen $list_screen ) {
return true;
}
}