function render_field($field) { acf_render_field($field); }
?> " /> </div> <table class="form-table"> <tbody> <tr> <th> <label for="acf-field-acf_pro_licence"><?php _e('License Key', 'acf'); ?> </label> </th> <td> <?php // render field acf_render_field(array('type' => $input, 'name' => 'acf_pro_licence', 'value' => str_repeat('*', strlen($license)), 'readonly' => $readonly)); ?> </td> </tr> <tr> <th></th> <td> <input type="submit" value="<?php echo $button; ?> " class="button button-primary"> </td> </tr> </tbody> </table> </form>
acf_render_field(array('type' => 'select', 'prefix' => $prefix, 'name' => 'field', 'value' => $rule['field'], 'choices' => $choices, 'class' => 'conditional-logic-field', 'disabled' => $disabled)); ?> </td> <td class="operator"> <?php $choices = array('==' => __("is equal to", 'acf'), '!=' => __("is not equal to", 'acf')); // create field acf_render_field(array('type' => 'select', 'prefix' => $prefix, 'name' => 'operator', 'value' => $rule['operator'], 'choices' => $choices, 'class' => 'conditional-logic-operator', 'disabled' => $disabled)); ?> </td> <td class="value"> <?php $choices = array(); $choices[$rule['value']] = $rule['value']; // create field acf_render_field(array('type' => 'select', 'prefix' => $prefix, 'name' => 'value', 'value' => $rule['value'], 'choices' => $choices, 'class' => 'conditional-logic-value', 'disabled' => $disabled)); ?> </td> <td class="add"> <a href="#" class="acf-button location-add-rule"><?php _e("and", 'acf'); ?> </a> </td> <td class="remove"> <a href="#" class="acf-icon location-remove-rule"><i class="acf-sprite-remove"></i></a> </td> </tr> <?php } ?>
function render_field($field) { // Change Field into a select $field['type'] = 'select'; $field['ui'] = 1; $field['ajax'] = 1; $field['choices'] = array(); // populate choices if value exists if (!empty($field['value'])) { // get posts $posts = $this->get_posts($field['value'], $field); // set choices if (!empty($posts)) { foreach (array_keys($posts) as $i) { // vars $post = acf_extract_var($posts, $i); if (is_object($post)) { // append to choices $field['choices'][$post->ID] = $this->get_post_title($post, $field); } else { // append to choices $field['choices'][$post] = $post; } } } } // render acf_render_field($field); }
$rule = wp_parse_args($rule, array('field' => '', 'operator' => '==', 'value' => '')); // $group_id must be completely different to $rule_id to avoid JS issues $rule_id = "rule_{$rule_id}"; ?> <tr data-id="<?php echo $rule_id; ?> "> <td class="param"><?php // create field acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$group_id}][{$rule_id}]", 'name' => 'param', 'value' => $rule['param'], 'choices' => $rule_types, 'class' => 'location-rule-param')); ?> </td> <td class="operator"><?php // create field acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$group_id}][{$rule_id}]", 'name' => 'operator', 'value' => $rule['operator'], 'choices' => $rule_operators, 'class' => 'location-rule-operator')); ?> </td> <td class="value"><?php $this->render_location_value(array('group_id' => $group_id, 'rule_id' => $rule_id, 'value' => $rule['value'], 'param' => $rule['param'], 'class' => 'location-rule-value')); ?> </td> <td class="add"> <a href="#" class="button add-location-rule"><?php _e("and", 'acf'); ?> </a> </td> <td class="remove"> <a href="#" class="acf-icon -minus remove-location-rule"></a> </td>
function render_location_value($options) { // vars $options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null)); // vars $choices = array(); // some case's have the same outcome if ($options['param'] == "page_parent") { $options['param'] = "page"; } switch ($options['param']) { /* * Post */ case "post_type": // get post types $post_types = acf_get_post_types(array('show_ui' => 1, 'exclude' => array('attachment'))); // get choices $choices = acf_get_pretty_post_types($post_types); // end break; case "post": // get post types $post_types = acf_get_post_types(array('exclude' => array('page', 'attachment'))); // get posts grouped by post type $groups = acf_get_grouped_posts(array('post_type' => $post_types)); if (!empty($groups)) { foreach (array_keys($groups) as $group_title) { // vars $posts = acf_extract_var($groups, $group_title); // override post data foreach (array_keys($posts) as $post_id) { // update $posts[$post_id] = acf_get_post_title($posts[$post_id]); } // append to $choices $choices[$group_title] = $posts; } } break; case "post_template": // vars $templates = wp_get_theme()->get_post_templates(); $default = apply_filters('default_page_template_title', __('Default Template', 'acf')); // choices $choices = array('default' => $default); // templates if (!empty($templates)) { foreach ($templates as $post_type => $post_type_templates) { $choices = array_merge($choices, $post_type_templates); } } // break break; case "post_category": $terms = acf_get_taxonomy_terms('category'); if (!empty($terms)) { $choices = array_pop($terms); } break; case "post_format": $choices = get_post_format_strings(); break; case "post_status": global $wp_post_statuses; if (!empty($wp_post_statuses)) { foreach ($wp_post_statuses as $status) { $choices[$status->name] = $status->label; } } break; case "post_taxonomy": $choices = acf_get_taxonomy_terms(); // unset post_format if (isset($choices['post_format'])) { unset($choices['post_format']); } break; /* * Page */ /* * Page */ case "page": // get posts grouped by post type $groups = acf_get_grouped_posts(array('post_type' => 'page')); if (!empty($groups)) { foreach (array_keys($groups) as $group_title) { // vars $posts = acf_extract_var($groups, $group_title); // override post data foreach (array_keys($posts) as $post_id) { // update $posts[$post_id] = acf_get_post_title($posts[$post_id]); } // append to $choices $choices = $posts; } } break; case "page_type": $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (no parent)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf')); break; case "page_parent": // refer to "page" break; case "page_template": // vars $templates = wp_get_theme()->get_page_templates(); $default = apply_filters('default_page_template_title', __('Default Template', 'acf')); // merge $choices = array_merge(array('default' => $default), $templates); break; /* * User */ /* * User */ case "current_user": // viewing $choices = array('logged_in' => __('Logged in', 'acf'), 'viewing_front' => __('Viewing front end', 'acf'), 'viewing_back' => __('Viewing back end', 'acf')); break; case "current_user_role": // global global $wp_roles; // specific roles $choices = $wp_roles->get_names(); // multi-site if (is_multisite()) { $choices = array_merge(array('super_admin' => __('Super Admin', 'acf')), $choices); } break; case "user_role": global $wp_roles; $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names()); break; case "user_form": $choices = array('all' => __('All', 'acf'), 'edit' => __('Add / Edit', 'acf'), 'register' => __('Register', 'acf')); break; /* * Forms */ /* * Forms */ case "attachment": $choices = array('all' => __('All', 'acf')); break; case "taxonomy": $choices = array_merge(array('all' => __('All', 'acf')), acf_get_taxonomies()); // unset post_format if (isset($choices['post_format'])) { unset($choices['post_format']); } break; case "comment": // vars $choices = array('all' => __('All', 'acf')); // append post types $choices = array_merge($choices, acf_get_pretty_post_types()); // end break; case "widget": global $wp_widget_factory; $choices = array('all' => __('All', 'acf')); if (!empty($wp_widget_factory->widgets)) { foreach ($wp_widget_factory->widgets as $widget) { $choices[$widget->id_base] = $widget->name; } } break; } // allow custom location rules $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices); // create field acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]", 'name' => 'value', 'value' => $options['value'], 'choices' => $choices)); }
</td> <td class="acf-input"> <ul class="acf-hl"> <li style="width:33%; padding-right:15px;"> <?php acf_render_field(array('type' => 'text', 'name' => 'width', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['width'], 'prepend' => 'width', 'append' => '%')); ?> </li> <li style="width:33%; padding-right:15px;"> <?php acf_render_field(array('type' => 'text', 'name' => 'class', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['class'], 'prepend' => 'class')); ?> </li> <li style="float:none;"> <?php acf_render_field(array('type' => 'text', 'name' => 'id', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['id'], 'prepend' => 'id')); ?> </li> </ul> </td> </tr> <tr class="field_save"> <td class="acf-label"></td> <td class="acf-input"> <ul class="acf-hl acf-clearfix"> <li> <a class="edit-field acf-button grey" title="<?php _e("Close Field", 'acf'); ?> " href="#"><?php _e("Close Field", 'acf');
function acf_render_field_wrap($field, $el = 'div', $instruction = 'label') { // get valid field $field = acf_get_valid_field($field); // prepare field for input $field = acf_prepare_field($field); // el $elements = apply_filters('acf/render_field_wrap/elements', array('div' => 'div', 'tr' => 'td', 'ul' => 'li', 'ol' => 'li', 'dl' => 'dt', 'td' => 'div')); // validate $el if (!array_key_exists($el, $elements)) { $el = 'div'; } // wrapper $wrapper = array('id' => '', 'class' => 'acf-field', 'width' => '', 'style' => '', 'data-name' => $field['name'], 'data-type' => $field['type'], 'data-key' => ''); // add required if ($field['required']) { $wrapper['data-required'] = 1; } // add type $wrapper['class'] .= " acf-field-{$field['type']}"; // add key if ($field['key']) { $wrapper['class'] .= " acf-field-{$field['key']}"; $wrapper['data-key'] = $field['key']; } // replace $wrapper['class'] = str_replace('_', '-', $wrapper['class']); $wrapper['class'] = str_replace('field-field-', 'field-', $wrapper['class']); // wrap classes have changed (5.2.7) if (acf_get_compatibility('field_wrapper_class')) { $wrapper['class'] .= " field_type-{$field['type']}"; if ($field['key']) { $wrapper['class'] .= " field_key-{$field['key']}"; } } // merge in atts $wrapper = acf_merge_atts($wrapper, $field['wrapper']); // add width $width = (int) acf_extract_var($wrapper, 'width'); if ($el == 'tr' || $el == 'td') { $width = 0; } elseif ($width > 0 && $width < 100) { $wrapper['data-width'] = $width; $wrapper['style'] .= " width:{$width}%;"; } // remove empty attributes foreach ($wrapper as $k => $v) { if ($v == '') { unset($wrapper[$k]); } } // vars $show_label = $el !== 'td' ? true : false; ?> <<?php echo $el; ?> <?php echo acf_esc_attr($wrapper); ?> > <?php if ($show_label) { ?> <<?php echo $elements[$el]; ?> class="acf-label"> <label for="<?php echo $field['id']; ?> "><?php echo acf_get_field_label($field); ?> </label> <?php if ($instruction == 'label' && $field['instructions']) { ?> <p class="description"><?php echo $field['instructions']; ?> </p> <?php } ?> </<?php echo $elements[$el]; ?> > <?php } ?> <<?php echo $elements[$el]; ?> class="acf-input"> <?php acf_render_field($field); if ($instruction == 'field' && $field['instructions']) { ?> <p class="description"><?php echo $field['instructions']; ?> </p> <?php } ?> </<?php echo $elements[$el]; ?> > <?php if (!empty($field['conditional_logic'])) { ?> <script type="text/javascript"> if(typeof acf !== 'undefined'){ acf.conditional_logic.add( '<?php echo $field['key']; ?> ', <?php echo json_encode($field['conditional_logic']); ?> ); } </script> <?php } ?> </<?php echo $el; ?> > <?php }
function acf_render_field_wrap($field, $el = 'div', $instruction = 'label', $atts = array()) { // get valid field $field = acf_get_valid_field($field); // prepare field for input $field = acf_prepare_field($field); // el $elements = apply_filters('acf/render_field_wrap/elements', array('div' => 'div', 'tr' => 'td', 'ul' => 'li', 'ol' => 'li', 'dl' => 'dt', 'td' => 'div')); // validate $el if (!array_key_exists($el, $elements)) { $el = 'div'; } // atts $atts = acf_parse_args($atts, array('class' => '', 'data-name' => $field['name'], 'data-type' => $field['type'])); // add to atts $atts['class'] .= " acf-field field_type-{$field['type']}"; // add key if ($field['key']) { $atts['class'] .= " field_key-{$field['key']}"; $atts['data-key'] = $field['key']; } // add required if ($field['required']) { $atts['data-required'] = 1; } // vars $show_label = true; if ($el == 'td') { $show_label = false; } ?> <<?php echo $el; ?> <?php echo acf_esc_attr($atts); ?> > <?php if ($show_label) { ?> <<?php echo $elements[$el]; ?> class="acf-label"> <label for="<?php echo $field['id']; ?> "><?php echo acf_get_field_label($field); ?> </label> <?php if ($instruction == 'label' && $field['instructions']) { ?> <p class="description"><?php echo $field['instructions']; ?> </p> <?php } ?> </<?php echo $elements[$el]; ?> > <?php } ?> <<?php echo $elements[$el]; ?> class="acf-input"> <?php acf_render_field($field); ?> <?php if ($instruction == 'field' && $field['instructions']) { ?> <p class="description"><?php echo $field['instructions']; ?> </p> <?php } ?> <?php if (!empty($field['conditional_logic'])) { ?> <script type="text/javascript"> (function($) { if( typeof acf !== 'undefined' ) { acf.conditional_logic.add( '<?php echo $field['key']; ?> ', <?php echo json_encode($field['conditional_logic']); ?> ); } })(jQuery); </script> <?php } ?> </<?php echo $elements[$el]; ?> > </<?php echo $el; ?> ><?php }
static function html($args) { //print_r($_POST); if (isset($_POST) && !empty($_POST)) { return; } if (!function_exists('acf_get_field_groups')) { echo 'You need ACF activated to use this screen'; exit; } /* Todo intercept and update the special key here */ //print_r($json); exit; ?> <div class="wrap acf-settings-wrap"> <h2><?php _e('Import / Export', 'acf'); ?> </h2> <div class="acf-box"> <div class="title"> <h3><?php _e('Generate Your Template Output', 'inboundnow'); ?> </h3> </div> <div class="inner"> <script type="text/javascript"> function replaceUrlParam(url, paramName, paramValue){ var pattern = new RegExp('('+paramName+'=).*?(&|$)') var newUrl=url if(url.search(pattern)>=0){ newUrl = url.replace(pattern,'$1' + paramValue + '$2'); } else{ newUrl = newUrl + (newUrl.indexOf('?')>0 ? '&' : '?') + paramName + '=' + paramValue } return newUrl } jQuery(document).ready(function($) { // put all your jQuery goodness in here. jQuery("#generate_template").on('change', function () { var val = jQuery(this).val(); var newUrl = replaceUrlParam(window.location.href, 'generate-template-id', val); window.location.href = newUrl; }); }); </script> <div id="options-available"> <?php $choices = array('none' => "Choose template"); $field_groups_ids = acf_get_field_groups(); // populate choices if (!empty($field_groups_ids)) { foreach ($field_groups_ids as $field_group) { //print_r($field_group); $choices[$field_group['key']] = $field_group['title']; } } echo "<label>Select the ACF options you wish to generate markup for</label>"; // render field $acf_id = isset($_GET['generate-template-id']) ? $_GET['generate-template-id'] : false; $template_name = isset($_GET['template-name']) ? $_GET['template-name'] : ''; acf_render_field(array('type' => 'select', 'name' => 'generate_template', 'prefix' => false, 'value' => $acf_id, 'toggle' => true, 'choices' => $choices)); acf_render_field(array('type' => 'text', 'name' => 'template_name', 'prefix' => false, 'value' => $template_name, 'placeholder' => "Template Name")); ?> </div> <p>This page is for helping developing templating super simple.</p> <p>This is generated output from your landing page options to copy/paste into your index.php</p> <?php /** * Generate the template here */ /* get the data */ $json = self::get_json(); //print_r($json); // validate if ($json === false || empty($json)) { acf_add_admin_notice(__("No field groups selected", 'acf'), 'error'); exit; } // vars $field_groups = $json; ?> <textarea style="width:100%; height:500px;" class="pre" readonly="true"> <?php echo "<?php\n/**\n* Template Name: __TEMPLATE_NAME__\n* @package WordPress Landing Pages\n* @author Inbound Template Generator\n*/\n\n/* Declare Template Key */\n\$key = basename(dirname(__FILE__));\n\n/* discover the absolute path of where this template is located. Core templates are loacted in /wp-content/plugins/landing-pages/templates/ while custom templates belong in /wp-content/uploads/landing-pages/tempaltes/ */\n\$path = (preg_match(\"/uploads/\", dirname(__FILE__))) ? LANDINGPAGES_UPLOADS_PATH . \$key .'/' : LANDINGPAGES_PATH.'templates/'.\$key.'/';\n\n\$urlpath = (preg_match(\"/uploads/\", dirname(__FILE__))) ? LANDINGPAGES_UPLOADS_URLPATH . \$key .'/' : LANDINGPAGES_URLPATH.'templates/'.\$key.'/';\n\n/* Include ACF Field Definitions */\ninclude_once(\$path .'config.php');\n\n/* Define Landing Pages's custom pre-load hook for 3rd party plugin integration */\ndo_action('wp_head');\n\$post_id = get_the_ID(); "; ?> ?> <?php echo '<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <!-- Define page title --> <title><?php wp_title(); ?></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- include your assets --> <!-- <link rel="stylesheet" href="<?php echo $urlpath; ?>css/css_file_name.css"> --> <!-- <script src="<?php echo $urlpath; ?>js/js_file_name.js"></script> --> <!-- Load Normal WordPress wp_head() function --> <?php wp_head(); ?> <!-- Load Landing Pages\'s custom pre-load hook for 3rd party plugin integration --> <?php do_action("lp_head"); ?> </head>' . "\r\n\r\n" . '<body>' . "\r\n\r\n"; //print_r($field_groups); exit; if (isset($field_groups)) { echo "<?php " . "\r\n\r\n"; foreach ($field_groups as $field_group) { foreach ($field_group['fields'] as $field) { if ($field['type'] === "repeater") { $repeater = self::inbound_repeater_output($field); echo $repeater; } else { if ($field['type'] === "flexible_content") { echo "/* Start " . $field['name'] . " Flexible Content Area Output */" . "\r\n"; echo "\tif(function_exists('have_rows')) :" . "\r\n"; echo "\t\tif(have_rows('" . $field['name'] . "')) :" . "\r\n"; echo "\t\t\t while(have_rows('" . $field['name'] . "')) : the_row();" . "\r\n"; echo "\t\t\t\t switch(get_sub_field('acf_fc_layout')) :" . "\r\n"; foreach ($field['layouts'] as $layout) { //print_r($layout); echo "\t\t\t\t/* start layout " . $layout['name'] . " */" . "\r\n"; echo "\t\t\t\t case '" . $layout['name'] . "' : " . "\r\n"; foreach ($layout['sub_fields'] as $layout_subfield) { if ($layout_subfield['type'] === 'repeater') { $test = self::inbound_repeater_output($layout_subfield, 4, false); echo $test; } else { echo "\t\t\t\t\t\$" . $layout_subfield['name'] . " = " . "get_sub_field(\"" . $layout_subfield['name'] . "\");" . "\r\n"; } } echo "\t\t\t?>" . "\r\n\r\n"; echo "\t\t\t<!-- your markup here -->" . "\r\n\r\n"; echo "\t\t\t<?php break;" . "\r\n"; //echo "\t\t\t\t/* end layout ".$layout['name']." */"."\r\n"; } echo "\t\t\t\tendswitch; /* end switch statement */ " . "\r\n"; echo "\t\t\tendwhile; /* end while statement */" . "\r\n"; echo "\t\t endif; /* end have_rows */" . "\r\n"; echo "\tendif; /* end function_exists */" . "\r\n"; echo "/* End " . $field['name'] . " Flexible Content Area Output */" . "\r\n\r\n"; } else { if ($field['name']) { echo "\t\$" . $field['name'] . " = " . "get_field(\"" . $field['name'] . "\", \$post_id);" . "\r\n"; } } } } } echo "?>" . "\r\n\r\n"; /* break; endwhile; endif; */ echo "<?php " . "\r\n"; echo "do_action('lp_footer');" . "\r\n"; echo "do_action('wp_footer');" . "\r\n"; echo "?>" . "\r\n"; echo "</body>" . "\r\n"; echo "</html>" . "\r\n"; } ?> </textarea> <p>This is the config.php file</p> <?php /* TODO: add config begging output */ ?> <textarea class="pre" readonly="true"><?php echo "if( function_exists('acf_add_local_field_group') ):" . "\r\n" . "\r\n"; foreach ($field_groups as $field_group) { // code $code = var_export($field_group, true); // change double spaces to tabs $code = str_replace(" ", "\t", $code); // correctly formats "=> array(" $code = preg_replace('/([\\t\\r\\n]+?)array/', 'array', $code); // Remove number keys from array $code = preg_replace('/[0-9]+ => array/', 'array', $code); // echo echo "acf_add_local_field_group({$code});" . "\r\n" . "\r\n"; } echo "endif;"; ?> </textarea> </div> </div> </div> <div class="acf-hidden"> <style type="text/css"> textarea.pre { width: 100%; padding: 15px; font-size: 14px; line-height: 1.5em; resize: none; } </style> <script type="text/javascript"> (function($){ var i = 0; $(document).on('click', 'textarea.pre', function(){ if( i == 0 ) { i++; $(this).focus().select(); return false; } }); $(document).on('keyup', 'textarea.pre', function(){ $(this).height( 0 ); $(this).height( this.scrollHeight ); }); $(document).ready(function(){ $('textarea.pre').trigger('keyup'); }); })(jQuery); </script> </div> <?php }
?> </label> </th> <td> <?php // vars $choices = array(); $field_groups = acf_get_field_groups(); // populate choices if (!empty($field_groups)) { foreach ($field_groups as $field_group) { $choices[$field_group['key']] = $field_group['title']; } } // render field acf_render_field(array('type' => 'checkbox', 'name' => 'acf_export_keys', 'prefix' => false, 'value' => false, 'toggle' => true, 'choices' => $choices)); ?> </td> </tr> <tr> <th></th> <td> <input type="submit" name="download" class="acf-button blue" value="<?php _e('Download export file', 'acf'); ?> " /> <input type="submit" name="generate" class="acf-button blue" value="<?php _e('Generate export code', 'acf'); ?> " /> </td>
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 } }
function render_field($field) { /* * Review the data of $field. * This will show what data is available */ // Change Field into a select $field['type'] = 'select'; $field['ui'] = 0; $field['ajax'] = 0; $field['choices'] = array(); $args = array('posts_per_page' => -1, 'post_type' => 'page', 'orderby' => 'title', 'order' => 'ASC', 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'sort_column' => 'menu_order, post_title', 'sort_order' => 'ASC', 'suppress_filters' => false, 'meta_key' => '_wp_page_template', 'meta_value' => ''); $template_name_by_file = array(); $page_templates = get_page_templates(); foreach ($page_templates as $template_name => $template_file) { $template_name_by_file[$template_file] = $template_name; } foreach ($field['page_template'] as $page_template) { $template_name = $template_name_by_file[$page_template]; // get pages $args['meta_value'] = $page_template; $pages = get_posts($args); if ($pages) { foreach ($pages as $post) { // find page title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory $title = ''; $ancestors = get_ancestors($post->ID, $post->post_type); if ($ancestors) { foreach ($ancestors as $a) { $title .= '–'; } } $title .= ' ' . apply_filters('the_title', $post->post_title, $post->ID); // status if ($post->post_status != 'publish') { $title .= " ({$post->post_status})"; } // WPML if (defined('ICL_LANGUAGE_CODE')) { $title .= ' (' . ICL_LANGUAGE_CODE . ')'; } // add to choices $field['choices'][$template_name][$post->ID] = $title; } } } // render acf_render_field($field); }
function render_field($field) { // Change Field into a select $field['type'] = 'select'; $field['ui'] = 1; $field['ajax'] = 1; $field['choices'] = array(); // populate choices if (!empty($field['value'])) { // force value to array $field['value'] = acf_get_array($field['value']); // convert values to int $field['value'] = array_map('intval', $field['value']); $users = get_users(array('include' => $field['value'])); if (!empty($users)) { foreach ($users as $user) { $field['choices'][$user->ID] = $this->get_result($user, $field); } } } // render acf_render_field($field); }
function render_field_select($field) { // Change Field into a select $field['type'] = 'select'; $field['ui'] = 1; $field['ajax'] = 1; $field['choices'] = array(); // value if (!empty($field['value'])) { // get terms } var_dump($field); // render select acf_render_field($field); }
function render_field_settings($field) { // load default layout if (empty($field['layouts'])) { $field['layouts'] = array(); $field['layouts'][] = $this->get_valid_layout(); } // loop through layouts foreach ($field['layouts'] as $layout) { // get valid layout $layout = $this->get_valid_layout($layout); // vars $layout_prefix = "{$field['prefix']}[layouts][{$layout['key']}]"; ?> <tr class="acf-field" data-name="fc_layout" data-setting="flexible_content" data-id="<?php echo $layout['key']; ?> "> <td class="acf-label"> <label><?php _e("Layout", 'acf'); ?> </label> <p class="description acf-fl-actions"> <a data-name="acf-fc-reorder" title="<?php _e("Reorder Layout", 'acf'); ?> " ><?php _e("Reorder", 'acf'); ?> </a> <a data-name="acf-fc-delete" title="<?php _e("Delete Layout", 'acf'); ?> " href="#"><?php _e("Delete", 'acf'); ?> </a> <a data-name="acf-fc-duplicate" title="<?php _e("Duplicate Layout", 'acf'); ?> " href="#"><?php _e("Duplicate", 'acf'); ?> </a> <a data-name="acf-fc-add" title="<?php _e("Add New Layout", 'acf'); ?> " href="#"><?php _e("Add New", 'acf'); ?> </a> </p> </td> <td class="acf-input"> <ul class="acf-fc-meta acf-bl"> <li class="acf-fc-meta-key"> <?php acf_hidden_input(array('name' => "{$layout_prefix}[key]", 'data-name' => 'layout-key', 'value' => $layout['key'])); ?> </li> <li class="acf-fc-meta-label"> <?php acf_render_field(array('type' => 'text', 'name' => 'label', 'prefix' => $layout_prefix, 'value' => $layout['label'], 'prepend' => __('Label', 'acf'))); ?> </li> <li class="acf-fc-meta-name"> <?php acf_render_field(array('type' => 'text', 'name' => 'name', 'prefix' => $layout_prefix, 'value' => $layout['name'], 'prepend' => __('Name', 'acf'))); ?> </li> <li class="acf-fc-meta-display"> <div class="acf-input-prepend"><?php _e('Layout', 'acf'); ?> </div> <div class="acf-input-wrap select"> <?php acf_render_field(array('type' => 'select', 'name' => 'display', 'prefix' => $layout_prefix, 'value' => $layout['display'], 'choices' => array('table' => __('Table', 'acf'), 'block' => __('Block', 'acf'), 'row' => __('Row', 'acf')))); ?> </div> </li> <li class="acf-fc-meta-min"> <?php acf_render_field(array('type' => 'text', 'name' => 'min', 'prefix' => $layout_prefix, 'value' => $layout['min'], 'prepend' => __('Min', 'acf'))); ?> </li> <li class="acf-fc-meta-max"> <?php acf_render_field(array('type' => 'text', 'name' => 'max', 'prefix' => $layout_prefix, 'value' => $layout['max'], 'prepend' => __('Max', 'acf'))); ?> </li> </ul> <?php // vars $args = array('fields' => $layout['sub_fields'], 'layout' => $layout['display'], 'parent' => $field['ID']); acf_get_view('field-group-fields', $args); ?> </td> </tr> <?php } // endforeach // min acf_render_field_setting($field, array('label' => __('Button Label', 'acf'), 'instructions' => '', 'type' => 'text', 'name' => 'button_label')); // min acf_render_field_setting($field, array('label' => __('Minimum Layouts', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'min')); // max acf_render_field_setting($field, array('label' => __('Maximum Layouts', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'max')); }
function render_field_settings($field) { //return; // defaults? $field = $this->setup_field($field); // key is needed in the field names to correctly save the data $key = $field['key']; $html_key = 'acf_fields-' . $field['ID']; $sub_field = $this->setup_sub_field($field); $sub_field['prefix'] = "{$field['prefix']}[sub_field]"; // remove types that don't jive well with this one $fields_names = apply_filters('acf/get_field_types', array()); unset($fields_names[__('Layout', 'acf')]); unset($fields_names[__('Basic', 'acf')]['validated_field']); $field_id = str_replace("-temp", "", $field['id']); $field_key = $field['key']; // layout acf_render_field_setting($field, array('label' => __('Read Only?', 'acf_vf'), 'instructions' => __('When a field is marked read only, it will be visible but uneditable. Read only fields are marked with ', 'acf_vf') . '<i class="fa fa-ban" style="color:red;" title="' . __('Read only', 'acf_vf') . '"></i>.', 'type' => 'radio', 'name' => 'read_only', 'layout' => 'horizontal', 'prefix' => $field['prefix'], 'choices' => array(false => __('No', 'acf_vf'), true => __('Yes', 'acf_vf')))); // Validate Drafts acf_render_field_setting($field, array('label' => __('Validate Drafts/Preview?', 'acf_vf'), 'instructions' => '', 'type' => 'radio', 'name' => 'drafts', 'prefix' => $field['prefix'], 'choices' => array(true => __('Yes', 'acf_vf'), false => __('No', 'acf_vf')), 'layout' => 'horizontal')); if (false && !$this->drafts) { echo '<em>'; _e('Warning', 'acf_vf'); echo ': <code>ACF_VF_DRAFTS</code> '; _e('has been set to <code>false</code> which overrides field level configurations', 'acf_vf'); echo '.</em>'; } ?> <tr class="acf-field acf-sub_field" data-setting="validated_field" data-name="sub_field"> <td class="acf-label"> <label><?php _e('Validated Field', 'acf_vf'); ?> </label> <p class="description"></p> </td> <td class="acf-input"> <?php $atts = array('id' => 'acfcloneindex', 'class' => "field field_type-{$sub_field['type']}", 'data-id' => $sub_field['id'], 'data-key' => $sub_field['key'], 'data-type' => $sub_field['type']); $metas = array('id' => $sub_field['id'], 'key' => $sub_field['key'], 'parent' => $sub_field['parent'], 'save' => ''); ?> <div <?php echo acf_esc_attr($atts); ?> > <div class="field-meta acf-hidden"> <?php // meta foreach ($metas as $k => $v) { acf_hidden_input(array('class' => "input-{$k}", 'name' => "{$sub_field['prefix']}[{$k}]", 'value' => $v)); } ?> </div> <div class="sub-field-settings"> <table class="acf-table"> <tbody> <?php if (!isset($sub_field['function']) || empty($sub_field['function'])) { $sub_field['function'] = 'none'; } // Validated Field Type acf_render_field_setting($sub_field, array('label' => __('Field Type', 'acf_vf'), 'instructions' => __('The underlying field type that you would like to validate.', 'acf_vf'), 'type' => 'select', 'name' => 'type', 'prefix' => $sub_field['prefix'], 'choices' => $fields_names, 'required' => true), 'tr'); // Render the Sub Field do_action("acf/render_field_settings/type={$sub_field['type']}", $sub_field); ?> <tr class="field_save acf-field" data-name="conditional_logic" style="display:none;"> <td class="acf-label"></td> <td class="acf-input"></td> </tr> </tbody> </table> </div> </div> </td> </tr> <?php if (!empty($field['mask']) && $sub_field['type'] == 'number') { } $mask_error = !empty($field['mask']) && $sub_field['type'] == 'number' ? 'color:red;' : ''; // Input Mask acf_render_field_setting($field, array('label' => __('Input mask', 'acf_vf'), 'instructions' => __('Use 'a' to match A-Za-z, '9' to match 0-9, and '*' to match any alphanumeric.', 'acf_vf') . ' <a href="http://digitalbush.com/projects/masked-input-plugin/" target="_new">' . __('More info', 'acf_vf') . '</a>.<br/><br/><strong style="' . $mask_error . '"><em>' . __('Input masking is not compatible with the "number" field type!', 'acf_vf') . '</em></strong>', 'type' => 'text', 'name' => 'mask', 'prefix' => $field['prefix'], 'value' => $field['mask'], 'layout' => 'horizontal', 'class' => 'input-mask')); // Input Mask acf_render_field_setting($field, array('label' => __('Input Mask: Autoclear', 'acf_vf'), 'instructions' => __('Clear values that do match the input mask, if provided.', 'acf_vf'), 'type' => 'radio', 'name' => 'mask_autoclear', 'prefix' => $field['prefix'], 'value' => $field['mask_autoclear'], 'layout' => 'horizontal', 'choices' => array(true => __('Yes', 'acf_vf'), false => __('No', 'acf_vf')), 'class' => 'mask-settings')); // Input Mask acf_render_field_setting($field, array('label' => __('Input Mask: Placeholder', 'acf_vf'), 'instructions' => __('Use this string or character as a placeholder for the input mask.', 'acf_vf'), 'type' => 'text', 'name' => 'mask_placeholder', 'prefix' => $field['prefix'], 'value' => $field['mask_placeholder'], 'class' => 'mask-settings')); // Validation Function acf_render_field_setting($field, array('label' => __('Validation: Function', 'acf_vf'), 'instructions' => __('How should the field be server side validated?', 'acf_vf'), 'type' => 'select', 'name' => 'function', 'prefix' => $field['prefix'], 'value' => $field['function'], 'choices' => array('none' => __('None', 'acf_vf'), 'regex' => __('Regular Expression', 'acf_vf'), 'php' => __('PHP Statement', 'acf_vf')), 'layout' => 'horizontal', 'optgroup' => true, 'multiple' => '0', 'class' => 'validated_select validation-function')); ?> <tr class="acf-field validation-settings" data-setting="validated_field" data-name="pattern" id="field_option_<?php echo $html_key; ?> _validation"> <td class="acf-label"> <label><?php _e('Validation: Pattern', 'acf_vf'); ?> </label> <p class="description"> <small> <div class="validation-info"> <div class='validation-type regex'> <?php _e('Pattern match the input using', 'acf_vf'); ?> <a href="http://php.net/manual/en/function.preg-match.php" target="_new">PHP preg_match()</a>. <br /> </div> <div class='validation-type php'> <ul> <li><?php _e('Use any PHP code and return true for success or false for failure. If nothing is returned it will evaluate to true.', 'acf_vf'); ?> </li> <li><?php _e('Available variables', 'acf_vf'); ?> : <ul> <li><code>$post_id = $post->ID</code></li> <li><code>$post_type = $post->post_type</code></li> <li><code>$name = meta_key</code></li> <li><code>$value = form value</code></li> <li><code>$prev_value = db value</code></li> <li><code>$inputs = array(<blockquote>'field'=>?,<br/>'value'=>?,<br/>'prev_value'=>?<br/></blockquote>)</code></li> <li><code>&$message = error message</code></li> </ul> </li> <li><?php _e('Example', 'acf_vf'); ?> : <small><code><pre>if ( $value == "123" ){ return '123 is not valid!'; }</pre></code></small></li> </ul> </div> <div class='validation-type sql'> <?php _e('SQL', 'acf_vf'); ?> . <br /> </div> </div> </small> </p> </td> <td class="acf-input"> <?php // Pattern acf_render_field(array('label' => __('Pattern', 'acf_vf'), 'instructions' => '', 'type' => 'textarea', 'name' => 'pattern', 'prefix' => $field['prefix'], 'value' => $field['pattern'], 'layout' => 'horizontal', 'class' => 'editor')); ?> <div id="<?php echo $field_id; ?> -editor" class='ace-editor' style="height:200px;"><?php echo $field['pattern']; ?> </div> </td> </tr> <?php // Error Message acf_render_field_setting($field, array('label' => __('Validation: Error Message', 'acf_vf'), 'instructions' => __('The default error message that is returned to the client.', 'acf_vf'), 'type' => 'text', 'name' => 'message', 'prefix' => $field['prefix'], 'value' => $field['message'], 'layout' => 'horizontal', 'class' => 'validation-settings')); // Validation Function acf_render_field_setting($field, array('label' => __('Unique Value?', 'acf_vf'), 'instructions' => __("Make sure this value is unique for...", 'acf_vf'), 'type' => 'select', 'name' => 'unique', 'prefix' => $field['prefix'], 'value' => $field['unique'], 'choices' => array('non-unique' => __('Non-Unique Value', 'acf_vf'), 'global' => __('Unique Globally', 'acf_vf'), 'post_type' => __('Unique For Post Type', 'acf_vf'), 'post_key' => __('Unique For Post Type', 'acf_vf') . ' + ' . __('Field/Meta Key', 'acf_vf'), 'this_post' => __('Unique For Post', 'acf_vf'), 'this_post_key' => __('Unique For Post', 'acf_vf') . ' + ' . __('Field/Meta Key', 'acf_vf')), 'layout' => 'horizontal', 'optgroup' => false, 'multiple' => '0', 'class' => 'validated_select validation-unique')); // Unique Status $statuses = $this->get_post_statuses(); $choices = array(); foreach ($statuses as $value => $status) { $choices[$value] = $status->label; } acf_render_field_setting($field, array('label' => __('Unique Value: Apply to...?', 'acf_vf'), 'instructions' => __("Make sure this value is unique for the checked post statuses.", 'acf_vf'), 'type' => 'checkbox', 'name' => 'unique_statuses', 'prefix' => $field['prefix'], 'value' => $field['unique_statuses'], 'choices' => $choices)); }
function render_field_select($field) { // Change Field into a select $field['type'] = 'select'; $field['ui'] = 1; $field['ajax'] = 1; $field['choices'] = array(); // value if (!empty($field['value'])) { // get terms $terms = $this->get_terms($field['value'], $field['taxonomy']); // set choices if (!empty($terms)) { foreach (array_keys($terms) as $i) { // vars $term = acf_extract_var($terms, $i); // append to choices $field['choices'][$term->term_id] = $this->get_term_title($term, $field); } } } // render select acf_render_field($field); }
function render_field($field) { // Change Field into a select $field['type'] = 'select'; $field['ui'] = 1; $field['ajax'] = 1; $field['choices'] = array(); // load posts $posts = $this->get_posts($field['value'], $field); if ($posts) { foreach (array_keys($posts) as $i) { // vars $post = acf_extract_var($posts, $i); // append to choices $field['choices'][$post->ID] = $this->get_post_title($post, $field); } } // render acf_render_field($field); }
function render_location_value($options) { // vars $options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null)); // vars $choices = array(); // some case's have the same outcome if ($options['param'] == "page_parent") { $options['param'] = "page"; } switch ($options['param']) { /* * Basic */ case "post_type": // all post types except attachment $exclude = array('attachment'); $choices = acf_get_post_types($exclude); $choices = acf_get_pretty_post_types($choices); break; case "user_type": global $wp_roles; $choices = $wp_roles->get_names(); if (is_multisite()) { $choices['super_admin'] = __('Super Admin'); } break; /* * Post */ /* * Post */ case "post": // get post types $exclude = array('page', 'attachment'); $post_types = acf_get_post_types($exclude); // get posts grouped by post type $groups = acf_get_posts(array('post_type' => $post_types)); if (!empty($groups)) { foreach (array_keys($groups) as $group_title) { // vars $posts = acf_extract_var($groups, $group_title); // override post data foreach (array_keys($posts) as $post_id) { // update $posts[$post_id] = acf_get_post_title($posts[$post_id]); } // append to $choices $choices[$group_title] = $posts; } } break; case "post_category": $terms = acf_get_taxonomy_terms('category'); if (!empty($terms)) { $choices = array_pop($terms); } break; case "post_format": $choices = get_post_format_strings(); break; case "post_status": $choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf')); break; case "post_taxonomy": $choices = acf_get_taxonomy_terms(); // unset post_format if (isset($choices['post_format'])) { unset($choices['post_format']); } break; /* * Page */ /* * Page */ case "page": // get posts grouped by post type $groups = acf_get_posts(array('post_type' => 'page')); if (!empty($groups)) { foreach (array_keys($groups) as $group_title) { // vars $posts = acf_extract_var($groups, $group_title); // override post data foreach (array_keys($posts) as $post_id) { // update $posts[$post_id] = acf_get_post_title($posts[$post_id]); } // append to $choices $choices = $posts; } } break; case "page_type": $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf')); break; case "page_parent": // refer to "page" break; case "page_template": $choices = array('default' => __("Default Template", 'acf')); $templates = get_page_templates(); foreach ($templates as $k => $v) { $choices[$v] = $k; } break; /* * User */ /* * User */ case "user_role": global $wp_roles; $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names()); break; case "user_form": $choices = array('all' => __('All', 'acf'), 'edit' => __('Add / Edit', 'acf'), 'register' => __('Register', 'acf')); break; /* * Forms */ /* * Forms */ case "attachment": $choices = array('all' => __('All', 'acf')); break; case "taxonomy": $choices = array_merge(array('all' => __('All', 'acf')), acf_get_taxonomies()); // unset post_format if (isset($choices['post_format'])) { unset($choices['post_format']); } break; case "comment": $choices = array('all' => __('All', 'acf')); break; case "widget": global $wp_widget_factory; $choices = array('all' => __('All', 'acf')); if (!empty($wp_widget_factory->widgets)) { foreach ($wp_widget_factory->widgets as $widget) { $choices[$widget->id_base] = $widget->name; } } break; } // allow custom location rules $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices); // create field acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]", 'name' => 'value', 'value' => $options['value'], 'choices' => $choices)); }
/** * Get raw field options from ACF * * @since 1.0 * * @param array $field ACF field array * @return array List of raw field options */ public function get_field_options_raw($field) { if (empty($field['value'])) { $field['value'] = ''; } $this->field_options = NULL; $acf_mv = function_exists('acf_get_setting') ? '5' : '4'; if ($acf_mv == '5') { add_action('acf/render_field', array($this, 'catch_field_options')); ob_start(); acf_render_field($field); ob_end_clean(); remove_action('acf/render_field', array($this, 'catch_field_options')); } else { add_action('acf/create_field', array($this, 'catch_field_options')); ob_start(); do_action('acf/create_field', $field); ob_end_clean(); remove_action('acf/create_field', array($this, 'catch_field_options')); } if (is_array($this->field_options)) { return $this->field_options; } return false; }