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 fields in the taxonomy page (edit-tags.php). |
12
|
|
|
* |
13
|
|
|
* @abstract |
14
|
|
|
* @since 3.0.0 |
15
|
|
|
* @package AdminPageFramework |
16
|
|
|
* @subpackage TaxonomyField |
17
|
|
|
* @extends AdminPageFramework_TaxonomyField_Controller |
18
|
|
|
*/ |
19
|
|
|
abstract class AdminPageFramework_TaxonomyField extends AdminPageFramework_TaxonomyField_Controller { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Defines the class object structure type. |
23
|
|
|
* |
24
|
|
|
* This is used to create a property object as well as to define the form element structure. |
25
|
|
|
* |
26
|
|
|
* @since 3.0.0 |
27
|
|
|
* @since 3.7.0 Changed the name from `$_sFieldsType`. Changed the default value from `taxonomy`. |
28
|
|
|
* @internal |
29
|
|
|
*/ |
30
|
|
|
protected $_sStructureType = 'taxonomy_field'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructs the class object instance of AdminPageFramework_TaxonomyField. |
34
|
|
|
* |
35
|
|
|
* Handles setting up properties and hooks. |
36
|
|
|
* |
37
|
|
|
* <h4>Examples</h4> |
38
|
|
|
* <code> |
39
|
|
|
* new APF_TaxonomyField( 'apf_sample_taxonomy' ); // taxonomy slug |
40
|
|
|
* </code> |
41
|
|
|
* |
42
|
|
|
* @since 3.0.0 |
43
|
|
|
* @param array|string The taxonomy slug(s). If multiple slugs need to be passed, enclose them in an array and pass the array. |
44
|
|
|
* @param string The option key used for the options table to save the data. By default, the instantiated class name will be applied. |
45
|
|
|
* @param string The access rights. Default: `manage_options`. |
46
|
|
|
* @param string The text domain. Default: `admin-page-framework`. |
47
|
|
|
* @return void |
|
|
|
|
48
|
|
|
*/ |
49
|
|
|
function __construct( $asTaxonomySlug, $sOptionKey='', $sCapability='manage_options', $sTextDomain='admin-page-framework' ) { |
|
|
|
|
50
|
|
|
|
51
|
|
|
if ( empty( $asTaxonomySlug ) ) { |
52
|
|
|
return; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Properties |
56
|
|
|
$_sProprtyClassName = isset( $this->aSubClassNames[ 'oProp' ] ) |
57
|
|
|
? $this->aSubClassNames[ 'oProp' ] |
58
|
|
|
: 'AdminPageFramework_Property_' . $this->_sStructureType; |
59
|
|
|
$this->oProp = new $_sProprtyClassName( |
60
|
|
|
$this, |
61
|
|
|
get_class( $this ), |
62
|
|
|
$sCapability, |
63
|
|
|
$sTextDomain, |
64
|
|
|
$this->_sStructureType |
65
|
|
|
); |
66
|
|
|
$this->oProp->aTaxonomySlugs = ( array ) $asTaxonomySlug; |
67
|
|
|
$this->oProp->sOptionKey = $sOptionKey |
68
|
|
|
? $sOptionKey |
69
|
|
|
: $this->oProp->sClassName; |
70
|
|
|
|
71
|
|
|
parent::__construct( $this->oProp ); |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
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.