@@ -109,7 +109,7 @@ |
||
109 | 109 | * Converts bytes to HR. |
110 | 110 | * |
111 | 111 | * @access private |
112 | - * @param mixed $bytes |
|
112 | + * @param mixed $nBytes |
|
113 | 113 | * @remark This is influenced by the work of Mike Jolley. |
114 | 114 | * @see http://mikejolley.com/projects/wp-page-load-stats/ |
115 | 115 | */ |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct( $oProp, $oMsg ) { |
30 | 30 | |
31 | - if ( $oProp->bIsAdminAjax || ! $oProp->bIsAdmin ) { |
|
31 | + if ( $oProp->bIsAdminAjax || !$oProp->bIsAdmin ) { |
|
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
35 | - if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { |
|
35 | + if ( !defined( 'WP_DEBUG' ) || !WP_DEBUG ) { |
|
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | return $sFooterHTML |
79 | 79 | . "<div id='admin-page-framework-page-load-stats'>" |
80 | 80 | . "<ul>" |
81 | - . "<li>" . sprintf( $this->oMsg->get( 'queries_in_seconds' ), $_nQueryCount, $_nSeconds ) . "</li>" |
|
82 | - . "<li>" . sprintf( $this->oMsg->get( 'out_of_x_memory_used' ), $_nMemoryUsage, $_nMemoryLimit, round( ( $_nMemoryUsage / $_nMemoryLimit ), 2 ) * 100 . '%' ) . "</li>" |
|
83 | - . "<li>" . sprintf( $this->oMsg->get( 'peak_memory_usage' ), $_nMemoryPeakUsage ) . "</li>" |
|
84 | - . "<li>" . sprintf( $this->oMsg->get( 'initial_memory_usage' ), $_sInitialMemoryUsage ) . "</li>" |
|
81 | + . "<li>".sprintf( $this->oMsg->get( 'queries_in_seconds' ), $_nQueryCount, $_nSeconds )."</li>" |
|
82 | + . "<li>".sprintf( $this->oMsg->get( 'out_of_x_memory_used' ), $_nMemoryUsage, $_nMemoryLimit, round( ( $_nMemoryUsage / $_nMemoryLimit ), 2 ) * 100.'%' )."</li>" |
|
83 | + . "<li>".sprintf( $this->oMsg->get( 'peak_memory_usage' ), $_nMemoryPeakUsage )."</li>" |
|
84 | + . "<li>".sprintf( $this->oMsg->get( 'initial_memory_usage' ), $_sInitialMemoryUsage )."</li>" |
|
85 | 85 | . "</ul>" |
86 | 86 | . "</div>"; |
87 | 87 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | private function _convertToNumber( $nSize ) { |
101 | 101 | |
102 | - $_nReturn = substr( $nSize, 0, -1 ); |
|
103 | - switch( strtoupper( substr( $nSize, -1 ) ) ) { |
|
102 | + $_nReturn = substr( $nSize, 0, -1 ); |
|
103 | + switch ( strtoupper( substr( $nSize, -1 ) ) ) { |
|
104 | 104 | case 'P': |
105 | 105 | $_nReturn *= 1024; |
106 | 106 | case 'T': |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $_nLog = log( $nBytes, 1024 ); |
130 | 130 | $_iPower = ( int ) $_nLog; |
131 | 131 | $_iSize = pow( 1024, $_nLog - $_iPower ); |
132 | - return $_iSize . $_aUnits[ $_iPower ]; |
|
132 | + return $_iSize.$_aUnits[ $_iPower ]; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | */ |
64 | 64 | public function _replyToGetPageLoadInfo( $sFooterHTML ) { |
65 | 65 | |
66 | - if ( self::$_bLoadedPageLoadInfo ) { |
|
66 | + if ( self::$_bLoadedPageLoadInfo ) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | self::$_bLoadedPageLoadInfo = true; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @access public |
188 | 188 | * @remark The actual registration will be performed in the `_replyToRegisterSettings()` method with the `admin_menu` hook. |
189 | 189 | * @remark The `$oForm` property should be created in each extended class. |
190 | - * @param array|string $aSection the section array. If a string is passed, it is considered as a target page slug that will be used as a page slug element from the next call so that the element can be omitted. |
|
190 | + * @param array|string $aSectionset the section array. If a string is passed, it is considered as a target page slug that will be used as a page slug element from the next call so that the element can be omitted. |
|
191 | 191 | * <h4>Section Definition Array</h4> |
192 | 192 | * <ul> |
193 | 193 | * <li>**section_id** - (string) the section ID. Avoid using non-alphabetic characters except underscore and numbers.</li> |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @since 3.0.0 The scope changed to public to indicate the users will use. |
300 | 300 | * @return void |
301 | 301 | * @remark The $oForm property should be created in each extended class. |
302 | - * @param array|string $asField A field definition array or a string of the target section id. |
|
302 | + * @param array|string $asFieldset A field definition array or a string of the target section id. |
|
303 | 303 | * <h4>Built-in Field Types</h4> |
304 | 304 | * <ul> |
305 | 305 | * <li>**text** - a normal field to enter text input.</li> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return array|string |
44 | 44 | * @since DEVVER |
45 | 45 | */ |
46 | - public function getMessage( $sKey='' ) { |
|
46 | + public function getMessage( $sKey = '' ) { |
|
47 | 47 | return $this->oMsg->get( $sKey ); |
48 | 48 | } |
49 | 49 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return array The array holing the queued items. |
64 | 64 | * @internal |
65 | 65 | */ |
66 | - public function enqueueStyles( $aSRCs, $_vArg2=null ) {} |
|
66 | + public function enqueueStyles( $aSRCs, $_vArg2 = null ) {} |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Enqueues a style of the given source. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return string The style handle ID. If the passed url is not a valid url string, an empty string will be returned. |
84 | 84 | * @internal |
85 | 85 | */ |
86 | - public function enqueueStyle( $sSRC, $_vArg2=null ) {} |
|
86 | + public function enqueueStyle( $sSRC, $_vArg2 = null ) {} |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Enqueues scripts by the given sources. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return array The array holding the queued items. |
105 | 105 | * @internal |
106 | 106 | */ |
107 | - public function enqueueScripts( $aSRCs, $_vArg2=null ) {} |
|
107 | + public function enqueueScripts( $aSRCs, $_vArg2 = null ) {} |
|
108 | 108 | /** |
109 | 109 | * Enqueues a script by the given source. |
110 | 110 | * |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return string The script handle ID. If the passed url is not a valid url string, an empty string will be returned. |
137 | 137 | * @internal |
138 | 138 | */ |
139 | - public function enqueueScript( $sSRC, $_vArg2=null ) {} |
|
139 | + public function enqueueScript( $sSRC, $_vArg2 = null ) {} |
|
140 | 140 | |
141 | 141 | /* |
142 | 142 | * Help Pane |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @since 2.1.0 |
155 | 155 | * @remark This method just adds the given text into the class property. The actual registration will be performed with the `replyToRegisterHelpTabTextForMetaBox()` method. |
156 | 156 | */ |
157 | - public function addHelpText( $sHTMLContent, $sHTMLSidebarContent="" ) { |
|
157 | + public function addHelpText( $sHTMLContent, $sHTMLSidebarContent = "" ) { |
|
158 | 158 | if ( method_exists( $this->oHelpPane, '_addHelpText' ) ) { |
159 | 159 | $this->oHelpPane->_addHelpText( $sHTMLContent, $sHTMLSidebarContent ); |
160 | 160 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function addSettingSections( /* $aSection1, $aSection2=null, $_and_more=null */ ) { |
192 | 192 | |
193 | - foreach( func_get_args() as $_asSectionset ) { |
|
193 | + foreach ( func_get_args() as $_asSectionset ) { |
|
194 | 194 | $this->addSettingSection( $_asSectionset ); |
195 | 195 | } |
196 | 196 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function addSettingSection( $aSectionset ) { |
263 | 263 | |
264 | - if ( ! is_array( $aSectionset ) ) { |
|
264 | + if ( !is_array( $aSectionset ) ) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @return void |
295 | 295 | */ |
296 | 296 | public function addSettingFields( /* $aField1, $aField2=null, $_and_more=null */ ) { |
297 | - foreach( func_get_args() as $_aFieldset ) { |
|
297 | + foreach ( func_get_args() as $_aFieldset ) { |
|
298 | 298 | $this->addSettingField( $_aFieldset ); |
299 | 299 | } |
300 | 300 | } |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @param boolean $bOverride (optional) If true, only one message will be shown in the next page load. false: do not override when there is a message of the same id. true: override the previous one. |
672 | 672 | * @return void |
673 | 673 | */ |
674 | - public function setSettingNotice( $sMessage, $sType='error', $asAttributes=array(), $bOverride=true ) { |
|
674 | + public function setSettingNotice( $sMessage, $sType = 'error', $asAttributes = array(), $bOverride = true ) { |
|
675 | 675 | $this->oForm->setSubmitNotice( |
676 | 676 | $sMessage, |
677 | 677 | $sType, |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * @param string $sType If empty, the method will check if a message exists in all types. Otherwise, it checks the existence of a message of the specified type. |
691 | 691 | * @return boolean True if a setting notice is set; otherwise, false. |
692 | 692 | */ |
693 | - public function hasSettingNotice( $sType='' ) { |
|
693 | + public function hasSettingNotice( $sType = '' ) { |
|
694 | 694 | return $this->oForm->hasSubmitNotice( $sType ); |
695 | 695 | } |
696 | 696 |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | public function addSettingSections( /* $aSection1, $aSection2=null, $_and_more=null */ ) { |
171 | 171 | |
172 | - foreach( func_get_args() as $_asSectionset ) { |
|
172 | + foreach( func_get_args() as $_asSectionset ) { |
|
173 | 173 | $this->addSettingSection( $_asSectionset ); |
174 | 174 | } |
175 | 175 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function addSettingSection( $aSectionset ) { |
240 | 240 | |
241 | - if ( ! is_array( $aSectionset ) ) { |
|
241 | + if ( ! is_array( $aSectionset ) ) { |
|
242 | 242 | return; |
243 | 243 | } |
244 | 244 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return void |
272 | 272 | */ |
273 | 273 | public function addSettingFields( /* $aField1, $aField2=null, $_and_more=null */ ) { |
274 | - foreach( func_get_args() as $_aFieldset ) { |
|
274 | + foreach( func_get_args() as $_aFieldset ) { |
|
275 | 275 | $this->addSettingField( $_aFieldset ); |
276 | 276 | } |
277 | 277 | } |
@@ -291,18 +291,18 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | - * Adds form fields. |
|
295 | - * |
|
296 | - * It inserts the given field definition arrays into the class property and later they are parsed when fields are registered. The field definition array requires specific keys. Refer to the parameter section of this method. |
|
297 | - * |
|
298 | - * @since 2.0.0 |
|
299 | - * @since 3.5.3 Removed the parameter declarations as they are caught with the func_get_args(). |
|
300 | - * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three. |
|
301 | - * @param array the field definition array. |
|
302 | - * @param array (optional) another field array. |
|
303 | - * @param array (optional) add more field arrays to the next parameters as many as necessary. |
|
304 | - * @return void |
|
305 | - */ |
|
294 | + * Adds form fields. |
|
295 | + * |
|
296 | + * It inserts the given field definition arrays into the class property and later they are parsed when fields are registered. The field definition array requires specific keys. Refer to the parameter section of this method. |
|
297 | + * |
|
298 | + * @since 2.0.0 |
|
299 | + * @since 3.5.3 Removed the parameter declarations as they are caught with the func_get_args(). |
|
300 | + * @remark Accepts variadic parameters; the number of accepted parameters are not limited to three. |
|
301 | + * @param array the field definition array. |
|
302 | + * @param array (optional) another field array. |
|
303 | + * @param array (optional) add more field arrays to the next parameters as many as necessary. |
|
304 | + * @return void |
|
305 | + */ |
|
306 | 306 | public function addSettingFields( /* $aField1, $aField2=null, $_and_more=null */ ) { |
307 | 307 | foreach( func_get_args() as $_aFieldset ) { |
308 | 308 | $this->addSettingField( $_aFieldset ); |
@@ -333,158 +333,158 @@ discard block |
||
333 | 333 | * @return void |
334 | 334 | * @remark The $oForm property should be created in each extended class. |
335 | 335 | * @param array|string $asField A field definition array or a string of the target section id. |
336 | - * <h4>Built-in Field Types</h4> |
|
337 | - * <ul> |
|
338 | - * <li>[text](./class-AdminPageFramework_FieldType_text.html) - a normal field to enter short text input.</li> |
|
339 | - * <li>[password](./class-AdminPageFramework_FieldType_text.html) - a masked text input field.</li> |
|
340 | - * <li>[textarea](./class-AdminPageFramework_FieldType_textarea.html) - a text input field with multiple lines. It supports rich text editors.</li> |
|
341 | - * <li>[radio](./class-AdminPageFramework_FieldType_radio.html) - a set of radio buttons that lets the user pick an option.</li> |
|
342 | - * <li>[checkbox](./class-AdminPageFramework_FieldType_checkbox.html) - a check box that lets the user enable/disable an item.</li> |
|
343 | - * <li>[select](./class-AdminPageFramework_FieldType_select.html) - a drop-down list that lest the user pick one or more item(s) from a list.</li> |
|
344 | - * <li>[hidden](./class-AdminPageFramework_FieldType_hidden.html) - a field with invisible input values.</li> |
|
345 | - * <li>[file](./class-AdminPageFramework_FieldType_file.html) - a file uploader that lets the user upload files.</li> |
|
346 | - * <li>[image](./class-AdminPageFramework_FieldType_image.html) - a text field with an image uploader that lets the user set the image URL.</li> |
|
347 | - * <li>[media](./class-AdminPageFramework_FieldType_media.html) - a text field with a media uploader that lets the user set the file URL.</li> |
|
348 | - * <li>[color](./class-AdminPageFramework_FieldType_color.html) - a text field with a color picker.</li> |
|
349 | - * <li>[submit](./class-AdminPageFramework_FieldType_submit.html) - a submit button that lets the user send the form.</li> |
|
350 | - * <li>[export](./class-AdminPageFramework_FieldType_export.html) - a custom submit field that lets the user export stored data.</li> |
|
351 | - * <li>[import](./class-AdminPageFramework_FieldType_import.html) - a custom combination field of file and submit fields that let the user import data.</li> |
|
352 | - * <li>[posttype](./class-AdminPageFramework_FieldType_posttype.html) - a check-list of post types enabled on the site.</li> |
|
353 | - * <li>[taxonomy](./class-AdminPageFramework_FieldType_taxonomy.html) - a set of check-lists of taxonomies enabled on the site in a tabbed box.</li> |
|
354 | - * <li>[size](./class-AdminPageFramework_FieldType_size.html) - a combination field of the text and the select fields that let the user set sizes with a selectable unit.</li> |
|
355 | - * <li>[section_title](./class-AdminPageFramework_FieldType_section_title.html) - [3.0.0+] a text field type that will be placed in the section title so that it lets the user set the section title. Note that only one field with this field type is allowed per a section.</li> |
|
356 | - * <li>[system](./class-AdminPageFramework_FieldType_system.html) - [3.3.0+] a custom text area field that displays the system information including the PHP settings, the framework version, MySQL version etc.</li> |
|
357 | - * <li>[inline_mixed](./class-AdminPageFramework_FieldType_inline_mixed.html) - [3.8.0+] a field that include inner fields with different field types. </li> |
|
358 | - * </ul> |
|
359 | - * <h4>Field Definition Array</h4> |
|
360 | - * <ul> |
|
361 | - * <li>**field_id** - (required, string) the field ID. Avoid using non-alphabetic characters except underscore and numbers.</li> |
|
362 | - * <li>**type** - (optional, string) the type of the field. The supported types are listed below. When creating nested fields, this argument can be omitted.</li> |
|
363 | - * <li>**section_id** - (optional, string) the section ID that the field belongs to. If not set, the internal `_default` section ID will be assigned.</li> |
|
364 | - * <li>**title** - (optional, string) the title of the section.</li> |
|
365 | - * <li>**description** - (optional, string) the description of the field which is inserted into the after the input field tag.</li> |
|
366 | - * <li>**tip** - (optional, string) the tip for the field which is displayed when the mouse is hovered over the field title.</li> |
|
367 | - * <li>**capability** - (optional, string) the <a href="http://codex.wordpress.org/Roles_and_Capabilities">access level</a> of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.</li> |
|
368 | - * <li>**error_message** - (optional, string) the error message to display above the input field.</li> |
|
369 | - * <li>**before_field** - (optional, string) the HTML string to insert before the input field output.</li> |
|
370 | - * <li>**after_field** - (optional, string) the HTML string to insert after the input field output.</li> |
|
371 | - * <li>**if** - (optional, boolean) if the passed value is false, the section will not be registered.</li> |
|
372 | - * <li>**order** - (optional, integer) the order number of the section. The higher the number is, the lower the position it gets.</li> |
|
373 | - * <li>**label** - (optional, string) the text label(s) associated with and displayed along with the input field. Some input types can ignore this key.</li> |
|
374 | - * <li>**default** - (optional, string|array) the default value(s) assigned to the input tag's value attribute.</li> |
|
375 | - * <li>**value** - (optional, string|array) the value(s) assigned to the input tag's `value` attribute to override the default and the stored value.</li> |
|
376 | - * <li>**delimiter** - (optional, string) the HTML string that delimits multiple elements. This is available if the <var>label</var> key is passed as array. It will be enclosed in inline-block elements so the passed HTML string should not contain block elements.</li> |
|
377 | - * <li>**before_input** - (optional, string) the HTML string inserted right before the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li> |
|
378 | - * <li>**after_input** - (optional, string) the HTML string inserted right after the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li> |
|
379 | - * <li>**label_min_width** - (optional, string) the inline style property of the `min-width` of the label tag for the field. If the unit is not specified, 'px' is applied. Default: `120`. e.g. `100%`</li> |
|
380 | - * <li>**help** - (optional, string) the help description added to the contextual help tab.</li> |
|
381 | - * <li>**help_aside** - (optional, string) the additional help description for the side bar of the contextual help tab.</li> |
|
382 | - * <li>**repeatable** - [3.0.0+] (optional, array|boolean) whether the fields should be repeatable. If it yields true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields. Optionally an setting array can be passed. |
|
383 | - * <h5>Repeatable Fields Setting Array</h5> |
|
384 | - * <ul> |
|
385 | - * <li>**max** - the allowed maximum number of fields to be repeated.</li> |
|
386 | - * <li>**min** - the allowed minimum number of fields to be repeated.</li> |
|
387 | - * </ul> |
|
388 | - * </li> |
|
389 | - * <li>**sortable** - [3.0.0+] (optional, boolean) whether the fields should be sortable. If it yields true, the fields will be enclosed in a draggable box. |
|
390 | - * <li>**attributes** - [3.0.0+] (optional, array) holds key-value pairs representing the attribute and its property. Note that some field types have specific keys in the first dimensions. e.g. `array( 'class' => 'my_custom_class_selector', 'style' => 'background-color:#777', 'size' => 20, )` Every field holds the following nested attribute definition arrays. |
|
391 | - * <ul> |
|
392 | - * <li>**fieldrow** - the `td` tag element containing the field output.</li> |
|
393 | - * <li>**fieldset** - the `fieldset` tag element containing the field output.</li> |
|
394 | - * <li>**fields** - the `div` tag element containing the sub-fields and the main field.</li> |
|
395 | - * <li>**field** - the `div` tag element containing each field.</li> |
|
396 | - * </ul> |
|
397 | - * </li> |
|
398 | - * <li>**show_title_column** - [3.0.0+] (optional, boolean) If true, the field title column will be omitted from the output.</li> |
|
399 | - * <li>**hidden** - [3.0.0+] (optional, boolean) If true, the entire field row output will be invisible with the inline style attribute of `style="display:none"`.</li> |
|
400 | - * <li>**save** - [3.6.0+] (optional, boolean) If `false`, the field value will not be saved. Default: `true`</li> |
|
401 | - * <li>**content** - (optional, string|array) [3.6.1+] a custom section output. [3.8.0+] Supports an array to be passed for nested and inline-mixed fields. If an array holding field definitions is set, those fields will be nested. |
|
402 | - * <h4>Example</h4> |
|
403 | - * <pre><code> |
|
404 | - * $this->addSettingFields( |
|
405 | - * 'my_section_id', // the target section ID - pass dimensional keys of the section |
|
406 | - * array( |
|
407 | - * 'field_id' => 'Y', |
|
408 | - * 'title' => __( 'Y', 'admin-page-framework-loader' ), |
|
409 | - * 'description' => __( 'By passing an array of field definition to the <code>content</code> argument, you can nest fields.', 'admin-page-framework-loader' ) |
|
410 | - * . ' ' . __( 'Also the <code>type</code> argument can be omitted.', 'admin-page-framework-loader' ), |
|
411 | - * 'content' => array( |
|
412 | - * array( |
|
413 | - * 'field_id' => 'i', |
|
414 | - * 'title' => __( 'i', 'admin-page-framework-loader' ), |
|
415 | - * 'type' => 'textarea', |
|
416 | - * ), |
|
417 | - * array( |
|
418 | - * 'field_id' => 'ii', |
|
419 | - * 'title' => __( 'ii', 'admin-page-framework-loader' ), |
|
420 | - * 'type' => 'color', |
|
421 | - * ), |
|
422 | - * array( |
|
423 | - * 'field_id' => 'iii', |
|
424 | - * 'title' => __( 'iii', 'admin-page-framework-loader' ), |
|
425 | - * 'repeatable' => true, |
|
426 | - * 'sortable' => true, |
|
427 | - * 'content' => array( |
|
428 | - * array( |
|
429 | - * 'field_id' => 'a', |
|
430 | - * 'title' => __( 'a', 'admin-page-framework-loader' ), |
|
431 | - * 'type' => 'image', |
|
432 | - * 'attributes' => array( |
|
433 | - * 'preview' => array( |
|
434 | - * 'style' => 'max-width: 200px;', |
|
435 | - * ), |
|
436 | - * ), |
|
437 | - * ), |
|
438 | - * array( |
|
439 | - * 'field_id' => 'b', |
|
440 | - * 'title' => __( 'b', 'admin-page-framework-loader' ), |
|
441 | - * 'content' => array( |
|
442 | - * array( |
|
443 | - * 'field_id' => 'first', |
|
444 | - * 'title' => __( '1st', 'admin-page-framework-loader' ), |
|
445 | - * 'type' => 'color', |
|
446 | - * 'repeatable' => true, |
|
447 | - * 'sortable' => true, |
|
448 | - * ), |
|
449 | - * array( |
|
450 | - * 'field_id' => 'second', |
|
451 | - * 'title' => __( '2nd', 'admin-page-framework-loader' ), |
|
452 | - * 'type' => 'size', |
|
453 | - * ), |
|
454 | - * array( |
|
455 | - * 'field_id' => 'third', |
|
456 | - * 'title' => __( '3rd', 'admin-page-framework-loader' ), |
|
457 | - * 'type' => 'select', |
|
458 | - * 'label' => array( |
|
459 | - * 'x' => 'X', |
|
460 | - * 'y' => 'Y', |
|
461 | - * 'z' => 'Z', |
|
462 | - * ), |
|
463 | - * ), |
|
464 | - * ), |
|
465 | - * // 'description' => '', |
|
466 | - * ), |
|
467 | - * array( |
|
468 | - * 'field_id' => 'c', |
|
469 | - * 'title' => __( 'c', 'admin-page-framework-loader' ), |
|
470 | - * 'type' => 'radio', |
|
471 | - * 'label' => array( |
|
472 | - * 'a' => __( 'Apple', 'admin-page-framework-loader' ), |
|
473 | - * 'b' => __( 'Banana', 'admin-page-framework-loader' ), |
|
474 | - * 'c' => __( 'Cherry', 'admin-page-framework-loader' ), |
|
475 | - * ), |
|
476 | - * 'default' => 'b', |
|
477 | - * ), |
|
478 | - * ) |
|
479 | - * ), |
|
480 | - * ), |
|
481 | - * ) |
|
482 | - * ); |
|
483 | - * </code></pre> |
|
484 | - * </li> |
|
485 | - * <li>**placement** - [3.8.0+] (optional, string) Specifies where the field is rendered. Either `normal` `section_title` or `field_title` is accepted. `field_title` can only be used by nested fields defined in the `content` argument. Default: `normal`</li> |
|
486 | - * </ul> |
|
487 | - */ |
|
336 | + * <h4>Built-in Field Types</h4> |
|
337 | + * <ul> |
|
338 | + * <li>[text](./class-AdminPageFramework_FieldType_text.html) - a normal field to enter short text input.</li> |
|
339 | + * <li>[password](./class-AdminPageFramework_FieldType_text.html) - a masked text input field.</li> |
|
340 | + * <li>[textarea](./class-AdminPageFramework_FieldType_textarea.html) - a text input field with multiple lines. It supports rich text editors.</li> |
|
341 | + * <li>[radio](./class-AdminPageFramework_FieldType_radio.html) - a set of radio buttons that lets the user pick an option.</li> |
|
342 | + * <li>[checkbox](./class-AdminPageFramework_FieldType_checkbox.html) - a check box that lets the user enable/disable an item.</li> |
|
343 | + * <li>[select](./class-AdminPageFramework_FieldType_select.html) - a drop-down list that lest the user pick one or more item(s) from a list.</li> |
|
344 | + * <li>[hidden](./class-AdminPageFramework_FieldType_hidden.html) - a field with invisible input values.</li> |
|
345 | + * <li>[file](./class-AdminPageFramework_FieldType_file.html) - a file uploader that lets the user upload files.</li> |
|
346 | + * <li>[image](./class-AdminPageFramework_FieldType_image.html) - a text field with an image uploader that lets the user set the image URL.</li> |
|
347 | + * <li>[media](./class-AdminPageFramework_FieldType_media.html) - a text field with a media uploader that lets the user set the file URL.</li> |
|
348 | + * <li>[color](./class-AdminPageFramework_FieldType_color.html) - a text field with a color picker.</li> |
|
349 | + * <li>[submit](./class-AdminPageFramework_FieldType_submit.html) - a submit button that lets the user send the form.</li> |
|
350 | + * <li>[export](./class-AdminPageFramework_FieldType_export.html) - a custom submit field that lets the user export stored data.</li> |
|
351 | + * <li>[import](./class-AdminPageFramework_FieldType_import.html) - a custom combination field of file and submit fields that let the user import data.</li> |
|
352 | + * <li>[posttype](./class-AdminPageFramework_FieldType_posttype.html) - a check-list of post types enabled on the site.</li> |
|
353 | + * <li>[taxonomy](./class-AdminPageFramework_FieldType_taxonomy.html) - a set of check-lists of taxonomies enabled on the site in a tabbed box.</li> |
|
354 | + * <li>[size](./class-AdminPageFramework_FieldType_size.html) - a combination field of the text and the select fields that let the user set sizes with a selectable unit.</li> |
|
355 | + * <li>[section_title](./class-AdminPageFramework_FieldType_section_title.html) - [3.0.0+] a text field type that will be placed in the section title so that it lets the user set the section title. Note that only one field with this field type is allowed per a section.</li> |
|
356 | + * <li>[system](./class-AdminPageFramework_FieldType_system.html) - [3.3.0+] a custom text area field that displays the system information including the PHP settings, the framework version, MySQL version etc.</li> |
|
357 | + * <li>[inline_mixed](./class-AdminPageFramework_FieldType_inline_mixed.html) - [3.8.0+] a field that include inner fields with different field types. </li> |
|
358 | + * </ul> |
|
359 | + * <h4>Field Definition Array</h4> |
|
360 | + * <ul> |
|
361 | + * <li>**field_id** - (required, string) the field ID. Avoid using non-alphabetic characters except underscore and numbers.</li> |
|
362 | + * <li>**type** - (optional, string) the type of the field. The supported types are listed below. When creating nested fields, this argument can be omitted.</li> |
|
363 | + * <li>**section_id** - (optional, string) the section ID that the field belongs to. If not set, the internal `_default` section ID will be assigned.</li> |
|
364 | + * <li>**title** - (optional, string) the title of the section.</li> |
|
365 | + * <li>**description** - (optional, string) the description of the field which is inserted into the after the input field tag.</li> |
|
366 | + * <li>**tip** - (optional, string) the tip for the field which is displayed when the mouse is hovered over the field title.</li> |
|
367 | + * <li>**capability** - (optional, string) the <a href="http://codex.wordpress.org/Roles_and_Capabilities">access level</a> of the section. If the page visitor does not have sufficient capability, the section will be invisible to them.</li> |
|
368 | + * <li>**error_message** - (optional, string) the error message to display above the input field.</li> |
|
369 | + * <li>**before_field** - (optional, string) the HTML string to insert before the input field output.</li> |
|
370 | + * <li>**after_field** - (optional, string) the HTML string to insert after the input field output.</li> |
|
371 | + * <li>**if** - (optional, boolean) if the passed value is false, the section will not be registered.</li> |
|
372 | + * <li>**order** - (optional, integer) the order number of the section. The higher the number is, the lower the position it gets.</li> |
|
373 | + * <li>**label** - (optional, string) the text label(s) associated with and displayed along with the input field. Some input types can ignore this key.</li> |
|
374 | + * <li>**default** - (optional, string|array) the default value(s) assigned to the input tag's value attribute.</li> |
|
375 | + * <li>**value** - (optional, string|array) the value(s) assigned to the input tag's `value` attribute to override the default and the stored value.</li> |
|
376 | + * <li>**delimiter** - (optional, string) the HTML string that delimits multiple elements. This is available if the <var>label</var> key is passed as array. It will be enclosed in inline-block elements so the passed HTML string should not contain block elements.</li> |
|
377 | + * <li>**before_input** - (optional, string) the HTML string inserted right before the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li> |
|
378 | + * <li>**after_input** - (optional, string) the HTML string inserted right after the input tag. It will be enclosed in the <code>label</code> tag so the passed HTML string should not contain block elements.</li> |
|
379 | + * <li>**label_min_width** - (optional, string) the inline style property of the `min-width` of the label tag for the field. If the unit is not specified, 'px' is applied. Default: `120`. e.g. `100%`</li> |
|
380 | + * <li>**help** - (optional, string) the help description added to the contextual help tab.</li> |
|
381 | + * <li>**help_aside** - (optional, string) the additional help description for the side bar of the contextual help tab.</li> |
|
382 | + * <li>**repeatable** - [3.0.0+] (optional, array|boolean) whether the fields should be repeatable. If it yields true, the plus and the minus buttons appear next to each field that lets the user add/remove the fields. Optionally an setting array can be passed. |
|
383 | + * <h5>Repeatable Fields Setting Array</h5> |
|
384 | + * <ul> |
|
385 | + * <li>**max** - the allowed maximum number of fields to be repeated.</li> |
|
386 | + * <li>**min** - the allowed minimum number of fields to be repeated.</li> |
|
387 | + * </ul> |
|
388 | + * </li> |
|
389 | + * <li>**sortable** - [3.0.0+] (optional, boolean) whether the fields should be sortable. If it yields true, the fields will be enclosed in a draggable box. |
|
390 | + * <li>**attributes** - [3.0.0+] (optional, array) holds key-value pairs representing the attribute and its property. Note that some field types have specific keys in the first dimensions. e.g. `array( 'class' => 'my_custom_class_selector', 'style' => 'background-color:#777', 'size' => 20, )` Every field holds the following nested attribute definition arrays. |
|
391 | + * <ul> |
|
392 | + * <li>**fieldrow** - the `td` tag element containing the field output.</li> |
|
393 | + * <li>**fieldset** - the `fieldset` tag element containing the field output.</li> |
|
394 | + * <li>**fields** - the `div` tag element containing the sub-fields and the main field.</li> |
|
395 | + * <li>**field** - the `div` tag element containing each field.</li> |
|
396 | + * </ul> |
|
397 | + * </li> |
|
398 | + * <li>**show_title_column** - [3.0.0+] (optional, boolean) If true, the field title column will be omitted from the output.</li> |
|
399 | + * <li>**hidden** - [3.0.0+] (optional, boolean) If true, the entire field row output will be invisible with the inline style attribute of `style="display:none"`.</li> |
|
400 | + * <li>**save** - [3.6.0+] (optional, boolean) If `false`, the field value will not be saved. Default: `true`</li> |
|
401 | + * <li>**content** - (optional, string|array) [3.6.1+] a custom section output. [3.8.0+] Supports an array to be passed for nested and inline-mixed fields. If an array holding field definitions is set, those fields will be nested. |
|
402 | + * <h4>Example</h4> |
|
403 | + * <pre><code> |
|
404 | + * $this->addSettingFields( |
|
405 | + * 'my_section_id', // the target section ID - pass dimensional keys of the section |
|
406 | + * array( |
|
407 | + * 'field_id' => 'Y', |
|
408 | + * 'title' => __( 'Y', 'admin-page-framework-loader' ), |
|
409 | + * 'description' => __( 'By passing an array of field definition to the <code>content</code> argument, you can nest fields.', 'admin-page-framework-loader' ) |
|
410 | + * . ' ' . __( 'Also the <code>type</code> argument can be omitted.', 'admin-page-framework-loader' ), |
|
411 | + * 'content' => array( |
|
412 | + * array( |
|
413 | + * 'field_id' => 'i', |
|
414 | + * 'title' => __( 'i', 'admin-page-framework-loader' ), |
|
415 | + * 'type' => 'textarea', |
|
416 | + * ), |
|
417 | + * array( |
|
418 | + * 'field_id' => 'ii', |
|
419 | + * 'title' => __( 'ii', 'admin-page-framework-loader' ), |
|
420 | + * 'type' => 'color', |
|
421 | + * ), |
|
422 | + * array( |
|
423 | + * 'field_id' => 'iii', |
|
424 | + * 'title' => __( 'iii', 'admin-page-framework-loader' ), |
|
425 | + * 'repeatable' => true, |
|
426 | + * 'sortable' => true, |
|
427 | + * 'content' => array( |
|
428 | + * array( |
|
429 | + * 'field_id' => 'a', |
|
430 | + * 'title' => __( 'a', 'admin-page-framework-loader' ), |
|
431 | + * 'type' => 'image', |
|
432 | + * 'attributes' => array( |
|
433 | + * 'preview' => array( |
|
434 | + * 'style' => 'max-width: 200px;', |
|
435 | + * ), |
|
436 | + * ), |
|
437 | + * ), |
|
438 | + * array( |
|
439 | + * 'field_id' => 'b', |
|
440 | + * 'title' => __( 'b', 'admin-page-framework-loader' ), |
|
441 | + * 'content' => array( |
|
442 | + * array( |
|
443 | + * 'field_id' => 'first', |
|
444 | + * 'title' => __( '1st', 'admin-page-framework-loader' ), |
|
445 | + * 'type' => 'color', |
|
446 | + * 'repeatable' => true, |
|
447 | + * 'sortable' => true, |
|
448 | + * ), |
|
449 | + * array( |
|
450 | + * 'field_id' => 'second', |
|
451 | + * 'title' => __( '2nd', 'admin-page-framework-loader' ), |
|
452 | + * 'type' => 'size', |
|
453 | + * ), |
|
454 | + * array( |
|
455 | + * 'field_id' => 'third', |
|
456 | + * 'title' => __( '3rd', 'admin-page-framework-loader' ), |
|
457 | + * 'type' => 'select', |
|
458 | + * 'label' => array( |
|
459 | + * 'x' => 'X', |
|
460 | + * 'y' => 'Y', |
|
461 | + * 'z' => 'Z', |
|
462 | + * ), |
|
463 | + * ), |
|
464 | + * ), |
|
465 | + * // 'description' => '', |
|
466 | + * ), |
|
467 | + * array( |
|
468 | + * 'field_id' => 'c', |
|
469 | + * 'title' => __( 'c', 'admin-page-framework-loader' ), |
|
470 | + * 'type' => 'radio', |
|
471 | + * 'label' => array( |
|
472 | + * 'a' => __( 'Apple', 'admin-page-framework-loader' ), |
|
473 | + * 'b' => __( 'Banana', 'admin-page-framework-loader' ), |
|
474 | + * 'c' => __( 'Cherry', 'admin-page-framework-loader' ), |
|
475 | + * ), |
|
476 | + * 'default' => 'b', |
|
477 | + * ), |
|
478 | + * ) |
|
479 | + * ), |
|
480 | + * ), |
|
481 | + * ) |
|
482 | + * ); |
|
483 | + * </code></pre> |
|
484 | + * </li> |
|
485 | + * <li>**placement** - [3.8.0+] (optional, string) Specifies where the field is rendered. Either `normal` `section_title` or `field_title` is accepted. `field_title` can only be used by nested fields defined in the `content` argument. Default: `normal`</li> |
|
486 | + * </ul> |
|
487 | + */ |
|
488 | 488 | public function addSettingField( $asFieldset ) { |
489 | 489 | if ( method_exists( $this->oForm, 'addField' ) ) { |
490 | 490 | $this->oForm->addField( $asFieldset ); |
@@ -548,28 +548,28 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | - * Sets the given message to be displayed in the next page load. |
|
552 | - * |
|
553 | - * This is used to inform users about the submitted input data, such as "Updated successfully." or "Problem occurred." etc. |
|
554 | - * and normally used in validation callback methods. |
|
555 | - * |
|
556 | - * <h4>Example</h4> |
|
557 | - * ` |
|
558 | - * if ( ! $bVerified ) { |
|
559 | - * $this->setFieldErrors( $aErrors ); |
|
560 | - * $this->setSettingNotice( 'There was an error in your input.' ); |
|
561 | - * return $aOldPageOptions; |
|
562 | - * } |
|
563 | - * ` |
|
564 | - * |
|
565 | - * @since 3.0.4 |
|
566 | - * @access public |
|
567 | - * @param string $sMessage the text message to be displayed. |
|
568 | - * @param string $sType (optional) the type of the message, either "error" or "updated" is used. |
|
569 | - * @param array $asAttributes (optional) the tag attribute array applied to the message container HTML element. If a string is given, it is used as the ID attribute value. |
|
570 | - * @param boolean $bOverride (optional) If true, only one message will be shown in the next page load. false: do not override when there is a message of the same id. true: override the previous one. |
|
571 | - * @return void |
|
572 | - */ |
|
551 | + * Sets the given message to be displayed in the next page load. |
|
552 | + * |
|
553 | + * This is used to inform users about the submitted input data, such as "Updated successfully." or "Problem occurred." etc. |
|
554 | + * and normally used in validation callback methods. |
|
555 | + * |
|
556 | + * <h4>Example</h4> |
|
557 | + * ` |
|
558 | + * if ( ! $bVerified ) { |
|
559 | + * $this->setFieldErrors( $aErrors ); |
|
560 | + * $this->setSettingNotice( 'There was an error in your input.' ); |
|
561 | + * return $aOldPageOptions; |
|
562 | + * } |
|
563 | + * ` |
|
564 | + * |
|
565 | + * @since 3.0.4 |
|
566 | + * @access public |
|
567 | + * @param string $sMessage the text message to be displayed. |
|
568 | + * @param string $sType (optional) the type of the message, either "error" or "updated" is used. |
|
569 | + * @param array $asAttributes (optional) the tag attribute array applied to the message container HTML element. If a string is given, it is used as the ID attribute value. |
|
570 | + * @param boolean $bOverride (optional) If true, only one message will be shown in the next page load. false: do not override when there is a message of the same id. true: override the previous one. |
|
571 | + * @return void |
|
572 | + */ |
|
573 | 573 | public function setSettingNotice( $sMessage, $sType='error', $asAttributes=array(), $bOverride=true ) { |
574 | 574 | $this->oForm->setSubmitNotice( |
575 | 575 | $sMessage, |
@@ -110,7 +110,6 @@ |
||
110 | 110 | * Retrieves the settings error array set by the user in the validation callback. |
111 | 111 | * |
112 | 112 | * @since 3.7.8 |
113 | - * @param boolean $bDelete whether or not the transient should be deleted after retrieving it. |
|
114 | 113 | * @return array |
115 | 114 | */ |
116 | 115 | public function get() { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $_sPageSlug = $this->getElement( $_GET, 'page', '' ); |
57 | 57 | $_sTabSlug = $this->getElement( $_GET, 'tab', '' ); |
58 | 58 | $_sUserID = get_current_user_id(); |
59 | - return "apf_li_" . md5( |
|
59 | + return "apf_li_".md5( |
|
60 | 60 | $_sPageNow |
61 | 61 | . $_sPageSlug |
62 | 62 | . $_sTabSlug |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | public function _replyToSave() { |
97 | - if ( ! isset( self::$_aLastInputs ) ) { |
|
97 | + if ( !isset( self::$_aLastInputs ) ) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | $this->setTransient( |
101 | 101 | $this->sTransientKey, |
102 | 102 | self::$_aLastInputs, |
103 | - 60*60 // store it for 1 hour |
|
103 | + 60 * 60 // store it for 1 hour |
|
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $_aLastInputs = self::$_aCaches[ $this->sTransientKey ]; |
121 | 121 | } else { |
122 | 122 | $_aLastInputs = $this->getTransient( $this->sTransientKey ); |
123 | - self::$_aCaches[ $this->sTransientKey ] = $_aLastInputs; |
|
123 | + self::$_aCaches[ $this->sTransientKey ] = $_aLastInputs; |
|
124 | 124 | if ( false !== $_aLastInputs ) { |
125 | - $this->delete(); // deletes at the end of the script. |
|
125 | + $this->delete(); // deletes at the end of the script. |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 |
@@ -94,7 +94,7 @@ |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | public function _replyToSave() { |
97 | - if ( ! isset( self::$_aLastInputs ) ) { |
|
97 | + if ( ! isset( self::$_aLastInputs ) ) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | $this->setTransient( |
@@ -77,6 +77,8 @@ |
||
77 | 77 | } |
78 | 78 | /** |
79 | 79 | * @since 3.6.0 |
80 | + * @param boolean $abCollapsible |
|
81 | + * @param string $sTitle |
|
80 | 82 | * @return array |
81 | 83 | */ |
82 | 84 | private function _getArguments( $abCollapsible, $sTitle, array $aSection ) { |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | * @since 3.6.0 Moved from `AdminPageFramework_FormDefinition`. |
24 | 24 | */ |
25 | 25 | static public $aStructure = array( |
26 | - 'title' => null, // (string) the section title will be assigned by default in the section formatting method. |
|
27 | - 'is_collapsed' => true, // (boolean) whether it is already collapsed or expanded |
|
28 | - 'toggle_all_button' => null, // (boolean|string|array) the position of where to display the toggle-all button that toggles the folding state of all collapsible sections. Accepts the following values. 'top-right', 'top-left', 'bottom-right', 'bottom-left'. If true is passed, the default 'top-right' will be used. To not to display, do not set any or pass `false` or `null`. |
|
29 | - 'collapse_others_on_expand' => true, // (boolean) whether the other collapsible sections should be folded when the section is unfolded. |
|
30 | - 'container' => 'sections', // (string) the container element that collapsible styling gets applied to. Either 'sections' or 'section' is accepted. |
|
31 | - 'type' => 'box', // 3.7.0+ (string) supported types 'box', 'button' Default: `box`. The `button` type is only supported when the `container` argument is `section`. |
|
26 | + 'title' => null, // (string) the section title will be assigned by default in the section formatting method. |
|
27 | + 'is_collapsed' => true, // (boolean) whether it is already collapsed or expanded |
|
28 | + 'toggle_all_button' => null, // (boolean|string|array) the position of where to display the toggle-all button that toggles the folding state of all collapsible sections. Accepts the following values. 'top-right', 'top-left', 'bottom-right', 'bottom-left'. If true is passed, the default 'top-right' will be used. To not to display, do not set any or pass `false` or `null`. |
|
29 | + 'collapse_others_on_expand' => true, // (boolean) whether the other collapsible sections should be folded when the section is unfolded. |
|
30 | + 'container' => 'sections', // (string) the container element that collapsible styling gets applied to. Either 'sections' or 'section' is accepted. |
|
31 | + 'type' => 'box', // 3.7.0+ (string) supported types 'box', 'button' Default: `box`. The `button` type is only supported when the `container` argument is `section`. |
|
32 | 32 | ); |
33 | 33 | |
34 | 34 | public $abCollapsible = false; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @remark The framework will not pass this parameter when formatting a section definition array. |
42 | 42 | * It will be passed when the framework is rendering a form table to generate collapsible elements. |
43 | 43 | */ |
44 | - public $aSection = array(); |
|
44 | + public $aSection = array(); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Sets up properties. |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | |
85 | 85 | $_aCollapsible = $this->getAsArray( $this->abCollapsible ) + array( |
86 | 86 | 'title' => $sTitle, |
87 | - ) + self::$aStructure; |
|
87 | + ) + self::$aStructure; |
|
88 | 88 | |
89 | 89 | $_aCollapsible[ 'toggle_all_button' ] = implode( |
90 | 90 | ',', |
91 | 91 | $this->getAsArray( $_aCollapsible[ 'toggle_all_button' ] ) |
92 | 92 | ); |
93 | 93 | |
94 | - if ( ! empty( $aSection ) ) { |
|
94 | + if ( !empty( $aSection ) ) { |
|
95 | 95 | $_aCollapsible[ 'toggle_all_button' ] = $this->_getToggleAllButtonArgument( |
96 | 96 | $_aCollapsible[ 'toggle_all_button' ], |
97 | 97 | $aSection |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | private function _getToggleAllButtonArgument( $sToggleAll, array $aSection ) { |
117 | 117 | |
118 | - if ( ! $aSection[ 'repeatable' ] ) { |
|
118 | + if ( !$aSection[ 'repeatable' ] ) { |
|
119 | 119 | return $sToggleAll; |
120 | 120 | } |
121 | 121 | |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | // Disable the toggle all button for middle sub-sections in repeatable sections. |
128 | - if ( ! $aSection[ '_is_first_index' ] && ! $aSection[ '_is_last_index' ] ) { |
|
128 | + if ( !$aSection[ '_is_first_index' ] && !$aSection[ '_is_last_index' ] ) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $_aToggleAll = $this->getAOrB( |
133 | - true === $sToggleAll || 1 === $sToggleAll, // evaluate |
|
134 | - array( 'top-right', 'bottom-right' ), // if true |
|
133 | + true === $sToggleAll || 1 === $sToggleAll, // evaluate |
|
134 | + array( 'top-right', 'bottom-right' ), // if true |
|
135 | 135 | explode( ',', $sToggleAll ) // if false |
136 | 136 | ); |
137 | 137 | $_aToggleAll = $this->getAOrB( |
@@ -114,7 +114,7 @@ |
||
114 | 114 | */ |
115 | 115 | private function _getToggleAllButtonArgument( $sToggleAll, array $aSection ) { |
116 | 116 | |
117 | - if ( ! $aSection[ 'repeatable' ] ) { |
|
117 | + if ( ! $aSection[ 'repeatable' ] ) { |
|
118 | 118 | return $sToggleAll; |
119 | 119 | } |
120 | 120 |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | * @since DEVVER Moved from `AdminPageFramework_FormDefinition`. Changed the name from `formatFields()`. |
99 | 99 | * Added the `$aSectionsets` parameter. |
100 | 100 | * @retuen array |
101 | + * @param string $sCapability |
|
101 | 102 | */ |
102 | 103 | private function _getFieldsetsFormatted( array $aFieldsets, array $aSectionsets, $sCapability ) { |
103 | 104 | |
@@ -271,6 +272,7 @@ discard block |
||
271 | 272 | * |
272 | 273 | * @since 3.0.0 |
273 | 274 | * @since DEVVER Moved from `AdminPageFramework_FormDefinition`. Changed the name from `formatField()`. |
275 | + * @param integer $iCountOfElements |
|
274 | 276 | * @return array|void An array of formatted field definition array. If required keys are not set, nothing will be returned. |
275 | 277 | */ |
276 | 278 | private function _getFieldsetFormatted( $aFieldset, $aSectionsets, $sCapability, $iCountOfElements, $iSubSectionIndex, $bIsSectionRepeatable, $oCallerObject ) { |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | private function _getFieldsetsFormatted( array $aFieldsets, array $aSectionsets, $sCapability ) { |
105 | 105 | |
106 | 106 | $_aNewFieldsets = array(); |
107 | - foreach( $aFieldsets as $_sSectionPath => $_aItems ) { |
|
107 | + foreach ( $aFieldsets as $_sSectionPath => $_aItems ) { |
|
108 | 108 | |
109 | 109 | // If the section is not set, skip. |
110 | - if ( ! isset( $aSectionsets[ $_sSectionPath ] ) ) { |
|
110 | + if ( !isset( $aSectionsets[ $_sSectionPath ] ) ) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $_aItems, |
117 | 117 | $this->getElement( // 3.6.0+ Get the section's capability |
118 | 118 | $aSectionsets, |
119 | - array( $_sSectionPath, 'capability', ), |
|
119 | + array( $_sSectionPath, 'capability',), |
|
120 | 120 | $sCapability |
121 | 121 | ), |
122 | 122 | $aSectionsets |
@@ -176,16 +176,16 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function _getNormalFieldsetsFormatted( $aItems, $sCapability, $aSectionsets, $_abSectionRepeatable ) { |
178 | 178 | |
179 | - $_aNewItems = array(); |
|
180 | - foreach( $aItems as $_sFieldID => $_aFieldset ) { |
|
179 | + $_aNewItems = array(); |
|
180 | + foreach ( $aItems as $_sFieldID => $_aFieldset ) { |
|
181 | 181 | |
182 | 182 | // Insert the formatted field definition array. The fields count is needed to set each order value. |
183 | - $_aFieldset = $this->_getFieldsetFormatted( |
|
183 | + $_aFieldset = $this->_getFieldsetFormatted( |
|
184 | 184 | $_aFieldset, |
185 | 185 | $aSectionsets, |
186 | 186 | $sCapability, |
187 | 187 | count( $_aNewItems ), // index of elements - zero based |
188 | - null, // sub-section index |
|
188 | + null, // sub-section index |
|
189 | 189 | $_abSectionRepeatable, |
190 | 190 | $this->oCallerForm |
191 | 191 | ); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return boolean |
205 | 205 | */ |
206 | 206 | private function _isSubSections( $aItems, $_abSectionRepeatable ) { |
207 | - if ( ! empty( $_abSectionRepeatable ) ) { |
|
207 | + if ( !empty( $_abSectionRepeatable ) ) { |
|
208 | 208 | return true; |
209 | 209 | } |
210 | 210 | return ( boolean ) count( $this->getIntegerKeyElements( $aItems ) ); |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | private function _getSubSectionsFormatted( $aItems, $sCapability, $aSectionsets, $_abSectionRepeatable ) { |
216 | 216 | |
217 | 217 | $_aNewFieldset = array(); |
218 | - foreach( $this->numerizeElements( $aItems ) as $_iSubSectionIndex => $_aFieldsets ) { |
|
218 | + foreach ( $this->numerizeElements( $aItems ) as $_iSubSectionIndex => $_aFieldsets ) { |
|
219 | 219 | |
220 | - foreach( $_aFieldsets as $_aFieldset ) { |
|
220 | + foreach ( $_aFieldsets as $_aFieldset ) { |
|
221 | 221 | $_iCountElement = count( $this->getElementAsArray( $_aNewFieldset, $_iSubSectionIndex ) ); |
222 | 222 | $_aFieldset = $this->_getFieldsetFormatted( |
223 | 223 | $_aFieldset, |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | if ( empty( $_aFieldset ) ) { |
232 | 232 | continue; |
233 | 233 | } |
234 | - $_aNewFieldset[ $_iSubSectionIndex ][ $_aFieldset['field_id'] ] = $_aFieldset; |
|
234 | + $_aNewFieldset[ $_iSubSectionIndex ][ $_aFieldset[ 'field_id' ] ] = $_aFieldset; |
|
235 | 235 | } |
236 | 236 | uasort( $_aNewFieldset[ $_iSubSectionIndex ], array( $this, 'sortArrayByKey' ) ); |
237 | 237 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | $_aSortedFields = array(); |
261 | - foreach( $aSectionsets as $_sSectionPath => $_aSecitonset ) { |
|
261 | + foreach ( $aSectionsets as $_sSectionPath => $_aSecitonset ) { |
|
262 | 262 | if ( isset( $aFieldsets[ $_sSectionPath ] ) ) { |
263 | 263 | $_aSortedFields[ $_sSectionPath ] = $aFieldsets[ $_sSectionPath ]; |
264 | 264 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | private function _getFieldsetFormatted( $aFieldset, $aSectionsets, $sCapability, $iCountOfElements, $iSubSectionIndex, $bIsSectionRepeatable, $oCallerObject ) { |
278 | 278 | |
279 | 279 | // 3.8.0+ Dropped the check for $aFieldset[ 'type' ] to allow it to be omitted. |
280 | - if ( ! isset( $aFieldset[ 'field_id' ] ) ) { |
|
280 | + if ( !isset( $aFieldset[ 'field_id' ] ) ) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | foreach( $aFieldsets as $_sSectionPath => $_aItems ) { |
108 | 108 | |
109 | 109 | // If the section is not set, skip. |
110 | - if ( ! isset( $aSectionsets[ $_sSectionPath ] ) ) { |
|
110 | + if ( ! isset( $aSectionsets[ $_sSectionPath ] ) ) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | $_aSortedFields = array(); |
261 | - foreach( $aSectionsets as $_sSectionPath => $_aSecitonset ) { |
|
261 | + foreach( $aSectionsets as $_sSectionPath => $_aSecitonset ) { |
|
262 | 262 | if ( isset( $aFieldsets[ $_sSectionPath ] ) ) { |
263 | 263 | $_aSortedFields[ $_sSectionPath ] = $aFieldsets[ $_sSectionPath ]; |
264 | 264 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | private function _getFieldsetFormatted( $aFieldset, $aSectionsets, $sCapability, $iCountOfElements, $iSubSectionIndex, $bIsSectionRepeatable, $oCallerObject ) { |
278 | 278 | |
279 | 279 | // 3.8.0+ Dropped the check for $aFieldset[ 'type' ] to allow it to be omitted. |
280 | - if ( ! isset( $aFieldset[ 'field_id' ] ) ) { |
|
280 | + if ( ! isset( $aFieldset[ 'field_id' ] ) ) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 |
@@ -30,7 +30,6 @@ |
||
30 | 30 | * Returns the field container attribute array. |
31 | 31 | * |
32 | 32 | * @remark Formatting each sub-field should be performed prior to callign this method. |
33 | - * @param array $aField The (sub-)field definition array. This should have been formatted already. |
|
34 | 33 | * @return array The generated field container attribute array. |
35 | 34 | * @internal |
36 | 35 | * @since 3.5.3 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @since 3.6.0 |
27 | 27 | */ |
28 | - public $sContext = 'field'; |
|
28 | + public $sContext = 'field'; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Returns the field container attribute array. |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | protected function _getAttributes() { |
42 | 42 | |
43 | 43 | // 3.8.0+ Supports omitting the `type` argument. |
44 | - $_sFieldTypeSelector = $this->getAOrB( |
|
44 | + $_sFieldTypeSelector = $this->getAOrB( |
|
45 | 45 | $this->aArguments[ 'type' ], |
46 | 46 | " admin-page-framework-field-{$this->aArguments[ 'type' ]}", |
47 | 47 | '' |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | return array( |
68 | 68 | 'id' => $this->aArguments[ '_field_container_id' ], |
69 | - 'data-type' => $this->aArguments[ 'type' ], // referred by the repeatable field JavaScript script. |
|
69 | + 'data-type' => $this->aArguments[ 'type' ], // referred by the repeatable field JavaScript script. |
|
70 | 70 | 'class' => "admin-page-framework-field{$_sFieldTypeSelector}{$_sNestedFieldSelector}{$_sMixedFieldSelector}{$_sChildFieldSelector}" |
71 | 71 | . $this->getAOrB( |
72 | 72 | $this->aArguments[ 'attributes' ][ 'disabled' ], |
@@ -60,6 +60,7 @@ |
||
60 | 60 | * |
61 | 61 | * @since 3.1.0 |
62 | 62 | * @since DEVVER Moved from `AdminPageFramework_Form_View___Fieldset`. |
63 | + * @param string $sHeadingMessage |
|
63 | 64 | * @return string The error string message. An empty value if not found. |
64 | 65 | */ |
65 | 66 | private function _getFieldError( $aErrors, $aSectionPath, $aFieldPath, $sHeadingMessage ) { |
@@ -65,7 +65,7 @@ |
||
65 | 65 | private function _getFieldError( $aErrors, $aSectionPath, $aFieldPath, $sHeadingMessage ) { |
66 | 66 | |
67 | 67 | // If this field has a section and the error element is set |
68 | - $_aErrorPath = array_merge( $aSectionPath, $aFieldPath ); |
|
68 | + $_aErrorPath = array_merge( $aSectionPath, $aFieldPath ); |
|
69 | 69 | if ( $this->_hasFieldError( $aErrors, $_aErrorPath ) ) { |
70 | 70 | return "<span class='field-error'>* " |
71 | 71 | . $sHeadingMessage |
@@ -176,6 +176,7 @@ discard block |
||
176 | 176 | * Returns the repeatable fields script. |
177 | 177 | * |
178 | 178 | * @since 2.1.3 |
179 | + * @param string $sFieldsContainerID |
|
179 | 180 | */ |
180 | 181 | protected function _getRepeaterFieldEnablerScript( $sFieldsContainerID, $iFieldCount, $aSettings ) { |
181 | 182 | |
@@ -222,6 +223,7 @@ discard block |
||
222 | 223 | * Returns the sortable fields script. |
223 | 224 | * |
224 | 225 | * @since 3.0.0 |
226 | + * @param string $sFieldsContainerID |
|
225 | 227 | */ |
226 | 228 | protected function _getSortableFieldEnablerScript( $sFieldsContainerID ) { |
227 | 229 |
@@ -239,7 +239,7 @@ |
||
239 | 239 | |
240 | 240 | return "<div class='admin-page-framework-repeatable-field-buttons' {$_sSettingsAttributes} >" |
241 | 241 | . "<a class='repeatable-field-remove-button button-secondary repeatable-field-button button {$_sSmallButtonSelector}{$_sDashiconMinus}' href='#' title='{$_sRemove}' {$_sVisibility} data-id='{$sFieldsContainerID}'>" |
242 | - . '-' // ( $_bDashiconSupported ? '' : '-' ) |
|
242 | + . '-' // ( $_bDashiconSupported ? '' : '-' ) |
|
243 | 243 | . "</a>" |
244 | 244 | . "<a class='repeatable-field-add-button button-secondary repeatable-field-button button {$_sSmallButtonSelector}{$_sDashiconPlus}' href='#' title='{$_sAdd}' data-id='{$sFieldsContainerID}'>" |
245 | 245 | . '+' // ( $_bDashiconSupported ? '' : '+' ) |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param object $oMsg An object storing the system messages. |
69 | 69 | * @param array $aCallbacks An array storing the form-field specific callbacks. |
70 | 70 | */ |
71 | - public function __construct( $aFieldset, $aOptions, $aErrors, &$aFieldTypeDefinitions, &$oMsg, array $aCallbacks=array() ) { |
|
71 | + public function __construct( $aFieldset, $aOptions, $aErrors, &$aFieldTypeDefinitions, &$oMsg, array $aCallbacks = array() ) { |
|
72 | 72 | |
73 | 73 | // Set up the properties that will be accessed later in the methods. |
74 | 74 | $this->aFieldset = $this->_getFormatted( $aFieldset, $aFieldTypeDefinitions ); |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | $this->aErrors = $this->getAsArray( $aErrors ); |
78 | 78 | $this->oMsg = $oMsg; |
79 | 79 | $this->aCallbacks = $aCallbacks + array( |
80 | - 'hfID' => null, // the input id attribute |
|
81 | - 'hfTagID' => null, // the fieldset/field row container id attribute |
|
82 | - 'hfName' => null, // the input name attribute |
|
83 | - 'hfNameFlat' => null, // the flat input name attribute |
|
80 | + 'hfID' => null, // the input id attribute |
|
81 | + 'hfTagID' => null, // the fieldset/field row container id attribute |
|
82 | + 'hfName' => null, // the input name attribute |
|
83 | + 'hfNameFlat' => null, // the flat input name attribute |
|
84 | 84 | 'hfInputName' => null, |
85 | 85 | 'hfInputNameFlat' => null, |
86 | - 'hfClass' => null, // the class attribute |
|
86 | + 'hfClass' => null, // the class attribute |
|
87 | 87 | ); |
88 | 88 | |
89 | 89 | // 2. Load necessary JavaScript scripts. |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @since 3.2.0 Added the `$sFieldsType` parameter. |
151 | 151 | * @internal |
152 | 152 | */ |
153 | - private function _loadScripts( $sStructureType='' ) { |
|
153 | + private function _loadScripts( $sStructureType = '' ) { |
|
154 | 154 | |
155 | - if ( 'widget' === $sStructureType && ! self::$_bIsLoadedJSScripts_Widget ) { |
|
155 | + if ( 'widget' === $sStructureType && !self::$_bIsLoadedJSScripts_Widget ) { |
|
156 | 156 | new AdminPageFramework_Form_View___Script_Widget; |
157 | 157 | self::$_bIsLoadedJSScripts_Widget = true; |
158 | 158 | } |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function _getRepeaterFieldEnablerScript( $sFieldsContainerID, $iFieldCount, $aSettings ) { |
179 | 179 | |
180 | - $_sSmallButtons = '"' . $this->_getRepeatableButtonHTML( $sFieldsContainerID, ( array ) $aSettings, $iFieldCount, true ) . '"'; |
|
181 | - $_sNestedFieldsButtons = '"' . $this->_getRepeatableButtonHTML( $sFieldsContainerID, ( array ) $aSettings, $iFieldCount, false ) . '"'; |
|
180 | + $_sSmallButtons = '"'.$this->_getRepeatableButtonHTML( $sFieldsContainerID, ( array ) $aSettings, $iFieldCount, true ).'"'; |
|
181 | + $_sNestedFieldsButtons = '"'.$this->_getRepeatableButtonHTML( $sFieldsContainerID, ( array ) $aSettings, $iFieldCount, false ).'"'; |
|
182 | 182 | $_aJSArray = json_encode( $aSettings ); |
183 | 183 | $_sScript = <<<JAVASCRIPTS |
184 | 184 | jQuery( document ).ready( function() { |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @since 3.8.0 |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - private function _getRepeatableButtonHTML( $sFieldsContainerID, array $aSettings, $iFieldCount, $bSmall=true ) { |
|
227 | + private function _getRepeatableButtonHTML( $sFieldsContainerID, array $aSettings, $iFieldCount, $bSmall = true ) { |
|
228 | 228 | |
229 | 229 | $_sAdd = $this->oMsg->get( 'add' ); |
230 | 230 | $_sRemove = $this->oMsg->get( 'remove' ); |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | $_sSmallButtonSelector = $bSmall ? ' button-small' : ''; |
234 | 234 | |
235 | 235 | // Not using dash-icons at the moment. |
236 | - $_bDashiconSupported = false; // version_compare( $GLOBALS[ 'wp_version' ], '3.8', '>=' ); |
|
237 | - $_sDashiconPlus = ''; // $_bDashiconSupported ? 'dashicons dashicons-plus' : ''; |
|
238 | - $_sDashiconMinus = ''; // $_bDashiconSupported ? 'dashicons dashicons-minus' : ''; |
|
236 | + $_bDashiconSupported = false; // version_compare( $GLOBALS[ 'wp_version' ], '3.8', '>=' ); |
|
237 | + $_sDashiconPlus = ''; // $_bDashiconSupported ? 'dashicons dashicons-plus' : ''; |
|
238 | + $_sDashiconMinus = ''; // $_bDashiconSupported ? 'dashicons dashicons-minus' : ''; |
|
239 | 239 | |
240 | 240 | return "<div class='admin-page-framework-repeatable-field-buttons' {$_sSettingsAttributes} >" |
241 | 241 | . "<a class='repeatable-field-remove-button button-secondary repeatable-field-button button {$_sSmallButtonSelector}{$_sDashiconMinus}' href='#' title='{$_sRemove}' {$_sVisibility} data-id='{$sFieldsContainerID}'>" |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | self::$_bIsLoadedJSScripts_Widget = true; |
158 | 158 | } |
159 | 159 | |
160 | - if ( self::$_bIsLoadedJSScripts ) { |
|
160 | + if ( self::$_bIsLoadedJSScripts ) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | self::$_bIsLoadedJSScripts = true; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @since 3.0.0 |
257 | 257 | */ |
258 | - protected function _getSortableFieldEnablerScript( $sFieldsContainerID ) { |
|
258 | + protected function _getSortableFieldEnablerScript( $sFieldsContainerID ) { |
|
259 | 259 | |
260 | 260 | $_sScript = <<<JAVASCRIPTS |
261 | 261 | jQuery( document ).ready( function() { |
@@ -23,7 +23,6 @@ |
||
23 | 23 | * @internal |
24 | 24 | * @since 3.5.3 |
25 | 25 | * @since 3.6.0 Moved from `AdminPageFramework_FormDefinition`. |
26 | - * @param array $aFieldset a field definition array. |
|
27 | 26 | * @return boolean |
28 | 27 | */ |
29 | 28 | protected function _isSectionSet() { |