wp_ajax_sample_permalink() WordPress Function
The wp_ajax_sample_permalink() function is used to create a sample permalink for a post. This is typically used when the user is creating a new post, and the permalink field is empty. This function will take the post title and generate a permalink based on it. This is just a sample permalink, and the user can still change it if they want.
wp_ajax_sample_permalink() #
Ajax handler to retrieve a sample permalink.
Source
File: wp-admin/includes/ajax-actions.php
function wp_ajax_sample_permalink() {
check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
$post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
$title = isset( $_POST['new_title'] ) ? $_POST['new_title'] : '';
$slug = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null;
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |