get_sample_permalink [ WordPress Function ]
get_sample_permalink ( $id, $title = null, $name = null )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: get_sample_permalink_html, get_permalink, get_post_permalink, get_blog_permalink, wp_ajax_sample_permalink
{@internal Missing Short Description}}
Source
<?php
function get_sample_permalink($id, $title = null, $name = null) {
$post = &get_post($id);
if ( !$post->ID )
return array('', '');
$ptype = get_post_type_object($post->post_type);
$original_status = $post->post_status;
$original_date = $post->post_date;
$original_name = $post->post_name;
// Hack: get_permalink would return ugly permalink for
// drafts, so we will fake, that our post is published
if ( in_array($post->post_status, array('draft', 'pending')) ) {
$post->post_status = 'publish';
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
}
// If the user wants to set a new name -- override the current one
// Note: if empty name is supplied -- use the title instead, see #6072
if ( !is_null($name) )
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
$post->filter = 'sample';
$permalink = get_permalink($post, true);
// Replace custom post_type Token with generic pagename token for ease of use.
$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
// Handle page hierarchy
if ( $ptype->hierarchical ) {
$uri = get_page_uri($post);
$uri = untrailingslashit($uri);
$uri = strrev( stristr( strrev( $uri ), '/' ) );
$uri = untrailingslashit($uri);
$uri = apply_filters( 'editable_slug', $uri );
if ( !empty($uri) )
$uri .= '/';
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
}
$permalink = array($permalink, apply_filters('editable_slug', $post->post_name));
$post->post_status = $original_status;
$post->post_date = $original_date;
$post->post_name = $original_name;
unset($post->filter);
return $permalink;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/get sample permalink « WordPress Codex
Function Reference/get sample permalink ... Source File. get_sample_permalink( ) is located in wp-admin/includes/post.php. Retrieved from ...
codex.wordpress.org - get_sample_permalink
Function and Method Cross Reference. get_sample_permalink(). Defined at: /wp- admin/includes/post.php -> line 1002. Referenced 1 times: ...
phpxref.ftwr.co.uk - get_sample_permalink | A HitchHackers guide through WordPress
Feb 12, 2011 ... Source code. function get_sample_permalink($id, $title = null, $name = null) { $ post = &get_post($id); if ( !$post->ID ) return array('', ''); $ptype ...
hitchhackerguide.com - The Geek Professor » Hack Wordpress to Make Postnames Always ...
Nov 7, 2009... $new_slug=null) { $post = &get_post($id); list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); if (false ...
www.thegeekprofessor.com