本文整理汇总了PHP中acf_disable_local函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_disable_local函数的具体用法?PHP acf_disable_local怎么用?PHP acf_disable_local使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_disable_local函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
function load()
{
// all export pages should not load local fields
acf_disable_local();
// run import / export
if (acf_verify_nonce('import')) {
$this->import();
} elseif (acf_verify_nonce('export')) {
if (isset($_POST['generate'])) {
$this->generate();
} else {
$this->export();
}
}
}
示例2: ajax_move_field
function ajax_move_field()
{
// disable JSON to avoid conflicts between DB and JSON
acf_disable_local();
$args = acf_parse_args($_POST, array('nonce' => '', '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 sprintf(__('The %s field can now be found in the %s field group', 'acf'), $v1, $v2) . '</p>';
echo '<a href="#" class="acf-button blue acf-close-popup">' . __("Close Window", 'acf') . '</a>';
die;
}
// get all field groups
$field_groups = acf_get_field_groups();
$choices = array();
if (!empty($field_groups)) {
foreach ($field_groups as $field_group) {
if ($field_group['ID']) {
$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="acf-button blue">' . __("Move Field", 'acf') . '</button>';
echo '</form>';
// die
die;
}
示例3: 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;
}
示例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']) {
// disable local - important as to avoid 'acf_get_fields_by_id' returning fields with ID = 0
acf_disable_local();
// load fields
$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']);
}
}
// enable local - important as to allow local to find new fields and save json file
acf_enable_local();
}
// 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;
}
示例5: acf_untrash_field
function acf_untrash_field($selector = 0)
{
// disable JSON to avoid conflicts between DB and JSON
acf_disable_local();
// load the origional field gorup
$field = acf_get_field($selector);
// bail early if field did not load correctly
if (empty($field)) {
return false;
}
// delete field
wp_untrash_post($field['ID']);
// action for 3rd party customisation
do_action('acf/untrash_field', $field);
// return
return true;
}