Skip to:
Content

bbPress.org

Changeset 6784


Ignore:
Timestamp:
02/16/2018 10:37:15 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Titles: error if forum/topic/reply title is too long.

This change introduces bbp_is_title_too_long() and adds error messages to related forms if titles are too long.

Fixes #3189.

Location:
trunk/src/includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/formatting.php

    r6774 r6784  
    748748    return $reason;
    749749}
    750 
  • trunk/src/includes/common/functions.php

    r6782 r6784  
    23102310        : 'http://';
    23112311}
     2312
     2313/** Titles ********************************************************************/
     2314
     2315/**
     2316 * Is a title longer that the maximum title length?
     2317 *
     2318 * @since 2.6.0 bbPress (r6783)
     2319 *
     2320 * @param string $title
     2321 * @return bool
     2322 */
     2323function bbp_is_title_too_long( $title = '' ) {
     2324    $max    = bbp_get_title_max_length();
     2325    $len    = mb_strlen( $title, '8bit' );
     2326    $result = ( $len > $max );
     2327
     2328    // Filter & return
     2329    return (bool) apply_filters( 'bbp_is_title_too_long', $result, $title, $max, $len );
     2330}
  • trunk/src/includes/forums/functions.php

    r6733 r6784  
    162162    }
    163163
     164    // Title too long
     165    if ( bbp_is_title_too_long( $forum_title ) ) {
     166        bbp_add_error( 'bbp_forum_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     167    }
     168
    164169    /** Forum Content *********************************************************/
    165170
     
    446451    }
    447452
     453    // Title too long
     454    if ( bbp_is_title_too_long( $forum_title ) ) {
     455        bbp_add_error( 'bbp_forum_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     456    }
     457
    448458    /** Forum Content *********************************************************/
    449459
  • trunk/src/includes/replies/functions.php

    r6721 r6784  
    275275    $reply_title = apply_filters( 'bbp_new_reply_pre_title', $reply_title );
    276276
     277    // Title too long
     278    if ( bbp_is_title_too_long( $reply_title ) ) {
     279        bbp_add_error( 'bbp_reply_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     280    }
     281
    277282    /** Reply Content *********************************************************/
    278283
     
    587592    $reply_title = apply_filters( 'bbp_edit_reply_pre_title', $reply_title, $reply_id );
    588593
     594    // Title too long
     595    if ( bbp_is_title_too_long( $reply_title ) ) {
     596        bbp_add_error( 'bbp_reply_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     597    }
     598
    589599    /** Reply Content *********************************************************/
    590600
  • trunk/src/includes/topics/functions.php

    r6777 r6784  
    159159    }
    160160
     161    // Title too long
     162    if ( bbp_is_title_too_long( $topic_title ) ) {
     163        bbp_add_error( 'bbp_topic_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     164    }
     165
    161166    /** Topic Content *********************************************************/
    162167
     
    526531    }
    527532
     533    // Title too long
     534    if ( bbp_is_title_too_long( $topic_title ) ) {
     535        bbp_add_error( 'bbp_topic_title', __( '<strong>ERROR</strong>: Your title is too long.', 'bbpress' ) );
     536    }
     537
    528538    /** Topic Content *********************************************************/
    529539
Note: See TracChangeset for help on using the changeset viewer.