in web/wp-content/plugins/acf-extended/includes/modules/option/module-option.php [326:584]
function add_metaboxes(){
$option = array(
'option_id' => 0,
'option_name' => '',
'option_value' => '',
'autoload' => 'no',
);
$option_id = absint(acfe_maybe_get_REQUEST('option'));
if($option_id){
global $wpdb;
$get_option = $wpdb->get_row("SELECT * FROM {$wpdb->options} WHERE option_id = '$option_id'", 'ARRAY_A');
if(!empty($get_option)){
$option = $get_option;
}
}
$field_group = array(
'ID' => 0,
'key' => 'group_acfe_options_edit',
'style' => 'default',
'label_placement' => 'left',
'instruction_placement' => 'label',
'fields' => array()
);
$fields = array();
$fields[] = array(
'label' => __('Name', 'acfe'),
'key' => 'field_acfe_options_edit_name',
'name' => 'field_acfe_options_edit_name',
'type' => 'text',
'prefix' => 'acf',
'instructions' => '',
'required' => true,
'conditional_logic' => false,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'value' => $option['option_name'],
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
);
// serialized || html
if(is_serialized($option['option_value']) || $option['option_value'] != strip_tags($option['option_value'])){
$type = 'serialized';
$instructions = 'Use this <a href="https://duzun.me/playground/serialize" target="_blank">online tool</a> to unserialize/seriliaze data.';
if($option['option_value'] != strip_tags($option['option_value'])){
$type = 'HTML';
$instructions = '';
}
$fields[] = array(
'label' => __('Value', 'acfe') . ' <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>',
'key' => 'field_acfe_options_edit_value',
'name' => 'field_acfe_options_edit_value',
'type' => 'textarea',
'prefix' => 'acf',
'instructions' => $instructions,
'required' => false,
'conditional_logic' => false,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'value' => $option['option_value'],
'class' => 'code',
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
);
}
// json
elseif(acfe_is_json($option['option_value'])){
$type = 'json';
$instructions = 'Use this <a href="http://solutions.weblite.ca/php2json/" target="_blank">online tool</a> to decode/encode json.';
$fields[] = array(
'label' => __('Value', 'acfe') . ' <code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">' . $type . '</code>',
'key' => 'field_acfe_options_edit_value',
'name' => 'field_acfe_options_edit_value',
'type' => 'textarea',
'prefix' => 'acf',
'instructions' => $instructions,
'required' => false,
'conditional_logic' => false,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'value' => $option['option_value'],
'class' => 'code',
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
);
}
// string
else{
$type = '';
if(!empty($option['option_value'])){
$type = '<code style="font-size:11px;float:right; line-height:1.2; margin-top:1px;">string</code>';
}
$fields[] = array(
'label' => __('Value', 'acfe') . ' ' . $type,
'key' => 'field_acfe_options_edit_value',
'name' => 'field_acfe_options_edit_value',
'type' => 'textarea',
'prefix' => 'acf',
'instructions' => '',
'required' => false,
'conditional_logic' => false,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'value' => $option['option_value'],
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
);
}
$fields[] = array(
'label' => __('Autoload', 'acfe'),
'key' => 'field_acfe_options_edit_autoload',
'name' => 'field_acfe_options_edit_autoload',
'type' => 'select',
'prefix' => 'acf',
'instructions' => '',
'required' => true,
'conditional_logic' => false,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
'value' => $option['autoload'],
'choices' => array(
'no' => __('No', 'acfe'),
'yes' => __('Yes', 'acfe'),
),
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
);
$field_group['fields'] = $fields;
$metabox_submit_title = __('Submit', 'acf');
$metabox_main_title = __('Add Option', 'acfe');
if(!empty($option['option_id'])){
$metabox_submit_title = __('Edit', 'acf');
$metabox_main_title = __('Edit Option', 'acfe');
}
// submit Metabox
add_meta_box('submitdiv', $metabox_submit_title, function($post, $args) use($option){
$delete_nonce = wp_create_nonce('acfe_options_delete_option');
?>
<div id="major-publishing-actions">
<?php if(!empty($option['option_id'])){ ?>
<div id="delete-action">
<a class="submitdelete deletion" style="color:#a00;" href="<?php echo sprintf('?page=%s&action=%s&option=%s&_wpnonce=%s', esc_attr($_REQUEST['page']), 'delete', $option['option_id'], $delete_nonce); ?>">
<?php _e('Delete'); ?>
</a>
</div>
<?php } ?>
<div id="publishing-action">
<span class="spinner"></span>
<input type="submit" accesskey="p" value="<?php _e('Update'); ?>" class="button button-primary button-large" id="publish" name="publish">
</div>
<div class="clear"></div>
</div>
<?php
}, 'acf_options_page', 'side', 'high');
// main metabox
add_meta_box('acf-group_acfe_options_edit', $metabox_main_title, function($post, $args){
// extract args
extract($args); // all variables from the add_meta_box function
extract($args); // all variables from the args argument
// vars
$o = array(
'id' => $id,
'key' => $field_group['key'],
'style' => $field_group['style'],
'label' => $field_group['label_placement'],
'editLink' => '',
'editTitle' => __('Edit field group', 'acf'),
'visibility' => true
);
// load fields
$fields = $field_group['fields'];
// render
acf_render_fields($fields, 'acfe-options-edit', 'div', $field_group['instruction_placement']);
?>
<script type="text/javascript">
if(typeof acf !== 'undefined'){
acf.newPostbox(<?php echo json_encode($o); ?>);
}
</script>
<?php
}, 'acf_options_page', 'normal', 'high', array('field_group' => $field_group));
}