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


PHP acf_delete_field函数代码示例

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


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

示例1: delete_field

 function delete_field($field)
 {
     if (!empty($field['layouts'])) {
         // loop through layouts
         foreach ($field['layouts'] as $layout) {
             // loop through sub fields
             if (!empty($layout['sub_fields'])) {
                 foreach ($layout['sub_fields'] as $sub_field) {
                     acf_delete_field($sub_field['ID']);
                 }
                 // foreach
             }
             // if
         }
         // foreach
     }
     // if
 }
开发者ID:Aqro,项目名称:NewDWM,代码行数:18,代码来源:flexible-content.php

示例2: save_post

 function save_post($post_id)
 {
     // do not save if this is an auto save routine
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // only save once! WordPress save's a revision as well.
     if (wp_is_post_revision($post_id)) {
         return $post_id;
     }
     // verify nonce
     if (!acf_verify_nonce('field_group')) {
         return $post_id;
     }
     // disable local to avoid conflicts between DB and local
     acf_disable_local();
     // save fields
     unset($_POST['acf_fields']['acfcloneindex']);
     if (!empty($_POST['acf_fields'])) {
         foreach ($_POST['acf_fields'] as $field) {
             // vars
             $specific = false;
             $save = acf_extract_var($field, 'save');
             // only saved field if has changed
             if ($save == 'meta') {
                 $specific = array('menu_order', 'post_parent');
             }
             // set field parent
             if (empty($field['parent'])) {
                 $field['parent'] = $post_id;
             }
             // save field
             acf_update_field($field, $specific);
         }
     }
     // delete fields
     if ($_POST['_acf_delete_fields']) {
         $ids = explode('|', $_POST['_acf_delete_fields']);
         $ids = array_map('intval', $ids);
         foreach ($ids as $id) {
             if ($id != 0) {
                 acf_delete_field($id);
             }
         }
     }
     // add args
     $_POST['acf_field_group']['ID'] = $post_id;
     $_POST['acf_field_group']['title'] = $_POST['post_title'];
     // save field group
     acf_update_field_group($_POST['acf_field_group']);
     // return
     return $post_id;
 }
开发者ID:eea76,项目名称:hammer,代码行数:53,代码来源:field-group.php

示例3: delete_field

 function delete_field($field)
 {
     // loop through sub fields
     if (!empty($field['sub_fields'])) {
         foreach ($field['sub_fields'] as $sub_field) {
             acf_delete_field($sub_field['ID']);
         }
     }
 }
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:9,代码来源:repeater.php

示例4: acf_import_field_group

function acf_import_field_group($field_group)
{
    // vars
    $ref = array();
    $order = array();
    // extract fields
    $fields = acf_extract_var($field_group, 'fields');
    // format fields
    $fields = acf_prepare_fields_for_import($fields);
    // remove old fields
    if ($field_group['ID']) {
        $db_fields = acf_get_fields_by_id($field_group['ID']);
        $db_fields = acf_prepare_fields_for_import($db_fields);
        // get field keys
        $keys = array();
        foreach ($fields as $field) {
            $keys[] = $field['key'];
        }
        // loop over db fields
        foreach ($db_fields as $field) {
            // add to ref
            $ref[$field['key']] = $field['ID'];
            if (!in_array($field['key'], $keys)) {
                acf_delete_field($field['ID']);
            }
        }
    }
    // 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 $field) {
        // add ID
        if (!$field['ID'] && isset($ref[$field['key']])) {
            $field['ID'] = $ref[$field['key']];
        }
        // 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']]++;
        // save field
        $field = acf_update_field($field);
        // add to ref
        $ref[$field['key']] = $field['ID'];
    }
    // return new field group
    return $field_group;
}
开发者ID:kochira,项目名称:competstrat,代码行数:59,代码来源:api-field-group.php

示例5: acf_delete_field_group

function acf_delete_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_delete_field($field['ID']);
        }
    }
    // delete
    wp_delete_post($field_group['ID']);
    // action for 3rd party customization
    do_action('acf/delete_field_group', $field_group);
    // return
    return true;
}
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:24,代码来源:api-field-group.php

示例6: save_post

 function save_post($post_id, $post)
 {
     // do not save if this is an auto save routine
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // bail early if not acf-field-group
     if ($post->post_type !== 'acf-field-group') {
         return $post_id;
     }
     // only save once! WordPress save's a revision as well.
     if (wp_is_post_revision($post_id)) {
         return $post_id;
     }
     // verify nonce
     if (!acf_verify_nonce('field_group')) {
         return $post_id;
     }
     // disable filters to ensure ACF loads raw data from DB
     acf_disable_filters();
     // save fields
     if (!empty($_POST['acf_fields'])) {
         foreach ($_POST['acf_fields'] as $field) {
             // vars
             $specific = false;
             $save = acf_extract_var($field, 'save');
             // only saved field if has changed
             if ($save == 'meta') {
                 $specific = array('menu_order', 'post_parent');
             }
             // set field parent
             if (empty($field['parent'])) {
                 $field['parent'] = $post_id;
             }
             // save field
             acf_update_field($field, $specific);
         }
     }
     // delete fields
     if ($_POST['_acf_delete_fields']) {
         // clean
         $ids = explode('|', $_POST['_acf_delete_fields']);
         $ids = array_map('intval', $ids);
         // loop
         foreach ($ids as $id) {
             // bai early if no id
             if (!$id) {
                 continue;
             }
             // delete
             acf_delete_field($id);
         }
     }
     // add args
     $_POST['acf_field_group']['ID'] = $post_id;
     $_POST['acf_field_group']['title'] = $_POST['post_title'];
     // save field group
     acf_update_field_group($_POST['acf_field_group']);
     // return
     return $post_id;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:61,代码来源:field-group.php

示例7: delete_field

 function delete_field($field)
 {
     // bail early if no sub fields
     if (empty($field['sub_fields'])) {
         return;
     }
     // loop through sub fields
     foreach ($field['sub_fields'] as $sub_field) {
         acf_delete_field($sub_field['ID']);
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:11,代码来源:repeater.php


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