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