Ejemplo n.º 1
0
    function pmai_render_field($field, $post = array(), $field_name = "")
    {
        if (empty($field['multiple'])) {
            $field['multiple'] = false;
        }
        if (empty($field['class'])) {
            $field['class'] = false;
        }
        if (empty($field['id'])) {
            $field['id'] = false;
        }
        $current_field = !empty($post['fields'][$field['key']]) ? $post['fields'][$field['key']] : false;
        $current_is_multiple_field_value = isset($post['is_multiple_field_value'][$field['key']]) ? $post['is_multiple_field_value'][$field['key']] : false;
        $current_multiple_value = isset($post['multiple_value'][$field['key']]) ? $post['multiple_value'][$field['key']] : false;
        if ("" != $field_name) {
            $field_keys = str_replace(array('[', ']'), array(''), str_replace('][', ':', $field_name));
            foreach (explode(":", $field_keys) as $n => $key) {
                $current_field = !empty($post['fields'][$key]) ? $post['fields'][$key] : $current_field[$key];
                $current_is_multiple_field_value = isset($post['is_multiple_field_value'][$key]) ? $post['is_multiple_field_value'][$key] : $current_is_multiple_field_value[$key];
                $current_multiple_value = isset($post['multiple_value'][$key]) ? $post['multiple_value'][$key] : $current_multiple_value[$key];
            }
            $current_field = !empty($current_field[$field['key']]) ? $current_field[$field['key']] : false;
            $current_is_multiple_field_value = isset($current_is_multiple_field_value[$field['key']]) ? $current_is_multiple_field_value[$field['key']] : false;
            $current_multiple_value = isset($current_multiple_value[$field['key']]) ? $current_multiple_value[$field['key']] : false;
        }
        global $acf;
        ?>
		
		<?php 
        if (!in_array($field['type'], array('message'))) {
            ?>
		
		<div class="field field_type-<?php 
            echo $field['type'];
            ?>
 field_key-<?php 
            echo $field['key'];
            ?>
">			
			<p class="label"><label><?php 
            echo in_array($field['type'], array('message', 'tab')) ? $field['type'] : (empty($field['label']) ? '' : $field['label']);
            ?>
</label></p>			
			<div class="wpallimport-clear"></div>
			<p class="label" style="display:block; margin:0;"><label></label></p>
			<div class="acf-input-wrap">
				<?php 
            switch ($field['type']) {
                case 'user':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text w95 widefat rad4"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Specify the user ID, username, or user e-mail address. Separate multiple values with commas.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'acf_cf7':
                case 'gravity_forms_field':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text w95 widefat rad4"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Specify the form ID.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'page_link':
                case 'post_object':
                case 'relationship':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text w95 widefat rad4"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Enter in the ID or slug, or IDs or slugs separated by commas.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'file':
                case 'image':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text w95 widefat rad4"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Specify the URL to the image or file.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'gallery':
                    ?>
						<div class="input">
							<label><?php 
                    _e('Enter image URL one per line, or separate them with a', 'pmxi_plugin');
                    ?>
 </label>
							<input type="text" style="width:5%; text-align:center;" value="<?php 
                    echo !empty($current_field['delim']) ? esc_attr($current_field['delim']) : '';
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][delim]" class="small rad4">
							<textarea placeholder="http://example.com/images/image-1.jpg" style="clear: both; display: block; margin-top: 10px;" class="newline rad4" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][gallery]"><?php 
                    echo !is_array($current_field) ? esc_attr($current_field) : esc_attr($current_field['gallery']);
                    ?>
</textarea>			
						</div>
						<?php 
                    break;
                case 'color_picker':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text w95 widefat rad4"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Specify the hex code the color preceded with a # - e.g. #ea5f1a.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'text':
                case 'number':
                case 'email':
                case 'password':
                case 'url':
                case 'oembed':
                case 'limiter':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text widefat rad4"/>
						<?php 
                    break;
                case 'wp_wysiwyg':
                case 'wysiwyg':
                case 'textarea':
                    ?>
						<textarea name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="widefat rad4"><?php 
                    echo esc_attr($current_field);
                    ?>
</textarea>
						<?php 
                    break;
                case 'date_picker':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text datepicker widefat rad4" style="width:200px;"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Use any format supported by the PHP strtotime function.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'date_time_picker':
                    ?>
						<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" class="text datetimepicker widefat rad4" style="width:200px;"/>
						<a href="#help" class="wpallimport-help" title="<?php 
                    _e('Use any format supported by the PHP strtotime function.', 'pmxi_plugin');
                    ?>
" style="top:0;">?</a>
						<?php 
                    break;
                case 'google_map':
                case 'location-field':
                    ?>
						<div class="input">
							<label><?php 
                    _e("Address");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['address']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][address]" class="text widefat rad4"/>												
						</div>
						<div class="input">
							<label><?php 
                    _e("Lat");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['lat']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][lat]" class="text widefat rad4"/>												
						</div>
						<div class="input">
							<label><?php 
                    _e("Lng");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['lng']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][lng]" class="text widefat rad4"/>
						</div>
						<?php 
                    break;
                case 'paypal_item':
                    ?>
						<div class="input">
							<label><?php 
                    _e("Item Name");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['item_name']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][item_name]" class="text widefat rad4"/>												
						</div>
						<div class="input">
							<label><?php 
                    _e("Item Description");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['item_description']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][item_description]" class="text widefat rad4"/>												
						</div>
						<div class="input">
							<label><?php 
                    _e("Price");
                    ?>
</label>
							<input type="text" placeholder="" value="<?php 
                    echo esc_attr($current_field['price']);
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][price]" class="text widefat rad4"/>
						</div>
						<?php 
                    break;
                case 'select':
                case 'checkbox':
                case 'radio':
                case 'true_false':
                    ?>
											
						<div class="input">
							<div class="main_choise">
								<input type="radio" id="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="switcher" name="is_multiple_field_value<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" value="yes" <?php 
                    echo 'no' != $current_is_multiple_field_value ? 'checked="checked"' : '';
                    ?>
/>
								<label for="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="chooser_label"><?php 
                    _e("Select value for all records", "pmxi_plugin");
                    ?>
</label>
							</div>
							<div class="wpallimport-clear"></div>
							<div class="switcher-target-is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes">
								<div class="input sub_input">
									<div class="input">
										<?php 
                    if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                        $field_class = 'acf_field_' . $field['type'];
                        $field['other_choice'] = false;
                        $field['_input'] = 'multiple_value' . $field_name . '[' . $field['key'] . ']';
                        $field['value'] = $current_multiple_value;
                        acf_render_field($field);
                    } else {
                        $field_class = 'acf_field_' . $field['type'];
                        $new_field = new $field_class();
                        $field['other_choice'] = false;
                        $field['name'] = 'multiple_value' . $field_name . '[' . $field['key'] . ']';
                        $field['value'] = $current_multiple_value;
                        $new_field->create_field($field);
                    }
                    ?>
									</div>
								</div>
							</div>
						</div>											
						
						<div class="clear"></div>

						<div class="input">
							<div class="main_choise">
								<input type="radio" id="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="switcher" name="is_multiple_field_value<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" value="no" <?php 
                    echo 'no' == $current_is_multiple_field_value ? 'checked="checked"' : '';
                    ?>
/>
								<label for="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="chooser_label"><?php 
                    _e('Set with XPath', 'pmxi_plugin');
                    ?>
</label>
							</div>
							<div class="wpallimport-clear"></div>
							<div class="switcher-target-is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no">
								<div class="input sub_input">
									<div class="input">
										<input type="text" class="smaller-text widefat rad4" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" style="width:300px;" value="<?php 
                    echo esc_attr($current_field);
                    ?>
"/>
										<?php 
                    if ($field['type'] == 'select' || $field['type'] == 'checkbox' || $field['type'] == 'radio') {
                        ?>
												<a href="#help" class="wpallimport-help" style="top:0;" title="<?php 
                        _e('Specify the value. For multiple values, separate with commas. If the choices are of the format option : Option, option-2 : Option 2, use option and option-2 for values.', 'pmxi_plugin');
                        ?>
">?</a>
												<?php 
                    } else {
                        ?>
												<a href="#help" class="wpallimport-help" style="top:0;" title="<?php 
                        _e('Specify the 0 for false, 1 for true.', 'pmxi_plugin');
                        ?>
">?</a>
												<?php 
                    }
                    ?>
									</div>
								</div>
							</div>
						</div>
						<?php 
                    break;
                case 'taxonomy':
                    ?>
						<div class="input">
							<div class="main_choise">
								<input type="radio" id="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="switcher" name="is_multiple_field_value<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" value="yes" <?php 
                    echo 'no' != $current_is_multiple_field_value ? 'checked="checked"' : '';
                    ?>
/>
								<label for="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="chooser_label"><?php 
                    _e("Select value for all records");
                    ?>
</label>
							</div>
							<div class="wpallimport-clear"></div>
							<div class="switcher-target-is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes">
								<div class="input sub_input">
									<div class="input">
										<?php 
                    if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                        $field_class = 'acf_field_' . $field['type'];
                        $field['other_choice'] = false;
                        $field['_input'] = 'multiple_value' . $field_name . '[' . $field['key'] . ']';
                        $field['value'] = $current_multiple_value;
                        acf_render_field($field);
                    } else {
                        $field_class = 'acf_field_' . $field['type'];
                        $new_field = new $field_class();
                        $field['other_choice'] = false;
                        $field['name'] = 'multiple_value' . $field_name . '[' . $field['key'] . ']';
                        $field['value'] = $current_multiple_value;
                        $new_field->create_field($field);
                    }
                    ?>
									</div>
								</div>
							</div>
						</div>											
						<div class="clear"></div>
						<div class="input" style="overflow:hidden;">
							<div class="main_choise">
								<input type="radio" id="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="switcher" name="is_multiple_field_value<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" value="no" <?php 
                    echo 'no' == $current_is_multiple_field_value ? 'checked="checked"' : '';
                    ?>
/>
								<label for="is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="chooser_label"><?php 
                    _e('Set with XPath', 'pmxi_plugin');
                    ?>
</label>
							</div>
							<div class="wpallimport-clear"></div>
							<div class="switcher-target-is_multiple_field_value_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no">
								<div class="input sub_input">
									<div class="input">
										<table class="pmai_taxonomy post_taxonomy">
											<tr>
												<td>
													<div class="col2" style="clear: both;">
														<ol class="sortable no-margin">
															<?php 
                    if (!empty($current_field)) {
                        $taxonomies_hierarchy = json_decode($current_field);
                        if (!empty($taxonomies_hierarchy) and is_array($taxonomies_hierarchy)) {
                            $i = 0;
                            foreach ($taxonomies_hierarchy as $cat) {
                                $i++;
                                if (is_null($cat->parent_id) or empty($cat->parent_id)) {
                                    ?>
																			<li id="item_<?php 
                                    echo $i;
                                    ?>
" class="dragging">
																				<div class="drag-element">
																					<input type="text" class="widefat xpath_field rad4" value="<?php 
                                    echo esc_attr($cat->xpath);
                                    ?>
"/>
																				</div>
																				<?php 
                                    if ($i > 1) {
                                        ?>
<a href="javascript:void(0);" class="icon-item remove-ico"></a><?php 
                                    }
                                    ?>

																				<?php 
                                    echo reverse_taxonomies_html($taxonomies_hierarchy, $cat->item_id, $i);
                                    ?>
																			</li>
																			<?php 
                                }
                            }
                        } else {
                            ?>
																	<li id="item_1" class="dragging">
																		<div class="drag-element" >
																			<!--input type="checkbox" class="assign_post" checked="checked" title="<?php 
                            _e('Assign post to the taxonomy.', 'pmxi_plugin');
                            ?>
"/-->														
																			<input type="text" class="widefat xpath_field rad4" value=""/>
																			<a href="javascript:void(0);" class="icon-item remove-ico"></a>
																		</div>
																	</li>
																	<?php 
                        }
                    } else {
                        ?>
														    <li id="item_1" class="dragging">
														    	<div class="drag-element">
														    		<!--input type="checkbox" class="assign_post" checked="checked" title="<?php 
                        _e('Assign post to the taxonomy.', 'pmxi_plugin');
                        ?>
"/-->									    		
														    		<input type="text" class="widefat xpath_field rad4" value=""/>
														    		<a href="javascript:void(0);" class="icon-item remove-ico"></a>
														    	</div>
														    </li>
															<?php 
                    }
                    ?>
															<li id="item" class="template">
														    	<div class="drag-element">
														    		<!--input type="checkbox" class="assign_post" checked="checked" title="<?php 
                    _e('Assign post to the taxonomy.', 'pmxi_plugin');
                    ?>
"/-->									    		
														    		<input type="text" class="widefat xpath_field rad4" value=""/>
														    		<a href="javascript:void(0);" class="icon-item remove-ico"></a>
														    	</div>
														    </li>
														</ol>
														<input type="hidden" class="hierarhy-output" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
]" value="<?php 
                    echo esc_attr($current_field);
                    ?>
"/>													
														<?php 
                    //$taxonomies_hierarchy = json_decode($current_field, true);
                    ?>
														<div class="delim">														
															<a href="javascript:void(0);" class="icon-item add-new-ico"><?php 
                    _e('Add more', 'pmxi_plugin');
                    ?>
</a>
														</div>
													</div>
												</td>
											</tr>										
										</table>
									</div>
								</div>
							</div>
						</div>
						<?php 
                    break;
                case 'repeater':
                    ?>
						<div class="repeater">
							
							<div class="input" style="margin-bottom: 10px;">
							
								<div class="input">
									<input type="radio" id="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="switcher variable_repeater_mode" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][is_variable]" value="no" <?php 
                    echo 'yes' != $current_field['is_variable'] ? 'checked="checked"' : '';
                    ?>
/>
									<label for="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no" class="chooser_label"><?php 
                    _e('Fixed Repeater Mode', 'pmxi_plugin');
                    ?>
</label>
								</div>
								<div class="wpallimport-clear"></div>
								<div class="switcher-target-is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no">
									<div class="input sub_input">
										<div class="input">
											<input type="hidden" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][is_ignore_empties]" value="0"/>
											<input type="checkbox" value="1" id="is_ignore_empties<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][is_ignore_empties]" <?php 
                    if (!empty($current_field['is_ignore_empties'])) {
                        echo 'checked="checked';
                    }
                    ?>
/>
											<label for="is_ignore_empties<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
"><?php 
                    _e('Ignore blank fields', 'pmxi_plugin');
                    ?>
</label>
											<a href="#help" class="wpallimport-help" style="top:0;" title="<?php 
                    _e('If the value of the element or column in your file is blank, it will be ignored. Use this option when some records in your file have a different number of repeating elements than others.', 'pmxi_plugin');
                    ?>
">?</a>
										</div>
									</div>
								</div>
								<div class="input">
									<input type="radio" id="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="switcher variable_repeater_mode" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][is_variable]" value="yes" <?php 
                    echo 'yes' == $current_field['is_variable'] ? 'checked="checked"' : '';
                    ?>
/>
									<label for="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes" class="chooser_label"><?php 
                    _e('Variable Repeater Mode (XML)', 'pmxi_plugin');
                    ?>
</label>
								</div>																	
								<div class="input">
									<input type="radio" id="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes_csv" class="switcher variable_repeater_mode" name="fields<?php 
                    echo $field_name;
                    ?>
[<?php 
                    echo $field['key'];
                    ?>
][is_variable]" value="csv" <?php 
                    echo 'csv' == $current_field['is_variable'] ? 'checked="checked"' : '';
                    ?>
/>
									<label for="is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes_csv" class="chooser_label"><?php 
                    _e('Variable Repeater Mode (CSV)', 'pmxi_plugin');
                    ?>
</label>									
								</div>																	
								<div class="wpallimport-clear"></div>
								<div class="switcher-target-is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes">
									<div class="input sub_input">
										<div class="input">
											<p>
												<?php 
                    printf(__("For each %s do ..."), '<input type="text" name="fields' . $field_name . '[' . $field["key"] . '][foreach]" value="' . $current_field["foreach"] . '" class="pmai_foreach widefat rad4"/>');
                    ?>
											
												<a href="http://www.wpallimport.com/documentation/advanced-custom-fields/repeater-fields/" target="_blank"><?php 
                    _e('(documentation)', 'pmxi_plugin');
                    ?>
</a>
											</p>
										</div>
									</div>
								</div>
								<div class="switcher-target-is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_yes_csv">
									<div class="input sub_input">
										<div class="input">
											<p>
												<?php 
                    printf(__("Separator Character %s"), '<input type="text" name="fields' . $field_name . '[' . $field["key"] . '][separator]" value="' . (empty($current_field["separator"]) ? '|' : $current_field["separator"]) . '" class="pmai_variable_separator widefat rad4"/>');
                    ?>
											
												<a href="#help" class="wpallimport-help" style="top:0;" title="<?php 
                    _e('Use this option when importing a CSV file with a column or columns that contains the repeating data, separated by separators. For example, if you had a repeater with two fields - image URL and caption, and your CSV file had two columns, image URL and caption, with values like \'url1,url2,url3\' and \'caption1,caption2,caption3\', use this option and specify a comma as the separator.', 'pmxi_plugin');
                    ?>
">?</a>
											</p>
										</div>
									</div>
								</div>

							</div>							

							<table class="widefat acf-input-table row_layout">								
								<tbody>
									<?php 
                    if (!empty($current_field['rows'])) {
                        foreach ($current_field['rows'] as $key => $row) {
                            if ("ROWNUMBER" == $key) {
                                continue;
                            }
                            ?>
									
									<tr class="row">							
										<td class="order" style="padding:8px;"><?php 
                            echo $key;
                            ?>
</td>	
										<td class="acf_input-wrap" style="padding:0 !important;">
											<table class="widefat acf_input" style="border:none;">
												<tbody>
													<?php 
                            if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                                $sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => !empty($field['id']) ? $field['id'] : $field['ID'], 'post_status' => 'publish'));
                                if (!empty($sub_fields)) {
                                    foreach ($sub_fields as $n => $sub_field) {
                                        $sub_fieldData = !empty($sub_field->post_content) ? unserialize($sub_field->post_content) : array();
                                        $sub_fieldData['id'] = $sub_field->ID;
                                        $sub_fieldData['label'] = $sub_field->post_title;
                                        $sub_fieldData['key'] = $sub_field->post_name;
                                        ?>
																<tr class="field sub_field field_type-<?php 
                                        echo $sub_fieldData['type'];
                                        ?>
 field_key-<?php 
                                        echo $sub_fieldData['key'];
                                        ?>
">
																	<td class="label">
																		<?php 
                                        echo $sub_fieldData['label'];
                                        ?>
																	</td>
																	<td>
																		<div class="inner input">																			
																			<?php 
                                        echo pmai_render_field($sub_fieldData, $post, $field_name . "[" . $field['key'] . "][rows][" . $key . "]");
                                        ?>
																		</div>
																	</td>
																</tr>													
																<?php 
                                    }
                                }
                            } else {
                                foreach ($field['sub_fields'] as $n => $sub_field) {
                                    ?>
														<tr class="field sub_field field_type-<?php 
                                    echo $sub_field['type'];
                                    ?>
 field_key-<?php 
                                    echo $sub_field['key'];
                                    ?>
">
															<td class="label">
																<?php 
                                    echo $sub_field['label'];
                                    ?>
															</td>
															<td>
																<div class="inner input">
																	<?php 
                                    echo pmai_render_field($sub_field, $post, $field_name . "[" . $field['key'] . "][rows][" . $key . "]");
                                    ?>
																</div>
															</td>
														</tr>													
														<?php 
                                }
                            }
                            ?>
												</tbody>
											</table>
										</td>
									</tr>
									<?php 
                        }
                    }
                    ?>
															
									<tr class="row-clone">							
										<td class="order" style="padding:8px;"></td>		
										<td class="acf_input-wrap" style="padding:0 !important;">
											<table class="widefat acf_input" style="border:none;">
												<tbody>
													<?php 
                    if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                        $sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => !empty($field['id']) ? $field['id'] : $field['ID'], 'post_status' => 'publish'));
                        if (!empty($sub_fields)) {
                            foreach ($sub_fields as $key => $sub_field) {
                                $sub_fieldData = !empty($sub_field->post_content) ? unserialize($sub_field->post_content) : array();
                                $sub_fieldData['ID'] = $sub_field->ID;
                                $sub_fieldData['label'] = $sub_field->post_title;
                                $sub_fieldData['key'] = $sub_field->post_name;
                                ?>
																<tr class="field sub_field field_type-<?php 
                                echo $sub_fieldData['type'];
                                ?>
 field_key-<?php 
                                echo $sub_fieldData['key'];
                                ?>
">
																	<td class="label">
																		<?php 
                                echo $sub_fieldData['label'];
                                ?>
																	</td>
																	<td>
																		<div class="inner">
																			<?php 
                                echo pmai_render_field($sub_fieldData, $post, $field_name . "[" . $field['key'] . "][rows][ROWNUMBER]");
                                ?>
																		</div>	
																	</td>
																</tr>													
																<?php 
                            }
                        }
                    } else {
                        foreach ($field['sub_fields'] as $key => $sub_field) {
                            ?>
														<tr class="field sub_field field_type-<?php 
                            echo $sub_field['type'];
                            ?>
 field_key-<?php 
                            echo $sub_field['key'];
                            ?>
">
															<td class="label">
																<?php 
                            echo $sub_field['label'];
                            ?>
															</td>
															<td>
																<div class="inner">
																	<?php 
                            echo pmai_render_field($sub_field, $post, $field_name . "[" . $field['key'] . "][rows][ROWNUMBER]");
                            ?>
																</div>	
															</td>
														</tr>													
														<?php 
                        }
                    }
                    ?>
												</tbody>
											</table>
										</td>
									</tr>
								</tbody>
							</table>								
							<div class="wpallimport-clear"></div>
							<div class="switcher-target-is_variable_<?php 
                    echo str_replace(array('[', ']'), '', $field_name);
                    ?>
_<?php 
                    echo $field['key'];
                    ?>
_no">
								<div class="input sub_input">
									<ul class="hl clearfix repeater-footer">
										<li class="right">
											<a href="javascript:void(0);" class="acf-button delete_row" style="margin-left:15px;"><?php 
                    _e('Delete Row', 'pmxi_plugin');
                    ?>
</a>
										</li>
										<li class="right">
											<a class="add-row-end acf-button" href="javascript:void(0);"><?php 
                    _e("Add Row", "pmxi_plugin");
                    ?>
</a>									
										</li>								
									</ul>							
								</div>							
							</div>							
						</div>
						<?php 
                    break;
                case 'validated_field':
                    if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                        /*$sub_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => ((!empty($field['id'])) ? $field['id'] : $field['ID']), 'post_status' => 'publish'));
                        
                        							if ( ! empty($sub_fields) ){
                        
                        								foreach ($sub_fields as $key => $sub_field){
                        									$sub_fieldData = (!empty($sub_field->post_content)) ? unserialize($sub_field->post_content) : array();			
                        									$sub_fieldData['ID'] = $sub_field->ID;
                        									$sub_fieldData['label'] = $sub_field->post_title;
                        									$sub_fieldData['key'] = $sub_field->post_name;																
                        									?>
                        									<tr class="field sub_field field_type-<?php echo $sub_fieldData['type'];?> field_key-<?php echo $sub_fieldData['key'];?>">
                        										<td class="label">
                        											<?php echo $sub_fieldData['label'];?>
                        										</td>
                        										<td>
                        											<div class="inner">
                        												<?php echo pmai_render_field($sub_fieldData, $post, $field_name . "[" . $field['key'] . "][rows][ROWNUMBER]"); ?>
                        											</div>	
                        										</td>
                        									</tr>													
                        									<?php 
                        								}
                        							}*/
                    } else {
                        if (!empty($field['sub_fields'])) {
                            foreach ($field['sub_fields'] as $key => $sub_field) {
                                ?>
								<tr class="field sub_field field_type-<?php 
                                echo $sub_field['type'];
                                ?>
 field_key-<?php 
                                echo $sub_field['key'];
                                ?>
">
									<td class="label">
										<?php 
                                echo $sub_field['label'];
                                ?>
									</td>
									<td>
										<div class="inner">
											<?php 
                                echo pmai_render_field($sub_field, $post, $field_name . "[" . $field['key'] . "][rows][ROWNUMBER]");
                                ?>
										</div>	
									</td>
								</tr>													
								<?php 
                            }
                        } elseif (!empty($field['sub_field'])) {
                            ?>
								<tr class="field sub_field field_type-<?php 
                            echo $field['sub_field']['type'];
                            ?>
 field_key-<?php 
                            echo $field['sub_field']['key'];
                            ?>
">									
									<td>
										<div class="inner">
											<?php 
                            echo pmai_render_field($field['sub_field'], $post, $field_name);
                            ?>
										</div>	
									</td>
								</tr>													
								<?php 
                        }
                    }
                    break;
                case 'flexible_content':
                    ?>
						<div class="acf-flexible-content">							
							<div class="clones">
							<?php 
                    if ($acf and version_compare($acf->settings['version'], '5.0.0') >= 0) {
                        // vars
                        $sub_fields = acf_get_fields($field);
                        // loop through layouts, sub fields and swap out the field key with the real field
                        foreach (array_keys($field['layouts']) as $i) {
                            // extract layout
                            $layout = acf_extract_var($field['layouts'], $i);
                            // validate layout
                            //$layout = $this->get_valid_layout( $layout );
                            // append sub fields
                            if (!empty($sub_fields)) {
                                foreach (array_keys($sub_fields) as $k) {
                                    // check if 'parent_layout' is empty
                                    if (empty($sub_fields[$k]['parent_layout'])) {
                                        // parent_layout did not save for this field, default it to first layout
                                        $sub_fields[$k]['parent_layout'] = $layout['key'];
                                    }
                                    // append sub field to layout,
                                    if ($sub_fields[$k]['parent_layout'] == $layout['key']) {
                                        $layout['sub_fields'][] = acf_extract_var($sub_fields, $k);
                                    }
                                }
                            }
                            // append back to layouts
                            $field['layouts'][$i] = $layout;
                        }
                    }
                    foreach ($field['layouts'] as $i => $layout) {
                        // vars
                        $order = is_numeric($i) ? $i + 1 : 0;
                        ?>
								<div class="layout" data-layout="<?php 
                        echo $layout['name'];
                        ?>
">
											
									<div style="display:none">
										<input type="hidden" name="fields<?php 
                        echo $field_name;
                        ?>
[<?php 
                        echo $field['key'];
                        ?>
][layouts][ROWNUMBER][acf_fc_layout]" value="<?php 
                        echo $layout['name'];
                        ?>
" />
									</div>									
										
									<div class="acf-fc-layout-handle">
										<span class="fc-layout-order"><?php 
                        echo $order;
                        ?>
</span>. <?php 
                        echo $layout['label'];
                        ?>
									</div>
									
									<table class="widefat acf-input-table <?php 
                        if ($layout['display'] == 'row') {
                            ?>
row_layout<?php 
                        }
                        ?>
">
										<?php 
                        if ($layout['display'] == 'table') {
                            ?>
											<thead>
												<tr>

													<?php 
                            foreach ($layout['sub_fields'] as $sub_field_i => $sub_field) {
                                // add width attr
                                $attr = "";
                                if (count($layout['sub_fields']) > 1 && isset($sub_field['column_width']) && $sub_field['column_width']) {
                                    $attr = 'width="' . $sub_field['column_width'] . '%"';
                                }
                                // required
                                $required_label = "";
                                if ($sub_field['required']) {
                                    $required_label = ' <span class="required">*</span>';
                                }
                                ?>
														<td class="acf-th-<?php 
                                echo $sub_field['name'];
                                ?>
 field_key-<?php 
                                echo $sub_field['key'];
                                ?>
" <?php 
                                echo $attr;
                                ?>
>
															<span><?php 
                                echo $sub_field['label'] . $required_label;
                                ?>
</span>
															<?php 
                                if (isset($sub_field['instructions'])) {
                                    ?>
																<span class="sub-field-instructions"><?php 
                                    echo $sub_field['instructions'];
                                    ?>
</span>
															<?php 
                                }
                                ?>
														</td><?php 
                            }
                            ?>
													
												</tr>
											</thead>
										<?php 
                        }
                        ?>
										<tbody>
											<tr>
											<?php 
                        // layout: Row
                        if ($layout['display'] == 'row') {
                            ?>
												<td class="acf_input-wrap">
													<table class="widefat acf_input">
											<?php 
                        }
                        ?>
																						
											<?php 
                        // loop though sub fields
                        if ($layout['sub_fields']) {
                            foreach ($layout['sub_fields'] as $sub_field) {
                                ?>
												
													<?php 
                                // attributes (can appear on tr or td depending on $field['layout'])
                                $attributes = array('class' => "field sub_field field_type-{$sub_field['type']} field_key-{$sub_field['key']}", 'data-field_type' => $sub_field['type'], 'data-field_key' => $sub_field['key'], 'data-field_name' => $sub_field['name']);
                                // required
                                if ($sub_field['required']) {
                                    $attributes['class'] .= ' required';
                                }
                                // value
                                $sub_field['value'] = false;
                                if (isset($value[$sub_field['key']])) {
                                    // this is a normal value
                                    $sub_field['value'] = $value[$sub_field['key']];
                                } elseif (!empty($sub_field['default_value'])) {
                                    // no value, but this sub field has a default value
                                    $sub_field['value'] = $sub_field['default_value'];
                                }
                                // add name
                                $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
                                // clear ID (needed for sub fields to work!)
                                unset($sub_field['id']);
                                // layout: Row
                                if ($layout['display'] == 'row') {
                                    ?>
														<tr <?php 
                                    pmai_join_attr($attributes);
                                    ?>
>
															<td class="label">
																<label>
																	<?php 
                                    echo $sub_field['label'];
                                    ?>
																	<?php 
                                    if ($sub_field['required']) {
                                        ?>
<span class="required">*</span><?php 
                                    }
                                    ?>
																</label>
																<?php 
                                    if (isset($sub_field['instructions'])) {
                                        ?>
																	<span class="sub-field-instructions"><?php 
                                        echo $sub_field['instructions'];
                                        ?>
</span>
																<?php 
                                    }
                                    ?>
															</td>
													<?php 
                                }
                                ?>
													
													<td <?php 
                                if ($layout['display'] != 'row') {
                                    pmai_join_attr($attributes);
                                }
                                ?>
>
														<div class="inner">
														<?php 
                                // create field
                                echo pmai_render_field($sub_field, $post, $field_name . "[" . $field['key'] . "][layouts][ROWNUMBER]");
                                ?>
														</div>
													</td>
													
													<?php 
                                // layout: Row
                                if ($layout['display'] == 'row') {
                                    ?>
														</tr>
													<?php 
                                }
                                ?>
													
												
												<?php 
                            }
                            ?>
											<?php 
                        }
                        ?>
											<?php 
                        // layout: Row
                        if ($layout['display'] == 'row') {
                            ?>
													</table>
												</td>
											<?php 
                        }
                        ?>
																			
											</tr>
										</tbody>
										
									</table>
									
								</div>
								<?php 
                    }
                    ?>
							</div>
							<div class="values ui-sortable">
								<?php 
                    if (!empty($current_field['layouts'])) {
                        foreach ($current_field['layouts'] as $key => $layout) {
                            if ("ROWNUMBER" == $key) {
                                continue;
                            }
                            ?>
								
								<div class="layout" data-layout="<?php 
                            if (!empty($field['layouts'][$key]['name'])) {
                                echo $field['layouts'][$key]['name'];
                            }
                            ?>
">
									
									<div style="display:none">
										<input type="hidden" name="fields<?php 
                            echo $field_name;
                            ?>
[<?php 
                            echo $field['key'];
                            ?>
][layouts][<?php 
                            echo $key;
                            ?>
][acf_fc_layout]" value="<?php 
                            echo $layout['acf_fc_layout'];
                            ?>
" />
									</div>									
									<?php 
                            $current_layout = false;
                            foreach ($field['layouts'] as $sub_lay) {
                                if ($sub_lay['name'] == $layout['acf_fc_layout']) {
                                    $current_layout = $sub_lay;
                                    break;
                                }
                            }
                            ?>
									<div class="acf-fc-layout-handle">
										<span class="fc-layout-order"><?php 
                            echo $key;
                            ?>
</span>. <?php 
                            echo $current_layout['label'];
                            ?>
									</div>

									<table class="widefat acf-input-table <?php 
                            if ($current_layout['display'] == 'row') {
                                ?>
row_layout<?php 
                            }
                            ?>
">
										<?php 
                            if ($current_layout['display'] == 'table') {
                                ?>
											<thead>
												<tr>
													<?php 
                                foreach ($current_layout['sub_fields'] as $sub_field_i => $sub_field) {
                                    // add width attr
                                    $attr = "";
                                    if (count($field['layouts'][$key - 1]['sub_fields']) > 1 && isset($sub_field['column_width']) && $sub_field['column_width']) {
                                        $attr = 'width="' . $sub_field['column_width'] . '%"';
                                    }
                                    // required
                                    $required_label = "";
                                    if ($sub_field['required']) {
                                        $required_label = ' <span class="required">*</span>';
                                    }
                                    ?>
														<td class="acf-th-<?php 
                                    echo $sub_field['name'];
                                    ?>
 field_key-<?php 
                                    echo $sub_field['key'];
                                    ?>
" <?php 
                                    echo $attr;
                                    ?>
>
															<span><?php 
                                    echo $sub_field['label'] . $required_label;
                                    ?>
</span>
															<?php 
                                    if (isset($sub_field['instructions'])) {
                                        ?>
																<span class="sub-field-instructions"><?php 
                                        echo $sub_field['instructions'];
                                        ?>
</span>
															<?php 
                                    }
                                    ?>
														</td><?php 
                                }
                                ?>
												</tr>
											</thead>
										<?php 
                            }
                            ?>
										<tbody>
											<tr>
											<?php 
                            // layout: Row
                            if ($current_layout['display'] == 'row') {
                                ?>
												<td class="acf_input-wrap">
													<table class="widefat acf_input">
											<?php 
                            }
                            ?>
											
											
											<?php 
                            // loop though sub fields
                            if ($current_layout['sub_fields']) {
                                foreach ($current_layout['sub_fields'] as $sub_field) {
                                    ?>
											
												<?php 
                                    // attributes (can appear on tr or td depending on $field['layout'])
                                    $attributes = array('class' => "field sub_field field_type-{$sub_field['type']} field_key-{$sub_field['key']}", 'data-field_type' => $sub_field['type'], 'data-field_key' => $sub_field['key'], 'data-field_name' => $sub_field['name']);
                                    // required
                                    if ($sub_field['required']) {
                                        $attributes['class'] .= ' required';
                                    }
                                    // value
                                    $sub_field['value'] = false;
                                    if (isset($value[$sub_field['key']])) {
                                        // this is a normal value
                                        $sub_field['value'] = $value[$sub_field['key']];
                                    } elseif (!empty($sub_field['default_value'])) {
                                        // no value, but this sub field has a default value
                                        $sub_field['value'] = $sub_field['default_value'];
                                    }
                                    // add name
                                    $sub_field['name'] = $field['name'] . '[' . $i . '][' . $sub_field['key'] . ']';
                                    // clear ID (needed for sub fields to work!)
                                    unset($sub_field['id']);
                                    // layout: Row
                                    if ($current_layout['display'] == 'row') {
                                        ?>
													<tr <?php 
                                        pmai_join_attr($attributes);
                                        ?>
>
														<td class="label">
															<label>
																<?php 
                                        echo $sub_field['label'];
                                        ?>
																<?php 
                                        if ($sub_field['required']) {
                                            ?>
<span class="required">*</span><?php 
                                        }
                                        ?>
															</label>
															<?php 
                                        if (isset($sub_field['instructions'])) {
                                            ?>
																<span class="sub-field-instructions"><?php 
                                            echo $sub_field['instructions'];
                                            ?>
</span>
															<?php 
                                        }
                                        ?>
														</td>
												<?php 
                                    }
                                    ?>
												
												<td <?php 
                                    if (empty($field['layouts'][$key - 1]['display']) or $field['layouts'][$key - 1]['display'] != 'row') {
                                        pmai_join_attr($attributes);
                                    }
                                    ?>
>
													<div class="inner">
													<?php 
                                    // create field
                                    echo pmai_render_field($sub_field, $post, $field_name . "[" . $field['key'] . "][layouts][" . $key . "]");
                                    ?>
													</div>
												</td>
												
												<?php 
                                    // layout: Row
                                    if (!empty($field['layouts'][$key - 1]['display']) and $field['layouts'][$key - 1]['display'] == 'row') {
                                        ?>
													</tr>
												<?php 
                                    }
                                    ?>
												
											
											<?php 
                                }
                                ?>
											<?php 
                            }
                            ?>
											<?php 
                            // layout: Row
                            if ($current_layout['display'] == 'row') {
                                ?>
													</table>
												</td>
											<?php 
                            }
                            ?>
																			
											</tr>
										</tbody>
										
									</table>
									
								</div>								
								<?php 
                        }
                    }
                    ?>
							</div>
							<div class="add_layout">
								<select>
									<option selected="selected">Select Layout</option>
									<?php 
                    foreach ($field['layouts'] as $key => $layout) {
                        ?>
										<option value="<?php 
                        echo $layout['name'];
                        ?>
"><?php 
                        echo $layout['label'];
                        ?>
</option>
										<?php 
                    }
                    ?>
								</select>
								<a href="javascript:void(0);" class="acf-button delete_layout" style="float:right; margin-top: 10px;"><?php 
                    _e("Delete Layout", "pmxi_plugin");
                    ?>
</a>
							</div>
						</div>
						<?php 
                    break;
                case 'message':
                    break;
                default:
                    ?>
						<p>
							<?php 
                    _e('This field type is not supported. E-mail support@soflyy.com with the details of the custom ACF field you are trying to import to, as well as a link to download the plugin to install to add this field type to ACF, and we will investigate the possiblity ot including support for it in the ACF add-on.', 'pmxi_plugin');
                    ?>
						</p>
						<?php 
                    break;
            }
            ?>
									
			</div>			
		</div>
		<?php 
        }
    }
Ejemplo n.º 2
0
function pmai_wp_ajax_get_acf()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can('manage_options')) {
        exit(json_encode(array('html' => __('Security check', 'wp_all_import_plugin'))));
    }
    global $acf;
    $version = $acf ? $acf->settings['version'] : false;
    ob_start();
    $acf_groups = PMXI_Plugin::$session->acf_groups;
    $acf_obj = false;
    if (!empty($acf_groups)) {
        foreach ($acf_groups as $key => $group) {
            if ($group['ID'] == $_GET['acf']) {
                $acf_obj = $group;
                break;
            }
        }
    }
    $import = new PMXI_Import_Record();
    if (!empty($_GET['id'])) {
        $import->getById($_GET['id']);
    }
    $is_loaded_template = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false;
    if ($is_loaded_template) {
        $default = PMAI_Plugin::get_default_import_options();
        $template = new PMXI_Template_Record();
        if (!$template->getById($is_loaded_template)->isEmpty()) {
            $options = (!empty($template->options) ? $template->options : array()) + $default;
        }
    } else {
        if (!$import->isEmpty()) {
            $options = $import->options;
        } else {
            $options = PMXI_Plugin::$session->options;
        }
    }
    ?>
	<div class="postbox  acf_postbox default acf_signle_group rad4" rel="<?php 
    echo $acf_obj['ID'];
    ?>
">
		<h3 class="hndle" style="margin-top:0;"><span><?php 
    echo $acf_obj['title'];
    ?>
</span></h3>
		<div class="inside">
		<?php 
    if ($version and version_compare($version, '5.0.0') >= 0) {
        if (is_numeric($acf_obj['ID'])) {
            $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $_GET['acf'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
            if (!empty($acf_fields)) {
                foreach ($acf_fields as $field) {
                    $fieldData = !empty($field->post_content) ? unserialize($field->post_content) : array();
                    $fieldData['ID'] = $field->ID;
                    $fieldData['id'] = $field->ID;
                    $fieldData['label'] = $field->post_title;
                    $fieldData['key'] = $field->post_name;
                    if (empty($fieldData['name'])) {
                        $fieldData['name'] = $field->post_excerpt;
                    }
                    echo pmai_render_field($fieldData, !empty($options) ? $options : array());
                }
            }
        } else {
            $fields = acf_local()->fields;
            if (!empty($fields)) {
                foreach ($fields as $key => $field) {
                    if ($field['parent'] == $acf_obj['key']) {
                        $fieldData = $field;
                        $fieldData['id'] = uniqid();
                        $fieldData['label'] = $field['label'];
                        $fieldData['key'] = $field['key'];
                        echo pmai_render_field($fieldData, !empty($options) ? $options : array());
                    }
                }
            }
        }
    } else {
        if (is_numeric($acf_obj['ID'])) {
            $fields = array();
            foreach (get_post_meta($acf_obj['ID'], '') as $cur_meta_key => $cur_meta_val) {
                if (strpos($cur_meta_key, 'field_') !== 0) {
                    continue;
                }
                $fields[] = !empty($cur_meta_val[0]) ? unserialize($cur_meta_val[0]) : array();
            }
            if (count($fields)) {
                $sortArray = array();
                foreach ($fields as $field) {
                    foreach ($field as $key => $value) {
                        if (!isset($sortArray[$key])) {
                            $sortArray[$key] = array();
                        }
                        $sortArray[$key][] = $value;
                    }
                }
                $orderby = "order_no";
                array_multisort($sortArray[$orderby], SORT_ASC, $fields);
                foreach ($fields as $field) {
                    echo pmai_render_field($field, !empty($options) ? $options : array());
                }
            }
        } else {
            global $acf_register_field_group;
            if (!empty($acf_register_field_group)) {
                foreach ($acf_register_field_group as $key => $group) {
                    if ($group['id'] == $acf_obj['ID']) {
                        foreach ($group['fields'] as $field) {
                            echo pmai_render_field($field, !empty($options) ? $options : array());
                        }
                    }
                }
            }
        }
    }
    ?>
								
		</div>
	</div>
	<?php 
    exit(json_encode(array('html' => ob_get_clean())));
    die;
}