[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
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 & 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 if ( current_theme_supports( 'align-wide' ) ) { 206 $settings['bp_nouveau_appearance[global_alignment]'] = array( 207 'index' => 'global_alignment', 208 'capability' => 'bp_moderate', 209 'sanitize_callback' => 'sanitize_html_class', 210 'transport' => 'refresh', 211 'type' => 'option', 212 ); 213 } 214 215 // Add the settings 216 foreach ( $settings as $id_setting => $setting_args ) { 217 $args = array(); 218 219 if ( empty( $setting_args['index'] ) || ! isset( $bp_nouveau_options[ $setting_args['index'] ] ) ) { 220 continue; 221 } 222 223 $args = array_merge( $setting_args, array( 'default' => $bp_nouveau_options[ $setting_args['index'] ] ) ); 224 225 $wp_customize->add_setting( $id_setting, $args ); 226 } 227 228 $controls = array( 229 'bp_site_avatars' => array( 230 'label' => __( 'Use the round style for member and group avatars.', 'buddypress' ), 231 'section' => 'bp_nouveau_general_settings', 232 'settings' => 'bp_nouveau_appearance[avatar_style]', 233 'type' => 'checkbox', 234 ), 235 'user_front_page' => array( 236 'label' => __( 'Enable default front page for member profiles.', 'buddypress' ), 237 'section' => 'bp_nouveau_user_front_page', 238 'settings' => 'bp_nouveau_appearance[user_front_page]', 239 'type' => 'checkbox', 240 ), 241 'user_front_bio' => array( 242 'label' => __( 'Display the biographical info from the member\'s WordPress profile.', 'buddypress' ), 243 'section' => 'bp_nouveau_user_front_page', 244 'settings' => 'bp_nouveau_appearance[user_front_bio]', 245 'type' => 'checkbox', 246 ), 247 'user_nav_display' => array( 248 'label' => __( 'Display the member navigation vertically.', 'buddypress' ), 249 'section' => 'bp_nouveau_user_primary_nav', 250 'settings' => 'bp_nouveau_appearance[user_nav_display]', 251 'type' => 'checkbox', 252 ), 253 'user_nav_tabs' => array( 254 'label' => __( 'Use tab styling for primary nav.', 'buddypress' ), 255 'section' => 'bp_nouveau_user_primary_nav', 256 'settings' => 'bp_nouveau_appearance[user_nav_tabs]', 257 'type' => 'checkbox', 258 ), 259 'user_subnav_tabs' => array( 260 'label' => __( 'Use tab styling for secondary nav.', 'buddypress' ), 261 'section' => 'bp_nouveau_user_primary_nav', 262 'settings' => 'bp_nouveau_appearance[user_subnav_tabs]', 263 'type' => 'checkbox', 264 ), 265 'user_nav_order' => array( 266 'class' => 'BP_Nouveau_Nav_Customize_Control', 267 'label' => __( 'Reorder the primary navigation for a user.', 'buddypress' ), 268 'section' => 'bp_nouveau_user_primary_nav', 269 'settings' => 'bp_nouveau_appearance[user_nav_order]', 270 'type' => 'user', 271 ), 272 'members_layout' => array( 273 'label' => __( 'Members', 'buddypress' ), 274 'section' => 'bp_nouveau_loops_layout', 275 'settings' => 'bp_nouveau_appearance[members_layout]', 276 'type' => 'select', 277 'choices' => bp_nouveau_customizer_grid_choices(), 278 ), 279 'members_friends_layout' => array( 280 'label' => __( 'Member > Friends', 'buddypress' ), 281 'section' => 'bp_nouveau_loops_layout', 282 'settings' => 'bp_nouveau_appearance[members_friends_layout]', 283 'type' => 'select', 284 'choices' => bp_nouveau_customizer_grid_choices(), 285 ), 286 'members_dir_layout' => array( 287 'label' => __( 'Use column navigation for the Members directory.', 'buddypress' ), 288 'section' => 'bp_nouveau_dir_layout', 289 'settings' => 'bp_nouveau_appearance[members_dir_layout]', 290 'type' => 'checkbox', 291 ), 292 'members_dir_tabs' => array( 293 'label' => __( 'Use tab styling for Members directory navigation.', 'buddypress' ), 294 'section' => 'bp_nouveau_dir_layout', 295 'settings' => 'bp_nouveau_appearance[members_dir_tabs]', 296 'type' => 'checkbox', 297 ), 298 ); 299 300 /** 301 * Filters the BuddyPress Nouveau customizer controls and their arguments. 302 * 303 * @since 3.0.0 304 * 305 * @param array $value Array of Customizer controls. 306 */ 307 $controls = apply_filters( 'bp_nouveau_customizer_controls', $controls ); 308 309 if ( current_theme_supports( 'align-wide' ) ) { 310 $controls['global_alignment'] = array( 311 'label' => __( 'Select the BuddyPress container width for your site.', 'buddypress' ), 312 'section' => 'bp_nouveau_general_settings', 313 'settings' => 'bp_nouveau_appearance[global_alignment]', 314 'type' => 'select', 315 'choices' => array( 316 'alignnone' => __( 'Default width', 'buddypress' ), 317 'alignwide' => __( 'Wide width', 'buddypress' ), 318 'alignfull' => __( 'Full width', 'buddypress' ), 319 ), 320 ); 321 } 322 323 // Add the controls to the customizer's section 324 foreach ( $controls as $id_control => $control_args ) { 325 if ( empty( $control_args['class'] ) ) { 326 $wp_customize->add_control( $id_control, $control_args ); 327 } else { 328 $wp_customize->add_control( new $control_args['class']( $wp_customize, $id_control, $control_args ) ); 329 } 330 } 331 } 332 add_action( 'bp_customize_register', 'bp_nouveau_customize_register', 10, 1 ); 333 334 /** 335 * Enqueue needed JS for our customizer Settings & Controls 336 * 337 * @since 3.0.0 338 */ 339 function bp_nouveau_customizer_enqueue_scripts() { 340 $min = bp_core_get_minified_asset_suffix(); 341 342 wp_enqueue_script( 343 'bp-nouveau-customizer', 344 trailingslashit( bp_get_theme_compat_url() ) . "js/customizer{$min}.js", 345 array( 'jquery', 'jquery-ui-sortable', 'customize-controls', 'iris', 'underscore', 'wp-util' ), 346 bp_nouveau()->version, 347 true 348 ); 349 350 /** 351 * Fires after Nouveau enqueues its required javascript. 352 * 353 * @since 3.0.0 354 */ 355 do_action( 'bp_nouveau_customizer_enqueue_scripts' ); 356 } 357 add_action( 'customize_controls_enqueue_scripts', 'bp_nouveau_customizer_enqueue_scripts' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Jan 23 01:01:37 2021 | Cross-referenced by PHPXref 0.7.1 |