[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-templates/bp-nouveau/includes/ -> customizer-controls.php (source)

   1  <?php
   2  /**
   3   * Customizer controls
   4   *
   5   * @since 3.0.0
   6   * @version 3.1.0
   7   */
   8  
   9  // Exit if accessed directly.
  10  defined( 'ABSPATH' ) || exit;
  11  
  12  /**
  13   * This control let users change the order of the BuddyPress
  14   * single items navigation items.
  15   *
  16   * NB: this is a first pass to improve by using Javascript templating as explained here:
  17   * https://developer.wordpress.org/themes/advanced-topics/customizer-api/#putting-the-pieces-together
  18   *
  19   * @since 3.0.0
  20   */
  21  class BP_Nouveau_Nav_Customize_Control extends WP_Customize_Control {
  22      /**
  23       * @var string
  24       */
  25      public $type = '';
  26  
  27      /**
  28       * Render the control's content.
  29       *
  30       * @since 3.0.0
  31       */
  32  	public function render_content() {
  33          $id       = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) );
  34          $class    = 'customize-control customize-control-' . $this->type;
  35          $setting  = "bp_nouveau_appearance[{$this->type}_nav_order]";
  36          $item_nav = array();
  37  
  38          // It's a group
  39          if ( 'group' === $this->type ) {
  40              $guide = __( 'Customizing the Groups navigation order needs you create at least one group first.', 'buddypress' );
  41  
  42              // Try to fetch any random group:
  43              $random = groups_get_groups(
  44                  array(
  45                      'type'        => 'random',
  46                      'per_page'    => 1,
  47                      'show_hidden' => true,
  48                  )
  49              );
  50  
  51              if ( ! empty( $random['groups'] ) ) {
  52                  $group    = reset( $random['groups'] );
  53                  $nav      = new BP_Nouveau_Customizer_Group_Nav( $group->id );
  54                  $item_nav = $nav->get_group_nav();
  55              }
  56  
  57              if ( $item_nav ) {
  58                  $guide = __( 'Drag each possible group navigation items that are listed below into the order you prefer, in some groups some of these navigation items might not be active.', 'buddypress' );
  59              }
  60  
  61          // It's a user!
  62          } else {
  63              $item_nav = bp_nouveau_member_customizer_nav();
  64  
  65              $guide = __( 'Drag each possible member navigation items that are listed below into the order you prefer.', 'buddypress' );
  66          }
  67          ?>
  68  
  69          <?php if ( isset( $guide ) ) : ?>
  70              <p class="description">
  71                  <?php echo esc_html( $guide ); ?>
  72              </p>
  73          <?php endif; ?>
  74  
  75          <?php if ( ! empty( $item_nav ) ) : ?>
  76              <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 ); ?>">
  77  
  78                  <?php
  79                  $i = 0;
  80                  foreach ( $item_nav as $item ) :
  81                      $i += 1;
  82                  ?>
  83                      <li data-bp-nav="<?php echo esc_attr( $item->slug ); ?>">
  84                          <div class="menu-item-bar">
  85                              <div class="menu-item-handle ui-sortable-handle">
  86                                  <span class="item-title" aria-hidden="true">
  87                                      <span class="menu-item-title"><?php echo esc_html( _bp_strip_spans_from_title( $item->name ) ); ?></span>
  88                                  </span>
  89                              </div>
  90                          </div>
  91                      </li>
  92                  <?php endforeach; ?>
  93  
  94              </ul>
  95          <?php endif; ?>
  96  
  97              <input id="<?php echo esc_attr( 'bp_item_' . $this->type ); ?>" type="hidden" value="" data-customize-setting-link="<?php echo esc_attr( $setting ); ?>" />
  98  
  99          <?php
 100      }
 101  }


Generated: Fri Apr 26 01:01:11 2024 Cross-referenced by PHPXref 0.7.1