1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Admin Page Framework |
4
|
|
|
* |
5
|
|
|
* http://en.michaeluno.jp/admin-page-framework/ |
6
|
|
|
* Copyright (c) 2013-2015 Michael Uno; Licensed MIT |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Provides methods to generate tool tip outputs. |
12
|
|
|
* |
13
|
|
|
* @package AdminPageFramework |
14
|
|
|
* @subpackage Form |
15
|
|
|
* @since DEVVER |
16
|
|
|
* @internal |
17
|
|
|
*/ |
18
|
|
|
class AdminPageFramework_Form_View___ToolTip extends AdminPageFramework_Form_View___Section_Base { |
|
|
|
|
19
|
|
|
|
20
|
|
|
public $aArguments = array( |
21
|
|
|
'attributes' => array(), // attributes |
22
|
|
|
'icon' => null, // the icon output |
23
|
|
|
'title' => null, |
24
|
|
|
'content' => null, |
25
|
|
|
); |
26
|
|
|
|
27
|
|
|
public $sTitleElementID; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Sets up properties. |
31
|
|
|
* @since 3.6.0 |
32
|
|
|
* @since DEVVER Changed the parameter structure. |
33
|
|
|
*/ |
34
|
|
|
public function __construct( /* $aArguments, $sTitleElementID */ ) { |
35
|
|
|
|
36
|
|
|
$_aParameters = func_get_args() + array( |
37
|
|
|
$this->aArguments, |
38
|
|
|
$this->sTitleElementID, |
39
|
|
|
); |
40
|
|
|
|
41
|
|
|
if ( is_string( $_aParameters[ 0 ] ) ) { |
42
|
|
|
$this->aArguments[ 'content' ] = $_aParameters[ 0 ]; |
43
|
|
|
} else { |
44
|
|
|
$this->aArguments = $this->getAsArray( $_aParameters[ 0 ] ) + $this->aArguments; |
45
|
|
|
} |
46
|
|
|
$this->sTitleElementID = $_aParameters[ 1 ]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Returns HTML formatted description blocks by the given description definition. |
51
|
|
|
* |
52
|
|
|
* @return string The output. |
53
|
|
|
*/ |
54
|
|
|
public function get() { |
55
|
|
|
if ( ! $this->aArguments[ 'content' ] ) { |
56
|
|
|
return ''; |
57
|
|
|
} |
58
|
|
|
$_sHref = esc_attr( "#{$this->sTitleElementID}" ); |
59
|
|
|
return '' |
60
|
|
|
. "<a href='{$_sHref}' class='admin-page-framework-form-tooltip'>" |
61
|
|
|
. $this->_getTipLinkIcon() |
62
|
|
|
. "<span class='admin-page-framework-form-tooltip-content'>" |
63
|
|
|
. $this->_getTipTitle() |
64
|
|
|
. $this->_getDescriptions() |
65
|
|
|
. "</a>" |
66
|
|
|
|
67
|
|
|
; |
68
|
|
|
} |
69
|
|
|
/** |
70
|
|
|
* @since DEVVER |
71
|
|
|
* @return string |
72
|
|
|
*/ |
73
|
|
|
private function _getTipLinkIcon() { |
|
|
|
|
74
|
|
|
|
75
|
|
|
if ( isset( $this->aArguments[ 'icon' ] ) ) { |
76
|
|
|
return $this->aArguments[ 'icon' ]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
if ( version_compare( $GLOBALS['wp_version'], '3.8', '>=' ) ) { |
80
|
|
|
return "<span class='dashicons dashicons-editor-help'></span>"; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return '[ ? ]'; |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
/** |
87
|
|
|
* @since DEVVER |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
private function _getTipTitle() { |
|
|
|
|
91
|
|
|
if ( isset( $this->aArguments[ 'title' ] ) ) { |
92
|
|
|
return "<span class='admin-page-framework-form-tool-tip-title'>" |
93
|
|
|
. $this->aArguments[ 'title' ] |
94
|
|
|
. "</span>"; |
95
|
|
|
} |
96
|
|
|
return ''; |
97
|
|
|
} |
98
|
|
|
/** |
99
|
|
|
* @since DEVVER |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
private function _getDescriptions() { |
|
|
|
|
103
|
|
|
|
104
|
|
|
if ( isset( $this->aArguments[ 'content' ] ) ) { |
105
|
|
|
return "<span class='admin-page-framework-form-tool-tip-description'>" |
106
|
|
|
|
107
|
|
|
. $this->aArguments[ 'content' ] |
108
|
|
|
. "</span>" |
109
|
|
|
; |
110
|
|
|
} |
111
|
|
|
return ''; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
} |
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.