Changes from tags/4.0/src/wp-includes/link-template.php at r59508 to tags/3.9.2/src/wp-includes/link-template.php at r59508
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/3.9.2/src/wp-includes/link-template.php
r59508 r59508 137 137 138 138 if ( $post->post_type == 'page' ) 139 return get_page_link($post , $leavename, $sample);139 return get_page_link($post->ID, $leavename, $sample); 140 140 elseif ( $post->post_type == 'attachment' ) 141 return get_attachment_link( $post , $leavename );141 return get_attachment_link( $post->ID, $leavename ); 142 142 elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) 143 return get_post_permalink($post , $leavename, $sample);143 return get_post_permalink($post->ID, $leavename, $sample); 144 144 145 145 $permalink = get_option('permalink_structure'); … … 291 291 * @since 1.0.0 292 292 * 293 * @param int |WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.293 * @param int $post_id Optional. Post ID. 294 294 * @param mixed $deprecated Not used. 295 295 * @return string … … 1197 1197 * @since 1.0.0 1198 1198 * 1199 * @param string $ textOptional. Anchor text.1199 * @param string $link Optional. Anchor text. 1200 1200 * @param string $before Optional. Display before edit link. 1201 1201 * @param string $after Optional. Display after edit link. 1202 1202 * @param int $id Optional. Post ID. 1203 1203 */ 1204 function edit_post_link( $ text= null, $before = '', $after = '', $id = 0 ) {1205 if ( ! $post = get_post( $id ) ) {1204 function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) { 1205 if ( !$post = get_post( $id ) ) 1206 1206 return; 1207 } 1208 1209 if ( ! $url = get_edit_post_link( $post->ID ) ) { 1207 1208 if ( !$url = get_edit_post_link( $post->ID ) ) 1210 1209 return; 1211 } 1212 1213 if ( null === $text ) { 1214 $text = __( 'Edit This' ); 1215 } 1216 1217 $link = '<a class="post-edit-link" href="' . $url . '">' . $text . '</a>'; 1210 1211 if ( null === $link ) 1212 $link = __('Edit This'); 1213 1214 $post_type_obj = get_post_type_object( $post->post_type ); 1215 $link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>'; 1218 1216 1219 1217 /** … … 1224 1222 * @param string $link Anchor tag for the edit link. 1225 1223 * @param int $post_id Post ID. 1226 * @param string $text Anchor text. 1227 */ 1228 echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after; 1224 */ 1225 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; 1229 1226 } 1230 1227 … … 1302 1299 * @since 1.0.0 1303 1300 * 1304 * @param string $ textOptional. Anchor text.1301 * @param string $link Optional. Anchor text. 1305 1302 * @param string $before Optional. Display before edit link. 1306 1303 * @param string $after Optional. Display after edit link. 1307 1304 */ 1308 function edit_comment_link( $ text= null, $before = '', $after = '' ) {1305 function edit_comment_link( $link = null, $before = '', $after = '' ) { 1309 1306 global $comment; 1310 1307 1311 if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {1308 if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) 1312 1309 return; 1313 } 1314 1315 if ( null === $text ) { 1316 $text = __( 'Edit This' ); 1317 } 1318 1319 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $text . '</a>'; 1310 1311 if ( null === $link ) 1312 $link = __('Edit This'); 1313 1314 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>'; 1320 1315 1321 1316 /** … … 1326 1321 * @param string $link Anchor tag for the edit link. 1327 1322 * @param int $comment_id Comment ID. 1328 * @param string $text Anchor text. 1329 */ 1330 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after; 1323 */ 1324 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; 1331 1325 } 1332 1326 … … 1478 1472 1479 1473 $join = ''; 1480 $where = ''; 1481 1474 $posts_in_ex_terms_sql = ''; 1482 1475 if ( $in_same_term || ! empty( $excluded_terms ) ) { 1483 1476 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 1484 $where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );1485 1486 if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {1487 // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "1488 if ( false !== strpos( $excluded_terms, ' and ' ) ) {1489 _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );1490 $excluded_terms = explode( ' and ', $excluded_terms );1491 } else {1492 $excluded_terms = explode( ',', $excluded_terms );1493 }1494 1495 $excluded_terms = array_map( 'intval', $excluded_terms );1496 }1497 1477 1498 1478 if ( $in_same_term ) { … … 1500 1480 return ''; 1501 1481 $term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) ); 1502 1503 // Remove any exclusions from the term array to include.1504 $term_array = array_diff( $term_array, (array) $excluded_terms );1505 $term_array = array_map( 'intval', $term_array );1506 1507 1482 if ( ! $term_array || is_wp_error( $term_array ) ) 1508 1483 return ''; 1509 1510 $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; 1484 $join .= $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id IN (" . implode( ',', array_map( 'intval', $term_array ) ) . ")", $taxonomy ); 1511 1485 } 1512 1486 1487 $posts_in_ex_terms_sql = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); 1513 1488 if ( ! empty( $excluded_terms ) ) { 1514 $where .= " AND p.ID NOT IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (" . implode( $excluded_terms, ',' ) . ') )'; 1489 if ( ! is_array( $excluded_terms ) ) { 1490 // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " 1491 if ( false !== strpos( $excluded_terms, ' and ' ) ) { 1492 _deprecated_argument( __FUNCTION__, '3.3', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); 1493 $excluded_terms = explode( ' and ', $excluded_terms ); 1494 } else { 1495 $excluded_terms = explode( ',', $excluded_terms ); 1496 } 1497 } 1498 1499 $excluded_terms = array_map( 'intval', $excluded_terms ); 1500 1501 if ( ! empty( $term_array ) ) { 1502 $excluded_terms = array_diff( $excluded_terms, $term_array ); 1503 $posts_in_ex_terms_sql = ''; 1504 } 1505 1506 if ( ! empty( $excluded_terms ) ) { 1507 $posts_in_ex_terms_sql = $wpdb->prepare( " AND tt.taxonomy = %s AND tt.term_id NOT IN (" . implode( $excluded_terms, ',' ) . ')', $taxonomy ); 1508 } 1515 1509 } 1516 1510 } … … 1546 1540 * @param array $excluded_terms Array of excluded term IDs. 1547 1541 */ 1548 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $ where", $current_post_date, $post->post_type), $in_same_term, $excluded_terms );1542 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_terms_sql", $current_post_date, $post->post_type), $in_same_term, $excluded_terms ); 1549 1543 1550 1544 /** … … 1656 1650 */ 1657 1651 function adjacent_posts_rel_link_wp_head() { 1658 if ( ! is_single() || is_attachment() ) {1652 if ( !is_singular() || is_attachment() ) 1659 1653 return; 1660 }1661 1654 adjacent_posts_rel_link(); 1662 1655 } … … 1760 1753 * @return string 1761 1754 */ 1762 function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_ term= false, $excluded_terms = '', $taxonomy = 'category' ) {1763 return get_adjacent_post_link( $format, $link, $in_same_ term, $excluded_terms, true, $taxonomy );1755 function get_previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 1756 return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, true, $taxonomy ); 1764 1757 } 1765 1758 … … 1776 1769 * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. 1777 1770 */ 1778 function previous_post_link( $format = '« %link', $link = '%title', $in_same_ term= false, $excluded_terms = '', $taxonomy = 'category' ) {1779 echo get_previous_post_link( $format, $link, $in_same_ term, $excluded_terms, $taxonomy );1771 function previous_post_link( $format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 1772 echo get_previous_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy ); 1780 1773 } 1781 1774 … … 1792 1785 * @return string 1793 1786 */ 1794 function get_next_post_link( $format = '%link »', $link = '%title', $in_same_ term= false, $excluded_terms = '', $taxonomy = 'category' ) {1795 return get_adjacent_post_link( $format, $link, $in_same_ term, $excluded_terms, false, $taxonomy );1787 function get_next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 1788 return get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, false, $taxonomy ); 1796 1789 } 1797 1790 … … 1808 1801 * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. 1809 1802 */ 1810 function next_post_link( $format = '%link »', $link = '%title', $in_same_ term= false, $excluded_terms = '', $taxonomy = 'category' ) {1811 echo get_next_post_link( $format, $link, $in_same_ term, $excluded_terms, $taxonomy );1803 function next_post_link( $format = '%link »', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ) { 1804 echo get_next_post_link( $format, $link, $in_same_cat, $excluded_terms, $taxonomy ); 1812 1805 } 1813 1806 … … 1827 1820 * @return string 1828 1821 */ 1829 function get_adjacent_post_link( $format, $link, $in_same_ term= false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {1822 function get_adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 1830 1823 if ( $previous && is_attachment() ) 1831 1824 $post = get_post( get_post()->post_parent ); 1832 1825 else 1833 $post = get_adjacent_post( $in_same_ term, $excluded_terms, $previous, $taxonomy );1826 $post = get_adjacent_post( $in_same_cat, $excluded_terms, $previous, $taxonomy ); 1834 1827 1835 1828 if ( ! $post ) { … … 1883 1876 * @param string $format Link anchor format. 1884 1877 * @param string $link Link permalink format. 1885 * @param bool $in_same_ term Optional. Whether link should be in a same taxonomy term.1878 * @param bool $in_same_cat Optional. Whether link should be in a same category. 1886 1879 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs. 1887 1880 * @param bool $previous Optional. Whether to display link to previous or next post. Default true. … … 1889 1882 * @return string 1890 1883 */ 1891 function adjacent_post_link( $format, $link, $in_same_ term= false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {1892 echo get_adjacent_post_link( $format, $link, $in_same_ term, $excluded_terms, $previous, $taxonomy );1884 function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) { 1885 echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_terms, $previous, $taxonomy ); 1893 1886 } 1894 1887 … … 2627 2620 2628 2621 /** 2629 * Retrieve a URL within the plugins or mu-plugins directory. 2630 * 2631 * Defaults to the plugins directory URL if no arguments are supplied. 2622 * Retrieve the url to the plugins directory or to a specific file within that directory. 2623 * You can hardcode the plugin slug in $path or pass __FILE__ as a second argument to get the correct folder name. 2632 2624 * 2633 2625 * @since 2.6.0 2634 2626 * 2635 * @param string $path Optional. Extra path appended to the end of the URL, including 2636 * the relative directory if $plugin is supplied. Default empty. 2637 * @param string $plugin Optional. A full path to a file inside a plugin or mu-plugin. 2638 * The URL will be relative to its directory. Default empty. 2639 * Typically this is done by passing `__FILE__` as the argument. 2640 * @return string Plugins URL link with optional paths appended. 2627 * @param string $path Optional. Path relative to the plugins url. 2628 * @param string $plugin Optional. The plugin file that you want to be relative to - i.e. pass in __FILE__ 2629 * @return string Plugins url link with optional path appended. 2641 2630 */ 2642 function plugins_url( $path = '', $plugin = '' ) { 2643 2644 $path = wp_normalize_path( $path ); 2645 $plugin = wp_normalize_path( $plugin ); 2646 $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); 2631 function plugins_url($path = '', $plugin = '') { 2632 2633 $mu_plugin_dir = WPMU_PLUGIN_DIR; 2634 foreach ( array('path', 'plugin', 'mu_plugin_dir') as $var ) { 2635 $$var = str_replace('\\' ,'/', $$var); // sanitize for Win32 installs 2636 $$var = preg_replace('|/+|', '/', $$var); 2637 } 2647 2638 2648 2639 if ( !empty($plugin) && 0 === strpos($plugin, $mu_plugin_dir) ) … … 2849 2840 function set_url_scheme( $url, $scheme = null ) { 2850 2841 $orig_scheme = $scheme; 2851 2852 if ( ! $scheme ) { 2853 $scheme = is_ssl() ? 'https' : 'http'; 2854 } elseif ( $scheme === 'admin' || $scheme === 'login' || $scheme === 'login_post' || $scheme === 'rpc' ) { 2855 $scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http'; 2856 } elseif ( $scheme !== 'http' && $scheme !== 'https' && $scheme !== 'relative' ) { 2857 $scheme = is_ssl() ? 'https' : 'http'; 2842 if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) { 2843 if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) ) 2844 $scheme = 'https'; 2845 elseif ( ( 'login' == $scheme ) && force_ssl_admin() ) 2846 $scheme = 'https'; 2847 elseif ( ( 'admin' == $scheme ) && force_ssl_admin() ) 2848 $scheme = 'https'; 2849 else 2850 $scheme = ( is_ssl() ? 'https' : 'http' ); 2858 2851 } 2859 2852
Note: See TracChangeset
for help on using the changeset viewer.