Skip to:
Content

bbPress.org

Changeset 5177


Ignore:
Timestamp:
11/23/2013 01:19:54 PM (6 years ago)
Author:
johnjamesjacoby
Message:

When creating new replies, do not force them to have a title. This is new as of WordPress 3.7, to be more accommodating to post formats that don't cater to titles very well (image/status/video/etc...)

Until now, replies to topics have always shared the topic title (and incremental slugs) in common with each other. With this change, replies will now mostly be identified via their post ID. This helps with search results, and avoids some reply-slug confusion as to why they need to have titles or slugs at all.

Props alex-ye for the clever solution. Fixes #2291.

Location:
trunk/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/common/template.php

    r5163 r5177  
    15801580    if ( bbp_is_reply_edit() ) : ?>
    15811581
    1582         <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php bbp_reply_title(); ?>" />
    15831582        <input type="hidden" name="bbp_reply_id"    id="bbp_reply_id"    value="<?php bbp_reply_id(); ?>" />
    15841583        <input type="hidden" name="bbp_reply_to"    id="bbp_reply_to"    value="<?php bbp_form_reply_to(); ?>" />
     
    15921591    else : ?>
    15931592
    1594         <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf( __( 'Reply To: %s', 'bbpress' ), bbp_get_topic_title() ); ?>" />
    15951593        <input type="hidden" name="bbp_topic_id"    id="bbp_topic_id"    value="<?php bbp_topic_id(); ?>" />
    15961594        <input type="hidden" name="bbp_reply_to"    id="bbp_reply_to"    value="<?php bbp_form_reply_to(); ?>" />
  • trunk/includes/core/filters.php

    r5132 r5177  
    9494add_filter( 'bbp_edit_reply_pre_title', 'wp_filter_kses'  );
    9595add_filter( 'bbp_edit_topic_pre_title', 'wp_filter_kses'  );
     96
     97// Reply title fallback
     98add_filter( 'the_title', 'bbp_get_reply_title_fallback', 1, 2 );
    9699
    97100// Prevent posting malicious or malformed content on new/edit topic/reply
  • trunk/includes/replies/functions.php

    r5055 r5177  
    275275    // Filter and sanitize
    276276    $reply_title = apply_filters( 'bbp_new_reply_pre_title', $reply_title );
    277 
    278     // No reply title
    279     if ( empty( $reply_title ) )
    280         bbp_add_error( 'bbp_reply_title', __( '<strong>ERROR</strong>: Your reply needs a title.', 'bbpress' ) );
    281277
    282278    /** Reply Content *********************************************************/
  • trunk/includes/replies/template.php

    r5130 r5177  
    547547    }
    548548
     549    /**
     550     * Get empty reply title fallback.
     551     *
     552     * @since bbPress (r5177)
     553     *
     554     * @param string $reply_title Required. Reply Title
     555     * @param int $reply_id Required. Reply ID
     556     * @uses bbp_get_reply_topic_title() To get the reply topic title
     557     * @uses apply_filters() Calls 'bbp_get_reply_title_fallback' with the title and reply ID
     558     * @return string Title of reply
     559     */
     560    function bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ) {
     561
     562        // Bail if title not empty, or post is not a reply
     563        if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) {
     564            return $post_title;
     565        }
     566
     567        // Get reply topic title.
     568        $topic_title = bbp_get_reply_topic_title( $post_id );
     569
     570        // Get empty reply title fallback.
     571        $reply_title = sprintf( __( 'Reply To: %s', 'bbpress' ), $topic_title );
     572
     573        return apply_filters( 'bbp_get_reply_title_fallback', $reply_title, $post_id, $topic_title );
     574    }
     575
    549576/**
    550577 * Output the content of the reply
     
    15801607     * @uses apply_filters() Calls 'bbp_get_reply_to_link' with the formatted link,
    15811608     *                        the arguments array, and the reply
    1582      * @return string Link for a reply to a reply 
     1609     * @return string Link for a reply to a reply
    15831610     */
    15841611    function bbp_get_reply_to_link( $args = array() ) {
Note: See TracChangeset for help on using the changeset viewer.