1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Admin Page Framework Loader |
4
|
|
|
* |
5
|
|
|
* Demonstrates the usage of Admin Page Framework. |
6
|
|
|
* |
7
|
|
|
* http://en.michaeluno.jp/admin-page-framework/ |
8
|
|
|
* Copyright (c) 2013-2015 Michael Uno; Licensed GPLv2 |
9
|
|
|
* |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Adds a tab of the set page to the loader plugin. |
14
|
|
|
* |
15
|
|
|
* @since 3.5.0 |
16
|
|
|
* @since 3.5.3 Extends `AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase`. |
17
|
|
|
* @extends AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase |
18
|
|
|
*/ |
19
|
|
|
class AdminPageFrameworkLoader_AdminPage_Help_Tip extends AdminPageFrameworkLoader_AdminPage_Tab_ReadMeBase { |
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Triggered when the tab is loaded. |
23
|
|
|
*/ |
24
|
|
|
public function replyToLoadTab( $oAdminPage ) { |
25
|
|
|
|
26
|
|
|
$_aItems = $this->getContentsByHeader( $this->getReadmeContents(), 4 ); |
27
|
|
|
$_iLastIndex = count( $_aItems ) - 1; |
28
|
|
|
foreach( $_aItems as $_iIndex => $_aContent ) { |
29
|
|
|
|
30
|
|
|
$_oParser = new AdminPageFramework_WPReadmeParser( $_aContent[ 1 ] ); |
31
|
|
|
$_sContent = $_oParser->get(); |
32
|
|
|
$oAdminPage->addSettingSections( |
33
|
|
|
$this->sPageSlug, // the target page slug |
34
|
|
|
array( |
35
|
|
|
'section_id' => 'tips_' . $_iIndex, |
36
|
|
|
'title' => $_aContent[ 0 ], |
37
|
|
|
'collapsible' => array( |
38
|
|
|
'toggle_all_button' => $_iLastIndex === $_iIndex |
39
|
|
|
? array( 'bottom-right' ) |
40
|
|
|
: ( 0 === $_iIndex |
41
|
|
|
? array( 'top-right' ) |
42
|
|
|
: false |
43
|
|
|
), |
44
|
|
|
), |
45
|
|
|
'content' => $_sContent, |
46
|
|
|
|
47
|
|
|
) |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
/** |
54
|
|
|
* @return string |
55
|
|
|
*/ |
56
|
|
|
private function getReadMeContents() { |
57
|
|
|
return $this->_getReadmeContents( |
58
|
|
|
AdminPageFrameworkLoader_Registry::$sDirPath . '/readme.txt', // source path |
59
|
|
|
'', // TOC title |
60
|
|
|
array( 'Other Notes' ) // sections |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
|
|
|
|
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.