Skip to:
Content

BuddyPress.org

Changes between Version 8 and Version 9 of Ticket #6507, comment 1


Ignore:
Timestamp:
06/16/2015 07:43:56 PM (10 years ago)
Author:
CodeMonkeyBanana
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6507, comment 1

    v8 v9  
    2525
    2626        // exit if full path not specified
    27         if (empty($_POST['component']) || empty($_POST['action'])) {
     27        if (empty($_POST['component']) || empty($_POST['tab']) || empty($_POST['slug'])) {
    2828                if ( SCRIPT_DEBUG ) {
    2929                        exit( 'missing path component' );
     
    3232                }
    3333        }
    34        
     34
    3535        // get path
    3636        $component = sanitize_title( $_POST['component'] );
    37         $action = sanitize_title( $_POST['action'] );
    38         $path = 'members/single/'.$component.'/'.$action;
     37        $tab_name = sanitize_title( $_POST['tab'] );
     38        $slug = sanitize_title( $_POST['slug'] );
    3939
    40         if ($bp->bp_options_nav[$component][$action]['user_has_access'] == true)
     40        // create template list to search for in order
     41        // looks first for a new template file that is name but lowercase with spaces replaced to hyphen
     42        // then looks for the slug.  This will allow it to return to initial tab without loading double menu
     43        $templates = array();
     44        $templates[] = 'members/single/'.$component.'/'.$tab_name.'.php';
     45        $templates[] = 'members/single/'.$component.'/'.$slug.'.php';
     46
     47        // check user has permission to view template part
     48        if ($bp->bp_options_nav[$component][$slug]['user_has_access'] == true)
    4149        {
    42                 // they are allowed to view it so return template
    43                 bp_get_template_part( $path );
    44                 exit( '0' );
     50                do_action( 'get_template_part_' . $slug, $slug, '' );
     51                // Execute code for this ajax tab template part
     52                /**
     53                 * Fires before ajax tab template part is loaded.
     54                 *
     55                 * This is a variable hook that is dependent on the slug passed in.
     56                 *
     57                 * @param string $slug The tabs slug.
     58                 * @param string $name The tabs name, lower case with space replaced with hyphens.
     59                 */
     60                do_action( 'get_template_ajax_tab_' . $slug, $slug, $tab_name );
     61
     62                // allow ajax template part specific filtering
     63                $templates = apply_filters( 'bp_get_template_part_ajax', $templates, $slug, $tab_name );
     64
     65                // Return the part that is found
     66                bp_locate_template( $templates, true, false );
     67                exit();
    4568
    4669        }