Completed
Branch master (bf4987)
by Michael
03:55
created

AdminPageFramework_Property_widget   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 129
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 1
A getFormArguments() 0 7 1
1
<?php
2
/**
3
 * Admin Page Framework
4
 * 
5
 * http://en.michaeluno.jp/admin-page-framework/
6
 * Copyright (c) 2013-2017 Michael Uno; Licensed MIT
7
 * 
8
 */
9
10
/**
11
 * Provides the space to store the shared properties for custom post types.
12
 * 
13
 * This class stores various types of values. This is used to encapsulate properties so that it helps to avoid naming conflicts.
14
 * 
15
 * @since       3.2.0
16
 * @package     AdminPageFramework/Factory/Widget/Property
17
 * @extends     AdminPageFramework_Property_Base
18
 * @internal
19
 */
20
class AdminPageFramework_Property_widget extends AdminPageFramework_Property_Base {
21
22
    /**
23
     * Defines the property type.
24
     * @remark      Setting the property type helps to check whether some components are loaded such as scripts that can be reused per a class type basis.
25
     * @since       3.2.0
26
     * @internal
27
     */
28
    public $_sPropertyType = 'widget';
29
30
    /**
31
     * Indicates the fields type.
32
     * 
33
     * @since       3.2.0
34
     * @internal
35
     */
36
    public $sStructureType = 'widget';
37
38
    /**
39
     * Stores the extended instantiated class name.
40
     * 
41
     * @since       3.2.0
42
     * @var         string
43
     * @access      public
44
     */     
45
    public $sClassName = '';
46
47
    /**
48
     * Stores the caller script path.
49
     * 
50
     * @since 3.2.0
51
     * @var string
52
     * @access public
53
     */         
54
    public $sCallerPath = '';
55
56
    /**
57
     * Stores the widget title.
58
     * 
59
     * @since   3.2.0
60
     * @todo    3.7.10      Now the base property supports $sTitle property so maybe use that and deprecated this item.
61
     */
62
    public $sWidgetTitle = '';
63
64
    /**
65
     * Stores the widget arguments.
66
     * 
67
     * Structure:
68
     * array(
69
     *  'classname'     => '...',
70
     *  'description'   => __( '...', '...' ),
71
     * )
72
     * 
73
     * @since       3.2.0
74
     */
75
    public $aWidgetArguments = array();    
76
77
    /**
78
     * Determines whether the widget title should be displayed in the front end.
79
     * 
80
     * By default when the 'title' field ID exists and has a value, the framework displays the title. 
81
     * This property value can disable this behaviour by setting it to false.
82
     * 
83
     * @since       3.5.7
84
     */
85
    public $bShowWidgetTitle = true;
86
87
    /**
88
     * Stores the widget object.
89
     * 
90
     * @since       3.5.9
91
     */ 
92
    public $oWidget;
93
94
    /**
95
     * Indicates the action hook to display setting notices.
96
     * @since       3.7.9
97
     */
98
    public $sSettingNoticeActionHook = '';    
99
    
100
    /**
101
     * Stores the action hook name that gets triggered when the form registration is performed.
102
     * 'admin_page' and 'network_admin_page' will use a custom hook for it.
103
     * @since       3.7.0
104
     * @access      pulbic      Called externally.
105
     */
106
    // public $_sFormRegistrationHook = 'admin_enqueue_scripts'; 
107
    // public $_sFormRegistrationHook = ''; 
108
    
109
    /**
110
     * Sets up properties.
111
     * @since       3.7.0
112
     */
113
    public function __construct( $oCaller, $sCallerPath, $sClassName, $sCapability='manage_options', $sTextDomain='admin-page-framework', $sStructureType ) {
114
115
        // 3.7.0+
116
        $this->_sFormRegistrationHook   = 'load_' . $sClassName; 
117
        
118
        // 3.7.9+ - setting a custom action hook for admin notices prevents the form object from being instantiated unnecessarily.
119
        $this->sSettingNoticeActionHook = 'load_' . $sClassName; 
120
121
        parent::__construct(
122
            $oCaller,
123
            $sCallerPath,
124
            $sClassName,
125
            $sCapability, 
126
            $sTextDomain,
127
            $sStructureType
128
        );
129
130
    }
131
132
    /**
133
     * Overrides the parent method.
134
     * No need to set `admin_init` to the `action_hook_form_registration` element.
135
     * Otherwise, the widgets become not be updated visually, which is done in Ajax.
136
     *
137
     * @return      array
138
     * @since       3.8.14
139
     */
140
    public function getFormArguments() {
141
        return array(
142
            'caller_id'                         => $this->sClassName,
143
            'structure_type'                    => $this->_sPropertyType,
144
            'action_hook_form_registration'     => $this->_sFormRegistrationHook,
145
        ) + $this->aFormArguments;
146
    }
147
    
148
}
149