Changeset 18680 for trunk/wp-includes/link-template.php
- Timestamp:
- 09/15/2011 04:54:59 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r18639 r18680 1301 1301 1302 1302 /** 1303 * Get boundary post relational link.1304 *1305 * Can either be start or end post relational link.1306 *1307 * @since 2.8.01308 *1309 * @param string $title Optional. Link title format.1310 * @param bool $in_same_cat Optional. Whether link should be in same category.1311 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.1312 * @param bool $start Optional, default is true. Whether display link to first or last post.1313 * @return string1314 */1315 function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {1316 $posts = get_boundary_post($in_same_cat, $excluded_categories, $start);1317 // If there is no post stop.1318 if ( empty($posts) )1319 return;1320 1321 // Even though we limited get_posts to return only 1 item it still returns an array of objects.1322 $post = $posts[0];1323 1324 if ( empty($post->post_title) )1325 $post->post_title = $start ? __('First Post') : __('Last Post');1326 1327 $date = mysql2date(get_option('date_format'), $post->post_date);1328 1329 $title = str_replace('%title', $post->post_title, $title);1330 $title = str_replace('%date', $date, $title);1331 $title = apply_filters('the_title', $title, $post->ID);1332 1333 $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";1334 $link .= esc_attr($title);1335 $link .= "' href='" . get_permalink($post) . "' />\n";1336 1337 $boundary = $start ? 'start' : 'end';1338 return apply_filters( "{$boundary}_post_rel_link", $link );1339 }1340 1341 /**1342 * Display relational link for the first post.1343 *1344 * @since 2.8.01345 *1346 * @param string $title Optional. Link title format.1347 * @param bool $in_same_cat Optional. Whether link should be in same category.1348 * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.1349 */1350 function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {1351 echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true);1352 }1353 1354 /**1355 * Get site index relational link.1356 *1357 * @since 2.8.01358 *1359 * @return string1360 */1361 function get_index_rel_link() {1362 $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n";1363 return apply_filters( "index_rel_link", $link );1364 }1365 1366 /**1367 * Display relational link for the site index.1368 *1369 * @since 2.8.01370 */1371 function index_rel_link() {1372 echo get_index_rel_link();1373 }1374 1375 /**1376 * Get parent post relational link.1377 *1378 * @since 2.8.01379 *1380 * @param string $title Optional. Link title format.1381 * @return string1382 */1383 function get_parent_post_rel_link($title = '%title') {1384 if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) )1385 $post = & get_post($GLOBALS['post']->post_parent);1386 1387 if ( empty($post) )1388 return;1389 1390 $date = mysql2date(get_option('date_format'), $post->post_date);1391 1392 $title = str_replace('%title', $post->post_title, $title);1393 $title = str_replace('%date', $date, $title);1394 $title = apply_filters('the_title', $title, $post->ID);1395 1396 $link = "<link rel='up' title='";1397 $link .= esc_attr( $title );1398 $link .= "' href='" . get_permalink($post) . "' />\n";1399 1400 return apply_filters( "parent_post_rel_link", $link );1401 }1402 1403 /**1404 * Display relational link for parent item1405 *1406 * @since 2.8.01407 */1408 function parent_post_rel_link($title = '%title') {1409 echo get_parent_post_rel_link($title);1410 }1411 1412 /**1413 1303 * Display previous post link that is adjacent to the current post. 1414 1304 *
Note: See TracChangeset
for help on using the changeset viewer.