Making WordPress.org


Ignore:
Timestamp:
02/08/2017 07:08:35 PM (7 years ago)
Author:
coffee2code
Message:

Support Theme: Fix edit links for pending posts.

bbPress appends '/edit/' even to ugly permalinks, which pending posts will always have.

Fixes #2478.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

    r4890 r4892  
    296296add_filter( 'bbp_topic_admin_links', 'wporg_support_change_super_sticky_text' );
    297297
     298/**
     299 * Correct reply URLs for pending posts.
     300 *
     301 * bbPress appends '/edit/' even to ugly permalinks, which pending posts will
     302 * always have.
     303 *
     304 * @see https://meta.trac.wordpress.org/ticket/2478
     305 * @see https://bbpress.trac.wordpress.org/ticket/3054
     306 *
     307 * @param string $url     URL to edit the post.
     308 * @param int    $post_id Post ID.
     309 * @return string
     310 */
     311function wporg_support_fix_pending_posts_reply_url( $url, $post_id ) {
     312    if ( false !== strpos( $url, '?' ) && false !== strpos( $url, '/edit/' ) ) {
     313        $url = str_replace( '/edit/', '', $url );
     314        $url = add_query_arg( 'edit', '1', $url );
     315    }
     316
     317    return $url;
     318}
     319add_filter( 'bbp_get_topic_edit_url', 'wporg_support_fix_pending_posts_reply_url', 10, 2 );
     320add_filter( 'bbp_get_reply_edit_url', 'wporg_support_fix_pending_posts_reply_url', 10, 2 );
     321
     322
    298323/** bb Base *******************************************************************/
    299324
Note: See TracChangeset for help on using the changeset viewer.