@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * Defines the field type slugs used for this field type. |
119 | 119 | * @var array |
120 | 120 | */ |
121 | - public $aFieldTypeSlugs = array( 'taxonomy', ); |
|
121 | + public $aFieldTypeSlugs = array( 'taxonomy',); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Defines the default key-values of this field type. |
@@ -127,41 +127,41 @@ discard block |
||
127 | 127 | * @var array |
128 | 128 | */ |
129 | 129 | protected $aDefaultKeys = array( |
130 | - 'taxonomy_slugs' => 'category', // (array|string) This is for the taxonomy field type. |
|
131 | - 'height' => '250px', // the tab box height |
|
132 | - 'width' => null, // 3.5.7.2+ the tab box width |
|
133 | - 'max_width' => '100%', // for the taxonomy checklist field type, since 2.1.1. |
|
134 | - 'show_post_count' => true, // (boolean) 3.2.0+ whether or not the post count associated with the term should be displayed or not. |
|
130 | + 'taxonomy_slugs' => 'category', // (array|string) This is for the taxonomy field type. |
|
131 | + 'height' => '250px', // the tab box height |
|
132 | + 'width' => null, // 3.5.7.2+ the tab box width |
|
133 | + 'max_width' => '100%', // for the taxonomy checklist field type, since 2.1.1. |
|
134 | + 'show_post_count' => true, // (boolean) 3.2.0+ whether or not the post count associated with the term should be displayed or not. |
|
135 | 135 | 'attributes' => array(), |
136 | - 'select_all_button' => true, // (boolean|string) 3.3.0+ to change the label, set the label here |
|
137 | - 'select_none_button' => true, // (boolean|string) 3.3.0+ to change the label, set the label here |
|
138 | - 'label_no_term_found' => null, // (string) 3.3.2+ The label to display when no term is found. null needs to be set here as the default value will be assigned in the field output method. |
|
139 | - 'label_list_title' => '', // (string) 3.3.2+ The heading title string for a term list. Default: `''`. Insert an HTML custom string right before the list starts. |
|
136 | + 'select_all_button' => true, // (boolean|string) 3.3.0+ to change the label, set the label here |
|
137 | + 'select_none_button' => true, // (boolean|string) 3.3.0+ to change the label, set the label here |
|
138 | + 'label_no_term_found' => null, // (string) 3.3.2+ The label to display when no term is found. null needs to be set here as the default value will be assigned in the field output method. |
|
139 | + 'label_list_title' => '', // (string) 3.3.2+ The heading title string for a term list. Default: `''`. Insert an HTML custom string right before the list starts. |
|
140 | 140 | 'query' => array( // (array) 3.3.2+ Defines the default query argument. |
141 | 141 | // see the arguments of the get_category() function: http://codex.wordpress.org/Function_Reference/get_categories |
142 | 142 | // see the argument of the get_terms() function: http://codex.wordpress.org/Function_Reference/get_terms |
143 | 143 | 'child_of' => 0, |
144 | 144 | 'parent' => '', |
145 | - 'orderby' => 'name', // (string) 'ID' or 'term_id' or 'name' |
|
146 | - 'order' => 'ASC', // (string) 'ASC' or 'DESC' |
|
147 | - 'hide_empty' => false, // (boolean) whether to show the terms with no post associated. Default: false |
|
148 | - 'hierarchical' => true, // (boolean) whether to show the terms as a hierarchical tree. |
|
149 | - 'number' => '', // (integer) The maximum number of the terms to show. |
|
150 | - 'pad_counts' => false, // (boolean) whether to sum up the post counts with the child post counts. |
|
151 | - 'exclude' => array(), // (string) Comma separated term IDs to exclude from the list. for example `1` will remove the 'Uncategorized' category from the list. |
|
145 | + 'orderby' => 'name', // (string) 'ID' or 'term_id' or 'name' |
|
146 | + 'order' => 'ASC', // (string) 'ASC' or 'DESC' |
|
147 | + 'hide_empty' => false, // (boolean) whether to show the terms with no post associated. Default: false |
|
148 | + 'hierarchical' => true, // (boolean) whether to show the terms as a hierarchical tree. |
|
149 | + 'number' => '', // (integer) The maximum number of the terms to show. |
|
150 | + 'pad_counts' => false, // (boolean) whether to sum up the post counts with the child post counts. |
|
151 | + 'exclude' => array(), // (string) Comma separated term IDs to exclude from the list. for example `1` will remove the 'Uncategorized' category from the list. |
|
152 | 152 | 'exclude_tree' => array(), |
153 | - 'include' => array(), // (string) Comma separated term IDs to include in the list. |
|
153 | + 'include' => array(), // (string) Comma separated term IDs to include in the list. |
|
154 | 154 | 'fields' => 'all', |
155 | 155 | 'slug' => '', |
156 | 156 | 'get' => '', |
157 | 157 | 'name__like' => '', |
158 | 158 | 'description__like' => '', |
159 | 159 | 'offset' => '', |
160 | - 'search' => '', // (string) The search keyword to get the term with. |
|
160 | + 'search' => '', // (string) The search keyword to get the term with. |
|
161 | 161 | 'cache_domain' => 'core', |
162 | 162 | ), |
163 | - 'queries' => array(), // (optional, array) 3.3.2+ Sets a query argument for each taxonomy. The array key must be the taxonomy slug and the value is the query argument array. |
|
164 | - 'save_unchecked' => true, // (optional, boolean) 3.8.8+ Whether to store the values of unchecked items. |
|
163 | + 'queries' => array(), // (optional, array) 3.3.2+ Sets a query argument for each taxonomy. The array key must be the taxonomy slug and the value is the query argument array. |
|
164 | + 'save_unchecked' => true, // (optional, boolean) 3.8.8+ Whether to store the values of unchecked items. |
|
165 | 165 | ); |
166 | 166 | |
167 | 167 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $_aJSArray = json_encode( $this->aFieldTypeSlugs ); |
193 | 193 | |
194 | - return parent::getScripts() . |
|
194 | + return parent::getScripts(). |
|
195 | 195 | // return |
196 | 196 | <<<JAVASCRIPTS |
197 | 197 | /* For tabs */ |
@@ -412,22 +412,22 @@ discard block |
||
412 | 412 | // Parse |
413 | 413 | $_aTabs = array(); |
414 | 414 | $_aCheckboxes = array(); |
415 | - foreach( $this->getAsArray( $aField[ 'taxonomy_slugs' ] ) as $_isKey => $_sTaxonomySlug ) { |
|
415 | + foreach ( $this->getAsArray( $aField[ 'taxonomy_slugs' ] ) as $_isKey => $_sTaxonomySlug ) { |
|
416 | 416 | $_aAssociatedDataAttributes = $this->_getDataAttributesOfAssociatedPostTypes( |
417 | 417 | $_sTaxonomySlug, |
418 | 418 | $this->_getPostTypesByTaxonomySlug( $_sTaxonomySlug ) |
419 | 419 | ); |
420 | - $_aTabs[] = $this->_getTaxonomyTab( $aField, $_isKey, $_sTaxonomySlug, $_aAssociatedDataAttributes ); |
|
421 | - $_aCheckboxes[] = $this->_getTaxonomyCheckboxes( $aField, $_isKey, $_sTaxonomySlug, $_aAssociatedDataAttributes ); |
|
420 | + $_aTabs[ ] = $this->_getTaxonomyTab( $aField, $_isKey, $_sTaxonomySlug, $_aAssociatedDataAttributes ); |
|
421 | + $_aCheckboxes[ ] = $this->_getTaxonomyCheckboxes( $aField, $_isKey, $_sTaxonomySlug, $_aAssociatedDataAttributes ); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | // Output |
425 | - return "<div id='tabbox-{$aField['field_id']}' class='tab-box-container categorydiv' style='max-width:{$aField['max_width']};'>" |
|
425 | + return "<div id='tabbox-{$aField[ 'field_id' ]}' class='tab-box-container categorydiv' style='max-width:{$aField[ 'max_width' ]};'>" |
|
426 | 426 | . "<ul class='tab-box-tabs category-tabs'>" |
427 | 427 | . implode( PHP_EOL, $_aTabs ) |
428 | 428 | . "</ul>" |
429 | 429 | . "<div class='tab-box-contents-container'>" |
430 | - . "<div class='tab-box-contents' style='height: {$aField['height']};'>" |
|
430 | + . "<div class='tab-box-contents' style='height: {$aField[ 'height' ]};'>" |
|
431 | 431 | . implode( PHP_EOL, $_aCheckboxes ) |
432 | 432 | . "</div>" |
433 | 433 | . "</div>" |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | private function _getDataAttributesOfAssociatedPostTypes( $sTaxonomySlusg, $aPostTypes ) { |
454 | 454 | return array( |
455 | 455 | 'data-associated-with' => $sTaxonomySlusg, |
456 | - 'data-associated-post-types' => implode( ',', $aPostTypes ) . ',', // must add a trailing comma for jQuery to detect the item. |
|
456 | + 'data-associated-post-types' => implode( ',', $aPostTypes ).',', // must add a trailing comma for jQuery to detect the item. |
|
457 | 457 | ); |
458 | 458 | } |
459 | 459 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | private function _getTaxonomyCheckboxes( array $aField, $sKey, $sTaxonomySlug, $aAttributes ) { |
469 | 469 | |
470 | 470 | $_aTabBoxContainerArguments = array( |
471 | - 'id' => "tab_{$aField['input_id']}_{$sKey}", |
|
471 | + 'id' => "tab_{$aField[ 'input_id' ]}_{$sKey}", |
|
472 | 472 | 'class' => 'tab-box-content', |
473 | 473 | 'style' => $this->getInlineCSS( |
474 | 474 | array( |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | ) |
478 | 478 | ), |
479 | 479 | ) + $aAttributes; |
480 | - return "<div " . $this->getAttributes( $_aTabBoxContainerArguments ) . ">" |
|
480 | + return "<div ".$this->getAttributes( $_aTabBoxContainerArguments ).">" |
|
481 | 481 | . $this->getElement( $aField, array( 'before_label', $sKey ) ) |
482 | - . "<div " . $this->getAttributes( $this->_getCheckboxContainerAttributes( $aField ) ) . ">" |
|
482 | + . "<div ".$this->getAttributes( $this->_getCheckboxContainerAttributes( $aField ) ).">" |
|
483 | 483 | . "</div>" |
484 | 484 | . "<ul class='list:category taxonomychecklist form-no-clear'>" |
485 | 485 | . $this->_getTaxonomyChecklist( $aField, $sKey, $sTaxonomySlug ) |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'taxonomy' => $sTaxonomySlug, |
505 | 505 | '_name_prefix' => is_array( $aField[ 'taxonomy_slugs' ] ) |
506 | 506 | ? "{$aField[ '_input_name' ]}[{$sTaxonomySlug}]" |
507 | - : $aField[ '_input_name' ], // name prefix of the input |
|
507 | + : $aField[ '_input_name' ], // name prefix of the input |
|
508 | 508 | '_input_id_prefix' => $aField[ 'input_id' ], |
509 | 509 | '_attributes' => $this->getElementAsArray( |
510 | 510 | $aField, |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | ) + $aField[ 'attributes' ], |
513 | 513 | |
514 | 514 | // checked items ( term IDs ) e.g. array( 6, 10, 7, 15 ), |
515 | - '_selected_items' => $this->_getSelectedKeyArray( $aField['value'], $sTaxonomySlug ), |
|
515 | + '_selected_items' => $this->_getSelectedKeyArray( $aField[ 'value' ], $sTaxonomySlug ), |
|
516 | 516 | |
517 | - 'echo' => false, // returns the output |
|
518 | - 'show_post_count' => $aField[ 'show_post_count' ], // 3.2.0+ |
|
519 | - 'show_option_none' => $aField[ 'label_no_term_found' ], // 3.3.2+ |
|
520 | - 'title_li' => $aField[ 'label_list_title' ], // 3.3.2+ |
|
517 | + 'echo' => false, // returns the output |
|
518 | + 'show_post_count' => $aField[ 'show_post_count' ], // 3.2.0+ |
|
519 | + 'show_option_none' => $aField[ 'label_no_term_found' ], // 3.3.2+ |
|
520 | + 'title_li' => $aField[ 'label_list_title' ], // 3.3.2+ |
|
521 | 521 | |
522 | 522 | '_save_unchecked' => $aField[ 'save_unchecked' ], // 3.8.8+ Whether to insert hidden input element for unchecked. |
523 | 523 | ) |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | $_aLiAttribues = array( |
565 | 565 | 'class' => 'tab-box-tab', |
566 | 566 | ) + $aAttributes; |
567 | - return "<li " . $this->getAttributes( $_aLiAttribues ) . ">" |
|
568 | - . "<a href='#tab_{$aField['input_id']}_{$sKey}'>" |
|
567 | + return "<li ".$this->getAttributes( $_aLiAttribues ).">" |
|
568 | + . "<a href='#tab_{$aField[ 'input_id' ]}_{$sKey}'>" |
|
569 | 569 | . "<span class='tab-box-tab-text'>" |
570 | 570 | . $this->_getLabelFromTaxonomySlug( $sTaxonomySlug ) |
571 | 571 | . "</span>" |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function getField( $aField ) { |
108 | 108 | |
109 | - $_aOutput = array(); |
|
110 | - foreach( $this->getAsArray( $aField['label'] ) as $_sKey => $_sLabel ) { |
|
111 | - $_aOutput[] = $this->_getEachRadioButtonOutput( $aField, $_sKey, $_sLabel ); |
|
109 | + $_aOutput = array(); |
|
110 | + foreach ( $this->getAsArray( $aField[ 'label' ] ) as $_sKey => $_sLabel ) { |
|
111 | + $_aOutput[ ] = $this->_getEachRadioButtonOutput( $aField, $_sKey, $_sLabel ); |
|
112 | 112 | } |
113 | - $_aOutput[] = $this->_getUpdateCheckedScript( $aField['input_id'] ); |
|
113 | + $_aOutput[ ] = $this->_getUpdateCheckedScript( $aField[ 'input_id' ] ); |
|
114 | 114 | return implode( PHP_EOL, $_aOutput ); |
115 | 115 | |
116 | 116 | } |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | $_aAttributes = $aField[ 'attributes' ] + $this->getElementAsArray( $aField, array( 'attributes', $sKey ) ); |
127 | 127 | $_oRadio = new AdminPageFramework_Input_radio( $_aAttributes ); |
128 | 128 | $_oRadio->setAttributesByKey( $sKey ); |
129 | - $_oRadio->setAttribute( 'data-default', $aField['default'] ); // refered by the repeater script |
|
129 | + $_oRadio->setAttribute( 'data-default', $aField[ 'default' ] ); // refered by the repeater script |
|
130 | 130 | |
131 | 131 | // Output |
132 | 132 | return $this->getElementByLabel( $aField[ 'before_label' ], $sKey, $aField[ 'label' ] ) |
133 | - . "<div " . $this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-container admin-page-framework-radio-label' ) . ">" |
|
134 | - . "<label " . $this->getAttributes( |
|
133 | + . "<div ".$this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-container admin-page-framework-radio-label' ).">" |
|
134 | + . "<label ".$this->getAttributes( |
|
135 | 135 | array( |
136 | 136 | 'for' => $_oRadio->getAttribute( 'id' ), |
137 | 137 | 'class' => $_oRadio->getAttribute( 'disabled' ) |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | protected function getField( $aField ) { |
508 | 508 | |
509 | 509 | $_aOutput = array(); |
510 | - foreach( ( array ) $aField[ 'label' ] as $_sKey => $_sLabel ) { |
|
511 | - $_aOutput[] = $this->_getFieldOutputByLabel( |
|
510 | + foreach ( ( array ) $aField[ 'label' ] as $_sKey => $_sLabel ) { |
|
511 | + $_aOutput[ ] = $this->_getFieldOutputByLabel( |
|
512 | 512 | $_sKey, |
513 | 513 | $_sLabel, |
514 | 514 | $aField |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | // the repeatable field buttons will be replaced with this element. |
519 | - $_aOutput[] = "<div class='repeatable-field-buttons'></div>"; |
|
519 | + $_aOutput[ ] = "<div class='repeatable-field-buttons'></div>"; |
|
520 | 520 | return implode( '', $_aOutput ); |
521 | 521 | |
522 | 522 | } |
@@ -537,27 +537,27 @@ discard block |
||
537 | 537 | $aField[ 'rich' ] = $this->getElementByLabel( $aField[ 'rich' ], $sKey, $aField[ 'label' ] ); |
538 | 538 | $aField[ 'attributes' ] = $_bIsArray |
539 | 539 | ? array( |
540 | - 'name' => $aField[ 'attributes' ][ 'name' ] . "[{$sKey}]", |
|
541 | - 'id' => $aField[ 'attributes' ][ 'id' ] . "_{$sKey}", |
|
540 | + 'name' => $aField[ 'attributes' ][ 'name' ]."[{$sKey}]", |
|
541 | + 'id' => $aField[ 'attributes' ][ 'id' ]."_{$sKey}", |
|
542 | 542 | 'value' => $aField[ 'value' ], |
543 | 543 | ) |
544 | 544 | + $aField[ 'attributes' ] |
545 | 545 | : $aField[ 'attributes' ]; |
546 | - $_aOutput = array( |
|
547 | - $this->getElementByLabel( $aField['before_label'], $sKey, $aField[ 'label' ] ), |
|
546 | + $_aOutput = array( |
|
547 | + $this->getElementByLabel( $aField[ 'before_label' ], $sKey, $aField[ 'label' ] ), |
|
548 | 548 | "<div class='admin-page-framework-input-label-container {$_sClassSelector}'>", |
549 | - "<label for='" . $aField[ 'attributes' ][ 'id' ] . "'>", |
|
550 | - $this->getElementByLabel( $aField['before_input'], $sKey, $aField[ 'label' ] ), |
|
549 | + "<label for='".$aField[ 'attributes' ][ 'id' ]."'>", |
|
550 | + $this->getElementByLabel( $aField[ 'before_input' ], $sKey, $aField[ 'label' ] ), |
|
551 | 551 | $_sLabel |
552 | - ? "<span " . $this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ) . ">" |
|
552 | + ? "<span ".$this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ).">" |
|
553 | 553 | . $_sLabel |
554 | 554 | . "</span>" |
555 | 555 | : '', |
556 | 556 | $this->_getEditor( $aField ), |
557 | - $this->getElementByLabel( $aField['after_input'], $sKey, $aField[ 'label' ] ), |
|
557 | + $this->getElementByLabel( $aField[ 'after_input' ], $sKey, $aField[ 'label' ] ), |
|
558 | 558 | "</label>", |
559 | 559 | "</div>", |
560 | - $this->getElementByLabel( $aField['after_label'], $sKey, $aField[ 'label' ] ), |
|
560 | + $this->getElementByLabel( $aField[ 'after_label' ], $sKey, $aField[ 'label' ] ), |
|
561 | 561 | ); |
562 | 562 | return implode( '', $_aOutput ); |
563 | 563 | |
@@ -572,31 +572,31 @@ discard block |
||
572 | 572 | */ |
573 | 573 | private function _getEditor( $aField ) { |
574 | 574 | |
575 | - unset( $aField['attributes']['value'] ); |
|
575 | + unset( $aField[ 'attributes' ][ 'value' ] ); |
|
576 | 576 | |
577 | 577 | // For no TinyMCE |
578 | - if ( empty( $aField['rich'] ) || ! $this->isTinyMCESupported() ) { |
|
579 | - return "<textarea " . $this->getAttributes( $aField['attributes'] ) . " >" // this method is defined in the base class |
|
580 | - . esc_textarea( $aField['value'] ) |
|
578 | + if ( empty( $aField[ 'rich' ] ) || !$this->isTinyMCESupported() ) { |
|
579 | + return "<textarea ".$this->getAttributes( $aField[ 'attributes' ] )." >" // this method is defined in the base class |
|
580 | + . esc_textarea( $aField[ 'value' ] ) |
|
581 | 581 | . "</textarea>"; |
582 | 582 | } |
583 | 583 | |
584 | 584 | // Rich editor |
585 | 585 | ob_start(); |
586 | 586 | wp_editor( |
587 | - $aField['value'], |
|
588 | - $aField['attributes']['id'], |
|
587 | + $aField[ 'value' ], |
|
588 | + $aField[ 'attributes' ][ 'id' ], |
|
589 | 589 | $this->uniteArrays( |
590 | - ( array ) $aField['rich'], |
|
590 | + ( array ) $aField[ 'rich' ], |
|
591 | 591 | array( |
592 | 592 | 'wpautop' => true, // use wpautop? |
593 | 593 | 'media_buttons' => true, // show insert/upload button(s) |
594 | - 'textarea_name' => $aField['attributes']['name'], |
|
595 | - 'textarea_rows' => $aField['attributes']['rows'], |
|
594 | + 'textarea_name' => $aField[ 'attributes' ][ 'name' ], |
|
595 | + 'textarea_rows' => $aField[ 'attributes' ][ 'rows' ], |
|
596 | 596 | 'tabindex' => '', |
597 | 597 | 'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE |
598 | 598 | 'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped". |
599 | - 'editor_class' => $aField['attributes']['class'], // add extra class(es) to the editor textarea |
|
599 | + 'editor_class' => $aField[ 'attributes' ][ 'class' ], // add extra class(es) to the editor textarea |
|
600 | 600 | 'teeny' => false, // output the minimal editor config used in Press This |
601 | 601 | 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css) |
602 | 602 | 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | ob_end_clean(); |
609 | 609 | |
610 | 610 | return $_sContent |
611 | - . $this->_getScriptForRichEditor( $aField['attributes']['id'] ); |
|
611 | + . $this->_getScriptForRichEditor( $aField[ 'attributes' ][ 'id' ] ); |
|
612 | 612 | |
613 | 613 | } |
614 | 614 |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * Defines the default key-values of this field type. |
77 | 77 | */ |
78 | 78 | protected $aDefaultKeys = array( |
79 | - 'select_all_button' => false, // 3.3.0+ to change the label, set the label here |
|
80 | - 'select_none_button' => false, // 3.3.0+ to change the label, set the label here |
|
81 | - 'save_unchecked' => true, // (optional, boolean) 3.8.8+ Whether to store the values of unchecked items. |
|
79 | + 'select_all_button' => false, // 3.3.0+ to change the label, set the label here |
|
80 | + 'select_none_button' => false, // 3.3.0+ to change the label, set the label here |
|
81 | + 'save_unchecked' => true, // (optional, boolean) 3.8.8+ Whether to store the values of unchecked items. |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | protected function getScripts() { |
92 | 92 | new AdminPageFramework_Form_View___Script_CheckboxSelector; |
93 | - $_sClassSelectorSelectAll = $this->_getSelectButtonClassSelectors( |
|
93 | + $_sClassSelectorSelectAll = $this->_getSelectButtonClassSelectors( |
|
94 | 94 | $this->aFieldTypeSlugs, |
95 | 95 | 'select_all_button' // data attribute |
96 | 96 | ); |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | * @return string |
118 | 118 | * @internal |
119 | 119 | */ |
120 | - private function _getSelectButtonClassSelectors( array $aFieldTypeSlugs, $sDataAttribute='select_all_button' ) { |
|
120 | + private function _getSelectButtonClassSelectors( array $aFieldTypeSlugs, $sDataAttribute = 'select_all_button' ) { |
|
121 | 121 | |
122 | 122 | $_aClassSelectors = array(); |
123 | 123 | foreach ( $aFieldTypeSlugs as $_sSlug ) { |
124 | - if ( ! is_scalar( $_sSlug ) ) { |
|
124 | + if ( !is_scalar( $_sSlug ) ) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | - $_aClassSelectors[] = '.admin-page-framework-checkbox-container-' . $_sSlug . "[data-{$sDataAttribute}]"; |
|
127 | + $_aClassSelectors[ ] = '.admin-page-framework-checkbox-container-'.$_sSlug."[data-{$sDataAttribute}]"; |
|
128 | 128 | } |
129 | 129 | return implode( ',', $_aClassSelectors ); |
130 | 130 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | |
186 | 186 | $_aOutput = array(); |
187 | 187 | $_bIsMultiple = is_array( $aField[ 'label' ] ); |
188 | - foreach( $this->getAsArray( $aField[ 'label' ], true ) as $_sKey => $_sLabel ) { |
|
189 | - $_aOutput[] = $this->_getEachCheckboxOutput( |
|
188 | + foreach ( $this->getAsArray( $aField[ 'label' ], true ) as $_sKey => $_sLabel ) { |
|
189 | + $_aOutput[ ] = $this->_getEachCheckboxOutput( |
|
190 | 190 | $aField, |
191 | 191 | $_bIsMultiple |
192 | 192 | ? $_sKey |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $_sLabel |
195 | 195 | ); |
196 | 196 | } |
197 | - return "<div " . $this->getAttributes( $this->_getCheckboxContainerAttributes( $aField ) ) . ">" |
|
197 | + return "<div ".$this->getAttributes( $this->_getCheckboxContainerAttributes( $aField ) ).">" |
|
198 | 198 | . "<div class='repeatable-field-buttons'></div>" // the repeatable field buttons will be replaced with this element. |
199 | 199 | . implode( PHP_EOL, $_aOutput ) |
200 | 200 | . "</div>"; |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function _getCheckboxContainerAttributes( array $aField ) { |
211 | 211 | return array( |
212 | - 'class' => 'admin-page-framework-checkbox-container-' . $aField[ 'type' ], |
|
212 | + 'class' => 'admin-page-framework-checkbox-container-'.$aField[ 'type' ], |
|
213 | 213 | 'data-select_all_button' => $aField[ 'select_all_button' ] |
214 | - ? ( ! is_string( $aField[ 'select_all_button' ] ) ? $this->oMsg->get( 'select_all' ) : $aField[ 'select_all_button' ] ) |
|
214 | + ? ( !is_string( $aField[ 'select_all_button' ] ) ? $this->oMsg->get( 'select_all' ) : $aField[ 'select_all_button' ] ) |
|
215 | 215 | : null, |
216 | 216 | 'data-select_none_button' => $aField[ 'select_none_button' ] |
217 | - ? ( ! is_string( $aField[ 'select_none_button' ] ) ? $this->oMsg->get( 'select_none' ) : $aField[ 'select_none_button' ] ) |
|
217 | + ? ( !is_string( $aField[ 'select_none_button' ] ) ? $this->oMsg->get( 'select_none' ) : $aField[ 'select_none_button' ] ) |
|
218 | 218 | : null, |
219 | 219 | ); |
220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | private function _getEachCheckboxOutput( array $aField, $sKey, $sLabel ) { |
230 | 230 | |
231 | 231 | $_aInputAttributes = array( |
232 | - 'data-key' => $sKey, // 3.8.8+ For the `post_type_taxonomy` field type. |
|
232 | + 'data-key' => $sKey, // 3.8.8+ For the `post_type_taxonomy` field type. |
|
233 | 233 | ) + $aField[ 'attributes' ]; |
234 | 234 | $_oCheckbox = new AdminPageFramework_Input_checkbox( |
235 | 235 | $_aInputAttributes, |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | $_oCheckbox->setAttributesByKey( $sKey ); |
241 | 241 | $_oCheckbox->addClass( $this->_sCheckboxClassSelector ); |
242 | 242 | return $this->getElementByLabel( $aField[ 'before_label' ], $sKey, $aField[ 'label' ] ) |
243 | - . "<div " . $this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-container admin-page-framework-checkbox-label' ) . ">" |
|
244 | - . "<label " . $this->getAttributes( |
|
243 | + . "<div ".$this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-container admin-page-framework-checkbox-label' ).">" |
|
244 | + . "<label ".$this->getAttributes( |
|
245 | 245 | array( |
246 | 246 | 'for' => $_oCheckbox->getAttribute( 'id' ), |
247 | 247 | 'class' => $_oCheckbox->getAttribute( 'disabled' ) |
@@ -219,7 +219,7 @@ |
||
219 | 219 | * </code> |
220 | 220 | * @access public This must be public as accessed from outside. |
221 | 221 | */ |
222 | - public $aFieldTypeSlugs = array( 'default', ); |
|
222 | + public $aFieldTypeSlugs = array( 'default',); |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * Defines the default key-values of this field type. |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // For front-end |
86 | 86 | // @see http://wordpress.stackexchange.com/a/82722 |
87 | - if ( ! is_admin() ) { |
|
87 | + if ( !is_admin() ) { |
|
88 | 88 | |
89 | 89 | // wp_enqueue_style( 'wp-color-picker' ); |
90 | 90 | wp_enqueue_script( |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | protected function getField( $aField ) { |
277 | 277 | |
278 | 278 | // If the value is not set, apply the default value, 'transparent'. |
279 | - $aField['value'] = is_null( $aField['value'] ) |
|
279 | + $aField[ 'value' ] = is_null( $aField[ 'value' ] ) |
|
280 | 280 | ? 'transparent' |
281 | - : $aField['value']; |
|
281 | + : $aField[ 'value' ]; |
|
282 | 282 | |
283 | 283 | $aField[ 'attributes' ] = $this->_getInputAttributes( $aField ); |
284 | 284 | |
@@ -287,20 +287,20 @@ discard block |
||
287 | 287 | . "<div class='admin-page-framework-input-label-container'>" |
288 | 288 | . "<label for='{$aField[ 'input_id' ]}'>" |
289 | 289 | . $aField[ 'before_input' ] |
290 | - . ( $aField[ 'label' ] && ! $aField[ 'repeatable' ] |
|
291 | - ? "<span " . $this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ) . ">" |
|
292 | - . $aField['label'] |
|
290 | + . ( $aField[ 'label' ] && !$aField[ 'repeatable' ] |
|
291 | + ? "<span ".$this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ).">" |
|
292 | + . $aField[ 'label' ] |
|
293 | 293 | . "</span>" |
294 | 294 | : "" |
295 | 295 | ) |
296 | - . "<input " . $this->getAttributes( $aField[ 'attributes' ] ) . " />" |
|
296 | + . "<input ".$this->getAttributes( $aField[ 'attributes' ] )." />" |
|
297 | 297 | . $aField[ 'after_input' ] |
298 | 298 | . "<div class='repeatable-field-buttons'></div>" // the repeatable field buttons will be replaced with this element. |
299 | 299 | . "</label>" |
300 | 300 | . "<div class='colorpicker' id='color_{$aField[ 'input_id' ]}'></div>" // this div element with this class selector becomes a farbtastic color picker. ( below 3.4.x ) // rel='{$aField['input_id']}' |
301 | 301 | . $this->_getColorPickerEnablerScript( "{$aField[ 'input_id' ]}" ) |
302 | 302 | . "</div>" |
303 | - . $aField['after_label']; |
|
303 | + . $aField[ 'after_label' ]; |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | /** |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | private function _getInputAttributes( array $aField ) { |
313 | 313 | |
314 | 314 | return array( |
315 | - 'color' => $aField['value'], |
|
316 | - 'value' => $aField['value'], |
|
315 | + 'color' => $aField[ 'value' ], |
|
316 | + 'value' => $aField[ 'value' ], |
|
317 | 317 | 'data-default' => isset( $aField[ 'default' ] ) |
318 | 318 | ? $aField[ 'default' ] |
319 | 319 | : 'transparent', // used by the repeatable script |
320 | 320 | 'type' => 'text', // it must be text |
321 | - 'class' => trim( 'input_color ' . $aField['attributes']['class'] ), |
|
321 | + 'class' => trim( 'input_color '.$aField[ 'attributes' ][ 'class' ] ), |
|
322 | 322 | ) + $aField[ 'attributes' ]; |
323 | 323 | |
324 | 324 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Defines the field type slugs used for this field type. |
40 | 40 | */ |
41 | - public $aFieldTypeSlugs = array( 'text', 'password', 'date', 'datetime', 'datetime-local', 'email', 'month', 'search', 'tel', 'url', 'week', ); |
|
41 | + public $aFieldTypeSlugs = array( 'text', 'password', 'date', 'datetime', 'datetime-local', 'email', 'month', 'search', 'tel', 'url', 'week',); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Defines the default key-values of this field type. |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | protected function getField( $aField ) { |
83 | 83 | |
84 | 84 | $_aOutput = array(); |
85 | - foreach( ( array ) $aField[ 'label' ] as $_sKey => $_sLabel ) { |
|
86 | - $_aOutput[] = $this->_getFieldOutputByLabel( |
|
85 | + foreach ( ( array ) $aField[ 'label' ] as $_sKey => $_sLabel ) { |
|
86 | + $_aOutput[ ] = $this->_getFieldOutputByLabel( |
|
87 | 87 | $_sKey, |
88 | 88 | $_sLabel, |
89 | 89 | $aField |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | // the repeatable field buttons will be replaced with this element. |
94 | - $_aOutput[] = "<div class='repeatable-field-buttons'></div>"; |
|
94 | + $_aOutput[ ] = "<div class='repeatable-field-buttons'></div>"; |
|
95 | 95 | return implode( '', $_aOutput ); |
96 | 96 | |
97 | 97 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | $aField[ 'value' ] = $this->getElementByLabel( $aField[ 'value' ], $sKey, $aField[ 'label' ] ); |
112 | 112 | $_aInputAttributes = $_bIsArray |
113 | 113 | ? array( |
114 | - 'name' => $aField[ 'attributes' ][ 'name' ] . "[{$sKey}]", |
|
115 | - 'id' => $aField[ 'attributes' ][ 'id' ] . "_{$sKey}", |
|
114 | + 'name' => $aField[ 'attributes' ][ 'name' ]."[{$sKey}]", |
|
115 | + 'id' => $aField[ 'attributes' ][ 'id' ]."_{$sKey}", |
|
116 | 116 | 'value' => $aField[ 'value' ], |
117 | 117 | ) |
118 | 118 | + $this->getAsArray( |
@@ -120,17 +120,17 @@ discard block |
||
120 | 120 | ) // 3.8.6+ Allows the user to set individual attributes by label. |
121 | 121 | + $aField[ 'attributes' ] |
122 | 122 | : $aField[ 'attributes' ]; |
123 | - $_aOutput = array( |
|
123 | + $_aOutput = array( |
|
124 | 124 | $this->getElementByLabel( $aField[ 'before_label' ], $sKey, $aField[ 'label' ] ), |
125 | 125 | "<div class='admin-page-framework-input-label-container {$_sClassSelector}'>", |
126 | - "<label for='" . $_aInputAttributes[ 'id' ] . "'>", |
|
126 | + "<label for='".$_aInputAttributes[ 'id' ]."'>", |
|
127 | 127 | $this->getElementByLabel( $aField[ 'before_input' ], $sKey, $aField[ 'label' ] ), |
128 | 128 | $_sLabel |
129 | - ? "<span " . $this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ) . ">" |
|
129 | + ? "<span ".$this->getLabelContainerAttributes( $aField, 'admin-page-framework-input-label-string' ).">" |
|
130 | 130 | . $_sLabel |
131 | 131 | . "</span>" |
132 | 132 | : '', |
133 | - "<input " . $this->getAttributes( $_aInputAttributes ) . " />", |
|
133 | + "<input ".$this->getAttributes( $_aInputAttributes )." />", |
|
134 | 134 | $this->getElementByLabel( $aField[ 'after_input' ], $sKey, $aField[ 'label' ] ), |
135 | 135 | "</label>", |
136 | 136 | "</div>", |
@@ -47,7 +47,7 @@ |
||
47 | 47 | /** |
48 | 48 | * Defines the field type slugs used for this field type. |
49 | 49 | */ |
50 | - public $aFieldTypeSlugs = array( 'section_title', ); |
|
50 | + public $aFieldTypeSlugs = array( 'section_title',); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Defines the default key-values of this field type. |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Defines the field type slugs used for this field type. |
53 | 53 | */ |
54 | - public $aFieldTypeSlugs = array( 'export', ); |
|
54 | + public $aFieldTypeSlugs = array( 'export',); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Defines the default key-values of this field type. |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @remark $_aDefaultKeys holds shared default key-values defined in the base class. |
60 | 60 | */ |
61 | 61 | protected $aDefaultKeys = array( |
62 | - 'data' => null, // ( array|string|object ) This is for the export field type. Do not set a value here. |
|
63 | - 'format' => 'json', // ( string ) for the export field type. Do not set a default value here. Currently array, json, and text are supported. |
|
64 | - 'file_name' => null, // ( string ) for the export field type. Do not set a default value here. |
|
62 | + 'data' => null, // ( array|string|object ) This is for the export field type. Do not set a value here. |
|
63 | + 'format' => 'json', // ( string ) for the export field type. Do not set a default value here. Currently array, json, and text are supported. |
|
64 | + 'file_name' => null, // ( string ) for the export field type. Do not set a default value here. |
|
65 | 65 | 'attributes' => array( |
66 | 66 | 'class' => 'button button-primary', |
67 | 67 | ), |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | protected function getField( $aField ) { |
107 | 107 | |
108 | 108 | /* Set the transient data to export - If the value is not an array and the export data is set. */ |
109 | - if ( isset( $aField['data'] ) ) { |
|
110 | - $this->setTransient( md5( "{$aField['class_name']}_{$aField['input_id']}" ), $aField['data'], 60*2 ); // 2 minutes. |
|
109 | + if ( isset( $aField[ 'data' ] ) ) { |
|
110 | + $this->setTransient( md5( "{$aField[ 'class_name' ]}_{$aField[ 'input_id' ]}" ), $aField[ 'data' ], 60 * 2 ); // 2 minutes. |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /* Set some required values */ |
114 | - $aField['attributes']['name'] = "__export[submit][{$aField['input_id']}]"; |
|
115 | - $aField['file_name'] = $aField['file_name'] ? $aField['file_name'] : $this->_generateExportFileName( $aField['option_key'] ? $aField['option_key'] : $aField['class_name'], $aField['format'] ); |
|
116 | - $aField['label'] = $aField['label'] ? $aField['label'] : $this->oMsg->get( 'export' ); |
|
114 | + $aField[ 'attributes' ][ 'name' ] = "__export[submit][{$aField[ 'input_id' ]}]"; |
|
115 | + $aField[ 'file_name' ] = $aField[ 'file_name' ] ? $aField[ 'file_name' ] : $this->_generateExportFileName( $aField[ 'option_key' ] ? $aField[ 'option_key' ] : $aField[ 'class_name' ], $aField[ 'format' ] ); |
|
116 | + $aField[ 'label' ] = $aField[ 'label' ] ? $aField[ 'label' ] : $this->oMsg->get( 'export' ); |
|
117 | 117 | |
118 | 118 | return parent::getField( $aField ); |
119 | 119 | |
@@ -129,42 +129,42 @@ discard block |
||
129 | 129 | |
130 | 130 | $_aAttributes = array( 'type' => 'hidden' ); |
131 | 131 | return |
132 | - "<input " . $this->getAttributes( |
|
132 | + "<input ".$this->getAttributes( |
|
133 | 133 | array( |
134 | - 'name' => "__export[{$aField['input_id']}][input_id]", |
|
135 | - 'value' => $aField['input_id'], |
|
134 | + 'name' => "__export[{$aField[ 'input_id' ]}][input_id]", |
|
135 | + 'value' => $aField[ 'input_id' ], |
|
136 | 136 | ) + $_aAttributes |
137 | - ) . "/>" |
|
138 | - . "<input " . $this->getAttributes( |
|
137 | + )."/>" |
|
138 | + . "<input ".$this->getAttributes( |
|
139 | 139 | array( |
140 | - 'name' => "__export[{$aField['input_id']}][field_id]", |
|
141 | - 'value' => $aField['field_id'], |
|
140 | + 'name' => "__export[{$aField[ 'input_id' ]}][field_id]", |
|
141 | + 'value' => $aField[ 'field_id' ], |
|
142 | 142 | ) + $_aAttributes |
143 | - ) . "/>" |
|
144 | - . "<input " . $this->getAttributes( |
|
143 | + )."/>" |
|
144 | + . "<input ".$this->getAttributes( |
|
145 | 145 | array( |
146 | - 'name' => "__export[{$aField['input_id']}][section_id]", |
|
147 | - 'value' => isset( $aField['section_id'] ) && $aField['section_id'] != '_default' ? $aField['section_id'] : '', |
|
146 | + 'name' => "__export[{$aField[ 'input_id' ]}][section_id]", |
|
147 | + 'value' => isset( $aField[ 'section_id' ] ) && $aField[ 'section_id' ] != '_default' ? $aField[ 'section_id' ] : '', |
|
148 | 148 | ) + $_aAttributes |
149 | - ) . "/>" |
|
150 | - . "<input " . $this->getAttributes( |
|
149 | + )."/>" |
|
150 | + . "<input ".$this->getAttributes( |
|
151 | 151 | array( |
152 | - 'name' => "__export[{$aField['input_id']}][file_name]", |
|
153 | - 'value' => $aField['file_name'], |
|
152 | + 'name' => "__export[{$aField[ 'input_id' ]}][file_name]", |
|
153 | + 'value' => $aField[ 'file_name' ], |
|
154 | 154 | ) + $_aAttributes |
155 | - ) . "/>" |
|
156 | - . "<input " . $this->getAttributes( |
|
155 | + )."/>" |
|
156 | + . "<input ".$this->getAttributes( |
|
157 | 157 | array( |
158 | - 'name' => "__export[{$aField['input_id']}][format]", |
|
159 | - 'value' => $aField['format'], |
|
158 | + 'name' => "__export[{$aField[ 'input_id' ]}][format]", |
|
159 | + 'value' => $aField[ 'format' ], |
|
160 | 160 | ) + $_aAttributes |
161 | - ) . "/>" |
|
162 | - . "<input " . $this->getAttributes( |
|
161 | + )."/>" |
|
162 | + . "<input ".$this->getAttributes( |
|
163 | 163 | array( |
164 | - 'name' => "__export[{$aField['input_id']}][transient]", |
|
165 | - 'value' => isset( $aField['data'] ), |
|
164 | + 'name' => "__export[{$aField[ 'input_id' ]}][transient]", |
|
165 | + 'value' => isset( $aField[ 'data' ] ), |
|
166 | 166 | ) + $_aAttributes |
167 | - ) . "/>" |
|
167 | + )."/>" |
|
168 | 168 | ; |
169 | 169 | } |
170 | 170 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @since 2.1.5 Moved from the AdminPageFramework_FormField class. |
179 | 179 | * @internal |
180 | 180 | */ |
181 | - private function _generateExportFileName( $sOptionKey, $sExportFormat='json' ) { |
|
181 | + private function _generateExportFileName( $sOptionKey, $sExportFormat = 'json' ) { |
|
182 | 182 | |
183 | 183 | switch ( trim( strtolower( $sExportFormat ) ) ) { |
184 | 184 | case 'text': // for plain text. |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | break; |
194 | 194 | } |
195 | 195 | |
196 | - return $sOptionKey . '_' . date("Ymd") . '.' . $sExt; |
|
196 | + return $sOptionKey.'_'.date( "Ymd" ).'.'.$sExt; |
|
197 | 197 | |
198 | 198 | } |
199 | 199 |