WordPress.org

Make WordPress Core

Ticket #9702: 9702.patch

File 9702.patch, 3.0 KB (added by ramiy, 10 years ago)

edit_category_link() & get_edit_category_link()

  • link-template.php

     
    609609}
    610610
    611611/**
     612 * Retrieve edit category link.
     613 *
     614 * @since 2.8.0
     615 *
     616 * @param int $category_id Tag ID
     617 * @return string
     618 */
     619function get_edit_category_link( $category_id = 0, $taxonomy = 'category' ) {
     620        $category = get_term($category_id, $taxonomy);
     621
     622        if ( !current_user_can('manage_categories') )
     623                return;
     624
     625        $location = admin_url('categories.php?action=edit&taxonomy=' . $taxonomy . '&cat_ID=' . $category->term_id);
     626        return apply_filters( 'get_edit_category_link', $location );
     627}
     628
     629/**
     630 * Display or retrieve edit category link with formatting.
     631 *
     632 * @since 2.8.0
     633 *
     634 * @param string $link Optional. Anchor text.
     635 * @param string $before Optional. Display before edit link.
     636 * @param string $after Optional. Display after edit link.
     637 * @param int|object $category Tag object or ID
     638 * @return string|null HTML content, if $echo is set to false.
     639 */
     640function edit_category_link( $link = '', $before = '', $after = '', $category = null ) {
     641        $category = get_term($category, 'category');
     642
     643        if ( !current_user_can('manage_categories') )
     644                return;
     645
     646        if ( empty($link) )
     647                $link = __('Edit This');
     648
     649        $link = '<a href="' . get_edit_category_link( $category->term_id ) . '" title="' . __( 'Edit category' ) . '">' . $link . '</a>';
     650        echo $before . apply_filters( 'edit_category_link', $link, $category->term_id ) . $after;
     651}
     652
     653/**
    612654 * Retrieve the permalink for the feed of the search results.
    613655 *
    614656 * @since 2.5.0
     
    720762 * @param string $after Optional. Display after edit link.
    721763 * @param int $id Optional. Post ID.
    722764 */
    723 function edit_post_link( $link = 'Edit This', $before = '', $after = '', $id = 0 ) {
     765function edit_post_link( $link = '', $before = '', $after = '', $id = 0 ) {
    724766        if ( !$post = &get_post( $id ) )
    725767                return;
    726768
    727769        if ( !$url = get_edit_post_link( $post->ID ) )
    728770                return;
    729771
     772        if ( empty($link) )
     773                $link = __('Edit This');
     774
    730775        $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( __( 'Edit post' ) ) . '">' . $link . '</a>';
    731776        echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
    732777}
     
    765810 * @param string $after Optional. Display after edit link.
    766811 * @return string|null HTML content, if $echo is set to false.
    767812 */
    768 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
     813function edit_comment_link( $link = '', $before = '', $after = '' ) {
    769814        global $comment, $post;
    770815
    771816        if ( $post->post_type == 'attachment' ) {
     
    777822                        return;
    778823        }
    779824
     825        if ( empty($link) )
     826                $link = __('Edit This');
     827
    780828        $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
    781829        echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
    782830}