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


PHP acf_get_field_group函数代码示例

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


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

示例1: acf_pull

 /**
  * Import (overwrite) field groups into DB
  * @param string $params['name']
  * @param string $params['group']
  * @param string $params['old_value'] The previous settings data
  * @param string $params['new_value'] The new settings data
  */
 function acf_pull($params)
 {
     $field_group = $params['new_value'];
     if ($existing_group = acf_get_field_group($field_group['key'])) {
         $field_group['ID'] = $existing_group['ID'];
         $existing_fields = acf_get_fields($existing_group);
         // Remove fields
         foreach ($existing_fields as $field) {
             wp_delete_post($field['ID'], true);
         }
     }
     // extract fields
     $fields = acf_extract_var($field_group, 'fields');
     // format fields
     $fields = acf_prepare_fields_for_import($fields);
     // save field group
     $field_group = acf_update_field_group($field_group);
     // add to ref
     $ref[$field_group['key']] = $field_group['ID'];
     // add to order
     $order[$field_group['ID']] = 0;
     // add fields
     foreach ($fields as $index => $field) {
         // add parent
         if (empty($field['parent'])) {
             $field['parent'] = $field_group['ID'];
         } else {
             if (isset($ref[$field['parent']])) {
                 $field['parent'] = $ref[$field['parent']];
             }
         }
         // add field menu_order
         if (!isset($order[$field['parent']])) {
             $order[$field['parent']] = 0;
         }
         $field['menu_order'] = $order[$field['parent']];
         $order[$field['parent']]++;
         // save field
         $field = acf_update_field($field);
         // add to ref
         $ref[$field['key']] = $field['ID'];
     }
 }
开发者ID:joedooley,项目名称:wp-cfm,代码行数:50,代码来源:acf.php

示例2: get_json

 static function get_json()
 {
     if (!function_exists('acf_get_field_group')) {
         echo 'You need ACF activated to use this screen';
         exit;
     }
     $keys = isset($_GET['generate-template-id']) ? array($_GET['generate-template-id']) : array();
     //print_r($keys);
     //exit;
     //$keys = $_GET['acf_export_keys'];
     //$keys = array('group_55e23ad63ecc3');
     //$keys = array('group_55d38b033048e');
     //$keys = array('group_55d26a506a990');
     // validate
     if (empty($keys)) {
         return false;
     }
     // vars
     $json = array();
     // construct JSON
     foreach ($keys as $key) {
         // load field group
         $field_group = acf_get_field_group($key);
         // validate field group
         if (empty($field_group)) {
             continue;
         }
         // load fields
         $field_group['fields'] = acf_get_fields($field_group);
         // prepare fields
         $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']);
         // extract field group ID
         $id = acf_extract_var($field_group, 'ID');
         // add to json array
         $json[] = $field_group;
     }
     // return
     return $json;
 }
开发者ID:julsquintanilla,项目名称:landing-pages,代码行数:39,代码来源:class.template-utils.php

示例3: get_clone_setting_choice

 function get_clone_setting_choice($selector = '')
 {
     // bail early no selector
     if (!$selector) {
         return '';
     }
     // ajax_fields
     if (isset($_POST['fields'][$selector])) {
         return $this->get_clone_setting_field_choice($_POST['fields'][$selector]);
     }
     // field
     if (acf_is_field_key($selector)) {
         return $this->get_clone_setting_field_choice(acf_get_field($selector));
     }
     // group
     if (acf_is_field_group_key($selector)) {
         return $this->get_clone_setting_group_choice(acf_get_field_group($selector));
     }
     // return
     return $selector;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:21,代码来源:clone.php

示例4: 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

示例5: acf_untrash_field_group

function acf_untrash_field_group($selector = 0)
{
    // disable JSON to avoid conflicts between DB and JSON
    acf_disable_local();
    // load the origional field gorup
    $field_group = acf_get_field_group($selector);
    // bail early if field group did not load correctly
    if (empty($field_group)) {
        return false;
    }
    // get fields
    $fields = acf_get_fields($field_group);
    if (!empty($fields)) {
        foreach ($fields as $field) {
            acf_untrash_field($field['ID']);
        }
    }
    // delete
    wp_untrash_post($field_group['ID']);
    // action for 3rd party customization
    do_action('acf/untrash_field_group', $field_group);
    // return
    return true;
}
开发者ID:kochira,项目名称:competstrat,代码行数:24,代码来源:api-field-group.php

示例6: get_group_slug

 /**
  * Get an ACF group slug
  *
  * @param $group_id
  * @return string|bool
  */
 private static function get_group_slug($group_id)
 {
     global $acf_local;
     if (isset($acf_local->groups[$group_id])) {
         // First try the local groups (added by PHP).
         $title = $acf_local->groups[$group_id]['title'];
     } else {
         $args = ['post_type' => 'acf-field-group'];
         if (is_numeric($group_id)) {
             $args['id'] = $group_id;
         } else {
             $args['name'] = $group_id;
         }
         // Then try the db if not found in local.
         // @codingStandardsIgnoreStart
         // Ignore use WP_Query rule because we don't know if this will be a sub-query and hence create complications.
         $groups = get_posts($args);
         // @codingStandardsIgnoreEnd
         $title = empty($groups) ? false : $groups[0]->post_title;
         // Patch for the new version of ACF Fields plugins >= 5.4.*.
         if (!$title) {
             $groups = acf_get_field_group($group_id);
             $title = empty($groups) ? false : $groups['title'];
         }
     }
     if ($title) {
         return strtolower(str_replace(' ', '_', $title));
     }
     return false;
 }
开发者ID:moxie-lean,项目名称:wp-acf,代码行数:36,代码来源:Acf.php

示例7: importFields

 /**
  * An altered version of acf/admin/settings-tool.php::import()
  *
  * ACF's import function takes care of most things, but this
  * function makes up for what it lacks:
  *
  * - Removes fields that are in the DB, but not in the import file
  * - Removes field groups that are in the DB, but not in the import file
  * - Updates fields that have changed
  * - Displays command-line messages
  *
  * @return null
  */
 protected function importFields()
 {
     // validate
     if (empty($_FILES['acf_import_file'])) {
         acf_add_admin_notice(__("No file selected", 'acf'), 'error');
         return;
     }
     // vars
     $file = $_FILES['acf_import_file'];
     // validate error
     if ($file['error']) {
         acf_add_admin_notice(__('Error uploading file. Please try again', 'acf'), 'error');
         return;
     }
     // validate type
     if (pathinfo($file['name'], PATHINFO_EXTENSION) !== 'json') {
         acf_add_admin_notice(__('Incorrect file type', 'acf'), 'error');
         return;
     }
     // read file
     $json = file_get_contents($file['tmp_name']);
     // decode json
     $json = json_decode($json, true);
     // validate json
     if (empty($json)) {
         acf_add_admin_notice(__('Import file empty', 'acf'), 'error');
         return;
     }
     // if importing an auto-json, wrap field group in array
     if (isset($json['key'])) {
         $json = array($json);
     }
     // vars
     $added = array();
     $deletedgroups = array();
     $deletedfields = array();
     $ref = array();
     $order = array();
     $allgroups = $this->getFieldGroups();
     $allfields = $this->getFields();
     foreach ($json as $field_group) {
         $update = false;
         // check if field group exists
         if ($post = acf_get_field_group($field_group['key'], true)) {
             // \WP_CLI::log($field_group['title'] . " group already exists. Updating.");
             // add ID to trigger update instead of insert
             $field_group["ID"] = $post["ID"];
             $update = true;
             // } else {
             // 	\WP_CLI::log($field_group['title'] . " group is new. Adding.");
         }
         // remove fields
         $fields = acf_extract_var($field_group, 'fields');
         // format fields
         $fields = acf_prepare_fields_for_import($fields);
         // save field group
         $field_group = acf_update_field_group($field_group);
         // remove group from $allgroups array
         if (isset($allgroups[$field_group['ID']])) {
             unset($allgroups[$field_group['ID']]);
         }
         // add to ref
         $ref[$field_group['key']] = $field_group['ID'];
         // add to order
         $order[$field_group['ID']] = 0;
         // add fields
         foreach ($fields as $field) {
             // add parent
             if (empty($field['parent'])) {
                 $field['parent'] = $field_group['ID'];
             } elseif (isset($ref[$field['parent']])) {
                 $field['parent'] = $ref[$field['parent']];
             }
             // add field menu_order
             if (!isset($order[$field['parent']])) {
                 $order[$field['parent']] = 0;
             }
             $field['menu_order'] = $order[$field['parent']];
             $order[$field['parent']]++;
             // add ID if the field already exists
             if ($post = acf_get_field($field['key'], true)) {
                 // add ID to trigger update instead of insert
                 $field["ID"] = $post["ID"];
                 // \WP_CLI::log($field_group['title'] . "->" . $field['label'] . " field already exists. Updating.");
                 // } else {
                 // 	\WP_CLI::log($field_group['title'] . "->" . $field['label'] . " field is new. Adding.");
             }
//.........这里部分代码省略.........
开发者ID:johnshopkins,项目名称:vandelay,代码行数:101,代码来源:Vandelay.php

示例8: generate

 function generate()
 {
     // validate
     if (empty($_POST['acf_export_keys'])) {
         acf_add_admin_notice(__("No field groups selected", 'acf'), 'error');
         return;
     }
     // vars
     $id_ref = array();
     $json = array();
     // construct JSON
     foreach ($_POST['acf_export_keys'] as $key) {
         // load field group
         $field_group = acf_get_field_group($key);
         // validate field group
         if (empty($field_group)) {
             continue;
         }
         // load fields
         $fields = acf_get_fields($field_group);
         // prepare fields
         $fields = acf_prepare_fields_for_export($fields);
         // add to field group
         $field_group['fields'] = $fields;
         // extract field group ID
         $id = acf_extract_var($field_group, 'ID');
         // add to json array
         $json[] = $field_group;
     }
     // end foreach
     // update view
     $this->view = 'settings-export-generate';
     $this->data['field_groups'] = $json;
 }
开发者ID:mariussunde,项目名称:Sn-hetta-Designmanual-WP-Theme,代码行数:34,代码来源:settings-export.php

示例9: get_json

 function get_json()
 {
     // validate
     if (empty($_POST['acf_export_keys'])) {
         return false;
     }
     // vars
     $json = array();
     // construct JSON
     foreach ($_POST['acf_export_keys'] as $key) {
         // load field group
         $field_group = acf_get_field_group($key);
         // validate field group
         if (empty($field_group)) {
             continue;
         }
         // load fields
         $field_group['fields'] = acf_get_fields($field_group);
         // prepare fields
         $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']);
         // extract field group ID
         $id = acf_extract_var($field_group, 'ID');
         // add to json array
         $json[] = $field_group;
     }
     // return
     return $json;
 }
开发者ID:Aqro,项目名称:NewDWM,代码行数:28,代码来源:settings-tools.php

示例10: acf_get_field_group

<?php

// global
global $post;
// vars
$field_group = acf_get_field_group($post);
// UI needs at lease 1 location rule
if (empty($field_group['location'])) {
    $field_group['location'] = array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'post')));
}
?>
<table class="acf-table">
	<tbody>
		<tr class="acf-field">
			<td class="acf-label">
				<label><?php 
_e("Rules", 'acf');
?>
</label>
				<p><?php 
_e("Create a set of rules to determine which edit screens will use these advanced custom fields", 'acf');
?>
</p>
			</td>
			<td class="acf-input">
				<div class="location-groups">
					
					<?php 
foreach ($field_group['location'] as $group_id => $group) {
    // $group_id must be completely different to $rule_id to avoid JS issues
    $group_id = "group_{$group_id}";
开发者ID:taherbth,项目名称:bestbuy-bestsell,代码行数:31,代码来源:field-group-locations.php

示例11: render

    public function render()
    {
        acf_enqueue_scripts();
        do_action('acf/view', $this->args, $this);
        $post_id = $this->post_id;
        $args = $this->args;
        // 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);
                    }
                }
            }
        }
        ?>
		<div class="acf-fields acf-form-fields -<?php 
        echo $args['label_placement'];
        ?>
">

		<?php 
        // html before fields
        echo $args['html_before_fields'];
        // render
        acf_views_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
        // html after fields
        echo $args['html_after_fields'];
        ?>

		</div><!-- acf-form-fields -->
		<?php 
    }
开发者ID:NikolaGrdanjski,项目名称:acf-views,代码行数:61,代码来源:acf-views-view.php

示例12: export

 function export($args, $assoc_args)
 {
     // if empty it will show export all fields
     $export_field = '';
     if (is_multisite()) {
         $choice = $this->select_blog();
         switch_to_blog($choice);
     }
     //if export all is used skip the question popup
     if (empty($args) || $args[0] != 'all') {
         $export_field = $this->select_acf_field();
     }
     if (empty($export_field)) {
         WP_CLI::success("Exporting all fieldgroups \n");
     } else {
         WP_CLI::success("Exporting fieldgroup \n");
     }
     $field_groups = get_posts(array('numberposts' => -1, 'post_type' => 'acf-field-group', 'sort_column' => 'menu_order', 'order' => 'ASC', 'include' => $export_field));
     if ($field_groups) {
         if (isset($assoc_args['export-path']) && isset($this->paths[$assoc_args['export-path']])) {
             $export_path = $this->paths[$assoc_args['export-path']];
         } else {
             $export_path = $this->select_export_path();
         }
         $acf_fld_grp = new acf_field();
         if (!is_dir($export_path) && !mkdir($export_path, 0755, false)) {
             WP_CLI::line('fieldgroup directory exists or cant be created!');
         }
         foreach ($field_groups as $group) {
             $title = get_the_title($group->ID);
             $sanitized_title = sanitize_title($title);
             $subpath = $export_path . $sanitized_title;
             $uniquid_path = $subpath . '/uniqid';
             $field_group_array = array();
             $field_group = acf_get_field_group($group->ID);
             // validate field group
             if (empty($field_group)) {
                 continue;
             }
             // load fields
             $fields = acf_get_fields($field_group);
             // prepare fields
             $fields = acf_prepare_fields_for_export($fields);
             // add to field group
             $field_group['fields'] = $fields;
             // extract field group ID
             $id = acf_extract_var($field_group, 'ID');
             $json = acf_json_encode($field_group);
             // retrieve the uniquid from the file if it exists else we make a new one
             $uniqid = file_exists($uniquid_path) ? file_get_contents($uniquid_path) : uniqid();
             // each field_group gets it's own folder by field_group name
             if (!is_dir($subpath) && !mkdir($subpath, 0755, false)) {
                 WP_CLI::line('fieldgroup subdirectory exists or cant be created!');
             } else {
                 // let's write the array to a data.php file so it can be used later on
                 $fp = fopen($subpath . '/' . "data.php", "w");
                 $output = "<?php \n\$group = " . var_export($field_group, true) . ';';
                 fwrite($fp, $output);
                 fclose($fp);
                 $fp = fopen($subpath . '/' . "data.json", "w");
                 $output = $json;
                 fwrite($fp, $output);
                 fclose($fp);
                 // write the uniquid file if it doesn't exist
                 if (!file_exists($uniquid_path)) {
                     $fp = fopen($subpath . '/' . "uniqid", "w");
                     $output = $uniqid;
                     fwrite($fp, $output);
                     fclose($fp);
                 }
                 WP_CLI::success("Fieldgroup " . $title . " exported ");
             }
         }
     } else {
         //error seems to be returning and break out of my loop
         //WP_CLI::error( 'No field groups were found in the database' );
         echo 'No field groups were found in the database';
         echo ' ';
     }
     if (is_multisite()) {
         restore_current_blog();
     }
 }
开发者ID:scotto77,项目名称:advanced-custom-fields-wpcli,代码行数:83,代码来源:ACF5_Command.php

示例13: 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

示例14: ajax_move_field

 function ajax_move_field()
 {
     // disable filters to ensure ACF loads raw data from DB
     acf_disable_filters();
     $args = acf_parse_args($_POST, array('nonce' => '', 'post_id' => 0, 'field_id' => 0, 'field_group_id' => 0));
     // verify nonce
     if (!wp_verify_nonce($args['nonce'], 'acf_nonce')) {
         die;
     }
     // confirm?
     if ($args['field_id'] && $args['field_group_id']) {
         // vars
         $field = acf_get_field($args['field_id']);
         $field_group = acf_get_field_group($args['field_group_id']);
         // update parent
         $field['parent'] = $field_group['ID'];
         // remove conditional logic
         $field['conditional_logic'] = 0;
         // update field
         acf_update_field($field);
         $v1 = $field['label'];
         $v2 = '<a href="' . admin_url("post.php?post={$field_group['ID']}&action=edit") . '" target="_blank">' . $field_group['title'] . '</a>';
         echo '<p><strong>' . __('Move Complete.', 'acf') . '</strong></p>';
         echo '<p>' . sprintf(__('The %s field can now be found in the %s field group', 'acf'), $v1, $v2) . '</p>';
         echo '<a href="#" class="button button-primary acf-close-popup">' . __("Close Window", 'acf') . '</a>';
         die;
     }
     // get all field groups
     $field_groups = acf_get_field_groups();
     $choices = array();
     // check
     if (!empty($field_groups)) {
         // loop
         foreach ($field_groups as $field_group) {
             // bail early if no ID
             if (!$field_group['ID']) {
                 continue;
             }
             // bail ealry if is current
             if ($field_group['ID'] == $args['post_id']) {
                 continue;
             }
             // append
             $choices[$field_group['ID']] = $field_group['title'];
         }
     }
     // render options
     $field = acf_get_valid_field(array('type' => 'select', 'name' => 'acf_field_group', 'choices' => $choices));
     echo '<p>' . __('Please select the destination for this field', 'acf') . '</p>';
     echo '<form id="acf-move-field-form">';
     // render
     acf_render_field_wrap($field);
     echo '<button type="submit" class="button button-primary">' . __("Move Field", 'acf') . '</button>';
     echo '</form>';
     // die
     die;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:57,代码来源:field-group.php

示例15: field_group_columns_html

 function field_group_columns_html($column, $post_id)
 {
     // vars
     $field_group = acf_get_field_group($post_id);
     // render
     $this->render_column($column, $field_group);
 }
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:7,代码来源:field-groups.php


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