true), 'objects'); $filtered_post_types = array_filter($all_post_types, function($post_type) { return !in_array($post_type->name, array('page', 'attachment')); }); ?>

' . __('Security check failed. Please try again.', 'ait-easy-post-customization') . ''; return; } $custom_fields = get_option('aitepc_custom_fields', array()); $action = sanitize_text_field(wp_unslash($_POST['aitepc_custom_fields_action'])); if ($action === 'add' || $action === 'edit') { $key = sanitize_key(wp_unslash($_POST['field_key'])); $label = sanitize_text_field(wp_unslash($_POST['field_label'])); $type = sanitize_text_field(wp_unslash($_POST['field_type'])); $post_types = isset($_POST['field_post_types']) ? array_map('sanitize_text_field', wp_unslash($_POST['field_post_types'])) : []; if (empty($key) || empty($label) || empty($type)) { echo ''; return; } if ($action === 'add' && array_key_exists($key, $custom_fields)) { echo ''; return; } $custom_fields[$key] = array( 'label' => $label, 'type' => $type, 'post_types' => $post_types ); update_option('aitepc_custom_fields', $custom_fields); echo ''; } elseif ($action === 'delete') { $key = sanitize_key(wp_unslash($_POST['field_key'])); if (array_key_exists($key, $custom_fields)) { unset($custom_fields[$key]); update_option('aitepc_custom_fields', $custom_fields); echo ''; } } } // Function to display custom fields management function aitepc_display_custom_fields_form($filtered_post_types) { $custom_fields = get_option('aitepc_custom_fields', array()); $edit_key = isset($_GET['edit']) ? sanitize_key($_GET['edit']) : ''; $edit_field = $edit_key && isset($custom_fields[$edit_key]) ? $custom_fields[$edit_key] : null; ?>

pattern="[a-z0-9_]+">
name, $edit_field['post_types']) ? 'checked="checked"' : ''; ?>
id="field_name); ?>">

$field) : ?>