Changeset 52180 for trunk/src/wp-includes/link-template.php
- Timestamp:
- 11/16/2021 02:55:04 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r52111 r52180 905 905 * @since 2.5.0 906 906 * 907 * @param int $cat_id Category ID.908 * @param string $feedOptional. Feed type. Possible values include 'rss2', 'atom'.909 * Default is the value of get_default_feed().907 * @param int|WP_Term|object $cat The ID or term object whose feed link will be retrieved. 908 * @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'. 909 * Default is the value of get_default_feed(). 910 910 * @return string Link to the feed for the category specified by $cat_id. 911 911 */ 912 function get_category_feed_link( $cat _id, $feed = '' ) {913 return get_term_feed_link( $cat _id, 'category', $feed );912 function get_category_feed_link( $cat, $feed = '' ) { 913 return get_term_feed_link( $cat, 'category', $feed ); 914 914 } 915 915 … … 922 922 * @since 3.0.0 923 923 * 924 * @param int $term_id Term ID. 925 * @param string $taxonomy Optional. Taxonomy of `$term_id`. Default 'category'. 926 * @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'. 927 * Default is the value of get_default_feed(). 924 * @param int|WP_Term|object $term The ID or term object whose feed link will be retrieved. 925 * @param string $taxonomy Optional. Taxonomy of `$term_id`. 926 * Defaults to 'category' if term ID or non WP_Term object is passed. 927 * @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'. 928 * Default is the value of get_default_feed(). 928 929 * @return string|false Link to the feed for the term specified by $term_id and $taxonomy. 929 930 */ 930 function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { 931 $term_id = (int) $term_id; 932 933 $term = get_term( $term_id, $taxonomy ); 931 function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) { 932 if ( ! is_object( $term ) ) { 933 $term = (int) $term; 934 $taxonomy = 'category'; 935 } elseif ( ! $term instanceof WP_Term ) { 936 $taxonomy = $term->taxonomy; 937 } 938 939 $term = get_term( $term, $taxonomy ); 934 940 935 941 if ( empty( $term ) || is_wp_error( $term ) ) { … … 945 951 if ( ! $permalink_structure ) { 946 952 if ( 'category' === $taxonomy ) { 947 $link = home_url( "?feed=$feed&cat=$term _id" );953 $link = home_url( "?feed=$feed&cat=$term->term_id" ); 948 954 } elseif ( 'post_tag' === $taxonomy ) { 949 955 $link = home_url( "?feed=$feed&tag=$term->slug" ); … … 953 959 } 954 960 } else { 955 $link = get_term_link( $term _id, $term->taxonomy );961 $link = get_term_link( $term, $term->taxonomy ); 956 962 if ( get_default_feed() == $feed ) { 957 963 $feed_link = 'feed'; … … 1004 1010 * @since 2.3.0 1005 1011 * 1006 * @param int $tag_id Tag ID.1007 * @param string $feedOptional. Feed type. Possible values include 'rss2', 'atom'.1008 * Default is the value of get_default_feed().1009 * @return string The feed permalink for the given tag.1010 */ 1011 function get_tag_feed_link( $tag _id, $feed = '' ) {1012 return get_term_feed_link( $tag _id, 'post_tag', $feed );1012 * @param int|WP_Term|object $tag The ID or term object whose feed link will be retrieved. 1013 * @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'. 1014 * Default is the value of get_default_feed(). 1015 * @return string The feed permalink for the given tag. 1016 */ 1017 function get_tag_feed_link( $tag, $feed = '' ) { 1018 return get_term_feed_link( $tag, 'post_tag', $feed ); 1013 1019 } 1014 1020 … … 1018 1024 * @since 2.7.0 1019 1025 * 1020 * @param int $tag_id Tag ID.1021 * @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'.1026 * @param int|WP_Term|object $tag The ID or term object whose edit link will be retrieved. 1027 * @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'. 1022 1028 * @return string The edit tag link URL for the given tag. 1023 1029 */ 1024 function get_edit_tag_link( $tag _id, $taxonomy = 'post_tag' ) {1030 function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) { 1025 1031 /** 1026 1032 * Filters the edit link for a tag (or term in another taxonomy). … … 1030 1036 * @param string $link The term edit link. 1031 1037 */ 1032 return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag _id, $taxonomy ) );1038 return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) ); 1033 1039 } 1034 1040 … … 1063 1069 * @since 4.5.0 The `$taxonomy` parameter was made optional. 1064 1070 * 1065 * @param int $term_id Term ID.1066 * @param string $taxonomy Optional. Taxonomy. Defaults to the taxonomy of the term identified1067 * by `$term_id`.1068 * @param string $object_type Optional. The object type. Used to highlight the proper post type1069 * menu on the linked page. Defaults to the first object_type associated1070 * with the taxonomy.1071 * @param int|WP_Term|object $term The ID or term object whose edit link will be retrieved. 1072 * @param string $taxonomy Optional. Taxonomy. Defaults to the taxonomy of the term identified 1073 * by `$term`. 1074 * @param string $object_type Optional. The object type. Used to highlight the proper post type 1075 * menu on the linked page. Defaults to the first object_type associated 1076 * with the taxonomy. 1071 1077 * @return string|null The edit term link URL for the given term, or null on failure. 1072 1078 */ 1073 function get_edit_term_link( $term _id, $taxonomy = '', $object_type = '' ) {1074 $term = get_term( $term _id, $taxonomy );1079 function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) { 1080 $term = get_term( $term, $taxonomy ); 1075 1081 if ( ! $term || is_wp_error( $term ) ) { 1076 1082 return; 1077 1083 } 1078 1084 1079 $tax = get_taxonomy( $term->taxonomy ); 1080 if ( ! $tax || ! current_user_can( 'edit_term', $term->term_id ) ) { 1085 $tax = get_taxonomy( $term->taxonomy ); 1086 $term_id = $term->term_id; 1087 if ( ! $tax || ! current_user_can( 'edit_term', $term_id ) ) { 1081 1088 return; 1082 1089 } … … 1084 1091 $args = array( 1085 1092 'taxonomy' => $taxonomy, 1086 'tag_ID' => $term ->term_id,1093 'tag_ID' => $term_id, 1087 1094 ); 1088 1095 … … 1117 1124 * @since 3.1.0 1118 1125 * 1119 * @param string $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty.1120 * @param string $before Optional. Display before edit link. Default empty.1121 * @param string $after Optional. Display after edit link. Default empty.1122 * @param WP_Term $term Optional. Termobject. If null, the queried object will be inspected. Default null.1123 * @param bool $echo Optional. Whether or not to echo the return. Default true.1126 * @param string $link Optional. Anchor text. If empty, default is 'Edit This'. Default empty. 1127 * @param string $before Optional. Display before edit link. Default empty. 1128 * @param string $after Optional. Display after edit link. Default empty. 1129 * @param int|WP_Term|null $term Optional. Term ID or object. If null, the queried object will be inspected. Default null. 1130 * @param bool $echo Optional. Whether or not to echo the return. Default true. 1124 1131 * @return string|void HTML content. 1125 1132 */ … … 1127 1134 if ( is_null( $term ) ) { 1128 1135 $term = get_queried_object(); 1136 } else { 1137 $term = get_term( $term ); 1129 1138 } 1130 1139
Note: See TracChangeset
for help on using the changeset viewer.