BP_Nouveau_Nav_Customize_Control
This control let users change the order of the BuddyPress single items navigation items.
Description
NB: this is a first pass to improve by using Javascript templating as explained here: https://developer.wordpress.org/themes/advanced-topics/customizer-api/#putting-the-pieces-together
Source
File: bp-templates/bp-nouveau/includes/customizer-controls.php
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | class BP_Nouveau_Nav_Customize_Control extends WP_Customize_Control { /** * @var string */ public $type = '' ; /** * Render the control's content. * * @since BuddyPress 3.0.0 */ public function render_content() { $id = 'customize-control-' . str_replace ( '[' , '-' , str_replace ( ']' , '' , $this ->id ) ); $class = 'customize-control customize-control-' . $this ->type; $setting = "bp_nouveau_appearance[{$this->type}_nav_order]" ; $item_nav = array (); $type = '' ; // It's a group if ( 'group' === $this ->type ) { $guide = __( 'Customizing the Groups navigation requires you to create a group first.' , 'buddyboss' ); $slug = array (); $type = 'group' ; if ( isset( $_GET [ 'url' ] ) && ! empty ( $_GET [ 'url' ] ) ) { $parse_url = parse_url ( $_GET [ 'url' ] ); $path_arr = explode ( '/' , $parse_url [ 'path' ] ); if ( 'groups' === $path_arr [1] && '' !== $path_arr [2] ) { $slug = array ( $path_arr [2] ); } } // Try to fetch any random group: $random = groups_get_groups( array ( 'type' => 'random' , 'per_page' => 1, 'slug' => $slug , 'show_hidden' => true, ) ); if ( ! empty ( $random [ 'groups' ] ) ) { $group = reset( $random [ 'groups' ] ); $nav = new BP_Nouveau_Customizer_Group_Nav( $group ->id ); $item_nav = $nav ->get_group_nav(); } if ( $item_nav ) { $guide = __( 'Drag and drop each tab to change the group navigation order.' , 'buddyboss' ); } // It's a user! } else { $item_nav = bp_nouveau_member_customizer_nav(); $type = 'user' ; $guide = __( 'Drag and drop each tab to change the profile navigation order.' , 'buddyboss' ); } ?> <?php if ( isset( $guide ) ) : ?> <p class = "description" > <?php echo esc_html( $guide ); ?> </p> <?php endif ; ?> <?php if ( ! empty ( $item_nav ) ) : ?> <ul id= "<?php echo esc_attr( $id ); ?>" class = "ui-sortable" style= "margin-top: 0px; height: 500px;" data-bp-type= "<?php echo esc_attr( $this->type ); ?>" > <?php $i = 0; foreach ( $item_nav as $item ) : // Get current activated theme. $theme_name = wp_get_theme(); $name = $theme_name ->get( 'Name' ); // Check if theme is BuddyBoss if ( strpos ( $name , 'BuddyBoss' ) !== false && 'user' === $type ) { // If the BuddyBoss theme activated then remove ( Account, Notification abd Message ) tab. if ( ! in_array( $item ->slug, array ( 'settings' , 'notifications' , 'messages' ) ) ) { $i += 1; ?> <li data-bp-nav= "<?php echo esc_attr( $item->slug ); ?>" > <div class = "menu-item-bar" > <div class = "menu-item-handle ui-sortable-handle" > <span class = "item-title" aria-hidden= "true" > <span class = "menu-item-title" ><?php echo esc_html( _bp_strip_spans_from_title( $item ->name ) ); ?></span> </span> </div> </div> </li> <?php } // do nothing } else { $i += 1; ?> <li data-bp-nav= "<?php echo esc_attr( $item->slug ); ?>" > <div class = "menu-item-bar" > <div class = "menu-item-handle ui-sortable-handle" > <span class = "item-title" aria-hidden= "true" > <span class = "menu-item-title" ><?php echo esc_html( _bp_strip_spans_from_title( $item ->name ) ); ?></span> </span> </div> </div> </li> <?php } endforeach ; ?> </ul> <?php endif ; ?> <input id= "<?php echo esc_attr( 'bp_item_' . $this->type ); ?>" type= "hidden" value= "" data-customize-setting-link= "<?php echo esc_attr( $setting ); ?>" /> <?php } } |
Changelog
Version | Description |
---|---|
BuddyPress 3.0.0 | Introduced. |
Methods
- render_content — Render the control's content.
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.