WordPress.org

Make WordPress Core

Ticket #50225: 50225.diff

File 50225.diff, 8.4 KB (added by david.binda, 16 months ago)
  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    399399
    400400                $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
    401401
    402                 $edit_link = get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type );
     402                $edit_link = get_edit_term_link( $tag, $taxonomy, $this->screen->post_type );
    403403
    404404                if ( $edit_link ) {
    405405                        $edit_link = add_query_arg(
     
    465465                $edit_link = add_query_arg(
    466466                        'wp_http_referer',
    467467                        urlencode( wp_unslash( $uri ) ),
    468                         get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
     468                        get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
    469469                );
    470470
    471471                $actions = array();
  • src/wp-includes/category-template.php

     
    714714
    715715        foreach ( $tags as $key => $tag ) {
    716716                if ( 'edit' == $args['link'] ) {
    717                         $link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
     717                        $link = get_edit_term_link( $tag, $tag->taxonomy, $args['post_type'] );
    718718                } else {
    719                         $link = get_term_link( intval( $tag->term_id ), $tag->taxonomy );
     719                        $link = get_term_link( $tag, $tag->taxonomy );
    720720                }
    721721
    722722                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

     
    828828 *
    829829 * @since 2.5.0
    830830 *
    831  * @param int    $cat_id Category ID.
    832  * @param string $feed   Optional. Feed type. Possible values include 'rss2', 'atom'.
    833  *                       Default is the value of get_default_feed().
     831 * @param int|WP_Term|object $cat The ID or term object whose feed link will be retrieved.
     832 * @param string $feed            Optional. Feed type. Possible values include 'rss2', 'atom'.
     833 *                                Default is the value of get_default_feed().
    834834 * @return string Link to the feed for the category specified by $cat_id.
    835835 */
    836 function get_category_feed_link( $cat_id, $feed = '' ) {
    837         return get_term_feed_link( $cat_id, 'category', $feed );
     836function get_category_feed_link( $cat, $feed = '' ) {
     837        return get_term_feed_link( $cat, 'category', $feed );
    838838}
    839839
    840840/**
     
    845845 *
    846846 * @since 3.0.0
    847847 *
    848  * @param int    $term_id  Term ID.
    849  * @param string $taxonomy Optional. Taxonomy of `$term_id`. Default 'category'.
    850  * @param string $feed     Optional. Feed type. Possible values include 'rss2', 'atom'.
    851  *                         Default is the value of get_default_feed().
     848 * @param int|WP_Term|object $term The ID or term object whose feed link will be retrieved.
     849 * @param string $taxonomy         Optional. Taxonomy of `$term_id`.
     850 *                                 Defaults to 'category' if term ID or non WP_Term object is passed.
     851 * @param string $feed             Optional. Feed type. Possible values include 'rss2', 'atom'.
     852 *                                 Default is the value of get_default_feed().
    852853 * @return string|false Link to the feed for the term specified by $term_id and $taxonomy.
    853854 */
    854 function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
    855         $term_id = (int) $term_id;
     855function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) {
     856        if ( ! is_object( $term ) ) {
     857                $term = (int) $term;
     858                $taxonomy = 'category';
     859        } else if ( ! $term instanceof WP_Term ) {
     860                $taxomy = $term->taxonomy;
     861        }
    856862
    857         $term = get_term( $term_id, $taxonomy );
     863        $term = get_term( $term, $taxonomy );
    858864
    859865        if ( empty( $term ) || is_wp_error( $term ) ) {
    860866                return false;
     
    868874
    869875        if ( '' == $permalink_structure ) {
    870876                if ( 'category' == $taxonomy ) {
    871                         $link = home_url( "?feed=$feed&amp;cat=$term_id" );
     877                        $link = home_url( "?feed=$feed&amp;cat=$term->term_id" );
    872878                } elseif ( 'post_tag' == $taxonomy ) {
    873879                        $link = home_url( "?feed=$feed&amp;tag=$term->slug" );
    874880                } else {
     
    876882                        $link = home_url( "?feed=$feed&amp;$t->query_var=$term->slug" );
    877883                }
    878884        } else {
    879                 $link = get_term_link( $term_id, $term->taxonomy );
     885                $link = get_term_link( $term, $term->taxonomy );
    880886                if ( get_default_feed() == $feed ) {
    881887                        $feed_link = 'feed';
    882888                } else {
     
    927933 *
    928934 * @since 2.3.0
    929935 *
    930  * @param int    $tag_id Tag ID.
    931  * @param string $feed   Optional. Feed type. Possible values include 'rss2', 'atom'.
    932  *                       Default is the value of get_default_feed().
     936 * @param int|WP_Term|object $tag The ID or term object whose feed link will be retrieved.
     937 * @param string $feed            Optional. Feed type. Possible values include 'rss2', 'atom'.
     938 *                                Default is the value of get_default_feed().
    933939 * @return string The feed permalink for the given tag.
    934940 */
    935 function get_tag_feed_link( $tag_id, $feed = '' ) {
    936         return get_term_feed_link( $tag_id, 'post_tag', $feed );
     941function get_tag_feed_link( $tag, $feed = '' ) {
     942        return get_term_feed_link( $tag, 'post_tag', $feed );
    937943}
    938944
    939945/**
     
    941947 *
    942948 * @since 2.7.0
    943949 *
    944  * @param int    $tag_id   Tag ID.
    945  * @param string $taxonomy Optional. Taxonomy slug. Default 'post_tag'.
     950 * @param int|WP_Term|object $tag The ID or term object whose edit link will be retrieved.
     951 * @param string $taxonomy        Optional. Taxonomy slug. Default 'post_tag'.
    946952 * @return string The edit tag link URL for the given tag.
    947953 */
    948 function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) {
     954function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) {
    949955        /**
    950956         * Filters the edit link for a tag (or term in another taxonomy).
    951957         *
     
    953959         *
    954960         * @param string $link The term edit link.
    955961         */
    956         return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) );
     962        return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) );
    957963}
    958964
    959965/**
     
    986992 * @since 3.1.0
    987993 * @since 4.5.0 The `$taxonomy` parameter was made optional.
    988994 *
    989  * @param int    $term_id     Term ID.
    990  * @param string $taxonomy    Optional. Taxonomy. Defaults to the taxonomy of the term identified
    991  *                            by `$term_id`.
    992  * @param string $object_type Optional. The object type. Used to highlight the proper post type
    993  *                            menu on the linked page. Defaults to the first object_type associated
    994  *                            with the taxonomy.
     995 * @param int|WP_Term|object $term The ID or term object whose edit link will be retrieved.
     996 * @param string $taxonomy         Optional. Taxonomy. Defaults to the taxonomy of the term identified
     997 *                                 by `$term`.
     998 * @param string $object_type      Optional. The object type. Used to highlight the proper post type
     999 *                                 menu on the linked page. Defaults to the first object_type associated
     1000 *                                 with the taxonomy.
    9951001 * @return string|null The edit term link URL for the given term, or null on failure.
    9961002 */
    997 function get_edit_term_link( $term_id, $taxonomy = '', $object_type = '' ) {
    998         $term = get_term( $term_id, $taxonomy );
     1003function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) {
     1004        $term = get_term( $term, $taxonomy );
    9991005        if ( ! $term || is_wp_error( $term ) ) {
    10001006                return;
    10011007        }
     
    10321038         * @param string $taxonomy    Taxonomy name.
    10331039         * @param string $object_type The object type (eg. the post type).
    10341040         */
    1035         return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
     1041        return apply_filters( 'get_edit_term_link', $location, $term->term_id, $taxonomy, $object_type );
    10361042}
    10371043
    10381044/**