本文整理汇总了PHP中acf_render_field_wrap函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_render_field_wrap函数的具体用法?PHP acf_render_field_wrap怎么用?PHP acf_render_field_wrap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_render_field_wrap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($row[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $row[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = "{$field['name']}[{$i}]";
// render input
acf_render_field_wrap($sub_field, $el);
?>
<?php
}
?>
<?php
echo $after_fields;
?>
</tr>
</tbody>
</table>
</div>
示例2: render_layout
//.........这里部分代码省略.........
?>
"></a>
</li>
</ul>
<?php
if (!empty($layout['sub_fields'])) {
?>
<table <?php
acf_esc_attr_e($table_atts);
?>
>
<?php
if ($layout['display'] == 'table') {
?>
<thead>
<tr>
<?php
foreach ($layout['sub_fields'] as $sub_field) {
$atts = array('class' => "acf-th acf-th-{$sub_field['name']}", 'data-key' => $sub_field['key']);
// Add custom width
if ($sub_field['wrapper']['width']) {
$atts['data-width'] = $sub_field['wrapper']['width'];
}
?>
<th <?php
acf_esc_attr_e($atts);
?>
>
<?php
acf_the_field_label($sub_field);
?>
<?php
if ($sub_field['instructions']) {
?>
<p class="description"><?php
echo $sub_field['instructions'];
?>
</p>
<?php
}
?>
</th>
<?php
}
?>
</tr>
</thead>
<?php
}
?>
<tbody>
<tr>
<?php
echo $before_fields;
// loop though sub fields
foreach ($layout['sub_fields'] as $sub_field) {
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($value[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $value[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = "{$field['name']}[{$i}]";
// render input
acf_render_field_wrap($sub_field, $el);
}
// layout: Row
echo $after_fields;
?>
</tr>
</tbody>
</table>
<?php
}
?>
</div>
<?php
}
示例3: ajax_add_term
function ajax_add_term()
{
// vars
$args = acf_parse_args($_POST, array('nonce' => '', 'field_key' => '', 'term_name' => '', 'term_parent' => ''));
// verify nonce
if (!wp_verify_nonce($args['nonce'], 'acf_nonce')) {
die;
}
// load field
$field = acf_get_field($args['field_key']);
if (!$field) {
die;
}
// vars
$taxonomy_obj = get_taxonomy($field['taxonomy']);
$taxonomy_label = $taxonomy_obj->labels->singular_name;
// validate cap
// note: this situation should never occur due to condition of the add new button
if (!current_user_can($taxonomy_obj->cap->manage_terms)) {
echo '<p><strong>' . __("Error", 'acf') . '.</strong> ' . sprintf(__('User unable to add new %s', 'acf'), $taxonomy_label) . '</p>';
die;
}
// save?
if ($args['term_name']) {
// exists
if (term_exists($args['term_name'], $field['taxonomy'])) {
wp_send_json_error(array('error' => sprintf(__('%s already exists', 'acf'), $taxonomy_label)));
}
// insert
$extra = array();
if ($args['term_parent']) {
$extra['parent'] = $args['term_parent'];
}
$data = wp_insert_term($args['term_name'], $field['taxonomy'], $extra);
// error?
if (is_wp_error($data)) {
wp_send_json_error(array('error' => $data->get_error_message()));
}
// ancestors
$prefix = '';
$ancestors = get_ancestors($data['term_id'], $field['taxonomy']);
if (!empty($ancestors)) {
$prefix = str_repeat('- ', count($ancestors));
}
// success
wp_send_json_success(array('message' => sprintf(__('%s added', 'acf'), $taxonomy_label), 'term_id' => $data['term_id'], 'term_name' => $args['term_name'], 'term_label' => $prefix . $args['term_name'], 'term_parent' => $args['term_parent']));
}
?>
<form method="post"><?php
acf_render_field_wrap(array('label' => 'Name', 'name' => 'term_name', 'type' => 'text'));
if (is_taxonomy_hierarchical($field['taxonomy'])) {
$choices = array();
$choices2 = $this->get_choices(array('field_key' => $field['key']));
if ($choices2) {
foreach ($choices2 as $v) {
$choices[$v['id']] = $v['text'];
}
}
acf_render_field_wrap(array('label' => 'Parent', 'name' => 'term_parent', 'type' => 'select', 'allow_null' => 1, 'ui' => 0, 'choices' => $choices));
}
?>
<p class="acf-submit"><button class="acf-button blue" type="submit"><?php
_e("Add", 'acf');
?>
</button><i class="acf-loading"></i><span></span></p></form><?php
// die
die;
}
示例4: acf_render_field_wrap
// type
acf_render_field_wrap(array('label' => __('Field Type', 'acf'), 'instructions' => '', 'required' => 1, 'type' => 'select', 'name' => 'type', 'prefix' => $field['prefix'], 'value' => $field['type'], 'choices' => acf_get_field_types()), 'tr');
// instructions
acf_render_field_wrap(array('label' => __('Instructions', 'acf'), 'instructions' => __('Instructions for authors. Shown when submitting data', 'acf'), 'type' => 'textarea', 'name' => 'instructions', 'prefix' => $field['prefix'], 'value' => $field['instructions'], 'rows' => 5), 'tr');
// required
acf_render_field_wrap(array('label' => __('Required?', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'required', 'prefix' => $field['prefix'], 'value' => $field['required'], 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'), 'tr');
// type specific settings
do_action("acf/render_field_settings/type={$field['type']}", $field);
// 3rd party settings
do_action('acf/render_field_settings', $field);
// conditional logic
acf_get_view('field-group-field-conditional-logic', array('field' => $field));
// wrapper
acf_render_field_wrap(array('label' => __('Wrapper Attributes', 'acf'), 'instructions' => '', 'type' => 'text', 'name' => 'width', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['width'], 'prepend' => __('width', 'acf'), 'append' => '%', 'wrapper' => array('data-name' => 'wrapper')), 'tr');
acf_render_field_wrap(array('label' => '', 'instructions' => '', 'type' => 'text', 'name' => 'class', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['class'], 'prepend' => __('class', 'acf'), 'wrapper' => array('data-append' => 'wrapper')), 'tr');
acf_render_field_wrap(array('label' => '', 'instructions' => '', 'type' => 'text', 'name' => 'id', 'prefix' => $field['prefix'] . '[wrapper]', 'value' => $field['wrapper']['id'], 'prepend' => __('id', 'acf'), 'wrapper' => array('data-append' => 'wrapper')), 'tr');
?>
<tr class="acf-field acf-field-save">
<td class="acf-label"></td>
<td class="acf-input">
<ul class="acf-hl">
<li>
<a class="edit-field acf-button grey" title="<?php
_e("Close Field", 'acf');
?>
" href="#"><?php
_e("Close Field", 'acf');
?>
</a>
</li>
</ul>
示例5: render_field
//.........这里部分代码省略.........
<?php
if ($show_order) {
?>
<td class="acf-row-handle order" title="<?php
_e('Drag to reorder', 'acf');
?>
">
<?php
if ($field['collapsed']) {
?>
<a class="acf-icon -collapse small" href="#" data-event="collapse-row" title="<?php
_e('Click to toggle', 'acf');
?>
"></a>
<?php
}
?>
<span><?php
echo intval($i) + 1;
?>
</span>
</td>
<?php
}
?>
<?php
echo $before_fields;
?>
<?php
foreach ($sub_fields as $sub_field) {
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($row[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $row[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = $field['name'] . '[' . $i . ']';
// render input
acf_render_field_wrap($sub_field, $el);
?>
<?php
}
?>
<?php
echo $after_fields;
?>
<?php
if ($show_remove) {
?>
<td class="acf-row-handle remove">
<a class="acf-icon -plus small" href="#" data-event="add-row" title="<?php
_e('Add row', 'acf');
?>
"></a>
<a class="acf-icon -minus small" href="#" data-event="remove-row" title="<?php
_e('Remove row', 'acf');
?>
"></a>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
if ($show_add) {
?>
<ul class="acf-actions acf-hl">
<li>
<a class="acf-button button button-primary" data-event="add-row"><?php
echo $field['button_label'];
?>
</a>
</li>
</ul>
<?php
}
?>
</div>
<?php
}
示例6: render_field
//.........这里部分代码省略.........
}
?>
<tbody>
<?php
foreach ($field['value'] as $i => $row) {
?>
<tr class="acf-row<?php
echo $i === 'acfcloneindex' ? ' acf-clone' : '';
?>
">
<?php
if ($show_order) {
?>
<td class="order" title="<?php
_e('Drag to reorder', 'acf');
?>
"><?php
echo intval($i) + 1;
?>
</td>
<?php
}
?>
<?php
echo $before_fields;
?>
<?php
foreach ($field['sub_fields'] as $sub_field) {
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($row[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $row[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = "{$field['name']}[{$i}]";
// render input
acf_render_field_wrap($sub_field, $el);
?>
<?php
}
?>
<?php
echo $after_fields;
?>
<?php
if ($show_remove) {
?>
<td class="remove">
<a class="acf-icon small acf-repeater-add-row" href="#" data-before="1" title="<?php
_e('Add row', 'acf');
?>
"><i class="acf-sprite-add"></i></a>
<a class="acf-icon small acf-repeater-remove-row" href="#" title="<?php
_e('Remove row', 'acf');
?>
"><i class="acf-sprite-remove"></i></a>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
if ($show_add) {
?>
<ul class="acf-hl acf-clearfix">
<li class="acf-fr">
<a href="#" class="acf-button blue acf-repeater-add-row"><?php
echo $field['button_label'];
?>
</a>
</li>
</ul>
<?php
}
?>
</div>
<?php
}
示例7: render_layout
//.........这里部分代码省略.........
<?php
if ($layout['display'] == 'table') {
// update vars
$el = 'td';
?>
<table class="acf-table">
<thead>
<tr>
<?php
foreach ($layout['sub_fields'] as $sub_field) {
$atts = array('class' => "acf-th acf-th-{$sub_field['name']}", 'data-key' => $sub_field['key']);
// Add custom width
if ($sub_field['wrapper']['width']) {
$atts['data-width'] = $sub_field['wrapper']['width'];
}
?>
<th <?php
acf_esc_attr_e($atts);
?>
>
<?php
acf_the_field_label($sub_field);
?>
<?php
if ($sub_field['instructions']) {
?>
<p class="description"><?php
echo $sub_field['instructions'];
?>
</p>
<?php
}
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
} else {
?>
<div class="acf-fields <?php
if ($layout['display'] == 'row') {
?>
-left<?php
}
?>
">
<?php
}
?>
<?php
// loop though sub fields
foreach ($layout['sub_fields'] as $sub_field) {
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($value[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $value[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = "{$field['name']}[{$i}]";
// render input
acf_render_field_wrap($sub_field, $el);
}
?>
<?php
if ($layout['display'] == 'table') {
?>
</tbody>
</table>
<?php
} else {
?>
</div>
<?php
}
?>
<?php
}
?>
</div>
<?php
}
示例8: acf_render_field_wrap
// active
acf_render_field_wrap(array('label' => __('Status', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'active', 'prefix' => 'acf_field_group', 'value' => $field_group['active'], 'choices' => array(1 => __("Active", 'acf'), 0 => __("Disabled", 'acf'))));
// style
acf_render_field_wrap(array('label' => __('Style', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'style', 'prefix' => 'acf_field_group', 'value' => $field_group['style'], 'choices' => array('default' => __("Standard (WP metabox)", 'acf'), 'seamless' => __("Seamless (no metabox)", 'acf'))));
// position
acf_render_field_wrap(array('label' => __('Position', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'position', 'prefix' => 'acf_field_group', 'value' => $field_group['position'], 'choices' => array('acf_after_title' => __("High (after title)", 'acf'), 'normal' => __("Normal (after content)", 'acf'), 'side' => __("Side", 'acf')), 'default_value' => 'normal'));
// label_placement
acf_render_field_wrap(array('label' => __('Label placement', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'label_placement', 'prefix' => 'acf_field_group', 'value' => $field_group['label_placement'], 'choices' => array('top' => __("Top aligned", 'acf'), 'left' => __("Left Aligned", 'acf'))));
// instruction_placement
acf_render_field_wrap(array('label' => __('Instruction placement', 'acf'), 'instructions' => '', 'type' => 'select', 'name' => 'instruction_placement', 'prefix' => 'acf_field_group', 'value' => $field_group['instruction_placement'], 'choices' => array('label' => __("Below labels", 'acf'), 'field' => __("Below fields", 'acf'))));
// menu_order
acf_render_field_wrap(array('label' => __('Order No.', 'acf'), 'instructions' => __('Field groups with a lower order will appear first', 'acf'), 'type' => 'number', 'name' => 'menu_order', 'prefix' => 'acf_field_group', 'value' => $field_group['menu_order']));
// description
acf_render_field_wrap(array('label' => __('Description', 'acf'), 'instructions' => __('Shown in field group list', 'acf'), 'type' => 'text', 'name' => 'description', 'prefix' => 'acf_field_group', 'value' => $field_group['description']));
// hide on screen
acf_render_field_wrap(array('label' => __('Hide on screen', 'acf'), 'instructions' => __('<b>Select</b> items to <b>hide</b> them from the edit screen.', 'acf') . '<br /><br />' . __("If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)", 'acf'), 'type' => 'checkbox', 'name' => 'hide_on_screen', 'prefix' => 'acf_field_group', 'value' => $field_group['hide_on_screen'], 'toggle' => true, 'choices' => array('permalink' => __("Permalink", 'acf'), 'the_content' => __("Content Editor", 'acf'), 'excerpt' => __("Excerpt", 'acf'), 'custom_fields' => __("Custom Fields", 'acf'), 'discussion' => __("Discussion", 'acf'), 'comments' => __("Comments", 'acf'), 'revisions' => __("Revisions", 'acf'), 'slug' => __("Slug", 'acf'), 'author' => __("Author", 'acf'), 'format' => __("Format", 'acf'), 'page_attributes' => __("Page Attributes", 'acf'), 'featured_image' => __("Featured Image", 'acf'), 'categories' => __("Categories", 'acf'), 'tags' => __("Tags", 'acf'), 'send-trackbacks' => __("Send Trackbacks", 'acf'))));
// 3rd party settings
do_action('acf/render_field_group_settings', $field_group);
?>
<div class="acf-hidden">
<input type="hidden" name="acf_field_group[key]" value="<?php
echo $field_group['key'];
?>
" />
</div>
<script type="text/javascript">
if( typeof acf !== 'undefined' ) {
acf.postbox.render({
'id': 'acf-field-group-options',
'label': 'left'
示例9: acf_render_field_wrap
</ul>
<div class="field-settings">
<table class="acf-table">
<tbody>
<?php
// label
acf_render_field_wrap(array('label' => __('Field Label', 'acf'), 'instructions' => __('This is the name which will appear on the EDIT page', 'acf'), 'required' => 1, 'type' => 'text', 'name' => 'label', 'prefix' => $field['prefix'], 'value' => $field['label']), 'tr');
// name
acf_render_field_wrap(array('label' => __('Field Name', 'acf'), 'instructions' => __('Single word, no spaces. Underscores and dashes allowed', 'acf'), 'required' => 1, 'type' => 'text', 'name' => 'name', 'prefix' => $field['prefix'], 'value' => $field['name']), 'tr');
// type
acf_render_field_wrap(array('label' => __('Field Type', 'acf'), 'instructions' => '', 'required' => 1, 'type' => 'select', 'name' => 'type', 'prefix' => $field['prefix'], 'value' => $field['type'], 'choices' => acf_get_field_types()), 'tr');
// instructions
acf_render_field_wrap(array('label' => __('Instructions', 'acf'), 'instructions' => __('Instructions for authors. Shown when submitting data', 'acf'), 'type' => 'textarea', 'name' => 'instructions', 'prefix' => $field['prefix'], 'value' => $field['instructions']), 'tr');
// required
acf_render_field_wrap(array('label' => __('Required?', 'acf'), 'instructions' => '', 'type' => 'radio', 'name' => 'required', 'prefix' => $field['prefix'], 'value' => $field['required'], 'choices' => array(1 => __("Yes", 'acf'), 0 => __("No", 'acf')), 'layout' => 'horizontal'), 'tr');
// custom field options
acf_render_field_settings($field);
// load view
acf_get_view('field-group-field-conditional-logic', array('field' => $field));
?>
<tr class="field_save">
<td class="acf-label"></td>
<td class="acf-input">
<ul class="acf-hl acf-clearfix">
<li>
<a class="edit-field acf-button grey" title="<?php
_e("Close Field", 'acf');
?>
" href="#"><?php
_e("Close Field", 'acf');
示例10: acf_render_field_setting
function acf_render_field_setting($field, $setting, $global = false)
{
// vars
$atts = array();
// if this setting is not global, add a data attribute
if (!$global) {
$atts['data-setting'] = $field['type'];
}
// copy across prefix
$setting['prefix'] = $field['prefix'];
// copy across the $setting value
// Note: tab field contains no name for it's $setting (its just a message)
if (isset($setting['name'], $field[$setting['name']])) {
$setting['value'] = $field[$setting['name']];
}
// render
acf_render_field_wrap($setting, 'tr', 'label', $atts);
}
示例11: render_layout
//.........这里部分代码省略.........
$sub_field = acf_prepare_field($sub_field);
// bail ealry if no field
if (!$sub_field) {
continue;
}
// vars
$atts = array();
$atts['class'] = 'acf-th';
$atts['data-name'] = $sub_field['_name'];
$atts['data-type'] = $sub_field['type'];
$atts['data-key'] = $sub_field['key'];
// Add custom width
if ($sub_field['wrapper']['width']) {
$atts['data-width'] = $sub_field['wrapper']['width'];
$atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
}
?>
<th <?php
echo acf_esc_attr($atts);
?>
>
<?php
echo acf_get_field_label($sub_field);
?>
<?php
if ($sub_field['instructions']) {
?>
<p class="description"><?php
echo $sub_field['instructions'];
?>
</p>
<?php
}
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
} else {
?>
<div class="acf-fields <?php
if ($layout['display'] == 'row') {
?>
-left<?php
}
?>
">
<?php
}
?>
<?php
// loop though sub fields
foreach ($sub_fields as $sub_field) {
// prevent repeater field from creating multiple conditional logic items for each row
if ($i !== 'acfcloneindex') {
$sub_field['conditional_logic'] = 0;
}
// add value
if (isset($value[$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $value[$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
// update prefix to allow for nested values
$sub_field['prefix'] = $prefix;
// render input
acf_render_field_wrap($sub_field, $el);
}
?>
<?php
if ($layout['display'] == 'table') {
?>
</tbody>
</table>
<?php
} else {
?>
</div>
<?php
}
?>
<?php
}
?>
</div>
<?php
}
示例12: render_field_table
function render_field_table($field)
{
?>
<table class="acf-table">
<thead>
<tr>
<?php
foreach ($field['sub_fields'] as $sub_field) {
// prepare field (allow sub fields to be removed)
$sub_field = acf_prepare_field($sub_field);
// bail ealry if no field
if (!$sub_field) {
continue;
}
// vars
$atts = array();
$atts['class'] = 'acf-th';
$atts['data-name'] = $sub_field['_name'];
$atts['data-type'] = $sub_field['type'];
$atts['data-key'] = $sub_field['key'];
// Add custom width
if ($sub_field['wrapper']['width']) {
$atts['data-width'] = $sub_field['wrapper']['width'];
$atts['style'] = 'width: ' . $sub_field['wrapper']['width'] . '%;';
}
?>
<th <?php
acf_esc_attr_e($atts);
?>
>
<?php
echo acf_get_field_label($sub_field);
?>
<?php
if ($sub_field['instructions']) {
?>
<p class="description"><?php
echo $sub_field['instructions'];
?>
</p>
<?php
}
?>
</th>
<?php
}
?>
</tr>
</thead>
<tbody>
<tr class="acf-row">
<?php
foreach ($field['sub_fields'] as $sub_field) {
acf_render_field_wrap($sub_field, 'td');
}
?>
</tr>
</tbody>
</table>
<?php
}
示例13: render_field
public function render_field($field)
{
global $wp_widget_factory;
$widget = isset($field['value']) && isset($field['value']['the_widget']) ? $field['value']['the_widget'] : $field['widget'];
$the_widget = !empty($wp_widget_factory->widgets[$widget]) ? $wp_widget_factory->widgets[$widget] : false;
if (empty($the_widget)) {
return;
}
$the_widget->number = isset($field['value']) && isset($field['value']['number']) ? $field['value']['number'] : uniqid();
$the_widget->id = isset($field['value']) && isset($field['value']['widget_id']) ? $field['value']['widget_id'] : $the_widget->id_base . '-' . $the_widget->number;
$instance = apply_filters('widget_form_callback', isset($field['value']) && isset($field['value']['instance']) ? $field['value']['instance'] : array(), $the_widget);
if (false !== $instance) {
ob_start();
$the_widget->form($instance);
//do_action_ref_array( 'in_widget_form', array( &$the_widget, &$return, $instance ) );
$form = ob_get_clean();
// Convert the widget field naming into ones that Page Builder uses
$exp = preg_quote($the_widget->get_field_name('____'));
$exp = str_replace('____', '(.*?)', $exp);
$final = preg_replace('/' . $exp . '/', $field['name'] . '[widget_fields][$1]', $form);
echo $final;
}
//Now the regular widget fields are rendered.
//Render any additional fields that were added to the widget using advanced custom fields widget fields.
$el = 'div';
foreach ($field['sub_fields'] as $sub_field) {
// add value
if (isset($field['value'][$sub_field['key']])) {
// this is a normal value
$sub_field['value'] = $field['value'][$sub_field['key']];
} elseif (isset($sub_field['default_value'])) {
// no value, but this sub field has a default value
$sub_field['value'] = $sub_field['default_value'];
}
//Setup a field prefix so in our update value function we can grab the correct info.
$sub_field['prefix'] = "{$field['name']}";
acf_render_field_wrap($sub_field, $el);
}
}
示例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;
}
示例15: _e
<p><?php
_e('Select the field groups you would like to export and then select your export method. Use the download button to export to a .json file which you can then import to another ACF installation. Use the generate button to export to PHP code which you can place in your theme.', 'acf');
?>
</p>
<form method="post" action="">
<div class="acf-hidden">
<input type="hidden" name="_acfnonce" value="<?php
echo wp_create_nonce('export');
?>
" />
</div>
<table class="form-table">
<tbody>
<?php
acf_render_field_wrap($field, 'tr');
?>
<tr>
<th></th>
<td>
<input type="submit" name="download" class="acf-button blue" value="<?php
_e('Download export file', 'acf');
?>
" />
<input type="submit" name="generate" class="acf-button blue" value="<?php
_e('Generate export code', 'acf');
?>
" />
</td>
</tr>
</tbody>