WordPress.org

Make WordPress Core

Ticket #50225: 50225.1.diff

File 50225.1.diff, 8.3 KB (added by Hareesh Pillai, 11 months ago)

Refreshed patch. Fixed typo.

  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    404404
    405405                $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    406406
    407                 $edit_link = get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type );
     407                $edit_link = get_edit_term_link( $tag, $taxonomy, $this->screen->post_type );
    408408
    409409                if ( $edit_link ) {
    410410                        $edit_link = add_query_arg(
     
    470470                $edit_link = add_query_arg(
    471471                        'wp_http_referer',
    472472                        urlencode( wp_unslash( $uri ) ),
    473                         get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
     473                        get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
    474474                );
    475475
    476476                $actions = array();
  • src/wp-includes/category-template.php

     
    735735
    736736        foreach ( $tags as $key => $tag ) {
    737737                if ( 'edit' === $args['link'] ) {
    738                         $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
     738                        $link = get_edit_term_link( $tag, $tag->taxonomy, $args['post_type'] );
    739739                } else {
    740                         $link = get_term_link( (int) $tag->term_id, $tag->taxonomy );
     740                        $link = get_term_link( $tag, $tag->taxonomy );
    741741                }
    742742
    743743                if ( is_wp_error( $link ) ) {
  • src/wp-includes/class-walker-category.php

     
    158158                                $link .= '(';
    159159                        }
    160160
    161                         $link .= '<a href="' . esc_url( get_term_feed_link( $category->term_id, $category->taxonomy, $args['feed_type'] ) ) . '"';
     161                        $link .= '<a href="' . esc_url( get_term_feed_link( $category, $category->taxonomy, $args['feed_type'] ) ) . '"';
    162162
    163163                        if ( empty( $args['feed'] ) ) {
    164164                                /* translators: %s: Category name. */
  • src/wp-includes/link-template.php

     
    830830 *
    831831 * @since 2.5.0
    832832 *
    833  * @param int    $cat_id Category ID.
    834  * @param string $feed   Optional. Feed type. Possible values include 'rss2', 'atom'.
    835  *                       Default is the value of get_default_feed().
     833 * @param int|WP_Term|object $cat The ID or term object whose feed link will be retrieved.
     834 * @param string $feed            Optional. Feed type. Possible values include 'rss2', 'atom'.
     835 *                                Default is the value of get_default_feed().
    836836 * @return string Link to the feed for the category specified by $cat_id.
    837837 */
    838 function get_category_feed_link( $cat_id, $feed = '' ) {
    839         return get_term_feed_link( $cat_id, 'category', $feed );
     838function get_category_feed_link( $cat, $feed = '' ) {
     839        return get_term_feed_link( $cat, 'category', $feed );
    840840}
    841841
    842842/**
     
    847847 *
    848848 * @since 3.0.0
    849849 *
    850  * @param int    $term_id  Term ID.
    851  * @param string $taxonomy Optional. Taxonomy of `$term_id`. Default 'category'.
    852  * @param string $feed     Optional. Feed type. Possible values include 'rss2', 'atom'.
    853  *                         Default is the value of get_default_feed().
     850 * @param int|WP_Term|object $term      The ID or term object whose feed link will be retrieved.
     851 * @param string $taxonomy              Optional. Taxonomy of `$term_id`.
     852 *                                                                      Defaults to 'category' if term ID or non WP_Term object is passed.
     853 * @param string $feed                      Optional. Feed type. Possible values include 'rss2', 'atom'.
     854 *                                              Default is the value of get_default_feed().
    854855 * @return string|false Link to the feed for the term specified by $term_id and $taxonomy.
    855856 */
    856 function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
    857         $term_id = (int) $term_id;
     857function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) {
     858        if ( ! is_object( $term ) ) {
     859                $term = (int) $term;
     860                $taxonomy = 'category';
     861        } else if ( ! $term instanceof WP_Term ) {
     862                $taxonomy = $term->taxonomy;
     863        }
    858864
    859         $term = get_term( $term_id, $taxonomy );
     865        $term = get_term( $term, $taxonomy );
    860866
    861867        if ( empty( $term ) || is_wp_error( $term ) ) {
    862868                return false;
     
    870876
    871877        if ( ! $permalink_structure ) {
    872878                if ( 'category' === $taxonomy ) {
    873                         $link = home_url( "?feed=$feed&amp;cat=$term_id" );
     879                        $link = home_url( "?feed=$feed&amp;cat=$term->term_id" );
    874880                } elseif ( 'post_tag' === $taxonomy ) {
    875881                        $link = home_url( "?feed=$feed&amp;tag=$term->slug" );
    876882                } else {
     
    878884                        $link = home_url( "?feed=$feed&amp;$t->query_var=$term->slug" );
    879885                }
    880886        } else {
    881                 $link = get_term_link( $term_id, $term->taxonomy );
     887                $link = get_term_link( $term, $term->taxonomy );
    882888                if ( get_default_feed() == $feed ) {
    883889                        $feed_link = 'feed';
    884890                } else {
     
    929935 *
    930936 * @since 2.3.0
    931937 *
    932  * @param int    $tag_id Tag ID.
    933  * @param string $feed   Optional. Feed type. Possible values include 'rss2', 'atom'.
    934  *                      Default is the value of get_default_feed().
     938 * @param int|WP_Term|object $tag The ID or term object whose feed link will be retrieved.
     939 * @param string $feed                    Optional. Feed type. Possible values include 'rss2', 'atom'.
     940 *                                        Default is the value of get_default_feed().
    935941 * @return string The feed permalink for the given tag.
    936942 */
    937 function get_tag_feed_link( $tag_id, $feed = '' ) {
    938         return get_term_feed_link( $tag_id, 'post_tag', $feed );
     943function get_tag_feed_link( $tag, $feed = '' ) {
     944        return get_term_feed_link( $tag, 'post_tag', $feed );
    939945}
    940946
    941947/**
     
    943949 *
    944950 * @since 2.7.0
    945951 *
    946  * @param int    $tag_id   Tag ID.
    947  * @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'.
     952 * @param int|WP_Term|object $tag The ID or term object whose edit link will be retrieved.
     953 * @param string $taxonomy                Optional. Taxonomy slug. Default 'post_tag'.
    948954 * @return string The edit tag link URL for the given tag.
    949955 */
    950 function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) {
     956function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) {
    951957        /**
    952958         * Filters the edit link for a tag (or term in another taxonomy).
    953959         *
     
    955961         *
    956962         * @param string $link The term edit link.
    957963         */
    958         return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) );
     964        return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) );
    959965}
    960966
    961967/**
     
    988994 * @since 3.1.0
    989995 * @since 4.5.0 The `$taxonomy` parameter was made optional.
    990996 *
    991  * @param int    $term_id     Term ID.
    992  * @param string $taxonomy    Optional. Taxonomy. Defaults to the taxonomy of the term identified
    993  *                            by `$term_id`.
    994  * @param string $object_type Optional. The object type. Used to highlight the proper post type
    995  *                            menu on the linked page. Defaults to the first object_type associated
    996  *                            with the taxonomy.
     997 * @param int|WP_Term|object $term The ID or term object whose edit link will be retrieved.
     998 * @param string $taxonomy         Optional. Taxonomy. Defaults to the taxonomy of the term identified
     999 *                                 by `$term`.
     1000 * @param string $object_type      Optional. The object type. Used to highlight the proper post type
     1001 *                                 menu on the linked page. Defaults to the first object_type associated
     1002 *                                 with the taxonomy.
    9971003 * @return string|null The edit term link URL for the given term, or null on failure.
    9981004 */
    999 function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) {
    1000         $term = get_term( $term_id, $taxonomy );
     1005function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) {
     1006        $term = get_term( $term, $taxonomy );
    10011007        if ( ! $term || is_wp_error( $term ) ) {
    10021008                return;
    10031009        }
     
    10341040         * @param string $taxonomy    Taxonomy name.
    10351041         * @param string $object_type The object type (eg. the post type).
    10361042         */
    1037         return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
     1043        return apply_filters( 'get_edit_term_link', $location, $term, $taxonomy, $object_type );
    10381044}
    10391045
    10401046/**