This post will be automatically generated using artificial intelligence in background process.
";
echo "
";
if ($value_date) {
echo "
";
echo "
Last generation: " . esc_html($value_date) . "
";
echo "
";
}
}
// Save custom fields
add_action('save_post', 'ai_content_x_save_postdata');
function ai_content_x_save_postdata($post_id)
{
// Only save custom fields if the user has the right permissions
if (!current_user_can('manage_options')) {
return;
}
// Check if our nonce is set.
if (!isset($_POST['ai_content_x_queue_box_nonce'])) {
return;
}
// Verify that the nonce is valid.
if (!wp_verify_nonce($_POST['ai_content_x_queue_box_nonce'], 'ai_content_x_queue_box')) {
return;
}
// If this is an autosave, our form has not been submitted,
// so we don't want to do anything.
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// Check the user's permissions.
if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return;
}
} else {
if (!current_user_can('edit_post', $post_id)) {
return;
}
}
// Sanitize user input.
$my_data = sanitize_text_field($_POST['_ai_content_x_queue']);
// Update the meta field in the database.
update_post_meta($post_id, '_ai_content_x_queue', $my_data);
}