1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Admin Page Framework |
4
|
|
|
* |
5
|
|
|
* http://en.michaeluno.jp/admin-page-framework/ |
6
|
|
|
* Copyright (c) 2013-2016 Michael Uno; Licensed MIT |
7
|
|
|
* |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Stores properties of a network admin object. |
12
|
|
|
* |
13
|
|
|
* @since 3.1.0 |
14
|
|
|
* @package AdminPageFramework |
15
|
|
|
* @subpackage Property |
16
|
|
|
* @extends AdminPageFramework_Property_admin_page |
17
|
|
|
* @internal |
18
|
|
|
*/ |
19
|
|
|
class AdminPageFramework_Property_network_admin_page extends AdminPageFramework_Property_admin_page { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Defines the property type. |
23
|
|
|
* |
24
|
|
|
* @since 3.1.0 |
25
|
|
|
* @internal |
26
|
|
|
*/ |
27
|
|
|
public $_sPropertyType = 'network_admin_page'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Defines the fields type. |
31
|
|
|
* |
32
|
|
|
* @since 3.1.0 |
33
|
|
|
*/ |
34
|
|
|
public $sStructureType = 'network_admin_page'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Indicates the action hook to display setting notices. |
38
|
|
|
* @since 3.7.9 |
39
|
|
|
*/ |
40
|
|
|
public $sSettingNoticeActionHook = 'network_admin_notices'; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Returns the option array. |
44
|
|
|
* |
45
|
|
|
* @since 3.1.0 |
46
|
|
|
* @internal |
47
|
|
|
*/ |
48
|
|
|
protected function _getOptions() { |
|
|
|
|
49
|
|
|
|
50
|
|
|
return $this->addAndApplyFilter( |
51
|
|
|
$this->getElement( // the caller object |
52
|
|
|
$GLOBALS, |
53
|
|
|
array( 'aAdminPageFramework', 'aPageClasses', $this->sClassName ) |
54
|
|
|
), |
55
|
|
|
'options_' . $this->sClassName, // options_{instantiated class name} |
56
|
|
|
$this->sOptionKey |
57
|
|
|
? get_site_option( $this->sOptionKey, array() ) |
58
|
|
|
: array() |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Utility methods |
65
|
|
|
*/ |
66
|
|
|
/** |
67
|
|
|
* Saves the options into the database. |
68
|
|
|
* |
69
|
|
|
* @since 3.1.0 |
70
|
|
|
* @since 3.1.1 Made it return a boolean value. |
71
|
|
|
* @return boolean True if saved; otherwise, false. |
72
|
|
|
*/ |
73
|
|
|
public function updateOption( $aOptions=null ) { |
74
|
|
|
|
75
|
|
|
if ( $this->_bDisableSavingOptions ) { |
76
|
|
|
return; |
77
|
|
|
} |
78
|
|
|
return update_site_option( |
79
|
|
|
$this->sOptionKey, |
80
|
|
|
$aOptions !== null |
81
|
|
|
? $aOptions |
82
|
|
|
: $this->aOptions |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: