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


PHP acf_prepare_fields_for_export函数代码示例

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


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

示例1: update_field_group

 function update_field_group($field_group)
 {
     // vars
     $path = acf_get_setting('save_json');
     $file = $field_group['key'] . '.json';
     // remove trailing slash
     $path = untrailingslashit($path);
     // bail early if dir does not exist
     if (!is_writable($path)) {
         //error_log( 'ACF failed to save field group to .json file. Path does not exist: ' . $path );
         return;
     }
     // 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');
     // write file
     $f = fopen("{$path}/{$file}", 'w');
     fwrite($f, acf_json_encode($field_group));
     fclose($f);
 }
开发者ID:mariussunde,项目名称:Sn-hetta-Designmanual-WP-Theme,代码行数:25,代码来源:json.php

示例2: acf_push

 /**
  * Export an ACF field group
  */
 function acf_push($group_id)
 {
     // load field group
     $field_group = acf_get_field_group($group_id);
     // validate field group
     if (empty($field_group)) {
         return;
     }
     // 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
     return $field_group;
 }
开发者ID:joedooley,项目名称:wp-cfm,代码行数:22,代码来源:acf.php

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

示例4: prepare_field_for_export

 function prepare_field_for_export($field)
 {
     // sub field (parent_layout)
     acf_extract_var($field, 'parent_layout');
     // sub fields
     if ($field['type'] == 'repeater') {
         $field['sub_fields'] = acf_prepare_fields_for_export($field['sub_fields']);
     } elseif ($field['type'] == 'flexible_content') {
         foreach ($field['layouts'] as $l => $layout) {
             $field['layouts'][$l]['sub_fields'] = acf_prepare_fields_for_export($layout['sub_fields']);
         }
     }
     // return
     return $field;
 }
开发者ID:bmavus,项目名称:wp-theme-blank,代码行数:15,代码来源:acf-pro.php

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

示例6: acf_prepare_field_group_for_export

function acf_prepare_field_group_for_export($field_group)
{
    // extract field group ID
    $id = acf_extract_var($field_group, 'ID');
    // prepare fields
    $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']);
    // filter for 3rd party customization
    $field_group = apply_filters('acf/prepare_field_group_for_export', $field_group);
    // return
    return $field_group;
}
开发者ID:ashenkar,项目名称:sanga,代码行数:11,代码来源:api-field-group.php

示例7: acf_write_json_field_group

function acf_write_json_field_group($field_group)
{
    // vars
    $path = acf_get_setting('save_json');
    $file = $field_group['key'] . '.json';
    // remove trailing slash
    $path = untrailingslashit($path);
    // bail early if dir does not exist
    if (!is_writable($path)) {
        return false;
    }
    // extract field group ID
    $id = acf_extract_var($field_group, 'ID');
    // add modified time
    $field_group['modified'] = get_post_modified_time('U', true, $id, true);
    // prepare fields
    $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']);
    // write file
    $f = fopen("{$path}/{$file}", 'w');
    fwrite($f, acf_json_encode($field_group));
    fclose($f);
    // return
    return true;
}
开发者ID:Aqro,项目名称:NewDWM,代码行数:24,代码来源:json.php

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

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

示例10: create_commit

 /**
  * Create a new ACF Commit
  *
  * @param $commit_message - Detailed Message describing change to ACF Field Group
  * @param int $post_id - Post ID of ACF Field Group
  */
 public function create_commit($commit_message, $post_id = 0)
 {
     $_SESSION['commit-complete'] = true;
     $field_groups = acf_get_field_groups();
     $exportJSON = array();
     if (!empty($field_groups)) {
         foreach ($field_groups as $field_group) {
             $field_group['fields'] = acf_get_fields($field_group);
             $field_group['fields'] = acf_prepare_fields_for_export($field_group['fields']);
             acf_extract_var($field_group, 'ID');
             $exportJSON[] = $field_group;
         }
     }
     $export = acf_json_encode($exportJSON);
     $commitID = wp_insert_post(array('post_type' => 'acf-commit', 'post_status' => 'publish', 'post_content' => $export, 'post_title' => 'ACF Revision: ' . date('Y-m-d h:i:s')));
     update_field('commit_message', $commit_message, $commitID);
     update_field('acf_field_group', get_the_title($post_id), $commitID);
 }
开发者ID:2nickpick,项目名称:acf-commits,代码行数:24,代码来源:acf-commits.php


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