[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Code to hook into the WP Customizer
   4   *
   5   * @since 3.0.0
   6   * @version 3.1.0
   7   */
   8  
   9  /**
  10   * Add a specific panel for the BP Nouveau Template Pack.
  11   *
  12   * @since 3.0.0
  13   *
  14   * @param WP_Customize_Manager $wp_customize WordPress customizer.
  15   */
  16  function bp_nouveau_customize_register( WP_Customize_Manager $wp_customize ) {
  17      if ( ! bp_is_root_blog() ) {
  18          return;
  19      }
  20  
  21      require_once( trailingslashit( bp_nouveau()->includes_dir ) . 'customizer-controls.php' );
  22      $wp_customize->register_control_type( 'BP_Nouveau_Nav_Customize_Control' );
  23      $bp_nouveau_options = bp_nouveau_get_appearance_settings();
  24  
  25      $wp_customize->add_panel( 'bp_nouveau_panel', array(
  26          'description' => __( 'Customize the appearance of BuddyPress Nouveau Template pack.', 'buddypress' ),
  27          'title'       => _x( 'BuddyPress Nouveau', 'Customizer Panel', 'buddypress' ),
  28          'priority'    => 200,
  29      ) );
  30  
  31      /**
  32       * Filters the BuddyPress Nouveau customizer sections and their arguments.
  33       *
  34       * @since 3.0.0
  35       *
  36       * @param array $value Array of Customizer sections.
  37       */
  38      $sections = apply_filters( 'bp_nouveau_customizer_sections', array(
  39          'bp_nouveau_general_settings' => array(
  40              'title'       => __( 'General BP Settings', 'buddypress' ),
  41              'panel'       => 'bp_nouveau_panel',
  42              'priority'    => 10,
  43              'description' => __( 'Configure general BuddyPress appearance options.', 'buddypress' ),
  44          ),
  45          'bp_nouveau_user_front_page' => array(
  46              'title'       => __( 'Member front page', 'buddypress' ),
  47              'panel'       => 'bp_nouveau_panel',
  48              'priority'    => 30,
  49              'description' => __( 'Configure the default front page for members.', 'buddypress' ),
  50          ),
  51          'bp_nouveau_user_primary_nav' => array(
  52              'title'       => __( 'Member navigation', 'buddypress' ),
  53              'panel'       => 'bp_nouveau_panel',
  54              'priority'    => 50,
  55              'description' => __( 'Customize the navigation menu for members. In the preview window, navigate to a user to preview your changes.', 'buddypress' ),
  56          ),
  57          'bp_nouveau_loops_layout' => array(
  58              'title'       => __( 'Loop layouts', 'buddypress' ),
  59              'panel'       => 'bp_nouveau_panel',
  60              'priority'    => 70,
  61              'description' => __( 'Set the number of columns to use for BuddyPress loops.', 'buddypress' ),
  62          ),
  63          'bp_nouveau_dir_layout' => array(
  64              'title'       => __( 'Directory layouts', 'buddypress' ),
  65              'panel'       => 'bp_nouveau_panel',
  66              'priority'    => 80,
  67              'description' => __( 'Select the layout style for directory content &amp; navigation.', 'buddypress' ),
  68          ),
  69      ) );
  70  
  71      // Add the sections to the customizer
  72      foreach ( $sections as $id_section => $section_args ) {
  73          $wp_customize->add_section( $id_section, $section_args );
  74      }
  75  
  76      /**
  77       * Filters the BuddyPress Nouveau customizer settings and their arguments.
  78       *
  79       * @since 3.0.0
  80       *
  81       * @param array $value Array of Customizer settings.
  82       */
  83      $settings = apply_filters( 'bp_nouveau_customizer_settings', array(
  84          'bp_nouveau_appearance[avatar_style]' => array(
  85              'index'             => 'avatar_style',
  86              'capability'        => 'bp_moderate',
  87              'sanitize_callback' => 'absint',
  88              'transport'         => 'refresh',
  89              'type'              => 'option',
  90          ),
  91          'bp_nouveau_appearance[user_front_page]' => array(
  92              'index'             => 'user_front_page',
  93              'capability'        => 'bp_moderate',
  94              'sanitize_callback' => 'absint',
  95              'transport'         => 'refresh',
  96              'type'              => 'option',
  97          ),
  98          'bp_nouveau_appearance[user_front_bio]' => array(
  99              'index'             => 'user_front_bio',
 100              'capability'        => 'bp_moderate',
 101              'sanitize_callback' => 'absint',
 102              'transport'         => 'refresh',
 103              'type'              => 'option',
 104          ),
 105          'bp_nouveau_appearance[user_nav_display]' => array(
 106              'index'             => 'user_nav_display',
 107              'capability'        => 'bp_moderate',
 108              'sanitize_callback' => 'absint',
 109              'transport'         => 'refresh',
 110              'type'              => 'option',
 111          ),
 112          'bp_nouveau_appearance[user_nav_tabs]' => array(
 113              'index'             => 'user_nav_tabs',
 114              'capability'        => 'bp_moderate',
 115              'sanitize_callback' => 'absint',
 116              'transport'         => 'refresh',
 117              'type'              => 'option',
 118          ),
 119          'bp_nouveau_appearance[user_subnav_tabs]' => array(
 120              'index'             => 'user_subnav_tabs',
 121              'capability'        => 'bp_moderate',
 122              'sanitize_callback' => 'absint',
 123              'transport'         => 'refresh',
 124              'type'              => 'option',
 125          ),
 126          'bp_nouveau_appearance[user_nav_order]' => array(
 127              'index'             => 'user_nav_order',
 128              'capability'        => 'bp_moderate',
 129              'sanitize_callback' => 'bp_nouveau_sanitize_nav_order',
 130              'transport'         => 'refresh',
 131              'type'              => 'option',
 132          ),
 133          'bp_nouveau_appearance[members_layout]' => array(
 134              'index'             => 'members_layout',
 135              'capability'        => 'bp_moderate',
 136              'sanitize_callback' => 'absint',
 137              'transport'         => 'refresh',
 138              'type'              => 'option',
 139          ),
 140          'bp_nouveau_appearance[members_group_layout]' => array(
 141              'index'             => 'members_group_layout',
 142              'capability'        => 'bp_moderate',
 143              'sanitize_callback' => 'absint',
 144              'transport'         => 'refresh',
 145              'type'              => 'option',
 146          ),
 147          'bp_nouveau_appearance[members_friends_layout]' => array(
 148              'index'             => 'members_friends_layout',
 149              'capability'        => 'bp_moderate',
 150              'sanitize_callback' => 'absint',
 151              'transport'         => 'refresh',
 152              'type'              => 'option',
 153          ),
 154          'bp_nouveau_appearance[activity_dir_layout]' => array(
 155              'index'             => 'activity_dir_layout',
 156              'capability'        => 'bp_moderate',
 157              'sanitize_callback' => 'absint',
 158              'transport'         => 'refresh',
 159              'type'              => 'option',
 160          ),
 161          'bp_nouveau_appearance[activity_dir_tabs]' => array(
 162              'index'             => 'activity_dir_tabs',
 163              'capability'        => 'bp_moderate',
 164              'sanitize_callback' => 'absint',
 165              'transport'         => 'refresh',
 166              'type'              => 'option',
 167          ),
 168          'bp_nouveau_appearance[members_dir_layout]' => array(
 169              'index'             => 'members_dir_layout',
 170              'capability'        => 'bp_moderate',
 171              'sanitize_callback' => 'absint',
 172              'transport'         => 'refresh',
 173              'type'              => 'option',
 174          ),
 175          'bp_nouveau_appearance[members_dir_tabs]' => array(
 176              'index'             => 'members_dir_tabs',
 177              'capability'        => 'bp_moderate',
 178              'sanitize_callback' => 'absint',
 179              'transport'         => 'refresh',
 180              'type'              => 'option',
 181          ),
 182          'bp_nouveau_appearance[groups_dir_layout]' => array(
 183              'index'             => 'groups_dir_layout',
 184              'capability'        => 'bp_moderate',
 185              'sanitize_callback' => 'absint',
 186              'transport'         => 'refresh',
 187              'type'              => 'option',
 188          ),
 189          'bp_nouveau_appearance[sites_dir_layout]' => array(
 190              'index'             => 'sites_dir_layout',
 191              'capability'        => 'bp_moderate',
 192              'sanitize_callback' => 'absint',
 193              'transport'         => 'refresh',
 194              'type'              => 'option',
 195          ),
 196          'bp_nouveau_appearance[sites_dir_tabs]' => array(
 197              'index'             => 'sites_dir_tabs',
 198              'capability'        => 'bp_moderate',
 199              'sanitize_callback' => 'absint',
 200              'transport'         => 'refresh',
 201              'type'              => 'option',
 202          ),
 203      ) );
 204  
 205      // Add the settings
 206      foreach ( $settings as $id_setting => $setting_args ) {
 207          $args = array();
 208  
 209          if ( empty( $setting_args['index'] ) || ! isset( $bp_nouveau_options[ $setting_args['index'] ] ) ) {
 210              continue;
 211          }
 212  
 213          $args = array_merge( $setting_args, array( 'default' => $bp_nouveau_options[ $setting_args['index'] ] ) );
 214  
 215          $wp_customize->add_setting( $id_setting, $args );
 216      }
 217  
 218      $controls = array(
 219          'bp_site_avatars' => array(
 220              'label'      => __( 'Use the round style for member and group avatars.', 'buddypress' ),
 221              'section'    => 'bp_nouveau_general_settings',
 222              'settings'   => 'bp_nouveau_appearance[avatar_style]',
 223              'type'       => 'checkbox',
 224          ),
 225          'user_front_page' => array(
 226              'label'      => __( 'Enable default front page for member profiles.', 'buddypress' ),
 227              'section'    => 'bp_nouveau_user_front_page',
 228              'settings'   => 'bp_nouveau_appearance[user_front_page]',
 229              'type'       => 'checkbox',
 230          ),
 231          'user_front_bio' => array(
 232              'label'      => __( 'Display the biographical info from the member\'s WordPress profile.', 'buddypress' ),
 233              'section'    => 'bp_nouveau_user_front_page',
 234              'settings'   => 'bp_nouveau_appearance[user_front_bio]',
 235              'type'       => 'checkbox',
 236          ),
 237          'user_nav_display' => array(
 238              'label'      => __( 'Display the member navigation vertically.', 'buddypress' ),
 239              'section'    => 'bp_nouveau_user_primary_nav',
 240              'settings'   => 'bp_nouveau_appearance[user_nav_display]',
 241              'type'       => 'checkbox',
 242          ),
 243          'user_nav_tabs' => array(
 244              'label'      => __( 'Use tab styling for primary nav.', 'buddypress' ),
 245              'section'    => 'bp_nouveau_user_primary_nav',
 246              'settings'   => 'bp_nouveau_appearance[user_nav_tabs]',
 247              'type'       => 'checkbox',
 248          ),
 249          'user_subnav_tabs' => array(
 250              'label'      => __( 'Use tab styling for secondary nav.', 'buddypress' ),
 251              'section'    => 'bp_nouveau_user_primary_nav',
 252              'settings'   => 'bp_nouveau_appearance[user_subnav_tabs]',
 253              'type'       => 'checkbox',
 254          ),
 255          'user_nav_order' => array(
 256              'class'      => 'BP_Nouveau_Nav_Customize_Control',
 257              'label'      => __( 'Reorder the primary navigation for a user.', 'buddypress' ),
 258              'section'    => 'bp_nouveau_user_primary_nav',
 259              'settings'   => 'bp_nouveau_appearance[user_nav_order]',
 260              'type'       => 'user',
 261          ),
 262          'members_layout' => array(
 263              'label'      => __( 'Members', 'buddypress' ),
 264              'section'    => 'bp_nouveau_loops_layout',
 265              'settings'   => 'bp_nouveau_appearance[members_layout]',
 266              'type'       => 'select',
 267              'choices'    => bp_nouveau_customizer_grid_choices(),
 268          ),
 269          'members_friends_layout' => array(
 270              'label'      => __( 'Member > Friends', 'buddypress' ),
 271              'section'    => 'bp_nouveau_loops_layout',
 272              'settings'   => 'bp_nouveau_appearance[members_friends_layout]',
 273              'type'       => 'select',
 274              'choices'    => bp_nouveau_customizer_grid_choices(),
 275          ),
 276          'members_dir_layout' => array(
 277              'label'      => __( 'Use column navigation for the Members directory.', 'buddypress' ),
 278              'section'    => 'bp_nouveau_dir_layout',
 279              'settings'   => 'bp_nouveau_appearance[members_dir_layout]',
 280              'type'       => 'checkbox',
 281          ),
 282          'members_dir_tabs' => array(
 283              'label'      => __( 'Use tab styling for Members directory navigation.', 'buddypress' ),
 284              'section'    => 'bp_nouveau_dir_layout',
 285              'settings'   => 'bp_nouveau_appearance[members_dir_tabs]',
 286              'type'       => 'checkbox',
 287          ),
 288      );
 289  
 290      /**
 291       * Filters the BuddyPress Nouveau customizer controls and their arguments.
 292       *
 293       * @since 3.0.0
 294       *
 295       * @param array $value Array of Customizer controls.
 296       */
 297      $controls = apply_filters( 'bp_nouveau_customizer_controls', $controls );
 298  
 299      // Add the controls to the customizer's section
 300      foreach ( $controls as $id_control => $control_args ) {
 301          if ( empty( $control_args['class'] ) ) {
 302              $wp_customize->add_control( $id_control, $control_args );
 303          } else {
 304              $wp_customize->add_control( new $control_args['class']( $wp_customize, $id_control, $control_args ) );
 305          }
 306      }
 307  }
 308  add_action( 'bp_customize_register', 'bp_nouveau_customize_register', 10, 1 );
 309  
 310  /**
 311   * Enqueue needed JS for our customizer Settings & Controls
 312   *
 313   * @since 3.0.0
 314   */
 315  function bp_nouveau_customizer_enqueue_scripts() {
 316      $min = bp_core_get_minified_asset_suffix();
 317  
 318      wp_enqueue_script(
 319          'bp-nouveau-customizer',
 320          trailingslashit( bp_get_theme_compat_url() ) . "js/customizer{$min}.js",
 321          array( 'jquery', 'jquery-ui-sortable', 'customize-controls', 'iris', 'underscore', 'wp-util' ),
 322          bp_nouveau()->version,
 323          true
 324      );
 325  
 326      /**
 327       * Fires after Nouveau enqueues its required javascript.
 328       *
 329       * @since 3.0.0
 330       */
 331      do_action( 'bp_nouveau_customizer_enqueue_scripts' );
 332  }
 333  add_action( 'customize_controls_enqueue_scripts', 'bp_nouveau_customizer_enqueue_scripts' );


Generated: Thu Nov 14 01:01:40 2019 Cross-referenced by PHPXref 0.7.1