Goal
When a user asks for modifying, extending, or adding admin-side listing edit features (e.g., expiry date, toggle options, extra metadata) in the bulk edit or quick edit panel, generate a structured solution using the same pattern shown below.
Use Case Pattern
User Request Example:
"I want to bulk update the expiration date for Directorist listings and also have an option to make them never expire."
Core Concept
Directorist listings are stored under
post_type = at_biz_dir.WordPress allows custom fields in bulk_edit_custom_box and quick_edit_custom_box.
You can add new inputs like checkbox, datetime picker, dropdown, etc.
Save the data using
save_postand use meta keys like_never_expire,_expiry_date.
Complete Sample Solution
1. Hook Into the Edit Box
add_filter('bulk_edit_custom_box', 'directorist_custom_box_never_expire', 10, 2);
add_filter('quick_edit_custom_box', 'directorist_custom_box_never_expire', 10, 2);
function directorist_custom_box_never_expire($column_name, $post_type) {
if ($column_name === 'atbdp_date' && $post_type === ATBDP_POST_TYPE) {
?>
<fieldset class="inline-edit-col-right">
<div class="misc-pub-section misc-pub-atbdp-never-expires">
<label>
<input type="checkbox" name="never_expire" value="1" />
<strong>Never Expires</strong>
</label>
<div class="atbdp_expiry_date">
<label><strong>Expiry Date</strong></label>
<input type="datetime-local" name="expiry_date" />
</div>
</div>
</fieldset>
<?php
}
}2. Save the Data When Listings Are Updated
add_action('save_post', 'directorist_custom_box_never_expire_save');
function directorist_custom_box_never_expire_save($post_id) {
if (!is_admin()) return;
if (get_post_type($post_id) !== ATBDP_POST_TYPE) return;
if (!current_user_can('edit_posts')) return;
// Handle "Never Expire"
if (!empty($_REQUEST['never_expire'])) {
update_post_meta($post_id, '_never_expire', sanitize_text_field($_REQUEST['never_expire']));
}
// Handle Expiry Date
if (!empty($_REQUEST['expiry_date'])) {
update_post_meta($post_id, '_expiry_date', sanitize_text_field($_REQUEST['expiry_date']));
update_post_meta($post_id, '_never_expire', 0); // Unset never expire
}
}3. Optional JavaScript (Dynamic Toggle)
add_action('admin_footer', function() {
?>
<script>
jQuery(document).ready(function($){
$('.misc-pub-atbdp-never-expires input[name="never_expire"]').change(function(){
if ($(this).is(":checked")) {
$('.misc-pub-atbdp-never-expires .atbdp_expiry_date').hide();
$('.misc-pub-atbdp-never-expires input[name="expiry_date"]').val('');
} else {
$('.misc-pub-atbdp-never-expires .atbdp_expiry_date').show();
}
});
});
</script>
<?php
});Guidelines for Reuse
When a user asks for a similar customization for Directorist listings in the WordPress admin:
Check for request intent:
Is it about mass/bulk updating data?
Does it relate to admin listing table, edit panel, or expiration logic?
Follow this structure:
Use
bulk_edit_custom_box/quick_edit_custom_boxto inject fieldsUse
save_postto store the metadataOptional: JS to dynamically show/hide fields based on user action
Use custom meta keys with a naming pattern:
_custom_field_nameAlways verify post type with
ATBDP_POST_TYPEconstant to restrict changes only to listings.Check for permissions with
current_user_can('edit_posts')
🔁 Future Examples AI Can Handle
User Wants To... | Hook into | Meta Key | Field Type |
|---|---|---|---|
Set listing priority |
|
| dropdown |
Mark listing as urgent |
|
| checkbox |
Tag listings with agent name |
|
| text input |
Set visibility level |
|
| select (public/private) |
Testing Tips
Use admin bulk edit from Listings → All Listings
Modify multiple listings to test save logic
Check saved data in listing post meta via Custom Fields or programmatically
Summary
This solution enables AI (like ChatGPT) to provide repeatable patterns for customizing admin listing edit behavior in Directorist. When users request feature additions to the admin interface for listings, follow this 3-part structure:
UI field injection in
bulk_edit_custom_box/quick_edit_custom_boxData saving via
save_postOptional admin JS for field interactions
Let me know if you'd like this packaged as a training file, markdown doc, or embedded into your plugin developer portal.