//Custom Functions to Extend the WordPress Custom Field Bulk Editor Plugin
//These files can go in a plugin or in functions.php
//First Function Adds Lines Before Built-in Custom Field Lines
function add_my_custom_lines($post_type) {
//If you only want to add this functionality to pages, you can use this to bail on the function if it isn't "page"
if ($post_type != 'page') return;
//Write special code for each line you want to add
?>
<tr>
<td>
<?php $field_name = "my_custom_field_1"; ?>
<label for="<?php echo $field_name; ?>" class="cfbe_special_label"><?php _e('My Custom Field 1'); ?></label>
<input type="radio" name="<?php echo $field_name; ?>_status" id="<?php echo $field_name; ?>_status0" value="0" checked="checked" />
<label for="<?php echo $field_name; ?>_status0" class="cfbe_leave_unchanged"><?php _e("Leave Unchanged"); ?></label>
<input type="radio" name="<?php echo $field_name; ?>_status" id="<?php echo $field_name; ?>_status1" value="1" />
<label for="<?php echo $field_name; ?>_status1"><?php _e("Change To"); ?>:</label>
<input type="text" name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" value="" class="cfbe_field_name no_right_margin" onfocus="jQuery('#<?php echo $field_name; ?>_status1').prop('checked', true);" />
<small>Reminder What This Field Is For</small>
<div style="clear: both;"></div>
</td>
</tr>
<tr>
<td>
<?php $field_name = "my_custom_field_2"; ?>
<label for="<?php echo $field_name; ?>" class="cfbe_special_label"><?php _e('My Custom Field 2'); ?></label>
<input type="radio" name="<?php echo $field_name; ?>_status" id="<?php echo $field_name; ?>_status0" value="0" checked="checked" />
<label for="<?php echo $field_name; ?>_status0" class="cfbe_leave_unchanged"><?php _e("Leave Unchanged"); ?></label>
<input type="radio" name="<?php echo $field_name; ?>_status" id="<?php echo $field_name; ?>_status1" value="1" />
<label for="<?php echo $field_name; ?>_status1"><?php _e("Change To"); ?>:</label>
<input type="text" name="<?php echo $field_name; ?>" id="<?php echo $field_name; ?>" value="" class="cfbe_field_name no_right_margin" onfocus="jQuery('#<?php echo $field_name; ?>_status1').prop('checked', true);" />
<small>Special Instructions For Field</small>
<div style="clear: both;"></div>
</td>
</tr>
<?php
}
//Assign to Action (before built in lines)
//To do you own metabox, the action is 'cfbe_before_metabox'
add_action('cfbe_before_fields', 'add_my_custom_lines');
//Function to run on every post being updated. Process your special custom fields here.
function save_my_custom_fields($post_type, $post_id) {
//Optional. Bail if this isn't for pages
//Useful for your own Custom Post Type
if ($post_type != "page") return;
//Save Your Fields
$field_name = "my_custom_field_1";
if ($_POST[$field_name] == 1) {
cfbe_save_meta_data($field_name, $_POST[$field_name]);
}
$field_name = "my_custom_field_2";
if ($_POST[$field_name] == 1) {
cfbe_save_meta_data($field_name, $_POST[$field_name]);
}
}
//Add Save Action
add_action('cfbe_save_fields', 'save_my_custom_fields', 10, 2);