Definition:
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {}
sample permalink html
intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
Parameters
- int|object $id: Post ID or post object.
- string $new_title: (optional) New title
- string $new_slug: (optional) New slug
Return values
returns:intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
Defined filters
- get_sample_permalink_html
apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug)
- get_sample_permalink_html
apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug)
Source code
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { global $wpdb; $post = &get_post($id); list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); if ( 'publish' == $post->post_status ) { $ptype = get_post_type_object($post->post_type); $view_post = $ptype->labels->view_item; $title = __('Click to edit this part of the permalink'); } else { $title = __('Temporary permalink. Click to edit this part.'); } if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n"; if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; if ( isset($view_post) ) $return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n"; $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); return $return; } if ( function_exists('mb_strlen') ) { if ( mb_strlen($post_name) > 30 ) { $post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14); } else { $post_name_abridged = $post_name; } } else { if ( strlen($post_name) > 30 ) { $post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14); } else { $post_name_abridged = $post_name; } } $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; $display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink); $view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink); $return = '<strong>' . __('Permalink:') . "</strong>\n"; $return .= '<span id="sample-permalink">' . $display_link . "</span>\n"; $return .= '‎'; // Fix bi-directional text display defect in RTL languages. $return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n"; $return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n"; if ( isset($view_post) ) $return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n"; $return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug); return $return; }
1667
No comments yet... Be the first to leave a reply!