当前位置: 首页>>代码示例>>PHP>>正文


PHP acf_render_fields函数代码示例

本文整理汇总了PHP中acf_render_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_render_fields函数的具体用法?PHP acf_render_fields怎么用?PHP acf_render_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了acf_render_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit_attachment

        function edit_attachment($form_fields, $post)
        {
            // vars
            $el = 'tr';
            $post_id = $post->ID;
            $args = array('attachment' => 'All');
            // $el
            if ($this->validate_page()) {
                //$el = 'div';
            }
            // get field groups
            $field_groups = acf_get_field_groups($args);
            // render
            if (!empty($field_groups)) {
                // get acf_form_data
                ob_start();
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'attachment'));
                if ($this->validate_page()) {
                    echo '<style type="text/css">
					.compat-attachment-fields,
					.compat-attachment-fields > tbody,
					.compat-attachment-fields > tbody > tr,
					.compat-attachment-fields > tbody > tr > th,
					.compat-attachment-fields > tbody > tr > td {
						display: block;
					}
					tr.acf-field {
						display: block;
						margin: 0 0 13px;
					}
					tr.acf-field td.acf-label {
						display: block;
						margin: 0;
					}
					tr.acf-field td.acf-input {
						display: block;
						margin: 0;
					}
				</style>';
                }
                // $el
                //if( $el == 'tr' ) {
                echo '</td></tr>';
                //}
                foreach ($field_groups as $field_group) {
                    $fields = acf_get_fields($field_group);
                    acf_render_fields($post_id, $fields, $el, 'field');
                }
                // $el
                //if( $el == 'tr' ) {
                echo '<tr class="compat-field-acf-blank"><td>';
                //}
                $html = ob_get_contents();
                ob_end_clean();
                $form_fields['acf-form-data'] = array('label' => '', 'input' => 'html', 'html' => $html);
            }
            // return
            return $form_fields;
        }
开发者ID:de190909,项目名称:WPTest,代码行数:59,代码来源:attachment.php

示例2: get_field_groups

        function get_field_groups()
        {
            // options
            $options = acf_parse_args($_POST, array('nonce' => '', 'post_id' => 0, 'ajax' => 1));
            // vars
            $r = array();
            $nonce = acf_extract_var($options, 'nonce');
            // verify nonce
            if (!wp_verify_nonce($nonce, 'acf_nonce')) {
                die;
            }
            // get field groups
            $field_groups = acf_get_field_groups($options);
            // loop through field groups and build $r
            if (!empty($field_groups)) {
                foreach ($field_groups as $field_group) {
                    // vars
                    $class = 'acf-postbox ' . $field_group['style'];
                    // load fields
                    $fields = acf_get_fields($field_group);
                    // get field HTML
                    ob_start();
                    // render
                    if ($field_group['label_placement'] == 'left') {
                        ?>
					<table class="acf-table">
						<tbody>
							<?php 
                        acf_render_fields($options['post_id'], $fields, 'tr', $field_group['instruction_placement']);
                        ?>
						</tbody>
					</table>
					<?php 
                    } else {
                        acf_render_fields($options['post_id'], $fields, 'div', $field_group['instruction_placement']);
                    }
                    $html = ob_get_clean();
                    // get style
                    $style = acf_get_field_group_style($field_group);
                    // append to $r
                    $r[] = array('key' => $field_group['key'], 'title' => $field_group['title'], 'html' => $html, 'style' => $style, 'class' => $class);
                }
            }
            // return
            wp_send_json_success($r);
        }
开发者ID:tofubuddha,项目名称:example,代码行数:46,代码来源:post.php

示例3: edit_term

        function edit_term($term, $taxonomy)
        {
            // vars
            $post_id = "{$taxonomy}_{$term->term_id}";
            $args = array('taxonomy' => $taxonomy);
            // update vars
            $this->form = '#edittag';
            // get field groups
            $field_groups = acf_get_field_groups($args);
            // render
            if (!empty($field_groups)) {
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'taxonomy'));
                foreach ($field_groups as $field_group) {
                    $fields = acf_get_fields($field_group);
                    ?>
				<?php 
                    if ($field_group['style'] == 'default') {
                        ?>
					<h3><?php 
                        echo $field_group['title'];
                        ?>
</h3>
				<?php 
                    }
                    ?>
				<table class="form-table">
					<tbody>
						<?php 
                    acf_render_fields($post_id, $fields, 'tr', 'field');
                    ?>
					</tbody>
				</table>
				<?php 
                }
            }
        }
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:36,代码来源:taxonomy.php

示例4: add_comment

        function add_comment()
        {
            // vars
            $post_id = "comment_0";
            // get field groups
            $field_groups = acf_get_field_groups(array('comment' => 'new'));
            if (!empty($field_groups)) {
                // render post data
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'comment'));
                foreach ($field_groups as $field_group) {
                    $fields = acf_get_fields($field_group);
                    ?>
				<table class="form-table">
					<tbody>
						<?php 
                    acf_render_fields($post_id, $fields, 'tr', 'field');
                    ?>
					</tbody>
				</table>
				<?php 
                }
            }
        }
开发者ID:tofubuddha,项目名称:example,代码行数:23,代码来源:comment.php

示例5: render_meta_box

    function render_meta_box($post, $args)
    {
        // extract args
        extract($args);
        // all variables from the add_meta_box function
        extract($args);
        // all variables from the args argument
        // vars
        $o = array('id' => $id, 'key' => $field_group['key'], 'style' => $field_group['style'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'), 'visibility' => true);
        // vars
        $post_id = acf_get_valid_post_id('options');
        // load fields
        $fields = acf_get_fields($field_group);
        // render
        if ($field_group['label_placement'] == 'left') {
            ?>
			<table class="acf-table">
				<tbody>
					<?php 
            acf_render_fields($post_id, $fields, 'tr', $field_group['instruction_placement']);
            ?>
				</tbody>
			</table>
			<?php 
        } else {
            acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
        }
        // edit_url
        if ($field_group['ID'] && acf_current_user_can_admin()) {
            $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
        }
        ?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
		
	acf.postbox.render(<?php 
        echo json_encode($o);
        ?>
);	

}
</script>
<?php 
    }
开发者ID:bmavus,项目名称:wp-theme-blank,代码行数:44,代码来源:options-page.php

示例6: acf_form

function acf_form($args = array())
{
    // vars
    $url = home_url($_SERVER['REQUEST_URI']);
    // defaults
    $args = wp_parse_args($args, array('id' => 'acf-form', 'post_id' => false, 'new_post' => false, 'field_groups' => false, 'fields' => false, 'post_title' => false, 'post_content' => false, 'form' => true, 'form_attributes' => array(), 'return' => add_query_arg('updated', 'true', $url), 'html_before_fields' => '', 'html_after_fields' => '', 'submit_value' => __("Update", 'acf'), 'updated_message' => __("Post updated", 'acf'), 'label_placement' => 'top', 'instruction_placement' => 'label', 'field_el' => 'div'));
    $args['form_attributes'] = wp_parse_args($args['form_attributes'], array('id' => 'post', 'class' => '', 'action' => '', 'method' => 'post'));
    // filter post_id
    $args['post_id'] = acf_get_valid_post_id($args['post_id']);
    // load values from this post
    $post_id = $args['post_id'];
    // new post?
    if ($post_id == 'new_post') {
        // dont load values
        $post_id = false;
        // new post defaults
        $args['new_post'] = acf_parse_args($args['new_post'], array('post_type' => 'post', 'post_status' => 'draft'));
    }
    // attributes
    $args['form_attributes']['class'] .= ' acf-form';
    // vars
    $field_groups = array();
    $fields = array();
    // post_title
    if ($args['post_title']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_title', 'label' => 'Title', 'type' => 'text', 'value' => $post_id ? get_post_field('post_title', $post_id) : '', 'required' => true));
    }
    // post_content
    if ($args['post_content']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_content', 'label' => 'Content', 'type' => 'wysiwyg', 'value' => $post_id ? get_post_field('post_content', $post_id) : ''));
    }
    // specific fields
    if (!empty($args['fields'])) {
        foreach ($args['fields'] as $selector) {
            $fields[] = acf_get_field($selector);
        }
    } elseif (!empty($args['field_groups'])) {
        foreach ($args['field_groups'] as $selector) {
            $field_groups[] = acf_get_field_group($selector);
        }
    } elseif ($args['post_id'] == 'new_post') {
        $field_groups = acf_get_field_groups(array('post_type' => $args['new_post']['post_type']));
    } else {
        $field_groups = acf_get_field_groups(array('post_id' => $args['post_id']));
    }
    //load fields based on field groups
    if (!empty($field_groups)) {
        foreach ($field_groups as $field_group) {
            $fields = array_merge($fields, acf_get_fields($field_group));
        }
    }
    // updated message
    if (!empty($_GET['updated']) && $args['updated_message']) {
        echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
    }
    // display form
    if ($args['form']) {
        ?>
	
	<form <?php 
        acf_esc_attr_e($args['form_attributes']);
        ?>
>
	
	<?php 
    }
    // render post data
    acf_form_data(array('post_id' => $args['post_id'], 'nonce' => 'acf_form'));
    ?>
	<div class="acf-hidden">
		
		<?php 
    acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args))));
    ?>
			
	</div>
	
	<div class="acf-form-fields">
	
		<?php 
    // html before fields
    echo $args['html_before_fields'];
    // start table
    if ($args['label_placement'] == 'left') {
        $args['field_el'] = 'tr';
        ?>
<table class="acf-table"><tbody><?php 
    }
    acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
    // end table
    if ($args['label_placement'] == 'left') {
        ?>
</tbody></table><?php 
    }
    // html after fields
    echo $args['html_after_fields'];
    ?>
	
	</div><!-- acf-form-fields -->
	
//.........这里部分代码省略.........
开发者ID:pellio11,项目名称:ns-select-project,代码行数:101,代码来源:api-template.php

示例7: render

 function render($user_id, $user_form, $el = 'tr')
 {
     // vars
     $post_id = "user_{$user_id}";
     $show_title = true;
     // show title
     if ($user_form === 'register') {
         $show_title = false;
     }
     // args
     $args = array('user_id' => 'new', 'user_form' => $user_form);
     if ($user_id) {
         $args['user_id'] = $user_id;
     }
     // get field groups
     $field_groups = acf_get_field_groups($args);
     // bail early if no field groups
     if (empty($field_groups)) {
         return;
     }
     // form data
     acf_form_data(array('post_id' => $post_id, 'nonce' => 'user'));
     // loop
     foreach ($field_groups as $field_group) {
         // vars
         $fields = acf_get_fields($field_group);
         // title
         if ($show_title && $field_group['style'] === 'default') {
             echo '<h2>' . $field_group['title'] . '</h2>';
         }
         // table start
         if ($el == 'tr') {
             echo '<table class="form-table"><tbody>';
         }
         // render fields
         acf_render_fields($post_id, $fields, $el, $field_group['instruction_placement']);
         // table end
         if ($el == 'tr') {
             echo '</tbody></table>';
         }
     }
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:42,代码来源:user.php

示例8: get_field_groups

 function get_field_groups()
 {
     // options
     $options = acf_parse_args($_POST, array('nonce' => '', 'post_id' => 0, 'ajax' => 1, 'exists' => array()));
     // vars
     $json = array();
     $nonce = acf_extract_var($options, 'nonce');
     $exists = acf_extract_var($options, 'exists');
     // verify nonce
     if (!wp_verify_nonce($nonce, 'acf_nonce')) {
         die;
     }
     // get field groups
     $field_groups = acf_get_field_groups($options);
     // bail early if no field groups
     if (empty($field_groups)) {
         wp_send_json_success($json);
     }
     // loop through field groups
     foreach ($field_groups as $i => $field_group) {
         // vars
         $item = array('key' => $field_group['key'], 'title' => $field_group['title'], 'html' => '', 'style' => '');
         // style
         if ($i == 0) {
             $item['style'] = acf_get_field_group_style($field_group);
         }
         // html
         if (!in_array($field_group['key'], $exists)) {
             // load fields
             $fields = acf_get_fields($field_group);
             // get field HTML
             ob_start();
             // render
             acf_render_fields($options['post_id'], $fields, 'div', $field_group['instruction_placement']);
             $item['html'] = ob_get_clean();
         }
         // append
         $json[] = $item;
     }
     // return
     wp_send_json_success($json);
 }
开发者ID:andresagraf,项目名称:summitmutual2016,代码行数:42,代码来源:post.php

示例9: acf_form

function acf_form($args = array())
{
    // vars
    $url = acf_get_current_url();
    // defaults
    $args = wp_parse_args($args, array('id' => 'acf-form', 'post_id' => false, 'new_post' => false, 'field_groups' => false, 'fields' => false, 'post_title' => false, 'post_content' => false, 'form' => true, 'form_attributes' => array(), 'return' => add_query_arg('updated', 'true', $url), 'html_before_fields' => '', 'html_after_fields' => '', 'submit_value' => __("Update", 'acf'), 'updated_message' => __("Post updated", 'acf'), 'label_placement' => 'top', 'instruction_placement' => 'label', 'field_el' => 'div'));
    $args['form_attributes'] = wp_parse_args($args['form_attributes'], array('id' => 'post', 'class' => '', 'action' => '', 'method' => 'post'));
    // filter post_id
    $args['post_id'] = acf_get_valid_post_id($args['post_id']);
    // load values from this post
    $post_id = $args['post_id'];
    // new post?
    if ($post_id == 'new_post') {
        // dont load values
        $post_id = false;
        // new post defaults
        $args['new_post'] = acf_parse_args($args['new_post'], array('post_type' => 'post', 'post_status' => 'draft'));
    }
    // attributes
    $args['form_attributes']['class'] .= ' acf-form';
    // vars
    $field_groups = array();
    $fields = array();
    // post_title
    if ($args['post_title']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_title', 'label' => 'Title', 'type' => 'text', 'value' => $post_id ? get_post_field('post_title', $post_id) : '', 'required' => true));
    }
    // post_content
    if ($args['post_content']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_content', 'label' => 'Content', 'type' => 'wysiwyg', 'value' => $post_id ? get_post_field('post_content', $post_id) : ''));
    }
    // specific fields
    if (!empty($args['fields'])) {
        foreach ($args['fields'] as $selector) {
            $fields[] = get_field_object($selector, $post_id, false, false);
        }
    } elseif (!empty($args['field_groups'])) {
        foreach ($args['field_groups'] as $selector) {
            $field_groups[] = acf_get_field_group($selector);
        }
    } elseif ($args['post_id'] == 'new_post') {
        $field_groups = acf_get_field_groups(array('post_type' => $args['new_post']['post_type']));
    } else {
        $field_groups = acf_get_field_groups(array('post_id' => $args['post_id']));
    }
    //load fields based on field groups
    if (!empty($field_groups)) {
        foreach ($field_groups as $field_group) {
            $field_group_fields = acf_get_fields($field_group);
            if (!empty($field_group_fields)) {
                foreach (array_keys($field_group_fields) as $i) {
                    $fields[] = acf_extract_var($field_group_fields, $i);
                }
            }
        }
    }
    // updated message
    if (!empty($_GET['updated']) && $args['updated_message']) {
        echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
    }
    // display form
    if ($args['form']) {
        ?>
	
	<form <?php 
        acf_esc_attr_e($args['form_attributes']);
        ?>
>
	
	<?php 
    }
    // render post data
    acf_form_data(array('post_id' => $args['post_id'], 'nonce' => 'acf_form'));
    ?>
	<div class="acf-hidden">
		<?php 
    acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args))));
    ?>
	</div>
	<div class="acf-fields acf-form-fields">
	
		<?php 
    // html before fields
    echo $args['html_before_fields'];
    // start table
    if ($args['label_placement'] == 'left') {
        $args['field_el'] = 'tr';
        ?>
<table class="acf-table"><tbody><?php 
    }
    acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
    // end table
    if ($args['label_placement'] == 'left') {
        ?>
</tbody></table><?php 
    }
    // html after fields
    echo $args['html_after_fields'];
    ?>
	
//.........这里部分代码省略.........
开发者ID:brycefrees,项目名称:nddLive,代码行数:101,代码来源:api-template.php

示例10: get_form_html

 /**
  * Get form HTML for a set of fields
  *
  * @param array $fields ACF fields
  * @return string Form HTML
  */
 public static function get_form_html($fields)
 {
     ob_start();
     if (self::is_pro_installed()) {
         acf_render_fields(0, $fields);
         // 0 = post_id
     } else {
         do_action('acf/create_fields', $fields, 0);
         // 0 = post_id
     }
     return ob_get_clean();
 }
开发者ID:hingst,项目名称:layotter,代码行数:18,代码来源:acf-abstraction.php

示例11: render

        function render($user_id, $user_form, $el = 'tr')
        {
            // vars
            $post_id = "user_{$user_id}";
            $show_title = true;
            // show title
            if ($user_form == 'register') {
                $show_title = false;
            }
            // args
            $args = array('user_id' => 'new', 'user_form' => $user_form);
            if ($user_id) {
                $args['user_id'] = $user_id;
            }
            // get field groups
            $field_groups = acf_get_field_groups($args);
            // render
            if (!empty($field_groups)) {
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'user'));
                foreach ($field_groups as $field_group) {
                    $fields = acf_get_fields($field_group);
                    ?>
				<?php 
                    if ($show_title && $field_group['style'] == 'default') {
                        ?>
					<h3><?php 
                        echo $field_group['title'];
                        ?>
</h3>
				<?php 
                    }
                    ?>
				
				<?php 
                    if ($el == 'tr') {
                        ?>
					<table class="form-table">
						<tbody>
				<?php 
                    }
                    ?>
				
					<?php 
                    acf_render_fields($post_id, $fields, $el, 'field');
                    ?>
				
				<?php 
                    if ($el == 'tr') {
                        ?>
						</tbody>
					</table>
				<?php 
                    }
                    ?>
				<?php 
                }
            }
        }
开发者ID:tofubuddha,项目名称:example,代码行数:58,代码来源:user.php

示例12: comment_form_field_comment

 function comment_form_field_comment($html)
 {
     // global
     global $post;
     // vars
     $post_id = false;
     // get field groups
     $field_groups = acf_get_field_groups(array('comment' => $post->post_type));
     // bail early if no field groups
     if (!$field_groups) {
         return $html;
     }
     // ob
     ob_start();
     // render post data
     acf_form_data(array('post_id' => $post_id, 'nonce' => 'comment'));
     foreach ($field_groups as $field_group) {
         $fields = acf_get_fields($field_group);
         acf_render_fields($post_id, $fields, 'p', $field_group['instruction_placement']);
     }
     // append
     $html .= ob_get_contents();
     ob_end_clean();
     // return
     return $html;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:26,代码来源:comment.php

示例13: add_comment

        function add_comment()
        {
            // vars
            $post_id = "comment_0";
            // get field groups
            $field_groups = acf_get_field_groups(array('comment' => 'new'));
            if (!empty($field_groups)) {
                // render post data
                acf_form_data(array('post_id' => $post_id, 'nonce' => 'comment'));
                foreach ($field_groups as $field_group) {
                    $fields = acf_get_fields($field_group);
                    ?>
				<div class="acf-fields -<?php 
                    echo $field_group['label_placement'];
                    ?>
">
					<?php 
                    acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
                    ?>
				</div>
				<?php 
                }
            }
        }
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:24,代码来源:comment.php

示例14: postbox_acf

    function postbox_acf($post, $args)
    {
        // extract args
        extract($args);
        // all variables from the add_meta_box function
        extract($args);
        // all variables from the args argument
        // vars
        $o = array('id' => $id, 'key' => $field_group['key'], 'style' => $field_group['style'], 'label' => $field_group['label_placement'], 'edit_url' => '', 'edit_title' => __('Edit field group', 'acf'), 'visibility' => true);
        // get post_id (allow lang modification)
        $post_id = acf_get_valid_post_id($this->page['post_id']);
        // edit_url
        if ($field_group['ID'] && acf_current_user_can_admin()) {
            $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit');
        }
        // load fields
        $fields = acf_get_fields($field_group);
        // render
        acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']);
        ?>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
		
	acf.postbox.render(<?php 
        echo json_encode($o);
        ?>
);	

}
</script>
<?php 
    }
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:32,代码来源:options-page.php

示例15: acf_form

function acf_form($args = array())
{
    // vars
    $url = acf_get_current_url();
    // defaults
    $args = wp_parse_args($args, array('id' => 'acf-form', 'post_id' => false, 'new_post' => false, 'field_groups' => false, 'fields' => false, 'post_title' => false, 'post_content' => false, 'form' => true, 'form_attributes' => array(), 'return' => add_query_arg('updated', 'true', $url), 'html_before_fields' => '', 'html_after_fields' => '', 'submit_value' => __("Update", 'acf'), 'updated_message' => __("Post updated", 'acf'), 'label_placement' => 'top', 'instruction_placement' => 'label', 'field_el' => 'div', 'uploader' => 'wp'));
    $args['form_attributes'] = wp_parse_args($args['form_attributes'], array('id' => 'post', 'class' => '', 'action' => '', 'method' => 'post'));
    // filter post_id
    $args['post_id'] = acf_get_valid_post_id($args['post_id']);
    // load values from this post
    $post_id = $args['post_id'];
    // new post?
    if ($post_id == 'new_post') {
        // dont load values
        $post_id = false;
        // new post defaults
        $args['new_post'] = acf_parse_args($args['new_post'], array('post_type' => 'post', 'post_status' => 'draft'));
    }
    // attributes
    $args['form_attributes']['class'] .= ' acf-form';
    // vars
    $field_groups = array();
    $fields = array();
    // post_title
    if ($args['post_title']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_title', 'label' => 'Title', 'type' => 'text', 'value' => $post_id ? get_post_field('post_title', $post_id) : '', 'required' => true));
    }
    // post_content
    if ($args['post_content']) {
        $fields[] = acf_get_valid_field(array('name' => '_post_content', 'label' => 'Content', 'type' => 'wysiwyg', 'value' => $post_id ? get_post_field('post_content', $post_id) : ''));
    }
    // specific fields
    if ($args['fields']) {
        foreach ($args['fields'] as $selector) {
            // append field ($strict = false to allow for better compatibility with field names)
            $fields[] = acf_maybe_get_field($selector, $post_id, false);
        }
    } elseif ($args['field_groups']) {
        foreach ($args['field_groups'] as $selector) {
            $field_groups[] = acf_get_field_group($selector);
        }
    } elseif ($args['post_id'] == 'new_post') {
        $field_groups = acf_get_field_groups(array('post_type' => $args['new_post']['post_type']));
    } else {
        $field_groups = acf_get_field_groups(array('post_id' => $args['post_id']));
    }
    //load fields based on field groups
    if (!empty($field_groups)) {
        foreach ($field_groups as $field_group) {
            $field_group_fields = acf_get_fields($field_group);
            if (!empty($field_group_fields)) {
                foreach (array_keys($field_group_fields) as $i) {
                    $fields[] = acf_extract_var($field_group_fields, $i);
                }
            }
        }
    }
    // updated message
    if (!empty($_GET['updated']) && $args['updated_message']) {
        echo '<div id="message" class="updated"><p>' . $args['updated_message'] . '</p></div>';
    }
    // uploader (always set incase of multiple forms on the page)
    acf_update_setting('uploader', $args['uploader']);
    // display form
    if ($args['form']) {
        ?>

	
	<form <?php 
        acf_esc_attr_e($args['form_attributes']);
        ?>
>
	
	<?php 
    }
    // render post data
    acf_form_data(array('post_id' => $args['post_id'], 'nonce' => 'acf_form'));
    ?>

	<div class="acf-hidden">
		<?php 
    acf_hidden_input(array('name' => '_acf_form', 'value' => base64_encode(json_encode($args))));
    ?>

	</div>
	<div class="acf-fields acf-form-fields -<?php 
    echo $args['label_placement'];
    ?>
">
	
		<?php 
    // html before fields
    echo $args['html_before_fields'];
    // render
    acf_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
    // html after fields
    echo $args['html_after_fields'];
    ?>

	
//.........这里部分代码省略.........
开发者ID:de190909,项目名称:WPTest,代码行数:101,代码来源:api-template.php


注:本文中的acf_render_fields函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。