WordPress.org

Ready to get started?Download WordPress

Forums

Request: Choice of anchor words in URLs (2 posts)

  1. frames
    Member
    Posted 6 years ago #

    First off, excuse me for the length of this. I wanted to detail my findings as much as possible. But let's get down to business ...

    The request:

    I believe it would be good if we could choose which "word" we could use for the comments link (basically, the #comments part of the URL).

    If you have an English language site, you would get something like this for the comments links with WordPress:

    http://mysite.com/category/post#comments
    http://mysite.com/category/post#comment-1

    That's cool. But my blog is in Spanish, and if I want to have all my URLs in Spanish, the only bit that I cannot 'translate' is the link to the comments in the page:

    http://misitio.com/categoria/entrada#comments
    http://misitio.com/categoria/entrada#comment-1

    I think you'd get the point. Of course, the same applies to French (e.g. #commentaires), German, Italian or any other language.

    Furthermore, English sites would be able to change #comments to something like #responses/#response-1, #feedback/#comment-1, #replies/#comment-1 or whatever.

    I think (correct me if I'm wrong, I'm no programmer at all) that this would mean a relatively simple change in the code. This is what I have found:

    #comments and #comment-X

    There are "only" 5 files affected in wp-includes for these two cases:

    grep "#comment" *
    comment-template.php:   return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
    comment-template.php:   return get_permalink() . '#comments';
    feed-atom.php:          <link rel="replies" type="text/html" href="<?php the_permalink_rss() ?>#comments" thr:count="<?php echo get_comments_number()?>"/>
    feed.php:       return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
    pluggable.php:  $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    widgets.php:                    echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';

    With the following 4 functions coming into place:

    comments_popup_link, comments_link, get_comments_link and get_comment_link

    Looking at it, changes required would be minor and not all the functions have to be modified for this to work.

    Only 1 file affected in wp-admin (rtl.css was returned, but it does not have anything to do with this):

    grep "#comment" *
    comment.php:            wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' );
    comment.php:            wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' );
    comment.php:    $location = ( empty( $_POST['referredby'] ) ? "edit.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;

    And one other file in the root directory:

    grep "#comm" *
    wp-comments-post.php:$location = ( empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to'] ) . '#comment-' . $comment_id;

    #respond

    There is also a single file for the #respond anchor (which is used for the comments' form), which would be the same thing:

    comment-template.php: echo get_permalink() . '#respond';

    With only one function affected (comments_popup_link, which was in fact found above already).

    #more

    And finally, one single file for #more (which is used for scerpts) in wp-includes:

    grep "#more" *
    post-template.php:                              $output .= ' <a href="'. get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>";

    The function affected is get_the_content.

    I haven't found this in the admin files or the files in the root directory.

    I was trying to achieve all of this with a plugin and explained the problem in the Forums, but apparently this is not doable via a plugin. I also explained there why I cannot create a custom function (that works, but breaks the admin interface and the comments feeds).

    Thanks a lot for your attention.

  2. hot8357
    Member
    Posted 6 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags