Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/24/2024 07:39:16 AM (2 years ago)
Author:
imath
Message:

Improve the page / buddypress post types slugs unicity checks

To avoid slug conflicts between the page & buddypress post types as both URI Schemas put their slugs right after the site domain, 12.0.0 introduced a filter to extend the WordPress built-in check performed by wp_unique_post_slug().

This filter needed to be improve to :

  • make sure to allow WordPress sub-pages to have the same slugs than the BP Directory ones as in this case the URI Schemas puts the parent page slug before the sub-page one.
  • only request the page or buddypress post types having the same post_name than the page or buddypress post type being inserted.

Props ahegyes, emaralive

See #9086 (trunk)
Closes https://github.com/buddypress/buddypress/pull/256

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-functions.php

    r13744 r13777  
    969969 */
    970970function bp_core_set_unique_directory_page_slug( $slug = '', $post_ID = 0, $post_status = '', $post_type = '', $post_parent = 0, $original_slug = '' ) {
    971     if ( ( 'buddypress' === $post_type || 'page' === $post_type ) && $slug === $original_slug ) {
     971    if ( ( 'buddypress' === $post_type || 'page' === $post_type ) && $slug === $original_slug && ! $post_parent ) {
    972972        $pages = get_posts(
    973973            array(
     
    975975                'post_status'  => bp_core_get_directory_pages_stati(),
    976976                'post_type'    => array( 'buddypress', 'page' ),
     977                'post_parent'  => 0,     // Only get a top level page.
     978                'name'         => $slug, // Only get the same name page.
    977979            )
    978980        );
Note: See TracChangeset for help on using the changeset viewer.