@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | // do not delete! |
| 49 | - parent::__construct(); |
|
| 49 | + parent::__construct(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_text') ) : |
|
| 14 | +if ( ! class_exists('acf_field_text')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_text extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'text'; |
| 36 | - $this->label = __("Text",'acf'); |
|
| 36 | + $this->label = __("Text", 'acf'); |
|
| 37 | 37 | $this->defaults = array( |
| 38 | 38 | 'default_value' => '', |
| 39 | 39 | 'maxlength' => '', |
@@ -62,16 +62,16 @@ discard block |
||
| 62 | 62 | * @date 23/01/13 |
| 63 | 63 | */ |
| 64 | 64 | |
| 65 | - function render_field( $field ) { |
|
| 65 | + function render_field($field) { |
|
| 66 | 66 | |
| 67 | 67 | // vars |
| 68 | - $o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' ); |
|
| 69 | - $s = array( 'readonly', 'disabled' ); |
|
| 68 | + $o = array('type', 'id', 'class', 'name', 'value', 'placeholder'); |
|
| 69 | + $s = array('readonly', 'disabled'); |
|
| 70 | 70 | $e = ''; |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | // maxlength |
| 74 | - if( $field['maxlength'] !== "" ) { |
|
| 74 | + if ($field['maxlength'] !== "") { |
|
| 75 | 75 | |
| 76 | 76 | $o[] = 'maxlength'; |
| 77 | 77 | |
@@ -79,38 +79,38 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // prepend |
| 82 | - if( $field['prepend'] !== "" ) { |
|
| 82 | + if ($field['prepend'] !== "") { |
|
| 83 | 83 | |
| 84 | 84 | $field['class'] .= ' acf-is-prepended'; |
| 85 | - $e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>'; |
|
| 85 | + $e .= '<div class="acf-input-prepend">'.$field['prepend'].'</div>'; |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | // append |
| 91 | - if( $field['append'] !== "" ) { |
|
| 91 | + if ($field['append'] !== "") { |
|
| 92 | 92 | |
| 93 | 93 | $field['class'] .= ' acf-is-appended'; |
| 94 | - $e .= '<div class="acf-input-append">' . $field['append'] . '</div>'; |
|
| 94 | + $e .= '<div class="acf-input-append">'.$field['append'].'</div>'; |
|
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | // populate atts |
| 100 | 100 | $atts = array(); |
| 101 | - foreach( $o as $k ) { |
|
| 101 | + foreach ($o as $k) { |
|
| 102 | 102 | |
| 103 | - $atts[ $k ] = $field[ $k ]; |
|
| 103 | + $atts[$k] = $field[$k]; |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | // special atts |
| 109 | - foreach( $s as $k ) { |
|
| 109 | + foreach ($s as $k) { |
|
| 110 | 110 | |
| 111 | - if( $field[ $k ] ) { |
|
| 111 | + if ($field[$k]) { |
|
| 112 | 112 | |
| 113 | - $atts[ $k ] = $k; |
|
| 113 | + $atts[$k] = $k; |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // render |
| 121 | 121 | $e .= '<div class="acf-input-wrap">'; |
| 122 | - $e .= '<input ' . acf_esc_attr( $atts ) . ' />'; |
|
| 122 | + $e .= '<input '.acf_esc_attr($atts).' />'; |
|
| 123 | 123 | $e .= '</div>'; |
| 124 | 124 | |
| 125 | 125 | |
@@ -141,48 +141,48 @@ discard block |
||
| 141 | 141 | * @date 23/01/13 |
| 142 | 142 | */ |
| 143 | 143 | |
| 144 | - function render_field_settings( $field ) { |
|
| 144 | + function render_field_settings($field) { |
|
| 145 | 145 | |
| 146 | 146 | // default_value |
| 147 | - acf_render_field_setting( $field, array( |
|
| 148 | - 'label' => __('Default Value','acf'), |
|
| 149 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
| 147 | + acf_render_field_setting($field, array( |
|
| 148 | + 'label' => __('Default Value', 'acf'), |
|
| 149 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
| 150 | 150 | 'type' => 'text', |
| 151 | 151 | 'name' => 'default_value', |
| 152 | 152 | )); |
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | // placeholder |
| 156 | - acf_render_field_setting( $field, array( |
|
| 157 | - 'label' => __('Placeholder Text','acf'), |
|
| 158 | - 'instructions' => __('Appears within the input','acf'), |
|
| 156 | + acf_render_field_setting($field, array( |
|
| 157 | + 'label' => __('Placeholder Text', 'acf'), |
|
| 158 | + 'instructions' => __('Appears within the input', 'acf'), |
|
| 159 | 159 | 'type' => 'text', |
| 160 | 160 | 'name' => 'placeholder', |
| 161 | 161 | )); |
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | // prepend |
| 165 | - acf_render_field_setting( $field, array( |
|
| 166 | - 'label' => __('Prepend','acf'), |
|
| 167 | - 'instructions' => __('Appears before the input','acf'), |
|
| 165 | + acf_render_field_setting($field, array( |
|
| 166 | + 'label' => __('Prepend', 'acf'), |
|
| 167 | + 'instructions' => __('Appears before the input', 'acf'), |
|
| 168 | 168 | 'type' => 'text', |
| 169 | 169 | 'name' => 'prepend', |
| 170 | 170 | )); |
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | // append |
| 174 | - acf_render_field_setting( $field, array( |
|
| 175 | - 'label' => __('Append','acf'), |
|
| 176 | - 'instructions' => __('Appears after the input','acf'), |
|
| 174 | + acf_render_field_setting($field, array( |
|
| 175 | + 'label' => __('Append', 'acf'), |
|
| 176 | + 'instructions' => __('Appears after the input', 'acf'), |
|
| 177 | 177 | 'type' => 'text', |
| 178 | 178 | 'name' => 'append', |
| 179 | 179 | )); |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | // maxlength |
| 183 | - acf_render_field_setting( $field, array( |
|
| 184 | - 'label' => __('Character Limit','acf'), |
|
| 185 | - 'instructions' => __('Leave blank for no limit','acf'), |
|
| 183 | + acf_render_field_setting($field, array( |
|
| 184 | + 'label' => __('Character Limit', 'acf'), |
|
| 185 | + 'instructions' => __('Leave blank for no limit', 'acf'), |
|
| 186 | 186 | 'type' => 'number', |
| 187 | 187 | 'name' => 'maxlength', |
| 188 | 188 | )); |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | // do not delete! |
| 49 | - parent::__construct(); |
|
| 49 | + parent::__construct(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_textarea') ) : |
|
| 14 | +if ( ! class_exists('acf_field_textarea')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_textarea extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'textarea'; |
| 36 | - $this->label = __("Text Area",'acf'); |
|
| 36 | + $this->label = __("Text Area", 'acf'); |
|
| 37 | 37 | $this->defaults = array( |
| 38 | 38 | 'default_value' => '', |
| 39 | 39 | 'new_lines' => '', |
@@ -62,16 +62,16 @@ discard block |
||
| 62 | 62 | * @date 23/01/13 |
| 63 | 63 | */ |
| 64 | 64 | |
| 65 | - function render_field( $field ) { |
|
| 65 | + function render_field($field) { |
|
| 66 | 66 | |
| 67 | 67 | // vars |
| 68 | - $o = array( 'id', 'class', 'name', 'placeholder', 'rows' ); |
|
| 69 | - $s = array( 'readonly', 'disabled' ); |
|
| 68 | + $o = array('id', 'class', 'name', 'placeholder', 'rows'); |
|
| 69 | + $s = array('readonly', 'disabled'); |
|
| 70 | 70 | $e = ''; |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | // maxlength |
| 74 | - if( $field['maxlength'] !== '' ) { |
|
| 74 | + if ($field['maxlength'] !== '') { |
|
| 75 | 75 | |
| 76 | 76 | $o[] = 'maxlength'; |
| 77 | 77 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // rows |
| 82 | - if( empty($field['rows']) ) { |
|
| 82 | + if (empty($field['rows'])) { |
|
| 83 | 83 | |
| 84 | 84 | $field['rows'] = 8; |
| 85 | 85 | |
@@ -88,27 +88,27 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | // populate atts |
| 90 | 90 | $atts = array(); |
| 91 | - foreach( $o as $k ) { |
|
| 91 | + foreach ($o as $k) { |
|
| 92 | 92 | |
| 93 | - $atts[ $k ] = $field[ $k ]; |
|
| 93 | + $atts[$k] = $field[$k]; |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | // special atts |
| 99 | - foreach( $s as $k ) { |
|
| 99 | + foreach ($s as $k) { |
|
| 100 | 100 | |
| 101 | - if( $field[ $k ] ) { |
|
| 101 | + if ($field[$k]) { |
|
| 102 | 102 | |
| 103 | - $atts[ $k ] = $k; |
|
| 103 | + $atts[$k] = $k; |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | |
| 110 | - $e .= '<textarea ' . acf_esc_attr( $atts ) . ' >'; |
|
| 111 | - $e .= esc_textarea( $field['value'] ); |
|
| 110 | + $e .= '<textarea '.acf_esc_attr($atts).' >'; |
|
| 111 | + $e .= esc_textarea($field['value']); |
|
| 112 | 112 | $e .= '</textarea>'; |
| 113 | 113 | |
| 114 | 114 | |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | * @date 23/01/13 |
| 131 | 131 | */ |
| 132 | 132 | |
| 133 | - function render_field_settings( $field ) { |
|
| 133 | + function render_field_settings($field) { |
|
| 134 | 134 | |
| 135 | 135 | // ACF4 migration |
| 136 | - if( empty($field['ID']) ) { |
|
| 136 | + if (empty($field['ID'])) { |
|
| 137 | 137 | |
| 138 | 138 | $field['new_lines'] = 'wpautop'; |
| 139 | 139 | |
@@ -141,36 +141,36 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | // default_value |
| 144 | - acf_render_field_setting( $field, array( |
|
| 145 | - 'label' => __('Default Value','acf'), |
|
| 146 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
| 144 | + acf_render_field_setting($field, array( |
|
| 145 | + 'label' => __('Default Value', 'acf'), |
|
| 146 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
| 147 | 147 | 'type' => 'textarea', |
| 148 | 148 | 'name' => 'default_value', |
| 149 | 149 | )); |
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | // placeholder |
| 153 | - acf_render_field_setting( $field, array( |
|
| 154 | - 'label' => __('Placeholder Text','acf'), |
|
| 155 | - 'instructions' => __('Appears within the input','acf'), |
|
| 153 | + acf_render_field_setting($field, array( |
|
| 154 | + 'label' => __('Placeholder Text', 'acf'), |
|
| 155 | + 'instructions' => __('Appears within the input', 'acf'), |
|
| 156 | 156 | 'type' => 'text', |
| 157 | 157 | 'name' => 'placeholder', |
| 158 | 158 | )); |
| 159 | 159 | |
| 160 | 160 | |
| 161 | 161 | // maxlength |
| 162 | - acf_render_field_setting( $field, array( |
|
| 163 | - 'label' => __('Character Limit','acf'), |
|
| 164 | - 'instructions' => __('Leave blank for no limit','acf'), |
|
| 162 | + acf_render_field_setting($field, array( |
|
| 163 | + 'label' => __('Character Limit', 'acf'), |
|
| 164 | + 'instructions' => __('Leave blank for no limit', 'acf'), |
|
| 165 | 165 | 'type' => 'number', |
| 166 | 166 | 'name' => 'maxlength', |
| 167 | 167 | )); |
| 168 | 168 | |
| 169 | 169 | |
| 170 | 170 | // rows |
| 171 | - acf_render_field_setting( $field, array( |
|
| 172 | - 'label' => __('Rows','acf'), |
|
| 173 | - 'instructions' => __('Sets the textarea height','acf'), |
|
| 171 | + acf_render_field_setting($field, array( |
|
| 172 | + 'label' => __('Rows', 'acf'), |
|
| 173 | + 'instructions' => __('Sets the textarea height', 'acf'), |
|
| 174 | 174 | 'type' => 'number', |
| 175 | 175 | 'name' => 'rows', |
| 176 | 176 | 'placeholder' => 8 |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | // formatting |
| 181 | - acf_render_field_setting( $field, array( |
|
| 182 | - 'label' => __('New Lines','acf'), |
|
| 183 | - 'instructions' => __('Controls how new lines are rendered','acf'), |
|
| 181 | + acf_render_field_setting($field, array( |
|
| 182 | + 'label' => __('New Lines', 'acf'), |
|
| 183 | + 'instructions' => __('Controls how new lines are rendered', 'acf'), |
|
| 184 | 184 | 'type' => 'select', |
| 185 | 185 | 'name' => 'new_lines', |
| 186 | 186 | 'choices' => array( |
| 187 | - 'wpautop' => __("Automatically add paragraphs",'acf'), |
|
| 188 | - 'br' => __("Automatically add <br>",'acf'), |
|
| 189 | - '' => __("No Formatting",'acf') |
|
| 187 | + 'wpautop' => __("Automatically add paragraphs", 'acf'), |
|
| 188 | + 'br' => __("Automatically add <br>", 'acf'), |
|
| 189 | + '' => __("No Formatting", 'acf') |
|
| 190 | 190 | ) |
| 191 | 191 | )); |
| 192 | 192 | |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | * @return $value (mixed) the modified value |
| 210 | 210 | */ |
| 211 | 211 | |
| 212 | - function format_value( $value, $post_id, $field ) { |
|
| 212 | + function format_value($value, $post_id, $field) { |
|
| 213 | 213 | |
| 214 | 214 | // bail early if no value or not for template |
| 215 | - if( empty($value) || !is_string($value) ) { |
|
| 215 | + if (empty($value) || ! is_string($value)) { |
|
| 216 | 216 | |
| 217 | 217 | return $value; |
| 218 | 218 | |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | |
| 222 | 222 | // new lines |
| 223 | - if( $field['new_lines'] == 'wpautop' ) { |
|
| 223 | + if ($field['new_lines'] == 'wpautop') { |
|
| 224 | 224 | |
| 225 | 225 | $value = wpautop($value); |
| 226 | 226 | |
| 227 | - } elseif( $field['new_lines'] == 'br' ) { |
|
| 227 | + } elseif ($field['new_lines'] == 'br') { |
|
| 228 | 228 | |
| 229 | 229 | $value = nl2br($value); |
| 230 | 230 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | // do not delete! |
| 45 | - parent::__construct(); |
|
| 45 | + parent::__construct(); |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | 48 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_true_false') ) : |
|
| 14 | +if ( ! class_exists('acf_field_true_false')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_true_false extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'true_false'; |
| 36 | - $this->label = __("True / False",'acf'); |
|
| 36 | + $this->label = __("True / False", 'acf'); |
|
| 37 | 37 | $this->category = 'choice'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'default_value' => 0, |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @date 23/01/13 |
| 60 | 60 | */ |
| 61 | 61 | |
| 62 | - function render_field( $field ) { |
|
| 62 | + function render_field($field) { |
|
| 63 | 63 | |
| 64 | 64 | // vars |
| 65 | 65 | $atts = array( |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | // checked |
| 74 | - if( !empty($field['value']) ) { |
|
| 74 | + if ( ! empty($field['value'])) { |
|
| 75 | 75 | |
| 76 | 76 | $atts['checked'] = 'checked'; |
| 77 | 77 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // html |
| 82 | - echo '<ul class="acf-checkbox-list acf-bl ' . acf_esc_attr($field['class']) . '">'; |
|
| 83 | - echo '<input type="hidden" name="' . acf_esc_attr($field['name']) . '" value="0" />'; |
|
| 84 | - echo '<li><label><input ' . acf_esc_attr($atts) . '/>' . $field['message'] . '</label></li>'; |
|
| 82 | + echo '<ul class="acf-checkbox-list acf-bl '.acf_esc_attr($field['class']).'">'; |
|
| 83 | + echo '<input type="hidden" name="'.acf_esc_attr($field['name']).'" value="0" />'; |
|
| 84 | + echo '<li><label><input '.acf_esc_attr($atts).'/>'.$field['message'].'</label></li>'; |
|
| 85 | 85 | echo '</ul>'; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -99,20 +99,20 @@ discard block |
||
| 99 | 99 | * @param $field - an array holding all the field's data |
| 100 | 100 | */ |
| 101 | 101 | |
| 102 | - function render_field_settings( $field ) { |
|
| 102 | + function render_field_settings($field) { |
|
| 103 | 103 | |
| 104 | 104 | // message |
| 105 | - acf_render_field_setting( $field, array( |
|
| 106 | - 'label' => __('Message','acf'), |
|
| 107 | - 'instructions' => __('eg. Show extra content','acf'), |
|
| 105 | + acf_render_field_setting($field, array( |
|
| 106 | + 'label' => __('Message', 'acf'), |
|
| 107 | + 'instructions' => __('eg. Show extra content', 'acf'), |
|
| 108 | 108 | 'type' => 'text', |
| 109 | 109 | 'name' => 'message', |
| 110 | 110 | )); |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | // default_value |
| 114 | - acf_render_field_setting( $field, array( |
|
| 115 | - 'label' => __('Default Value','acf'), |
|
| 114 | + acf_render_field_setting($field, array( |
|
| 115 | + 'label' => __('Default Value', 'acf'), |
|
| 116 | 116 | 'instructions' => '', |
| 117 | 117 | 'type' => 'true_false', |
| 118 | 118 | 'name' => 'default_value', |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @return $value (mixed) the modified value |
| 138 | 138 | */ |
| 139 | 139 | |
| 140 | - function format_value( $value, $post_id, $field ) { |
|
| 140 | + function format_value($value, $post_id, $field) { |
|
| 141 | 141 | |
| 142 | 142 | return empty($value) ? false : true; |
| 143 | 143 | |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | * @return $post_id (int) |
| 158 | 158 | */ |
| 159 | 159 | |
| 160 | - function validate_value( $valid, $value, $field, $input ){ |
|
| 160 | + function validate_value($valid, $value, $field, $input) { |
|
| 161 | 161 | |
| 162 | 162 | // bail early if not required |
| 163 | - if( ! $field['required'] ) { |
|
| 163 | + if ( ! $field['required']) { |
|
| 164 | 164 | |
| 165 | 165 | return $valid; |
| 166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | |
| 170 | 170 | // value may be '0' |
| 171 | - if( !$value ) { |
|
| 171 | + if ( ! $value) { |
|
| 172 | 172 | |
| 173 | 173 | return false; |
| 174 | 174 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | // do not delete! |
| 44 | - parent::__construct(); |
|
| 44 | + parent::__construct(); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_url') ) : |
|
| 14 | +if ( ! class_exists('acf_field_url')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_url extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'url'; |
| 36 | - $this->label = __("Url",'acf'); |
|
| 36 | + $this->label = __("Url", 'acf'); |
|
| 37 | 37 | $this->defaults = array( |
| 38 | 38 | 'default_value' => '', |
| 39 | 39 | 'placeholder' => '', |
@@ -57,28 +57,28 @@ discard block |
||
| 57 | 57 | * @date 23/01/13 |
| 58 | 58 | */ |
| 59 | 59 | |
| 60 | - function render_field( $field ) { |
|
| 60 | + function render_field($field) { |
|
| 61 | 61 | |
| 62 | 62 | // vars |
| 63 | - $o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' ); |
|
| 63 | + $o = array('type', 'id', 'class', 'name', 'value', 'placeholder'); |
|
| 64 | 64 | $e = ''; |
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | // populate atts |
| 68 | 68 | $atts = array(); |
| 69 | - foreach( $o as $k ) { |
|
| 69 | + foreach ($o as $k) { |
|
| 70 | 70 | |
| 71 | - $atts[ $k ] = $field[ $k ]; |
|
| 71 | + $atts[$k] = $field[$k]; |
|
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | // special atts |
| 77 | - foreach( array( 'readonly', 'disabled' ) as $k ) { |
|
| 77 | + foreach (array('readonly', 'disabled') as $k) { |
|
| 78 | 78 | |
| 79 | - if( !empty($field[ $k ]) ) { |
|
| 79 | + if ( ! empty($field[$k])) { |
|
| 80 | 80 | |
| 81 | - $atts[ $k ] = $k; |
|
| 81 | + $atts[$k] = $k; |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | // render |
| 89 | 89 | $e .= '<div class="acf-input-wrap acf-url">'; |
| 90 | - $e .= '<i class="acf-icon -globe small"></i><input ' . acf_esc_attr( $atts ) . ' />'; |
|
| 90 | + $e .= '<i class="acf-icon -globe small"></i><input '.acf_esc_attr($atts).' />'; |
|
| 91 | 91 | $e .= '</div>'; |
| 92 | 92 | |
| 93 | 93 | |
@@ -110,21 +110,21 @@ discard block |
||
| 110 | 110 | * @param $field - an array holding all the field's data |
| 111 | 111 | */ |
| 112 | 112 | |
| 113 | - function render_field_settings( $field ) { |
|
| 113 | + function render_field_settings($field) { |
|
| 114 | 114 | |
| 115 | 115 | // default_value |
| 116 | - acf_render_field_setting( $field, array( |
|
| 117 | - 'label' => __('Default Value','acf'), |
|
| 118 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
| 116 | + acf_render_field_setting($field, array( |
|
| 117 | + 'label' => __('Default Value', 'acf'), |
|
| 118 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
| 119 | 119 | 'type' => 'text', |
| 120 | 120 | 'name' => 'default_value', |
| 121 | 121 | )); |
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | // placeholder |
| 125 | - acf_render_field_setting( $field, array( |
|
| 126 | - 'label' => __('Placeholder Text','acf'), |
|
| 127 | - 'instructions' => __('Appears within the input','acf'), |
|
| 125 | + acf_render_field_setting($field, array( |
|
| 126 | + 'label' => __('Placeholder Text', 'acf'), |
|
| 127 | + 'instructions' => __('Appears within the input', 'acf'), |
|
| 128 | 128 | 'type' => 'text', |
| 129 | 129 | 'name' => 'placeholder', |
| 130 | 130 | )); |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | * @return $post_id (int) |
| 146 | 146 | */ |
| 147 | 147 | |
| 148 | - function validate_value( $valid, $value, $field, $input ){ |
|
| 148 | + function validate_value($valid, $value, $field, $input) { |
|
| 149 | 149 | |
| 150 | 150 | // bail early if empty |
| 151 | - if( empty($value) ) { |
|
| 151 | + if (empty($value)) { |
|
| 152 | 152 | |
| 153 | 153 | return $valid; |
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | - if( strpos($value, '://') !== false ) { |
|
| 158 | + if (strpos($value, '://') !== false) { |
|
| 159 | 159 | |
| 160 | 160 | // url |
| 161 | 161 | |
| 162 | - } elseif( strpos($value, '//') === 0 ) { |
|
| 162 | + } elseif (strpos($value, '//') === 0) { |
|
| 163 | 163 | |
| 164 | 164 | // protocol relative url |
| 165 | 165 | |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | // do not delete! |
| 51 | - parent::__construct(); |
|
| 51 | + parent::__construct(); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_user') ) : |
|
| 14 | +if ( ! class_exists('acf_field_user')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_user extends acf_field { |
| 17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | // vars |
| 35 | 35 | $this->name = 'user'; |
| 36 | - $this->label = __("User",'acf'); |
|
| 36 | + $this->label = __("User", 'acf'); |
|
| 37 | 37 | $this->category = 'relational'; |
| 38 | 38 | $this->defaults = array( |
| 39 | 39 | 'role' => '', |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | // extra |
| 46 | - add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query')); |
|
| 47 | - add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query')); |
|
| 46 | + add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query')); |
|
| 47 | + add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query')); |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | // do not delete! |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @return (array) |
| 67 | 67 | */ |
| 68 | 68 | |
| 69 | - function get_choices( $options = array() ) { |
|
| 69 | + function get_choices($options = array()) { |
|
| 70 | 70 | |
| 71 | 71 | // defaults |
| 72 | 72 | $options = acf_parse_args($options, array( |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | // load field |
| 85 | - $field = acf_get_field( $options['field_key'] ); |
|
| 85 | + $field = acf_get_field($options['field_key']); |
|
| 86 | 86 | |
| 87 | - if( !$field ) { |
|
| 87 | + if ( ! $field) { |
|
| 88 | 88 | |
| 89 | 89 | return false; |
| 90 | 90 | |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | // editable roles |
| 95 | 95 | $editable_roles = get_editable_roles(); |
| 96 | 96 | |
| 97 | - if( !empty($field['role']) ) { |
|
| 97 | + if ( ! empty($field['role'])) { |
|
| 98 | 98 | |
| 99 | - foreach( $editable_roles as $role => $role_info ) { |
|
| 99 | + foreach ($editable_roles as $role => $role_info) { |
|
| 100 | 100 | |
| 101 | - if( !in_array($role, $field['role']) ) { |
|
| 101 | + if ( ! in_array($role, $field['role'])) { |
|
| 102 | 102 | |
| 103 | - unset( $editable_roles[ $role ] ); |
|
| 103 | + unset($editable_roles[$role]); |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
@@ -110,10 +110,10 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | |
| 112 | 112 | // search |
| 113 | - if( $options['s'] ) { |
|
| 113 | + if ($options['s']) { |
|
| 114 | 114 | |
| 115 | 115 | // append to $args |
| 116 | - $args['search'] = '*' . $options['s'] . '*'; |
|
| 116 | + $args['search'] = '*'.$options['s'].'*'; |
|
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | // add reference |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | // filters |
| 130 | - $args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']); |
|
| 131 | - $args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']); |
|
| 132 | - $args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']); |
|
| 130 | + $args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']); |
|
| 131 | + $args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']); |
|
| 132 | + $args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']); |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | // get users |
| 136 | - $users = get_users( $args ); |
|
| 136 | + $users = get_users($args); |
|
| 137 | 137 | |
| 138 | - if( !empty($users) && !empty($editable_roles) ) { |
|
| 138 | + if ( ! empty($users) && ! empty($editable_roles)) { |
|
| 139 | 139 | |
| 140 | - foreach( $editable_roles as $role => $role_info ) { |
|
| 140 | + foreach ($editable_roles as $role => $role_info) { |
|
| 141 | 141 | |
| 142 | 142 | // vars |
| 143 | 143 | $this_users = array(); |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | // loop over users |
| 148 | - foreach( array_keys($users) as $key ) { |
|
| 148 | + foreach (array_keys($users) as $key) { |
|
| 149 | 149 | |
| 150 | - if( in_array($role, $users[ $key ]->roles) ) { |
|
| 150 | + if (in_array($role, $users[$key]->roles)) { |
|
| 151 | 151 | |
| 152 | 152 | // extract user |
| 153 | - $user = acf_extract_var( $users, $key ); |
|
| 153 | + $user = acf_extract_var($users, $key); |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | 156 | // append to $this_users |
| 157 | - $this_users[ $user->ID ] = $this->get_result( $user, $field, $options['post_id'] ); |
|
| 157 | + $this_users[$user->ID] = $this->get_result($user, $field, $options['post_id']); |
|
| 158 | 158 | |
| 159 | 159 | } |
| 160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | |
| 164 | 164 | // bail early if no users for this role |
| 165 | - if( empty($this_users) ) { |
|
| 165 | + if (empty($this_users)) { |
|
| 166 | 166 | |
| 167 | 167 | continue; |
| 168 | 168 | |
@@ -170,34 +170,34 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | // order by search |
| 173 | - if( !empty($args['s']) ) { |
|
| 173 | + if ( ! empty($args['s'])) { |
|
| 174 | 174 | |
| 175 | - $this_users = acf_order_by_search( $this_users, $args['s'] ); |
|
| 175 | + $this_users = acf_order_by_search($this_users, $args['s']); |
|
| 176 | 176 | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | // append to json |
| 181 | - foreach( array_keys($this_users) as $user_id ) { |
|
| 181 | + foreach (array_keys($this_users) as $user_id) { |
|
| 182 | 182 | |
| 183 | 183 | // add to json |
| 184 | 184 | $this_json[] = array( |
| 185 | 185 | 'id' => $user_id, |
| 186 | - 'text' => $this_users[ $user_id ] |
|
| 186 | + 'text' => $this_users[$user_id] |
|
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | // add as optgroup or results |
| 193 | - if( count($editable_roles) == 1 ) { |
|
| 193 | + if (count($editable_roles) == 1) { |
|
| 194 | 194 | |
| 195 | 195 | $r = $this_json; |
| 196 | 196 | |
| 197 | 197 | } else { |
| 198 | 198 | |
| 199 | 199 | $r[] = array( |
| 200 | - 'text' => translate_user_role( $role_info['name'] ), |
|
| 200 | + 'text' => translate_user_role($role_info['name']), |
|
| 201 | 201 | 'children' => $this_json |
| 202 | 202 | ); |
| 203 | 203 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | function ajax_query() { |
| 231 | 231 | |
| 232 | 232 | // validate |
| 233 | - if( !acf_verify_ajax() ) { |
|
| 233 | + if ( ! acf_verify_ajax()) { |
|
| 234 | 234 | |
| 235 | 235 | die(); |
| 236 | 236 | |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | |
| 240 | 240 | // get choices |
| 241 | - $choices = $this->get_choices( $_POST ); |
|
| 241 | + $choices = $this->get_choices($_POST); |
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | 244 | // validate |
| 245 | - if( !$choices ) { |
|
| 245 | + if ( ! $choices) { |
|
| 246 | 246 | |
| 247 | 247 | die(); |
| 248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | |
| 252 | 252 | // return JSON |
| 253 | - echo json_encode( $choices ); |
|
| 253 | + echo json_encode($choices); |
|
| 254 | 254 | die(); |
| 255 | 255 | |
| 256 | 256 | } |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * @return (string) |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | - function get_result( $user, $field, $post_id = 0 ) { |
|
| 274 | + function get_result($user, $field, $post_id = 0) { |
|
| 275 | 275 | |
| 276 | 276 | // get post_id |
| 277 | - if( !$post_id ) { |
|
| 277 | + if ( ! $post_id) { |
|
| 278 | 278 | |
| 279 | 279 | $post_id = acf_get_setting('form_data/post_id', get_the_ID()); |
| 280 | 280 | |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | |
| 288 | 288 | // append name |
| 289 | - if( $user->first_name ) { |
|
| 289 | + if ($user->first_name) { |
|
| 290 | 290 | |
| 291 | - $result .= ' (' . $user->first_name; |
|
| 291 | + $result .= ' ('.$user->first_name; |
|
| 292 | 292 | |
| 293 | - if( $user->last_name ) { |
|
| 293 | + if ($user->last_name) { |
|
| 294 | 294 | |
| 295 | - $result .= ' ' . $user->last_name; |
|
| 295 | + $result .= ' '.$user->last_name; |
|
| 296 | 296 | |
| 297 | 297 | } |
| 298 | 298 | |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | |
| 304 | 304 | // filters |
| 305 | - $result = apply_filters("acf/fields/user/result", $result, $user, $field, $post_id); |
|
| 306 | - $result = apply_filters("acf/fields/user/result/name={$field['_name']}", $result, $user, $field, $post_id); |
|
| 307 | - $result = apply_filters("acf/fields/user/result/key={$field['key']}", $result, $user, $field, $post_id); |
|
| 305 | + $result = apply_filters("acf/fields/user/result", $result, $user, $field, $post_id); |
|
| 306 | + $result = apply_filters("acf/fields/user/result/name={$field['_name']}", $result, $user, $field, $post_id); |
|
| 307 | + $result = apply_filters("acf/fields/user/result/key={$field['key']}", $result, $user, $field, $post_id); |
|
| 308 | 308 | |
| 309 | 309 | |
| 310 | 310 | // return |
@@ -326,10 +326,10 @@ discard block |
||
| 326 | 326 | * @return $columns |
| 327 | 327 | */ |
| 328 | 328 | |
| 329 | - function user_search_columns( $columns, $search, $WP_User_Query ) { |
|
| 329 | + function user_search_columns($columns, $search, $WP_User_Query) { |
|
| 330 | 330 | |
| 331 | 331 | // bail early if no field |
| 332 | - if( empty($this->field) ) { |
|
| 332 | + if (empty($this->field)) { |
|
| 333 | 333 | |
| 334 | 334 | return $columns; |
| 335 | 335 | |
@@ -341,9 +341,9 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | |
| 343 | 343 | // filter for 3rd party customization |
| 344 | - $columns = apply_filters("acf/fields/user/search_columns", $columns, $search, $WP_User_Query, $field); |
|
| 345 | - $columns = apply_filters("acf/fields/user/search_columns/name={$field['_name']}", $columns, $search, $WP_User_Query, $field); |
|
| 346 | - $columns = apply_filters("acf/fields/user/search_columns/key={$field['key']}", $columns, $search, $WP_User_Query, $field); |
|
| 344 | + $columns = apply_filters("acf/fields/user/search_columns", $columns, $search, $WP_User_Query, $field); |
|
| 345 | + $columns = apply_filters("acf/fields/user/search_columns/name={$field['_name']}", $columns, $search, $WP_User_Query, $field); |
|
| 346 | + $columns = apply_filters("acf/fields/user/search_columns/key={$field['key']}", $columns, $search, $WP_User_Query, $field); |
|
| 347 | 347 | |
| 348 | 348 | |
| 349 | 349 | // return |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | * @param $field - an array holding all the field's data |
| 364 | 364 | */ |
| 365 | 365 | |
| 366 | - function render_field( $field ) { |
|
| 366 | + function render_field($field) { |
|
| 367 | 367 | |
| 368 | 368 | // Change Field into a select |
| 369 | 369 | $field['type'] = 'select'; |
@@ -373,10 +373,10 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | // populate choices |
| 376 | - if( !empty($field['value']) ) { |
|
| 376 | + if ( ! empty($field['value'])) { |
|
| 377 | 377 | |
| 378 | 378 | // force value to array |
| 379 | - $field['value'] = acf_get_array( $field['value'] ); |
|
| 379 | + $field['value'] = acf_get_array($field['value']); |
|
| 380 | 380 | |
| 381 | 381 | |
| 382 | 382 | // convert values to int |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | )); |
| 389 | 389 | |
| 390 | 390 | |
| 391 | - if( !empty($users) ) { |
|
| 391 | + if ( ! empty($users)) { |
|
| 392 | 392 | |
| 393 | - foreach( $users as $user ) { |
|
| 393 | + foreach ($users as $user) { |
|
| 394 | 394 | |
| 395 | - $field['choices'][ $user->ID ] = $this->get_result( $user, $field ); |
|
| 395 | + $field['choices'][$user->ID] = $this->get_result($user, $field); |
|
| 396 | 396 | |
| 397 | 397 | } |
| 398 | 398 | |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | // render |
| 405 | - acf_render_field( $field ); |
|
| 405 | + acf_render_field($field); |
|
| 406 | 406 | |
| 407 | 407 | } |
| 408 | 408 | |
@@ -420,21 +420,21 @@ discard block |
||
| 420 | 420 | * @param $field - an array holding all the field's data |
| 421 | 421 | */ |
| 422 | 422 | |
| 423 | - function render_field_settings( $field ) { |
|
| 423 | + function render_field_settings($field) { |
|
| 424 | 424 | |
| 425 | 425 | // role |
| 426 | 426 | $choices = array(); |
| 427 | 427 | $editable_roles = get_editable_roles(); |
| 428 | 428 | |
| 429 | - foreach( $editable_roles as $role => $details ) { |
|
| 429 | + foreach ($editable_roles as $role => $details) { |
|
| 430 | 430 | |
| 431 | 431 | // only translate the output not the value |
| 432 | - $choices[ $role ] = translate_user_role( $details['name'] ); |
|
| 432 | + $choices[$role] = translate_user_role($details['name']); |
|
| 433 | 433 | |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - acf_render_field_setting( $field, array( |
|
| 437 | - 'label' => __('Filter by role','acf'), |
|
| 436 | + acf_render_field_setting($field, array( |
|
| 437 | + 'label' => __('Filter by role', 'acf'), |
|
| 438 | 438 | 'instructions' => '', |
| 439 | 439 | 'type' => 'select', |
| 440 | 440 | 'name' => 'role', |
@@ -442,34 +442,34 @@ discard block |
||
| 442 | 442 | 'multiple' => 1, |
| 443 | 443 | 'ui' => 1, |
| 444 | 444 | 'allow_null' => 1, |
| 445 | - 'placeholder' => __("All user roles",'acf'), |
|
| 445 | + 'placeholder' => __("All user roles", 'acf'), |
|
| 446 | 446 | )); |
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | |
| 450 | 450 | // allow_null |
| 451 | - acf_render_field_setting( $field, array( |
|
| 452 | - 'label' => __('Allow Null?','acf'), |
|
| 451 | + acf_render_field_setting($field, array( |
|
| 452 | + 'label' => __('Allow Null?', 'acf'), |
|
| 453 | 453 | 'instructions' => '', |
| 454 | 454 | 'type' => 'radio', |
| 455 | 455 | 'name' => 'allow_null', |
| 456 | 456 | 'choices' => array( |
| 457 | - 1 => __("Yes",'acf'), |
|
| 458 | - 0 => __("No",'acf'), |
|
| 457 | + 1 => __("Yes", 'acf'), |
|
| 458 | + 0 => __("No", 'acf'), |
|
| 459 | 459 | ), |
| 460 | 460 | 'layout' => 'horizontal', |
| 461 | 461 | )); |
| 462 | 462 | |
| 463 | 463 | |
| 464 | 464 | // multiple |
| 465 | - acf_render_field_setting( $field, array( |
|
| 466 | - 'label' => __('Select multiple values?','acf'), |
|
| 465 | + acf_render_field_setting($field, array( |
|
| 466 | + 'label' => __('Select multiple values?', 'acf'), |
|
| 467 | 467 | 'instructions' => '', |
| 468 | 468 | 'type' => 'radio', |
| 469 | 469 | 'name' => 'multiple', |
| 470 | 470 | 'choices' => array( |
| 471 | - 1 => __("Yes",'acf'), |
|
| 472 | - 0 => __("No",'acf'), |
|
| 471 | + 1 => __("Yes", 'acf'), |
|
| 472 | + 0 => __("No", 'acf'), |
|
| 473 | 473 | ), |
| 474 | 474 | 'layout' => 'horizontal', |
| 475 | 475 | )); |
@@ -494,17 +494,17 @@ discard block |
||
| 494 | 494 | * @return $value - the modified value |
| 495 | 495 | */ |
| 496 | 496 | |
| 497 | - function update_value( $value, $post_id, $field ) { |
|
| 497 | + function update_value($value, $post_id, $field) { |
|
| 498 | 498 | |
| 499 | 499 | // array? |
| 500 | - if( is_array($value) && isset($value['ID']) ) { |
|
| 500 | + if (is_array($value) && isset($value['ID'])) { |
|
| 501 | 501 | |
| 502 | 502 | $value = $value['ID']; |
| 503 | 503 | |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | // object? |
| 507 | - if( is_object($value) && isset($value->ID) ) { |
|
| 507 | + if (is_object($value) && isset($value->ID)) { |
|
| 508 | 508 | |
| 509 | 509 | $value = $value->ID; |
| 510 | 510 | |
@@ -531,10 +531,10 @@ discard block |
||
| 531 | 531 | * @return $value |
| 532 | 532 | */ |
| 533 | 533 | |
| 534 | - function load_value( $value, $post_id, $field ) { |
|
| 534 | + function load_value($value, $post_id, $field) { |
|
| 535 | 535 | |
| 536 | 536 | // ACF4 null |
| 537 | - if( $value === 'null' ) { |
|
| 537 | + if ($value === 'null') { |
|
| 538 | 538 | |
| 539 | 539 | return false; |
| 540 | 540 | |
@@ -562,10 +562,10 @@ discard block |
||
| 562 | 562 | * @return $value (mixed) the modified value |
| 563 | 563 | */ |
| 564 | 564 | |
| 565 | - function format_value( $value, $post_id, $field ) { |
|
| 565 | + function format_value($value, $post_id, $field) { |
|
| 566 | 566 | |
| 567 | 567 | // bail early if no value |
| 568 | - if( empty($value) ) { |
|
| 568 | + if (empty($value)) { |
|
| 569 | 569 | |
| 570 | 570 | return $value; |
| 571 | 571 | |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | |
| 575 | 575 | // force value to array |
| 576 | - $value = acf_get_array( $value ); |
|
| 576 | + $value = acf_get_array($value); |
|
| 577 | 577 | |
| 578 | 578 | |
| 579 | 579 | // convert values to int |
@@ -581,41 +581,41 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | |
| 583 | 583 | // load users |
| 584 | - foreach( array_keys($value) as $i ) { |
|
| 584 | + foreach (array_keys($value) as $i) { |
|
| 585 | 585 | |
| 586 | 586 | // vars |
| 587 | - $user_id = $value[ $i ]; |
|
| 588 | - $user_data = get_userdata( $user_id ); |
|
| 587 | + $user_id = $value[$i]; |
|
| 588 | + $user_data = get_userdata($user_id); |
|
| 589 | 589 | |
| 590 | 590 | |
| 591 | 591 | //cope with deleted users by @adampope |
| 592 | - if( !is_object($user_data) ) { |
|
| 592 | + if ( ! is_object($user_data)) { |
|
| 593 | 593 | |
| 594 | - unset( $value[ $i ] ); |
|
| 594 | + unset($value[$i]); |
|
| 595 | 595 | continue; |
| 596 | 596 | |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | |
| 600 | 600 | // append to array |
| 601 | - $value[ $i ] = array(); |
|
| 602 | - $value[ $i ]['ID'] = $user_id; |
|
| 603 | - $value[ $i ]['user_firstname'] = $user_data->user_firstname; |
|
| 604 | - $value[ $i ]['user_lastname'] = $user_data->user_lastname; |
|
| 605 | - $value[ $i ]['nickname'] = $user_data->nickname; |
|
| 606 | - $value[ $i ]['user_nicename'] = $user_data->user_nicename; |
|
| 607 | - $value[ $i ]['display_name'] = $user_data->display_name; |
|
| 608 | - $value[ $i ]['user_email'] = $user_data->user_email; |
|
| 609 | - $value[ $i ]['user_url'] = $user_data->user_url; |
|
| 610 | - $value[ $i ]['user_registered'] = $user_data->user_registered; |
|
| 611 | - $value[ $i ]['user_description'] = $user_data->user_description; |
|
| 612 | - $value[ $i ]['user_avatar'] = get_avatar( $user_id ); |
|
| 601 | + $value[$i] = array(); |
|
| 602 | + $value[$i]['ID'] = $user_id; |
|
| 603 | + $value[$i]['user_firstname'] = $user_data->user_firstname; |
|
| 604 | + $value[$i]['user_lastname'] = $user_data->user_lastname; |
|
| 605 | + $value[$i]['nickname'] = $user_data->nickname; |
|
| 606 | + $value[$i]['user_nicename'] = $user_data->user_nicename; |
|
| 607 | + $value[$i]['display_name'] = $user_data->display_name; |
|
| 608 | + $value[$i]['user_email'] = $user_data->user_email; |
|
| 609 | + $value[$i]['user_url'] = $user_data->user_url; |
|
| 610 | + $value[$i]['user_registered'] = $user_data->user_registered; |
|
| 611 | + $value[$i]['user_description'] = $user_data->user_description; |
|
| 612 | + $value[$i]['user_avatar'] = get_avatar($user_id); |
|
| 613 | 613 | |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | |
| 617 | 617 | // convert back from array if neccessary |
| 618 | - if( !$field['multiple'] ) { |
|
| 618 | + if ( ! $field['multiple']) { |
|
| 619 | 619 | |
| 620 | 620 | $value = array_shift($value); |
| 621 | 621 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | |
| 47 | - // Create an acf version of the_content filter (acf_the_content) |
|
| 47 | + // Create an acf version of the_content filter (acf_the_content) |
|
| 48 | 48 | if( !empty($GLOBALS['wp_embed']) ) { |
| 49 | 49 | |
| 50 | 50 | add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | // do not delete! |
| 76 | - parent::__construct(); |
|
| 76 | + parent::__construct(); |
|
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * @subpackage Fields |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if( ! class_exists('acf_field_wysiwyg') ) : |
|
| 14 | +if ( ! class_exists('acf_field_wysiwyg')) : |
|
| 15 | 15 | |
| 16 | 16 | class acf_field_wysiwyg extends acf_field { |
| 17 | 17 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // vars |
| 36 | 36 | $this->name = 'wysiwyg'; |
| 37 | - $this->label = __("Wysiwyg Editor",'acf'); |
|
| 37 | + $this->label = __("Wysiwyg Editor", 'acf'); |
|
| 38 | 38 | $this->category = 'content'; |
| 39 | 39 | $this->defaults = array( |
| 40 | 40 | 'tabs' => 'all', |
@@ -45,31 +45,31 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | // Create an acf version of the_content filter (acf_the_content) |
| 48 | - if( !empty($GLOBALS['wp_embed']) ) { |
|
| 48 | + if ( ! empty($GLOBALS['wp_embed'])) { |
|
| 49 | 49 | |
| 50 | - add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 ); |
|
| 51 | - add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); |
|
| 50 | + add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
| 51 | + add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'autoembed'), 8); |
|
| 52 | 52 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - add_filter( 'acf_the_content', 'capital_P_dangit', 11 ); |
|
| 56 | - add_filter( 'acf_the_content', 'wptexturize' ); |
|
| 57 | - add_filter( 'acf_the_content', 'convert_smilies' ); |
|
| 58 | - add_filter( 'acf_the_content', 'convert_chars' ); // not found in WP 4.4 |
|
| 59 | - add_filter( 'acf_the_content', 'wpautop' ); |
|
| 60 | - add_filter( 'acf_the_content', 'shortcode_unautop' ); |
|
| 55 | + add_filter('acf_the_content', 'capital_P_dangit', 11); |
|
| 56 | + add_filter('acf_the_content', 'wptexturize'); |
|
| 57 | + add_filter('acf_the_content', 'convert_smilies'); |
|
| 58 | + add_filter('acf_the_content', 'convert_chars'); // not found in WP 4.4 |
|
| 59 | + add_filter('acf_the_content', 'wpautop'); |
|
| 60 | + add_filter('acf_the_content', 'shortcode_unautop'); |
|
| 61 | 61 | //add_filter( 'acf_the_content', 'prepend_attachment' ); should only be for the_content (causes double image on attachment page) |
| 62 | - if( function_exists('wp_make_content_images_responsive') ) { |
|
| 62 | + if (function_exists('wp_make_content_images_responsive')) { |
|
| 63 | 63 | |
| 64 | - add_filter( 'acf_the_content', 'wp_make_content_images_responsive' ); // added in WP 4.4 |
|
| 64 | + add_filter('acf_the_content', 'wp_make_content_images_responsive'); // added in WP 4.4 |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - add_filter( 'acf_the_content', 'do_shortcode', 11); |
|
| 68 | + add_filter('acf_the_content', 'do_shortcode', 11); |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | // actions |
| 72 | - add_action('acf/input/admin_footer_js', array($this, 'input_admin_footer_js')); |
|
| 72 | + add_action('acf/input/admin_footer_js', array($this, 'input_admin_footer_js')); |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | // do not delete! |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $editor_id = 'acf_content'; |
| 103 | 103 | |
| 104 | 104 | |
| 105 | - if( version_compare($wp_version, '3.9', '>=' ) ) { |
|
| 105 | + if (version_compare($wp_version, '3.9', '>=')) { |
|
| 106 | 106 | |
| 107 | 107 | // Full |
| 108 | 108 | $toolbars['Full'] = array( |
| 109 | 109 | |
| 110 | - 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id), |
|
| 110 | + 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv'), $editor_id), |
|
| 111 | 111 | |
| 112 | - 2 => apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id), |
|
| 112 | + 2 => apply_filters('mce_buttons_2', array('formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help'), $editor_id), |
|
| 113 | 113 | |
| 114 | 114 | 3 => apply_filters('mce_buttons_3', array(), $editor_id), |
| 115 | 115 | |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | // Full |
| 131 | 131 | $toolbars['Full'] = array( |
| 132 | 132 | |
| 133 | - 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id), |
|
| 133 | + 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv'), $editor_id), |
|
| 134 | 134 | |
| 135 | - 2 => apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id), |
|
| 135 | + 2 => apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help'), $editor_id), |
|
| 136 | 136 | |
| 137 | 137 | 3 => apply_filters('mce_buttons_3', array(), $editor_id), |
| 138 | 138 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | // Basic |
| 145 | 145 | $toolbars['Basic'] = array( |
| 146 | 146 | |
| 147 | - 1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ), |
|
| 147 | + 1 => apply_filters('teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id), |
|
| 148 | 148 | |
| 149 | 149 | ); |
| 150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | // Filter for 3rd party |
| 155 | - $toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', $toolbars ); |
|
| 155 | + $toolbars = apply_filters('acf/fields/wysiwyg/toolbars', $toolbars); |
|
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | // return |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | // bail ealry if no toolbars |
| 185 | - if( empty($toolbars) ) { |
|
| 185 | + if (empty($toolbars)) { |
|
| 186 | 186 | |
| 187 | 187 | return; |
| 188 | 188 | |
@@ -190,23 +190,23 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | // loop through toolbars |
| 193 | - foreach( $toolbars as $label => $rows ) { |
|
| 193 | + foreach ($toolbars as $label => $rows) { |
|
| 194 | 194 | |
| 195 | 195 | // vars |
| 196 | - $label = sanitize_title( $label ); |
|
| 196 | + $label = sanitize_title($label); |
|
| 197 | 197 | $label = str_replace('-', '_', $label); |
| 198 | 198 | |
| 199 | 199 | |
| 200 | 200 | // append to $json |
| 201 | - $json[ $label ] = array(); |
|
| 201 | + $json[$label] = array(); |
|
| 202 | 202 | |
| 203 | 203 | |
| 204 | 204 | // convert to strings |
| 205 | - if( !empty($rows) ) { |
|
| 205 | + if ( ! empty($rows)) { |
|
| 206 | 206 | |
| 207 | - foreach( $rows as $i => $row ) { |
|
| 207 | + foreach ($rows as $i => $row) { |
|
| 208 | 208 | |
| 209 | - $json[ $label ][ $i ] = implode(',', $row); |
|
| 209 | + $json[$label][$i] = implode(',', $row); |
|
| 210 | 210 | |
| 211 | 211 | } |
| 212 | 212 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @date 23/01/13 |
| 234 | 234 | */ |
| 235 | 235 | |
| 236 | - function render_field( $field ) { |
|
| 236 | + function render_field($field) { |
|
| 237 | 237 | |
| 238 | 238 | // global |
| 239 | 239 | global $wp_version; |
@@ -252,22 +252,22 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | // get height |
| 254 | 254 | $height = acf_get_user_setting('wysiwyg_height', 300); |
| 255 | - $height = max( $height, 300 ); // minimum height is 300 |
|
| 255 | + $height = max($height, 300); // minimum height is 300 |
|
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | // detect mode |
| 259 | - if( $field['tabs'] == 'visual' ) { |
|
| 259 | + if ($field['tabs'] == 'visual') { |
|
| 260 | 260 | |
| 261 | 261 | // case: visual tab only |
| 262 | 262 | $default_editor = 'tinymce'; |
| 263 | 263 | $show_tabs = false; |
| 264 | 264 | |
| 265 | - } elseif( $field['tabs'] == 'text' ) { |
|
| 265 | + } elseif ($field['tabs'] == 'text') { |
|
| 266 | 266 | |
| 267 | 267 | // case: text tab only |
| 268 | 268 | $show_tabs = false; |
| 269 | 269 | |
| 270 | - } elseif( wp_default_editor() == 'tinymce' ) { |
|
| 270 | + } elseif (wp_default_editor() == 'tinymce') { |
|
| 271 | 271 | |
| 272 | 272 | // case: both tabs |
| 273 | 273 | $default_editor = 'tinymce'; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | // must be logged in tp upload |
| 279 | - if( !current_user_can('upload_files') ) { |
|
| 279 | + if ( ! current_user_can('upload_files')) { |
|
| 280 | 280 | |
| 281 | 281 | $field['media_upload'] = 0; |
| 282 | 282 | |
@@ -288,17 +288,17 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | |
| 290 | 290 | // filter value for editor |
| 291 | - remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); |
|
| 292 | - remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 ); |
|
| 293 | - remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 ); |
|
| 291 | + remove_filter('acf_the_editor_content', 'format_for_editor', 10, 2); |
|
| 292 | + remove_filter('acf_the_editor_content', 'wp_htmledit_pre', 10, 1); |
|
| 293 | + remove_filter('acf_the_editor_content', 'wp_richedit_pre', 10, 1); |
|
| 294 | 294 | |
| 295 | 295 | |
| 296 | 296 | // WP 4.3 |
| 297 | - if( version_compare($wp_version, '4.3', '>=' ) ) { |
|
| 297 | + if (version_compare($wp_version, '4.3', '>=')) { |
|
| 298 | 298 | |
| 299 | - add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); |
|
| 299 | + add_filter('acf_the_editor_content', 'format_for_editor', 10, 2); |
|
| 300 | 300 | |
| 301 | - $button = 'data-wp-editor-id="' . $id . '"'; |
|
| 301 | + $button = 'data-wp-editor-id="'.$id.'"'; |
|
| 302 | 302 | |
| 303 | 303 | // WP < 4.3 |
| 304 | 304 | } else { |
@@ -313,25 +313,25 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | |
| 315 | 315 | // filter |
| 316 | - $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor ); |
|
| 316 | + $field['value'] = apply_filters('acf_the_editor_content', $field['value'], $default_editor); |
|
| 317 | 317 | |
| 318 | 318 | ?> |
| 319 | 319 | <div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $switch_class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>"> |
| 320 | 320 | <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js"> |
| 321 | - <?php if( $field['media_upload'] ): ?> |
|
| 321 | + <?php if ($field['media_upload']): ?> |
|
| 322 | 322 | <div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons"> |
| 323 | - <?php do_action( 'media_buttons', $id ); ?> |
|
| 323 | + <?php do_action('media_buttons', $id); ?> |
|
| 324 | 324 | </div> |
| 325 | 325 | <?php endif; ?> |
| 326 | - <?php if( user_can_richedit() && $show_tabs ): ?> |
|
| 326 | + <?php if (user_can_richedit() && $show_tabs): ?> |
|
| 327 | 327 | <div class="wp-editor-tabs"> |
| 328 | 328 | <button id="<?php echo $id; ?>-tmce" class="wp-switch-editor switch-tmce" <?php echo $button; ?> type="button"><?php echo __('Visual', 'acf'); ?></button> |
| 329 | - <button id="<?php echo $id; ?>-html" class="wp-switch-editor switch-html" <?php echo $button; ?> type="button"><?php echo _x( 'Text', 'Name for the Text editor tab (formerly HTML)', 'acf' ); ?></button> |
|
| 329 | + <button id="<?php echo $id; ?>-html" class="wp-switch-editor switch-html" <?php echo $button; ?> type="button"><?php echo _x('Text', 'Name for the Text editor tab (formerly HTML)', 'acf'); ?></button> |
|
| 330 | 330 | </div> |
| 331 | 331 | <?php endif; ?> |
| 332 | 332 | </div> |
| 333 | 333 | <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container"> |
| 334 | - <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>" <?php if($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $field['value']; ?></textarea> |
|
| 334 | + <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>" <?php if ($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $field['value']; ?></textarea> |
|
| 335 | 335 | </div> |
| 336 | 336 | </div> |
| 337 | 337 | <?php |
@@ -352,51 +352,51 @@ discard block |
||
| 352 | 352 | * @param $field - an array holding all the field's data |
| 353 | 353 | */ |
| 354 | 354 | |
| 355 | - function render_field_settings( $field ) { |
|
| 355 | + function render_field_settings($field) { |
|
| 356 | 356 | |
| 357 | 357 | // vars |
| 358 | 358 | $toolbars = $this->get_toolbars(); |
| 359 | 359 | $choices = array(); |
| 360 | 360 | |
| 361 | - if( !empty($toolbars) ) { |
|
| 361 | + if ( ! empty($toolbars)) { |
|
| 362 | 362 | |
| 363 | - foreach( $toolbars as $k => $v ) { |
|
| 363 | + foreach ($toolbars as $k => $v) { |
|
| 364 | 364 | |
| 365 | 365 | $label = $k; |
| 366 | - $name = sanitize_title( $label ); |
|
| 366 | + $name = sanitize_title($label); |
|
| 367 | 367 | $name = str_replace('-', '_', $name); |
| 368 | 368 | |
| 369 | - $choices[ $name ] = $label; |
|
| 369 | + $choices[$name] = $label; |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | |
| 374 | 374 | // default_value |
| 375 | - acf_render_field_setting( $field, array( |
|
| 376 | - 'label' => __('Default Value','acf'), |
|
| 377 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
| 375 | + acf_render_field_setting($field, array( |
|
| 376 | + 'label' => __('Default Value', 'acf'), |
|
| 377 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
| 378 | 378 | 'type' => 'textarea', |
| 379 | 379 | 'name' => 'default_value', |
| 380 | 380 | )); |
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | // tabs |
| 384 | - acf_render_field_setting( $field, array( |
|
| 385 | - 'label' => __('Tabs','acf'), |
|
| 384 | + acf_render_field_setting($field, array( |
|
| 385 | + 'label' => __('Tabs', 'acf'), |
|
| 386 | 386 | 'instructions' => '', |
| 387 | 387 | 'type' => 'select', |
| 388 | 388 | 'name' => 'tabs', |
| 389 | 389 | 'choices' => array( |
| 390 | - 'all' => __("Visual & Text",'acf'), |
|
| 391 | - 'visual' => __("Visual Only",'acf'), |
|
| 392 | - 'text' => __("Text Only",'acf'), |
|
| 390 | + 'all' => __("Visual & Text", 'acf'), |
|
| 391 | + 'visual' => __("Visual Only", 'acf'), |
|
| 392 | + 'text' => __("Text Only", 'acf'), |
|
| 393 | 393 | ) |
| 394 | 394 | )); |
| 395 | 395 | |
| 396 | 396 | |
| 397 | 397 | // toolbar |
| 398 | - acf_render_field_setting( $field, array( |
|
| 399 | - 'label' => __('Toolbar','acf'), |
|
| 398 | + acf_render_field_setting($field, array( |
|
| 399 | + 'label' => __('Toolbar', 'acf'), |
|
| 400 | 400 | 'instructions' => '', |
| 401 | 401 | 'type' => 'select', |
| 402 | 402 | 'name' => 'toolbar', |
@@ -405,15 +405,15 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | |
| 407 | 407 | // media_upload |
| 408 | - acf_render_field_setting( $field, array( |
|
| 409 | - 'label' => __('Show Media Upload Buttons?','acf'), |
|
| 408 | + acf_render_field_setting($field, array( |
|
| 409 | + 'label' => __('Show Media Upload Buttons?', 'acf'), |
|
| 410 | 410 | 'instructions' => '', |
| 411 | 411 | 'type' => 'radio', |
| 412 | 412 | 'name' => 'media_upload', |
| 413 | 413 | 'layout' => 'horizontal', |
| 414 | 414 | 'choices' => array( |
| 415 | - 1 => __("Yes",'acf'), |
|
| 416 | - 0 => __("No",'acf'), |
|
| 415 | + 1 => __("Yes", 'acf'), |
|
| 416 | + 0 => __("No", 'acf'), |
|
| 417 | 417 | ) |
| 418 | 418 | )); |
| 419 | 419 | |
@@ -436,10 +436,10 @@ discard block |
||
| 436 | 436 | * @return $value (mixed) the modified value |
| 437 | 437 | */ |
| 438 | 438 | |
| 439 | - function format_value( $value, $post_id, $field ) { |
|
| 439 | + function format_value($value, $post_id, $field) { |
|
| 440 | 440 | |
| 441 | 441 | // bail early if no value |
| 442 | - if( empty($value) ) { |
|
| 442 | + if (empty($value)) { |
|
| 443 | 443 | |
| 444 | 444 | return $value; |
| 445 | 445 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | // apply filters |
| 450 | - $value = apply_filters( 'acf_the_content', $value ); |
|
| 450 | + $value = apply_filters('acf_the_content', $value); |
|
| 451 | 451 | |
| 452 | 452 | |
| 453 | 453 | // follow the_content function in /wp-includes/post-template.php |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | $form_fields[ 'acf-form-data' ] = array( |
| 250 | - 'label' => '', |
|
| 250 | + 'label' => '', |
|
| 251 | 251 | 'input' => 'html', |
| 252 | 252 | 'html' => $html |
| 253 | 253 | ); |
@@ -284,8 +284,8 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
| 287 | - // validate and save |
|
| 288 | - if( acf_validate_save_post(true) ) { |
|
| 287 | + // validate and save |
|
| 288 | + if( acf_validate_save_post(true) ) { |
|
| 289 | 289 | |
| 290 | 290 | acf_save_post( $post['ID'] ); |
| 291 | 291 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @subpackage Forms |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if( ! class_exists('acf_form_attachment') ) : |
|
| 13 | +if ( ! class_exists('acf_form_attachment')) : |
|
| 14 | 14 | |
| 15 | 15 | class acf_form_attachment { |
| 16 | 16 | |
@@ -31,15 +31,15 @@ discard block |
||
| 31 | 31 | function __construct() { |
| 32 | 32 | |
| 33 | 33 | // actions |
| 34 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 34 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | // render |
| 38 | - add_filter('attachment_fields_to_edit', array($this, 'edit_attachment'), 10, 2); |
|
| 38 | + add_filter('attachment_fields_to_edit', array($this, 'edit_attachment'), 10, 2); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | // save |
| 42 | - add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2); |
|
| 42 | + add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2); |
|
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | // validate page |
| 67 | - if( $pagenow === 'post.php' && $typenow === 'attachment' ) { |
|
| 67 | + if ($pagenow === 'post.php' && $typenow === 'attachment') { |
|
| 68 | 68 | |
| 69 | 69 | return true; |
| 70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | // validate page |
| 75 | - if( $pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=') ) { |
|
| 75 | + if ($pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=')) { |
|
| 76 | 76 | |
| 77 | 77 | add_action('admin_footer', array($this, 'admin_footer'), 0); |
| 78 | 78 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | function admin_enqueue_scripts() { |
| 104 | 104 | |
| 105 | 105 | // bail early if not valid page |
| 106 | - if( !$this->validate_page() ) { |
|
| 106 | + if ( ! $this->validate_page()) { |
|
| 107 | 107 | |
| 108 | 108 | return; |
| 109 | 109 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @return $post_id (int) |
| 155 | 155 | */ |
| 156 | 156 | |
| 157 | - function edit_attachment( $form_fields, $post ) { |
|
| 157 | + function edit_attachment($form_fields, $post) { |
|
| 158 | 158 | |
| 159 | 159 | // vars |
| 160 | 160 | $el = 'tr'; |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | |
| 167 | 167 | // $el |
| 168 | - if( $this->validate_page() ) { |
|
| 168 | + if ($this->validate_page()) { |
|
| 169 | 169 | |
| 170 | 170 | //$el = 'div'; |
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // get field groups |
| 175 | - $field_groups = acf_get_field_groups( $args ); |
|
| 175 | + $field_groups = acf_get_field_groups($args); |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | // render |
| 179 | - if( !empty($field_groups) ) { |
|
| 179 | + if ( ! empty($field_groups)) { |
|
| 180 | 180 | |
| 181 | 181 | // get acf_form_data |
| 182 | 182 | ob_start(); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | )); |
| 189 | 189 | |
| 190 | 190 | |
| 191 | - if( $this->validate_page() ) { |
|
| 191 | + if ($this->validate_page()) { |
|
| 192 | 192 | |
| 193 | 193 | echo '<style type="text/css"> |
| 194 | 194 | .compat-attachment-fields, |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | //} |
| 224 | 224 | |
| 225 | 225 | |
| 226 | - foreach( $field_groups as $field_group ) { |
|
| 226 | + foreach ($field_groups as $field_group) { |
|
| 227 | 227 | |
| 228 | - $fields = acf_get_fields( $field_group ); |
|
| 228 | + $fields = acf_get_fields($field_group); |
|
| 229 | 229 | |
| 230 | - acf_render_fields( $post_id, $fields, $el, 'field' ); |
|
| 230 | + acf_render_fields($post_id, $fields, $el, 'field'); |
|
| 231 | 231 | |
| 232 | 232 | } |
| 233 | 233 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | ob_end_clean(); |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - $form_fields[ 'acf-form-data' ] = array( |
|
| 249 | + $form_fields['acf-form-data'] = array( |
|
| 250 | 250 | 'label' => '', |
| 251 | 251 | 'input' => 'html', |
| 252 | 252 | 'html' => $html |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | * @return $post_id (int) |
| 275 | 275 | */ |
| 276 | 276 | |
| 277 | - function save_attachment( $post, $attachment ) { |
|
| 277 | + function save_attachment($post, $attachment) { |
|
| 278 | 278 | |
| 279 | 279 | // bail early if not valid nonce |
| 280 | - if( ! acf_verify_nonce('attachment') ) { |
|
| 280 | + if ( ! acf_verify_nonce('attachment')) { |
|
| 281 | 281 | |
| 282 | 282 | return $post; |
| 283 | 283 | |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | |
| 287 | 287 | // validate and save |
| 288 | - if( acf_validate_save_post(true) ) { |
|
| 288 | + if (acf_validate_save_post(true)) { |
|
| 289 | 289 | |
| 290 | - acf_save_post( $post['ID'] ); |
|
| 290 | + acf_save_post($post['ID']); |
|
| 291 | 291 | |
| 292 | 292 | } |
| 293 | 293 | |
@@ -258,8 +258,8 @@ |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | - // validate and save |
|
| 262 | - if( acf_validate_save_post(true) ) { |
|
| 261 | + // validate and save |
|
| 262 | + if( acf_validate_save_post(true) ) { |
|
| 263 | 263 | |
| 264 | 264 | acf_save_post( "comment_{$comment_id}" ); |
| 265 | 265 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @subpackage Forms |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if( ! class_exists('acf_form_comment') ) : |
|
| 13 | +if ( ! class_exists('acf_form_comment')) : |
|
| 14 | 14 | |
| 15 | 15 | class acf_form_comment { |
| 16 | 16 | |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | function __construct() { |
| 32 | 32 | |
| 33 | 33 | // actions |
| 34 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
| 34 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | // render |
| 38 | - add_action( 'comment_form_logged_in_after', array( $this, 'add_comment') ); |
|
| 39 | - add_action( 'comment_form_after_fields', array( $this, 'add_comment') ); |
|
| 38 | + add_action('comment_form_logged_in_after', array($this, 'add_comment')); |
|
| 39 | + add_action('comment_form_after_fields', array($this, 'add_comment')); |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | // save |
| 43 | - add_action( 'edit_comment', array( $this, 'save_comment' ), 10, 1 ); |
|
| 44 | - add_action( 'comment_post', array( $this, 'save_comment' ), 10, 1 ); |
|
| 43 | + add_action('edit_comment', array($this, 'save_comment'), 10, 1); |
|
| 44 | + add_action('comment_post', array($this, 'save_comment'), 10, 1); |
|
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | // validate page |
| 69 | - if( $pagenow == 'comment.php' ) { |
|
| 69 | + if ($pagenow == 'comment.php') { |
|
| 70 | 70 | |
| 71 | 71 | return true; |
| 72 | 72 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | function admin_enqueue_scripts() { |
| 96 | 96 | |
| 97 | 97 | // validate page |
| 98 | - if( ! $this->validate_page() ) { |
|
| 98 | + if ( ! $this->validate_page()) { |
|
| 99 | 99 | |
| 100 | 100 | return; |
| 101 | 101 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | // actions |
| 110 | - add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
| 111 | - add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1); |
|
| 110 | + add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
| 111 | + add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1); |
|
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @return n/a |
| 127 | 127 | */ |
| 128 | 128 | |
| 129 | - function edit_comment( $comment ) { |
|
| 129 | + function edit_comment($comment) { |
|
| 130 | 130 | |
| 131 | 131 | // vars |
| 132 | 132 | $post_id = "comment_{$comment->comment_ID}"; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | // render |
| 142 | - if( !empty($field_groups) ) { |
|
| 142 | + if ( ! empty($field_groups)) { |
|
| 143 | 143 | |
| 144 | 144 | // render post data |
| 145 | 145 | acf_form_data(array( |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | )); |
| 149 | 149 | |
| 150 | 150 | |
| 151 | - foreach( $field_groups as $field_group ) { |
|
| 151 | + foreach ($field_groups as $field_group) { |
|
| 152 | 152 | |
| 153 | 153 | // load fields |
| 154 | - $fields = acf_get_fields( $field_group ); |
|
| 154 | + $fields = acf_get_fields($field_group); |
|
| 155 | 155 | |
| 156 | 156 | |
| 157 | 157 | // vars |
| 158 | 158 | $o = array( |
| 159 | - 'id' => 'acf-' . $field_group['ID'], |
|
| 159 | + 'id' => 'acf-'.$field_group['ID'], |
|
| 160 | 160 | 'key' => $field_group['key'], |
| 161 | 161 | 'label' => $field_group['label_placement'] |
| 162 | 162 | ); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | <div id="acf-<?php echo $field_group['ID']; ?>" class="stuffbox"> |
| 166 | 166 | <h3 class="hndle"><?php echo $field_group['title']; ?></h3> |
| 167 | 167 | <div class="inside"> |
| 168 | - <?php acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] ); ?> |
|
| 168 | + <?php acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']); ?> |
|
| 169 | 169 | <script type="text/javascript"> |
| 170 | 170 | if( typeof acf !== 'undefined' ) { |
| 171 | 171 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | )); |
| 210 | 210 | |
| 211 | 211 | |
| 212 | - if( !empty($field_groups) ) { |
|
| 212 | + if ( ! empty($field_groups)) { |
|
| 213 | 213 | |
| 214 | 214 | // render post data |
| 215 | 215 | acf_form_data(array( |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | )); |
| 219 | 219 | |
| 220 | 220 | |
| 221 | - foreach( $field_groups as $field_group ) { |
|
| 221 | + foreach ($field_groups as $field_group) { |
|
| 222 | 222 | |
| 223 | - $fields = acf_get_fields( $field_group ); |
|
| 223 | + $fields = acf_get_fields($field_group); |
|
| 224 | 224 | |
| 225 | 225 | ?> |
| 226 | 226 | <div class="acf-fields -<?php echo $field_group['label_placement']; ?>"> |
| 227 | - <?php acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] ); ?> |
|
| 227 | + <?php acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']); ?> |
|
| 228 | 228 | </div> |
| 229 | 229 | <?php |
| 230 | 230 | |
@@ -248,10 +248,10 @@ discard block |
||
| 248 | 248 | * @return n/a |
| 249 | 249 | */ |
| 250 | 250 | |
| 251 | - function save_comment( $comment_id ) { |
|
| 251 | + function save_comment($comment_id) { |
|
| 252 | 252 | |
| 253 | 253 | // bail early if not valid nonce |
| 254 | - if( ! acf_verify_nonce('comment') ) { |
|
| 254 | + if ( ! acf_verify_nonce('comment')) { |
|
| 255 | 255 | |
| 256 | 256 | return $comment_id; |
| 257 | 257 | |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | // validate and save |
| 262 | - if( acf_validate_save_post(true) ) { |
|
| 262 | + if (acf_validate_save_post(true)) { |
|
| 263 | 263 | |
| 264 | - acf_save_post( "comment_{$comment_id}" ); |
|
| 264 | + acf_save_post("comment_{$comment_id}"); |
|
| 265 | 265 | |
| 266 | 266 | } |
| 267 | 267 | |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | * @subpackage Forms |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if( ! class_exists('acf_form_post') ) : |
|
| 13 | +if ( ! class_exists('acf_form_post')) : |
|
| 14 | 14 | |
| 15 | 15 | class acf_form_post { |
| 16 | 16 | |
| 17 | - var $post_id = 0, |
|
| 18 | - $typenow = '', |
|
| 19 | - $style = ''; |
|
| 17 | + var $post_id = 0, |
|
| 18 | + $typenow = '', |
|
| 19 | + $style = ''; |
|
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /* |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | function __construct() { |
| 36 | 36 | |
| 37 | 37 | // actions |
| 38 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 38 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | // save |
| 42 | - add_filter('wp_insert_post_empty_content', array($this, 'wp_insert_post_empty_content'), 10, 2); |
|
| 43 | - add_action('save_post', array($this, 'save_post'), 10, 2); |
|
| 42 | + add_filter('wp_insert_post_empty_content', array($this, 'wp_insert_post_empty_content'), 10, 2); |
|
| 43 | + add_action('save_post', array($this, 'save_post'), 10, 2); |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | // ajax |
| 47 | - add_action('wp_ajax_acf/post/get_field_groups', array($this, 'get_field_groups')); |
|
| 47 | + add_action('wp_ajax_acf/post/get_field_groups', array($this, 'get_field_groups')); |
|
| 48 | 48 | |
| 49 | 49 | } |
| 50 | 50 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | // validate page |
| 76 | - if( in_array($pagenow, array('post.php', 'post-new.php')) ) { |
|
| 76 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
| 77 | 77 | |
| 78 | 78 | $return = true; |
| 79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | |
| 83 | 83 | // update vars |
| 84 | - if( !empty($post) ) { |
|
| 84 | + if ( ! empty($post)) { |
|
| 85 | 85 | |
| 86 | 86 | $this->post_id = $post->ID; |
| 87 | 87 | $this->typenow = $typenow; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 | // validate post type |
| 93 | - if( in_array($typenow, array('acf-field-group', 'attachment')) ) { |
|
| 93 | + if (in_array($typenow, array('acf-field-group', 'attachment'))) { |
|
| 94 | 94 | |
| 95 | 95 | return false; |
| 96 | 96 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | // validate page (Shopp) |
| 101 | - if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) ) { |
|
| 101 | + if ($pagenow == "admin.php" && isset($_GET['page']) && $_GET['page'] == "shopp-products" && isset($_GET['id'])) { |
|
| 102 | 102 | |
| 103 | 103 | $return = true; |
| 104 | 104 | |
| 105 | - $this->post_id = absint( $_GET['id'] ); |
|
| 105 | + $this->post_id = absint($_GET['id']); |
|
| 106 | 106 | $this->typenow = 'shopp_product'; |
| 107 | 107 | |
| 108 | 108 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | function admin_enqueue_scripts() { |
| 131 | 131 | |
| 132 | 132 | // validate page |
| 133 | - if( !$this->validate_page() ) return; |
|
| 133 | + if ( ! $this->validate_page()) return; |
|
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | // load acf scripts |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | // actions |
| 141 | - add_action('acf/input/admin_head', array($this,'admin_head')); |
|
| 142 | - add_action('acf/input/admin_footer', array($this,'admin_footer')); |
|
| 141 | + add_action('acf/input/admin_head', array($this, 'admin_head')); |
|
| 142 | + add_action('acf/input/admin_footer', array($this, 'admin_footer')); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | |
| 169 | 169 | // add meta boxes |
| 170 | - if( !empty($field_groups) ) { |
|
| 170 | + if ( ! empty($field_groups)) { |
|
| 171 | 171 | |
| 172 | - foreach( $field_groups as $i => $field_group ) { |
|
| 172 | + foreach ($field_groups as $i => $field_group) { |
|
| 173 | 173 | |
| 174 | 174 | // vars |
| 175 | 175 | $id = "acf-{$field_group['key']}"; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | // tweaks to vars |
| 186 | - if( $context == 'side' ) { |
|
| 186 | + if ($context == 'side') { |
|
| 187 | 187 | |
| 188 | 188 | $priority = 'core'; |
| 189 | 189 | |
@@ -195,22 +195,22 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | // visibility |
| 198 | - $args['visibility'] = acf_get_field_group_visibility( $field_group, array( |
|
| 198 | + $args['visibility'] = acf_get_field_group_visibility($field_group, array( |
|
| 199 | 199 | 'post_id' => $this->post_id, |
| 200 | 200 | 'post_type' => $this->typenow |
| 201 | 201 | )); |
| 202 | 202 | |
| 203 | 203 | |
| 204 | 204 | // add meta box |
| 205 | - add_meta_box( $id, $title, array($this, 'render_meta_box'), $this->typenow, $context, $priority, $args ); |
|
| 205 | + add_meta_box($id, $title, array($this, 'render_meta_box'), $this->typenow, $context, $priority, $args); |
|
| 206 | 206 | |
| 207 | 207 | |
| 208 | 208 | // update style |
| 209 | - if( !$style_found && $args['visibility'] ) { |
|
| 209 | + if ( ! $style_found && $args['visibility']) { |
|
| 210 | 210 | |
| 211 | 211 | $style_found = true; |
| 212 | 212 | |
| 213 | - $this->style = acf_get_field_group_style( $field_group ); |
|
| 213 | + $this->style = acf_get_field_group_style($field_group); |
|
| 214 | 214 | |
| 215 | 215 | } |
| 216 | 216 | |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | // render |
| 258 | - do_meta_boxes( get_current_screen(), 'acf_after_title', $post); |
|
| 258 | + do_meta_boxes(get_current_screen(), 'acf_after_title', $post); |
|
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | // clean up |
| 262 | - unset( $wp_meta_boxes['post']['acf_after_title'] ); |
|
| 262 | + unset($wp_meta_boxes['post']['acf_after_title']); |
|
| 263 | 263 | |
| 264 | 264 | } |
| 265 | 265 | |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | * @return $post_id (int) |
| 278 | 278 | */ |
| 279 | 279 | |
| 280 | - function render_meta_box( $post, $args ) { |
|
| 280 | + function render_meta_box($post, $args) { |
|
| 281 | 281 | |
| 282 | 282 | // extract args |
| 283 | - extract( $args ); // all variables from the add_meta_box function |
|
| 284 | - extract( $args ); // all variables from the args argument |
|
| 283 | + extract($args); // all variables from the add_meta_box function |
|
| 284 | + extract($args); // all variables from the args argument |
|
| 285 | 285 | |
| 286 | 286 | |
| 287 | 287 | // vars |
@@ -297,22 +297,22 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | |
| 299 | 299 | // edit_url |
| 300 | - if( $field_group['ID'] && acf_current_user_can_admin() ) { |
|
| 300 | + if ($field_group['ID'] && acf_current_user_can_admin()) { |
|
| 301 | 301 | |
| 302 | - $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit'); |
|
| 302 | + $o['edit_url'] = admin_url('post.php?post='.$field_group['ID'].'&action=edit'); |
|
| 303 | 303 | |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
| 307 | 307 | // load and render fields |
| 308 | - if( $visibility ) { |
|
| 308 | + if ($visibility) { |
|
| 309 | 309 | |
| 310 | 310 | // load fields |
| 311 | - $fields = acf_get_fields( $field_group ); |
|
| 311 | + $fields = acf_get_fields($field_group); |
|
| 312 | 312 | |
| 313 | 313 | |
| 314 | 314 | // render |
| 315 | - acf_render_fields( $this->post_id, $fields, 'div', $field_group['instruction_placement'] ); |
|
| 315 | + acf_render_fields($this->post_id, $fields, 'div', $field_group['instruction_placement']); |
|
| 316 | 316 | |
| 317 | 317 | // render replace-me div |
| 318 | 318 | } else { |
@@ -347,10 +347,10 @@ discard block |
||
| 347 | 347 | * @return $post_id (int) |
| 348 | 348 | */ |
| 349 | 349 | |
| 350 | - function admin_footer(){ |
|
| 350 | + function admin_footer() { |
|
| 351 | 351 | |
| 352 | 352 | // get style of first field group |
| 353 | - echo '<style type="text/css" id="acf-style">' . $this->style . '</style>'; |
|
| 353 | + echo '<style type="text/css" id="acf-style">'.$this->style.'</style>'; |
|
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | |
@@ -381,12 +381,12 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | // vars |
| 383 | 383 | $json = array(); |
| 384 | - $nonce = acf_extract_var( $options, 'nonce' ); |
|
| 385 | - $exists = acf_extract_var( $options, 'exists' ); |
|
| 384 | + $nonce = acf_extract_var($options, 'nonce'); |
|
| 385 | + $exists = acf_extract_var($options, 'exists'); |
|
| 386 | 386 | |
| 387 | 387 | |
| 388 | 388 | // verify nonce |
| 389 | - if( !wp_verify_nonce($nonce, 'acf_nonce') ) { |
|
| 389 | + if ( ! wp_verify_nonce($nonce, 'acf_nonce')) { |
|
| 390 | 390 | |
| 391 | 391 | die; |
| 392 | 392 | |
@@ -394,19 +394,19 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | |
| 396 | 396 | // get field groups |
| 397 | - $field_groups = acf_get_field_groups( $options ); |
|
| 397 | + $field_groups = acf_get_field_groups($options); |
|
| 398 | 398 | |
| 399 | 399 | |
| 400 | 400 | // bail early if no field groups |
| 401 | - if( empty($field_groups) ) { |
|
| 401 | + if (empty($field_groups)) { |
|
| 402 | 402 | |
| 403 | - wp_send_json_success( $json ); |
|
| 403 | + wp_send_json_success($json); |
|
| 404 | 404 | |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
| 408 | 408 | // loop through field groups |
| 409 | - foreach( $field_groups as $i => $field_group ) { |
|
| 409 | + foreach ($field_groups as $i => $field_group) { |
|
| 410 | 410 | |
| 411 | 411 | // vars |
| 412 | 412 | $item = array( |
@@ -419,18 +419,18 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | |
| 421 | 421 | // style |
| 422 | - if( $i == 0 ) { |
|
| 422 | + if ($i == 0) { |
|
| 423 | 423 | |
| 424 | - $item['style'] = acf_get_field_group_style( $field_group ); |
|
| 424 | + $item['style'] = acf_get_field_group_style($field_group); |
|
| 425 | 425 | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | |
| 429 | 429 | // html |
| 430 | - if( !in_array($field_group['key'], $exists) ) { |
|
| 430 | + if ( ! in_array($field_group['key'], $exists)) { |
|
| 431 | 431 | |
| 432 | 432 | // load fields |
| 433 | - $fields = acf_get_fields( $field_group ); |
|
| 433 | + $fields = acf_get_fields($field_group); |
|
| 434 | 434 | |
| 435 | 435 | |
| 436 | 436 | // get field HTML |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | |
| 440 | 440 | // render |
| 441 | - acf_render_fields( $options['post_id'], $fields, 'div', $field_group['instruction_placement'] ); |
|
| 441 | + acf_render_fields($options['post_id'], $fields, 'div', $field_group['instruction_placement']); |
|
| 442 | 442 | |
| 443 | 443 | |
| 444 | 444 | $item['html'] = ob_get_clean(); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | |
| 456 | 456 | // return |
| 457 | - wp_send_json_success( $json ); |
|
| 457 | + wp_send_json_success($json); |
|
| 458 | 458 | |
| 459 | 459 | } |
| 460 | 460 | |
@@ -473,9 +473,9 @@ discard block |
||
| 473 | 473 | * @return $maybe_empty |
| 474 | 474 | */ |
| 475 | 475 | |
| 476 | - function wp_insert_post_empty_content( $maybe_empty, $postarr ) { |
|
| 476 | + function wp_insert_post_empty_content($maybe_empty, $postarr) { |
|
| 477 | 477 | |
| 478 | - if( $maybe_empty && !empty($_POST['_acfchanged']) ) { |
|
| 478 | + if ($maybe_empty && ! empty($_POST['_acfchanged'])) { |
|
| 479 | 479 | |
| 480 | 480 | $maybe_empty = false; |
| 481 | 481 | |
@@ -500,10 +500,10 @@ discard block |
||
| 500 | 500 | * @return $post_id (int) |
| 501 | 501 | */ |
| 502 | 502 | |
| 503 | - function save_post( $post_id, $post ) { |
|
| 503 | + function save_post($post_id, $post) { |
|
| 504 | 504 | |
| 505 | 505 | // do not save if this is an auto save routine |
| 506 | - if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { |
|
| 506 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 507 | 507 | |
| 508 | 508 | return $post_id; |
| 509 | 509 | |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | |
| 512 | 512 | |
| 513 | 513 | // bail early if is acf-field-group or acf-field |
| 514 | - if( in_array($post->post_type, array('acf-field', 'acf-field-group'))) { |
|
| 514 | + if (in_array($post->post_type, array('acf-field', 'acf-field-group'))) { |
|
| 515 | 515 | |
| 516 | 516 | return $post_id; |
| 517 | 517 | |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | |
| 521 | 521 | // verify and remove nonce |
| 522 | - if( !acf_verify_nonce('post', $post_id) ) { |
|
| 522 | + if ( ! acf_verify_nonce('post', $post_id)) { |
|
| 523 | 523 | |
| 524 | 524 | return $post_id; |
| 525 | 525 | |
@@ -527,17 +527,17 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | |
| 529 | 529 | // validate and save |
| 530 | - if( get_post_status($post_id) == 'publish' ) { |
|
| 530 | + if (get_post_status($post_id) == 'publish') { |
|
| 531 | 531 | |
| 532 | - if( acf_validate_save_post(true) ) { |
|
| 532 | + if (acf_validate_save_post(true)) { |
|
| 533 | 533 | |
| 534 | - acf_save_post( $post_id ); |
|
| 534 | + acf_save_post($post_id); |
|
| 535 | 535 | |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | } else { |
| 539 | 539 | |
| 540 | - acf_save_post( $post_id ); |
|
| 540 | + acf_save_post($post_id); |
|
| 541 | 541 | |
| 542 | 542 | } |
| 543 | 543 | |
@@ -562,14 +562,14 @@ discard block |
||
| 562 | 562 | * @return $post_id (int) |
| 563 | 563 | */ |
| 564 | 564 | |
| 565 | - function is_protected_meta( $protected, $meta_key, $meta_type ) { |
|
| 565 | + function is_protected_meta($protected, $meta_key, $meta_type) { |
|
| 566 | 566 | |
| 567 | 567 | // if acf_get_field_reference returns a valid key, this is an acf value, so protect it! |
| 568 | - if( !$protected ) { |
|
| 568 | + if ( ! $protected) { |
|
| 569 | 569 | |
| 570 | - $reference = acf_get_field_reference( $meta_key, $this->post_id ); |
|
| 570 | + $reference = acf_get_field_reference($meta_key, $this->post_id); |
|
| 571 | 571 | |
| 572 | - if( acf_is_field_key($reference) ) { |
|
| 572 | + if (acf_is_field_key($reference)) { |
|
| 573 | 573 | |
| 574 | 574 | $protected = true; |
| 575 | 575 | |
@@ -130,7 +130,9 @@ |
||
| 130 | 130 | function admin_enqueue_scripts() { |
| 131 | 131 | |
| 132 | 132 | // validate page |
| 133 | - if( !$this->validate_page() ) return; |
|
| 133 | + if( !$this->validate_page() ) { |
|
| 134 | + return; |
|
| 135 | + } |
|
| 134 | 136 | |
| 135 | 137 | |
| 136 | 138 | // load acf scripts |