1 | <?php |
||
20 | class AdminPageFramework_Widget_Factory extends WP_Widget { |
||
1 ignored issue
–
show
|
|||
21 | |||
22 | /** |
||
23 | * Sets up internal properties. |
||
24 | * |
||
25 | * @since 3.2.0 |
||
26 | * @return void |
||
27 | */ |
||
28 | public function __construct( $oCaller, $sWidgetTitle, array $aArguments=array() ) { |
||
56 | |||
57 | /** |
||
58 | * Displays the widget contents in the front end. |
||
59 | * |
||
60 | * @since 3.2.0 |
||
61 | * @since 3.5.9 Changed the timing of the hooks (do_{...} and content_{...} ) to allow the user to decide |
||
62 | * whether the title should be visible or not depending on the content. |
||
63 | * @return void |
||
64 | */ |
||
65 | public function widget( $aArguments, $aFormData ) { |
||
91 | /** |
||
92 | * Returns the widget title. |
||
93 | * |
||
94 | * @since 3.5.7 |
||
95 | * @remark The user needs to add a field with the id, `title` to display a title. |
||
96 | * @remark In order to disable the title, add a field with the id `show_title` and if the value yields `false`, |
||
97 | * the title will not be displayed. |
||
98 | * @return string The widget title |
||
99 | */ |
||
100 | private function _getTitle( array $aArguments, array $aFormData ) { |
||
124 | |||
125 | /** |
||
126 | * Validates the submitted form data. |
||
127 | * |
||
128 | * @since 3.2.0 |
||
129 | * @return mixed The validated form data. The type should be an array but it is dealt by the framework user it will be unknown. |
||
130 | */ |
||
131 | public function update( $aSubmittedFormData, $aSavedFormData ) { |
||
145 | |||
146 | /** |
||
147 | * Constructs the widget form with the given saved form data. |
||
148 | * |
||
149 | * In widgets.php, this method is called multiple times per instance of the class defining the widget (widget model). |
||
150 | * It is called for the number of added widget instances via drag-and-drop in the UI |
||
151 | * of the widget model that the caller class defines. |
||
152 | * |
||
153 | * This means, the framework factory class has to renew the saved data every time this method is called. |
||
154 | * |
||
155 | * @return void |
||
156 | */ |
||
157 | public function form( $aFormData ) { |
||
188 | /** |
||
189 | * Calls the load() method of the caller factory object. |
||
190 | * |
||
191 | * Ensures it is called once per a page load. |
||
192 | * @since DEVVER |
||
193 | */ |
||
194 | private function _loadFrameworkFactory() { |
||
207 | |||
208 | /** |
||
209 | * |
||
210 | * @remark This one is tricky as the core widget factory method enclose this value in []. So when the framework field has a section, it must NOT end with ]. |
||
211 | * @since 3.5.7 Moved from `AdminPageFramework_FormField`. |
||
212 | * @since 3.6.0 Changed the name from `_replyToGetInputName`. |
||
213 | * @return string |
||
214 | */ |
||
215 | public function _replyToGetFieldName( /* $sNameAttribute, array $aField */ ) { |
||
229 | |||
230 | /** |
||
231 | * |
||
232 | * @since 3.6.0 |
||
233 | * @return string |
||
234 | */ |
||
235 | public function _replyToGetFieldInputName( /* $sNameAttribute, array $aField, $sIndex */ ) { |
||
255 | |||
256 | /** |
||
257 | * Returns the flat input name. |
||
258 | * |
||
259 | * A flat input name is a 'name' attribute value whose dimensional elements are delimited by the pile character. |
||
260 | * |
||
261 | * Instead of [] enclosing array elements, it uses the pipe(|) to represent the multi dimensional array key. |
||
262 | * This is used to create a reference to the submit field name to determine which button is pressed. |
||
263 | * |
||
264 | * @since 3.5.7 Moved from `AdminPageFramework_FormField`. |
||
265 | * @since 3.6.0 Changed the name from `_replyToGetFlatInputName()`. |
||
266 | * @return string |
||
267 | * @deprecated |
||
268 | */ |
||
269 | // protected function _replyToGetFlatFieldName( /* $sFlatInputName, array $aField */ ) { |
||
270 | // $_aParams = func_get_args() + array( null, null ); |
||
271 | // $aField = $_aParams[ 1 ]; |
||
1 ignored issue
–
show
|
|||
272 | |||
273 | |||
274 | // $_sSectionIndex = isset( $aField['section_id'], $aField['_section_index'] ) |
||
275 | // ? "|{$aField['_section_index']}" |
||
276 | // : ''; |
||
277 | // $sFlatInputName = $this->oCaller->isSectionSet( $aField ) |
||
278 | // ? "{$aField['section_id']}{$_sSectionIndex}|{$aField['field_id']}" |
||
279 | // : "{$aField['field_id']}"; |
||
280 | // return $sFlatInputName; |
||
281 | // } |
||
282 | |||
283 | /** |
||
284 | * Modifies the class Selector. |
||
285 | * |
||
286 | * @since 3.2.0 |
||
287 | * @remark currently not used |
||
288 | * @deprecated |
||
289 | */ |
||
290 | // public function _replyToAddClassSelector( $sClassSelectors ) { |
||
291 | |||
292 | // $sClassSelectors .= ' widefat'; |
||
293 | // return trim( $sClassSelectors ); |
||
1 ignored issue
–
show
|
|||
294 | |||
295 | // } |
||
296 | |||
297 | } |
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.