class-help-center-item.php
1.93 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
<?php
/**
* @package WPSEO\Admin\Options\Tabs
*/
/**
* Class WPSEO_Help_Center_Item
*/
class WPSEO_Help_Center_Item {
/** @var string Identifier for this tab. */
private $identifier;
/** @var string Label to display. */
private $label;
/** @var string The dashicon classname to display in front of the label. */
private $dashicon;
/** @var array Optional arguments. */
private $args = array();
/**
* WPSEO_Help_Center_Item constructor.
*
* @param string $identifier Unique identifier for this tab.
* @param string $label Label to display.
* @param array $args Optional. Settings for this tab.
* @param string $dashicon Optional. The classname of the dahsicon to put in front of the label.
*/
public function __construct( $identifier, $label, $args = array(), $dashicon = '' ) {
$this->identifier = $identifier;
$this->label = $label;
$this->dashicon = $dashicon;
$this->args = $args;
}
/**
* Get the label.
*
* @return string
*/
public function get_label() {
return $this->label;
}
/**
* Get the identifier.
*
* @return string
*/
public function get_identifier() {
return $this->identifier;
}
/**
* Get the dashicon.
*
* @return string
*/
public function get_dashicon() {
return $this->dashicon;
}
/**
* Get the content of this tab.
*
* @return mixed|string
*/
public function get_content() {
if ( ! empty( $this->args['content'] ) ) {
return $this->args['content'];
}
if ( ! empty( $this->args['callback'] ) ) {
return call_user_func_array( $this->args['callback'], array( $this ) );
}
if ( ! empty( $this->args['view'] ) ) {
$view = $this->args['view'];
if ( substr( $view, - 4 ) === '.php' ) {
$view = substr( $view, 0, - 4 );
}
if ( ! empty( $this->args['view_arguments'] ) ) {
extract( $this->args['view_arguments'] );
}
include WPSEO_PATH . 'admin/views/' . $view . '.php';
}
return '';
}
}