PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / fields / field-repeater.php
acf-extended / includes / fields Last commit date
field-advanced-link.php 3 months ago field-button-group.php 1 week ago field-button.php 7 months ago field-checkbox.php 3 months ago field-clone.php 2 years ago field-code-editor.php 3 months ago field-column.php 3 years ago field-dynamic-render.php 3 years ago field-file.php 3 months ago field-flexible-content-actions-title.php 3 months ago field-flexible-content-actions-toggle.php 3 months ago field-flexible-content-actions.php 3 months ago field-flexible-content-async.php 4 months ago field-flexible-content-compatibility.php 3 months ago field-flexible-content-controls.php 9 months ago field-flexible-content-hide.php 3 months ago field-flexible-content-hooks.php 9 months ago field-flexible-content-modal-edit.php 9 months ago field-flexible-content-modal-select.php 3 months ago field-flexible-content-modal-settings.php 3 months ago field-flexible-content-popup.php 3 months ago field-flexible-content-preview.php 3 months ago field-flexible-content-state.php 9 months ago field-flexible-content-thumbnail.php 9 months ago field-flexible-content-wysiwyg.php 9 months ago field-flexible-content.php 3 months ago field-forms.php 3 months ago field-gallery.php 3 months ago field-google-map.php 3 months ago field-group.php 3 months ago field-hidden.php 3 years ago field-image.php 3 months ago field-post-object.php 3 months ago field-post-statuses.php 3 months ago field-post-types.php 3 months ago field-radio.php 3 months ago field-recaptcha.php 3 months ago field-relationship.php 3 months ago field-repeater.php 3 months ago field-select.php 3 months ago field-slug.php 1 year ago field-taxonomies.php 3 months ago field-taxonomy-terms.php 3 months ago field-taxonomy.php 3 months ago field-textarea.php 3 months ago field-user-roles.php 3 months ago field-user.php 3 months ago field-wysiwyg.php 3 months ago
field-repeater.php
151 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_field_repeater')):
8
9 class acfe_field_repeater extends acfe_field_extend{
10
11 /**
12 * initialize
13 */
14 function initialize(){
15
16 $this->name = 'repeater';
17 $this->defaults = array(
18 'acfe_repeater_stylised_button' => 0,
19 );
20
21 $this->add_field_action('acf/render_field_settings', array($this, '_render_field_settings'), 0);
22
23 }
24
25
26 /**
27 * _render_field_settings
28 *
29 * acf/render_field_settings:0
30 *
31 * @param $field
32 */
33 function _render_field_settings($field){
34
35 // stylised button
36 acf_render_field_setting($field, array(
37 'label' => __('Stylised Button', 'acfe'),
38 'name' => 'acfe_repeater_stylised_button',
39 'key' => 'acfe_repeater_stylised_button',
40 'instructions' => __('Better row button integration'),
41 'type' => 'true_false',
42 'message' => '',
43 'default_value' => false,
44 'ui' => true,
45 ));
46
47 }
48
49
50 /**
51 * field_wrapper_attributes
52 *
53 * @param $wrapper
54 * @param $field
55 *
56 * @return mixed
57 */
58 function field_wrapper_attributes($wrapper, $field){
59
60 // stylised button
61 if($field['acfe_repeater_stylised_button']){
62 $wrapper['data-acfe-repeater-stylised-button'] = 1;
63 }
64
65 // lock sortable
66 $lock = false;
67 $lock = apply_filters("acfe/repeater/lock", $lock, $field);
68 $lock = apply_filters("acfe/repeater/lock/name={$field['_name']}", $lock, $field);
69 $lock = apply_filters("acfe/repeater/lock/key={$field['key']}", $lock, $field);
70
71 if($lock){
72 $wrapper['data-acfe-repeater-lock'] = 1;
73 }
74
75 // remove actions
76 $remove = false;
77 $remove = apply_filters("acfe/repeater/remove_actions", $remove, $field);
78 $remove = apply_filters("acfe/repeater/remove_actions/name={$field['_name']}", $remove, $field);
79 $remove = apply_filters("acfe/repeater/remove_actions/key={$field['key']}", $remove, $field);
80
81 if($remove){
82 $wrapper['data-acfe-repeater-remove-actions'] = 1;
83 }
84
85 // return
86 return $wrapper;
87
88 }
89
90
91 /**
92 * format_front_value
93 *
94 * @param $formatted
95 * @param $unformatted
96 * @param $post_id
97 * @param $field
98 * @param $form
99 *
100 * @return string
101 */
102 function format_front_value($formatted, $unformatted, $post_id, $field, $form){
103
104 // vars
105 $value = acfe_as_array($unformatted);
106 $return = '';
107
108 // loop values
109 foreach($value as $i => $sub_fields){
110
111 $array = array();
112 $return .= "<br/>\n- ";
113
114 // loop subfields keys
115 foreach($sub_fields as $key => $val){
116
117 // get subfield
118 $sub_field = acf_get_field($key);
119
120 // validate
121 if($sub_field){
122
123 // label
124 $label = !empty($sub_field['label']) ? $sub_field['label'] : $sub_field['name'];
125
126 // value
127 $sub_field['name'] = $field['name'] . '_' . $i . '_' . $sub_field['name'];
128 $val = acfe_form_format_value($val, $sub_field);
129
130 // append
131 $array[] = "{$label}: {$val}";
132
133 }
134
135 }
136
137 // merge
138 $return .= implode('. ', $array);
139
140 }
141
142 // return
143 return $return;
144
145 }
146
147 }
148
149 acf_new_instance('acfe_field_repeater');
150
151 endif;