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
|
|
|
* Provides methods for creating widgets. |
12
|
|
|
* |
13
|
|
|
* @abstract |
14
|
|
|
* @since 3.2.0 |
15
|
|
|
* @package AdminPageFramework |
16
|
|
|
* @subpackage Widget |
17
|
|
|
*/ |
18
|
|
|
abstract class AdminPageFramework_Widget extends AdminPageFramework_Widget_Controller { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Defines the class object structure type. |
22
|
|
|
* |
23
|
|
|
* This is used to create a property object as well as to define the form element structure. |
24
|
|
|
* |
25
|
|
|
* @since 3.2.0 |
26
|
|
|
* @since 3.7.0 Changed the name from `$_sFieldsType`. |
27
|
|
|
* @internal |
28
|
|
|
*/ |
29
|
|
|
protected $_sStructureType = 'widget'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The constructor of the class object. |
33
|
|
|
* |
34
|
|
|
* Registers necessary hooks and sets up internal properties. |
35
|
|
|
* |
36
|
|
|
* <h4>Example</h4> |
37
|
|
|
* <code> |
38
|
|
|
* new APF_Widget( __( 'Admin Page Framework', 'admin-page-framework-demo' ) ); // the widget title |
39
|
|
|
* new APF_Widget_CustomFieldTypes( __( 'APF - Advanced', 'admin-page-framework-demo' ) ); |
40
|
|
|
* new APF_Widget_Example( __( 'APF - GitHub Button', 'admin-page-framework-demo' ) ); |
41
|
|
|
* </code> |
42
|
|
|
* |
43
|
|
|
* @return void |
|
|
|
|
44
|
|
|
*/ |
45
|
|
|
public function __construct( $sWidgetTitle, $aWidgetArguments=array(), $sCapability='edit_theme_options', $sTextDomain='admin-page-framework' ) { |
46
|
|
|
|
47
|
|
|
if ( empty( $sWidgetTitle ) ) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
// Properties |
52
|
|
|
$_sProprtyClassName = isset( $this->aSubClassNames[ 'oProp' ] ) |
53
|
|
|
? $this->aSubClassNames[ 'oProp' ] |
54
|
|
|
: 'AdminPageFramework_Property_' . $this->_sStructureType; |
55
|
|
|
$this->oProp = new $_sProprtyClassName( |
56
|
|
|
$this, // caller object |
57
|
|
|
null, // the caller script path |
58
|
|
|
get_class( $this ), // class name |
59
|
|
|
$sCapability, // capability |
60
|
|
|
$sTextDomain, // text domain |
61
|
|
|
$this->_sStructureType // fields type |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$this->oProp->sWidgetTitle = $sWidgetTitle; |
65
|
|
|
$this->oProp->aWidgetArguments = $aWidgetArguments; |
66
|
|
|
|
67
|
|
|
parent::__construct( $this->oProp ); |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.