Skip to content

Instantly share code, notes, and snippets.

@webgurus
Created May 21, 2016 09:46
Show Gist options
  • Save webgurus/79b4e8d7924f868389055763957e1bda to your computer and use it in GitHub Desktop.
Save webgurus/79b4e8d7924f868389055763957e1bda to your computer and use it in GitHub Desktop.
<?php
function acf_add_local_field_group($array) {
// put absolute path to theme in here
$themePath = $_SERVER["DOCUMENT_ROOT"].'/wp-content/uploads/';
$acfJsonPath = $themePath;
$output = json_encode($array);
echo '<p>Writing file to ' . $acfJsonPath . $array['key'] . '.json</p>';
$file = file_put_contents( $acfJsonPath . $array['key'] . '.json', $output );
if ($file) {
echo "<p>". $file . " bytes file created.</p>";
} else {
'<p>Error, file not created.<';
}
}
// ACF PHP export goes here
acf_add_local_field_group(
array (
'key' => 'group_563cb24dc1b96',
'title' => 'Citycards',
'fields' => array (
array (
'key' => 'field_563cb2cecd069',
'label' => 'Top City Card',
'name' => 'top_city_card',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array (
'key' => 'field_563cb2c3cd068',
'label' => 'JSON path',
'name' => 'citycard_json_path',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
array (
'key' => 'field_563cb2a4cd067',
'label' => 'BCR CityCard',
'name' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'placement' => 'top',
'endpoint' => 0,
),
array (
'key' => 'field_563cb2769d42b',
'label' => 'JSON path',
'name' => 'bcr_json_path',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'readonly' => 0,
'disabled' => 0,
),
),
'location' => array (
array (
array (
'param' => 'options_page',
'operator' => '==',
'value' => 'acf-options',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment