Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/09/2014 06:31:14 PM (11 years ago)
Author:
johnjamesjacoby
Message:

When creating directory page mappings, check for and use pages that already exist with a matching slug. Fixes #5747.

File:
1 edited

Legend:

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

    r8557 r8570  
    508508    // Create the pages
    509509    foreach ( $pages_to_create as $component_name => $page_name ) {
    510         $pages[ $component_name ] = wp_insert_post( array(
    511             'comment_status' => 'closed',
    512             'ping_status'    => 'closed',
    513             'post_status'    => 'publish',
    514             'post_title'     => $page_name,
    515             'post_type'      => 'page',
    516         ) );
     510        $exists = get_page_by_path( $component_name );
     511
     512        // If page already exists, use it
     513        if ( ! empty( $exists ) ) {
     514            $pages[ $component_name ] = $exists->ID;
     515        } else {
     516            $pages[ $component_name ] = wp_insert_post( array(
     517                'comment_status' => 'closed',
     518                'ping_status'    => 'closed',
     519                'post_status'    => 'publish',
     520                'post_title'     => $page_name,
     521                'post_type'      => 'page',
     522            ) );
     523        }
    517524    }
    518525
Note: See TracChangeset for help on using the changeset viewer.