Skip to:
Content

bbPress.org

Changeset 6967


Ignore:
Timestamp:
11/19/2019 05:47:56 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Slugs: add support for configuring the "Edit" slug.

This commit adds supporting functions and UI for allowing the edit slug to be modified. This omission was originally intentional, as the rewrite rules and pretty permalink support were not fully implemented. Now that they are in 2.6, there is no reason not to allow this slug to be modified.

Related changes include swapping out the new slug setting for the rewrite ID in a few places, and removing a single hardcoded reference to 'edit' that was also overlooked.

Props espellcaste for noticing. Fixes #3285. For 2.7, trunk.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r6948 r6967  
    890890        // Tertiary Slugs
    891891        $feed_slug          = 'feed';
    892         $edit_slug          = 'edit';
     892        $edit_slug          = bbp_get_edit_slug();
    893893        $paged_slug         = bbp_get_paged_slug();
    894894        $user_favs_slug     = bbp_get_user_favorites_slug();
  • trunk/src/includes/admin/settings.php

    r6954 r6967  
    385385                'sanitize_callback' => 'bbp_sanitize_slug',
    386386                'args'              => array( 'label_for'=>'_bbp_reply_slug' )
     387            ),
     388
     389            // Edit slug setting
     390            '_bbp_edit_slug' => array(
     391                'title'             => esc_html__( 'Edit', 'bbpress' ),
     392                'callback'          => 'bbp_admin_setting_callback_edit_slug',
     393                'sanitize_callback' => 'bbp_sanitize_slug',
     394                'args'              => array( 'label_for'=>'_bbp_edit_slug' )
    387395            ),
    388396
     
    12771285?>
    12781286
    1279     <p><?php printf( esc_html__( 'Custom slugs for single forums, topics, replies, tags, views, and search.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
     1287    <p><?php printf( esc_html__( 'Custom slugs for single forums, topics, replies, tags, views, edit, and search.', 'bbpress' ), get_admin_url( null, 'options-permalink.php' ) ); ?></p>
    12801288
    12811289<?php
     
    13711379    // Slug Check
    13721380    bbp_form_slug_conflict_check( '_bbp_search_slug', 'search' );
     1381}
     1382
     1383/**
     1384 * Edit slug setting field
     1385 *
     1386 * @since 2.6.2 bbPress (r6965)
     1387 */
     1388function bbp_admin_setting_callback_edit_slug() {
     1389?>
     1390
     1391    <input name="_bbp_edit_slug" id="_bbp_edit_slug" type="text" class="regular-text code" value="<?php bbp_form_option( '_bbp_edit_slug', 'edit', true ); ?>"<?php bbp_maybe_admin_setting_disabled( '_bbp_edit_slug' ); ?> />
     1392
     1393<?php
     1394    // Slug Check
     1395    bbp_form_slug_conflict_check( '_bbp_edit_slug', 'edit' );
    13731396}
    13741397
     
    20252048            '_bbp_reply_slug'         => array( 'name' => esc_html__( 'Reply slug',  'bbpress' ), 'default' => 'reply',  'context' => 'bbPress' ),
    20262049
     2050            // Edit slug
     2051            '_bbp_edit_slug'          => array( 'name' => esc_html__( 'Edit slug',   'bbpress' ), 'default' => 'edit',   'context' => 'bbPress' ),
     2052
    20272053            // User profile slug
    20282054            '_bbp_user_slug'          => array( 'name' => esc_html__( 'User base',   'bbpress' ), 'default' => 'users',  'context' => 'bbPress' ),
  • trunk/src/includes/core/options.php

    r6896 r6967  
    974974}
    975975
     976/**
     977 * Return the edit slug
     978 *
     979 * @since 2.6.2 bbPress (r6965)
     980 *
     981 * @param string $default Optional. Default value 'edit'
     982 * @return string
     983 */
     984function bbp_get_edit_slug( $default = 'edit' ) {
     985
     986    // Filter & return
     987    return apply_filters( 'bbp_get_edit_slug', get_option( '_bbp_edit_slug', $default ) );
     988}
     989
    976990/** Legacy ********************************************************************/
    977991
  • trunk/src/includes/extend/buddypress/groups.php

    r6836 r6967  
    930930
    931931                    // Topic edit
    932                     if ( bp_action_variable( $offset + 2 ) === bbp_get_edit_rewrite_id() ) :
     932                    if ( bp_action_variable( $offset + 2 ) === bbp_get_edit_slug() ) :
    933933
    934934                        // Unset the super sticky link on edit topic template
     
    10031003                    }
    10041004
    1005                     if ( bp_action_variable( $offset + 2 ) === bbp_get_edit_rewrite_id() ) :
     1005                    if ( bp_action_variable( $offset + 2 ) === bbp_get_edit_slug() ) :
    10061006
    10071007                        // Get the main query object
  • trunk/src/includes/replies/template.php

    r6931 r6967  
    19061906        // https://bbpress.trac.wordpress.org/ticket/3054
    19071907        if ( false === strpos( $reply_link, '?' ) ) {
    1908             $url = trailingslashit( $reply_link ) . bbp_get_edit_rewrite_id();
     1908            $url = trailingslashit( $reply_link ) . bbp_get_edit_slug();
    19091909            $url = user_trailingslashit( $url );
    19101910
  • trunk/src/includes/topics/template.php

    r6923 r6967  
    24612461        // https://bbpress.trac.wordpress.org/ticket/3054
    24622462        if ( false === strpos( $topic_link, '?' ) ) {
    2463             $url = trailingslashit( $topic_link ) . bbp_get_edit_rewrite_id();
     2463            $url = trailingslashit( $topic_link ) . bbp_get_edit_slug();
    24642464            $url = user_trailingslashit( $url );
    24652465
     
    35843584            // Pretty or ugly URL
    35853585            $retval = bbp_use_pretty_urls()
    3586                 ? user_trailingslashit( trailingslashit( bbp_get_topic_tag_link() ) . bbp_get_edit_rewrite_id() )
     3586                ? user_trailingslashit( trailingslashit( bbp_get_topic_tag_link() ) . bbp_get_edit_slug() )
    35873587                : add_query_arg( array( bbp_get_edit_rewrite_id() => '1' ), bbp_get_topic_tag_link() );
    35883588
  • trunk/src/includes/users/template.php

    r6953 r6967  
    636636        // Pretty permalinks
    637637        if ( bbp_use_pretty_urls() ) {
    638             $url = trailingslashit( $profile_url ) . 'edit';
     638            $url = trailingslashit( $profile_url ) . bbp_get_edit_slug();
    639639            $url = user_trailingslashit( $url );
    640640
Note: See TracChangeset for help on using the changeset viewer.