Changeset 10525 for trunk/wp-includes/link-template.php
- Timestamp:
- 02/08/2009 01:38:02 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/link-template.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r10426 r10525 93 93 ); 94 94 95 if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) 95 if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter ) { 96 96 $post = $id; 97 else 97 $sample = true; 98 } else { 98 99 $post = &get_post($id); 100 $sample = false; 101 } 99 102 100 103 if ( empty($post->ID) ) return false; 101 104 102 105 if ( $post->post_type == 'page' ) 103 return get_page_link($post->ID, $leavename );106 return get_page_link($post->ID, $leavename, $sample); 104 107 elseif ($post->post_type == 'attachment') 105 108 return get_attachment_link($post->ID); … … 178 181 * 179 182 * @param int $id Optional. Post ID. 180 * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name. 181 * @return string 182 */ 183 function get_page_link($id = false, $leavename = false) { 183 * @param bool $leavename Optional, defaults to false. Whether to keep page name. 184 * @param bool $sample Optional, defaults to false. Is it a sample permalink. 185 * @return string 186 */ 187 function get_page_link( $id = false, $leavename = false, $sample = false ) { 184 188 global $post; 185 189 … … 191 195 $link = get_option('home'); 192 196 else 193 $link = _get_page_link( $id , $leavename );197 $link = _get_page_link( $id , $leavename, $sample ); 194 198 195 199 return apply_filters('page_link', $link, $id); … … 206 210 * @param int $id Optional. Post ID. 207 211 * @param bool $leavename Optional. Leave name. 208 * @return string 209 */ 210 function _get_page_link( $id = false, $leavename = false ) { 212 * @param bool $sample Optional. Sample permalink. 213 * @return string 214 */ 215 function _get_page_link( $id = false, $leavename = false, $sample = false ) { 211 216 global $post, $wp_rewrite; 212 217 … … 218 223 $pagestruct = $wp_rewrite->get_page_permastruct(); 219 224 220 if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status) {225 if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status ) || $sample ) ) { 221 226 $link = get_page_uri($id); 222 227 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)