Skip to:
Content

BuddyPress.org

Changeset 4053


Ignore:
Timestamp:
02/18/2011 03:23:04 AM (14 years ago)
Author:
djpaul
Message:

Move root component page creation code out of deprecated file.
Also tidy up of a teeny bit of PHPDoc.

Location:
trunk/bp-core
Files:
2 edited

Legend:

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

    r3987 r4053  
    1616 * Fetches BP pages from the meta table, depending on setup
    1717 *
    18  * @package BuddyPress Core Core
     18 * @package BuddyPress Core
    1919 */
    2020function bp_core_get_page_meta() {
     
    3030 * Stores BP pages in the meta table, depending on setup
    3131 *
    32  * @package BuddyPress Core Core
     32 * @package BuddyPress Core
    3333 */
    3434function bp_core_update_page_meta( $page_ids ) {
     
    722722}
    723723
     724/**
     725 * This function originally let plugins add support for pages in the root of the install.
     726 * These root level pages are now handled by actual WordPress pages and this function is now
     727 * a convenience for compatibility with the new method.
     728 *
     729 * @global $bp BuddyPress global settings
     730 * @param $slug str The slug of the component
     731 */
     732function bp_core_add_root_component( $slug ) {
     733    global $bp;
     734
     735    if ( empty( $bp->pages ) )
     736        $bp->pages = bp_core_get_page_names();
     737
     738    $match = false;
     739
     740    // Check if the slug is registered in the $bp->pages global
     741    foreach ( (array)$bp->pages as $key => $page ) {
     742        if ( $key == $slug || $page->slug == $slug )
     743            $match = true;
     744    }
     745
     746    // If there was no match, add a page for this root component
     747    if ( empty( $match ) ) {
     748        $bp->add_root[] = $slug;
     749        add_action( 'bp_init', 'bp_core_create_root_component_page' );
     750    }
     751}
     752
     753function bp_core_create_root_component_page() {
     754    global $bp;
     755
     756    $new_page_ids = array();
     757
     758    foreach ( (array)$bp->add_root as $slug )
     759        $new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
     760
     761    $page_ids = array_merge( (array) $new_page_ids, (array) bp_core_get_page_meta() );
     762    bp_core_update_page_meta( $page_ids );
     763}
    724764?>
  • trunk/bp-core/deprecated/1.3.php

    r3947 r4053  
    286286
    287287<?php
    288 }
    289 
    290 /**
    291  * This function originally let plugins add support for pages in the root of the install.
    292  * These pages are now handled by actual WordPress pages so this function is deprecated.
    293  * It now simply facilitates backwards compatibility by adding a WP page if the plugin has not been
    294  * updated to do so.
    295  *
    296  * @deprecated 1.3
    297  * @deprecated Use wp_insert_post() to create a page
    298  * @package BuddyPress Core
    299  * @param $slug str The slug of the component
    300  * @global $bp BuddyPress global settings
    301  */
    302 function bp_core_add_root_component( $slug ) {
    303     global $bp;
    304 
    305     _deprecated_function( __FUNCTION__, '1.3', 'wp_insert_post()' );
    306     if ( empty( $bp->pages ) )
    307         $bp->pages = bp_core_get_page_names();
    308 
    309     $match = false;
    310 
    311     // Check if the slug is registered in the $bp->pages global
    312     foreach ( (array)$bp->pages as $key => $page ) {
    313         if ( $key == $slug || $page->slug == $slug )
    314             $match = true;
    315     }
    316 
    317     // If there was no match, add a page for this root component
    318     if ( empty( $match ) ) {
    319         $bp->add_root[] = $slug;
    320         add_action( 'bp_init', 'bp_core_create_root_component_page' );
    321     }
    322 }
    323 
    324 function bp_core_create_root_component_page() {
    325     global $bp;
    326 
    327     $new_page_ids = array();
    328 
    329     foreach ( (array)$bp->add_root as $slug )
    330         $new_page_ids[$slug] = wp_insert_post( array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_title' => ucwords( $slug ), 'post_status' => 'publish', 'post_type' => 'page' ) );
    331 
    332     $page_ids = bp_core_get_page_meta();
    333     $page_ids = (array) $page_ids;
    334     $page_ids = array_merge( (array) $new_page_ids, (array) $page_ids );
    335 
    336     bp_core_update_page_meta( $page_ids );
    337288}
    338289
     
    491442}
    492443add_action( 'after_setup_theme', 'bp_dtheme_deprecated', 15 );
    493 
    494444?>
Note: See TracChangeset for help on using the changeset viewer.