Ticket #6592: 6592-customiser.01.patch
| File 6592-customiser.01.patch, 28.6 KB (added by , 10 years ago) |
|---|
-
src/bp-core/admin/bp-core-admin-functions.php
diff --git a/src/bp-core/admin/bp-core-admin-functions.php b/src/bp-core/admin/bp-core-admin-functions.php index bffe2a7..d95879d 100644
a b function bp_admin_do_wp_nav_menu_meta_box() { 811 811 } 812 812 813 813 /** 814 * In Emails post editor, add notice linking to token documentation on Codex. 815 * 816 * @since 2.5.0 817 */ 818 function bp_admin_email_add_codex_link() { 819 if ( get_current_screen()->post_type !== bp_get_email_post_type() ) { 820 return; 821 } 822 823 bp_core_add_admin_notice( 824 sprintf( 825 __( 'Phrases wrapped in braces <code>{{ }}</code> are email tokens. <a href="%s">Learn about the tokens on the BuddyPress Codex</a>.', 'buddypress' ), 826 esc_url( 'https://codex.buddypress.org/TODO' ) 827 ), 828 'error' 829 ); 830 } 831 add_action( 'admin_head-post.php', 'bp_admin_email_add_codex_link' ); 832 833 /** 814 834 * Restrict various items from view if editing a BuddyPress menu. 815 835 * 816 836 * If a person is editing a BP menu item, that person should not be able to -
new file src/bp-core/admin/css/customizer-controls-rtl.css
diff --git a/src/bp-core/admin/css/customizer-controls-rtl.css b/src/bp-core/admin/css/customizer-controls-rtl.css new file mode 100644 index 0000000..f56c366
- + 1 .customize-control-range output { 2 background-color: #FFF; 3 border: 1px solid #DDD; 4 box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 ); 5 float: right; 6 margin-left: 10px; 7 margin-top: -4px; 8 min-width: 16px; 9 padding: 5px; 10 } -
new file src/bp-core/admin/css/customizer-controls.css
diff --git a/src/bp-core/admin/css/customizer-controls.css b/src/bp-core/admin/css/customizer-controls.css new file mode 100644 index 0000000..c5673f8
- + 1 .customize-control-range output { 2 background-color: #FFF; 3 border: 1px solid #DDD; 4 box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 ); 5 float: left; 6 margin-right: 10px; 7 margin-top: -4px; 8 min-width: 16px; 9 padding: 5px; 10 } -
new file src/bp-core/admin/js/customizer-controls.js
diff --git a/src/bp-core/admin/js/customizer-controls.js b/src/bp-core/admin/js/customizer-controls.js new file mode 100644 index 0000000..508d09c
- + 1 /** 2 * Customizer controls implementation. 3 * 4 * If you're looking to add JS for a specific panel or control, don't add it here. 5 * The file only implements generic Customizer control implementations. 6 * 7 * @since 2.5.0 8 */ 9 10 (function( $ ) { 11 $( window ).on( 'load', function() { 12 /** 13 * <range> element: update label when value changes. 14 * 15 * @since 2.5.0 16 */ 17 $( '.customize-control-range input' ).on( 'input', function() { 18 var $this = $( this ); 19 $this.siblings( 'output' ).text( $this.val() ); 20 }); 21 }); 22 })( jQuery ); -
new file src/bp-core/admin/js/customizer-receiver-emails.js
diff --git a/src/bp-core/admin/js/customizer-receiver-emails.js b/src/bp-core/admin/js/customizer-receiver-emails.js new file mode 100644 index 0000000..61d13e8
- + 1 /** 2 * Customizer implementation for Email. 3 * 4 * If you're looking to add JS for every instance of a control, don't add it here. 5 * The file only implements the Customizer controls for Emails. 6 * 7 * @since 2.5.0 8 */ 9 10 (function( $ ) { 11 wp.customize( 'bp_email_options[email_bg]', function( value ) { 12 value.bind(function( newval ) { 13 if ( newval.length ) { 14 $( '.email_bg' ).attr( 'bgcolor', newval ); 15 $( 'hr' ).attr( 'color', newval ); 16 } 17 }); 18 }); 19 20 wp.customize( 'bp_email_options[header_bg]', function( value ) { 21 value.bind(function( newval ) { 22 if ( newval.length ) { 23 $( '.header_bg' ).attr( 'bgcolor', newval ); 24 } 25 }); 26 }); 27 28 wp.customize( 'bp_email_options[header_text_size]', function( value ) { 29 value.bind(function( newval ) { 30 if ( newval.length ) { 31 $( '.header_text_size' ).css( 'font-size', newval + 'px' ); 32 } 33 }); 34 }); 35 36 wp.customize( 'bp_email_options[header_text_color]', function( value ) { 37 value.bind(function( newval ) { 38 if ( newval.length ) { 39 $( '.header_text_color' ).css( 'color', newval ); 40 } 41 }); 42 }); 43 44 wp.customize( 'bp_email_options[highlight_color]', function( value ) { 45 value.bind(function( newval ) { 46 if ( newval.length ) { 47 $( '.header_bg' ).css( 'border-top-color', newval ); 48 $( 'a' ).css( 'color', newval ); 49 $( 'hr' ).attr( 'color', newval ); 50 } 51 }); 52 }); 53 54 wp.customize( 'bp_email_options[body_bg]', function( value ) { 55 value.bind(function( newval ) { 56 if ( newval.length ) { 57 $( '.body_bg' ).attr( 'bgcolor', newval ); 58 } 59 }); 60 }); 61 62 wp.customize( 'bp_email_options[body_text_size]', function( value ) { 63 value.bind(function( newval ) { 64 if ( newval.length ) { 65 // 1.618 = golden mean. 66 $( '.body_text_size' ) 67 .css( 'font-size', newval + 'px' ) 68 .css( 'line-height', Math.floor( newval * 1.618 ) + 'px' ); 69 70 // 1.35 = default body_text_size multipler. Gives default heading of 20px. 71 $( '.welcome' ).css( 'font-size', Math.floor( newval * 1.35 ) + 'px' ); 72 } 73 }); 74 }); 75 76 wp.customize( 'bp_email_options[body_text_color]', function( value ) { 77 value.bind(function( newval ) { 78 if ( newval.length ) { 79 $( '.body_text_color' ).css( 'color', newval ); 80 } 81 }); 82 }); 83 84 wp.customize( 'bp_email_options[footer_bg]', function( value ) { 85 value.bind(function( newval ) { 86 if ( newval.length ) { 87 $( '.footer_bg' ).attr( 'bgcolor', newval ); 88 } 89 }); 90 }); 91 92 wp.customize( 'bp_email_options[footer_text_size]', function( value ) { 93 value.bind(function( newval ) { 94 if ( newval.length ) { 95 $( '.footer_text_size' ) 96 .css( 'font-size', newval + 'px' ) 97 .css( 'line-height', Math.floor( newval * 1.618 ) + 'px' ); 98 } 99 }); 100 }); 101 102 wp.customize( 'bp_email_options[footer_text_color]', function( value ) { 103 value.bind(function( newval ) { 104 if ( newval.length ) { 105 $( '.footer_text_color' ).css( 'color', newval ); 106 } 107 }); 108 }); 109 110 wp.customize( 'bp_email_options[footer_text]', function( value ) { 111 value.bind(function( newval ) { 112 $( '.footer_text' ).text( newval ); 113 }); 114 }); 115 })( jQuery ); -
src/bp-core/bp-core-admin.php
diff --git a/src/bp-core/bp-core-admin.php b/src/bp-core/bp-core-admin.php index 25cc48b..026335c 100644
a b class BP_Admin { 295 295 'bp_core_admin_tools' 296 296 ); 297 297 298 // Fudge the highlighted subnav item when on a BuddyPress admin page. 298 $hooks[] = add_theme_page( 299 _x( 'Emails', 'screen heading', 'buddypress' ), 300 _x( 'Emails', 'screen heading', 'buddypress' ), 301 $this->capability, 302 'bp-emails-customizer-redirect', 303 'bp_email_redirect_to_customizer' 304 ); 305 299 306 foreach( $hooks as $hook ) { 300 307 add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' ); 301 308 } … … class BP_Admin { 906 913 'file' => $common_css, 907 914 'dependencies' => array(), 908 915 ), 916 917 // 2.5 918 'bp-customizer-controls' => array( 919 'file' => "{$url}customizer-controls{$min}.css", 920 'dependencies' => array(), 921 ), 909 922 ) ); 910 923 911 924 … … class BP_Admin { 938 951 * @param array $value Array of admin JS file information to register. 939 952 */ 940 953 $scripts = apply_filters( 'bp_core_admin_register_scripts', array( 954 // 2.5 955 'bp-customizer-controls' => array( 956 'file' => "{$url}customizer-controls{$min}.js", 957 'dependencies' => array( 'jquery' ), 958 'footer' => true, 959 ), 941 960 ) ); 942 961 943 944 962 $version = bp_get_version(); 945 963 946 964 foreach ( $scripts as $id => $script ) { -
new file src/bp-core/bp-core-customizer-email.php
diff --git a/src/bp-core/bp-core-customizer-email.php b/src/bp-core/bp-core-customizer-email.php new file mode 100644 index 0000000..5966626
- + 1 <?php 2 /** 3 * BuddyPress Customizer implementation for email. 4 * 5 * @since 2.5.0 6 * 7 * @package BuddyPress 8 * @subpackage Core 9 */ 10 11 // Exit if accessed directly. 12 defined( 'ABSPATH' ) || exit; 13 14 /** 15 * Initialize the Customizer for emails. 16 * 17 * @since 2.5.0 18 * 19 * @param WP_Customize_Manager $wp_customize The Customizer object. 20 */ 21 function bp_email_init_customizer( WP_Customize_Manager $wp_customize ) { 22 if ( ! bp_is_email_customizer() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 23 return; 24 } 25 26 $wp_customize->add_panel( 'bp_mailtpl', array( 27 'description' => __( 'Customize the appearance of emails sent by BuddyPress.', 'buddypress' ), 28 'title' => _x( 'Emails', 'screen heading', 'buddypress' ), 29 ) ); 30 31 $sections = bp_email_get_customizer_sections(); 32 foreach( $sections as $section_id => $args ) { 33 $wp_customize->add_section( $section_id, $args ); 34 } 35 36 $settings = bp_email_get_customizer_settings(); 37 foreach( $settings as $setting_id => $args ) { 38 $wp_customize->add_setting( $setting_id, $args ); 39 } 40 41 /** 42 * BP_Customizer_Control_Range class. 43 */ 44 require_once dirname( __FILE__ ) . '/classes/class-bp-customizer-control-range.php'; 45 46 /** 47 * Fires to let plugins register extra Customizer controls for emails. 48 * 49 * @since 2.5.0 50 * 51 * @param WP_Customize_Manager $wp_customize The Customizer object. 52 */ 53 do_action( 'bp_email_customizer_register_sections', $wp_customize ); 54 55 $controls = bp_email_get_customizer_controls(); 56 foreach ( $controls as $control_id => $args ) { 57 $wp_customize->add_control( new $args['class']( $wp_customize, $control_id, $args ) ); 58 } 59 60 61 /* 62 * Hook actions/filters for further configuration. 63 */ 64 65 add_filter( 'customize_section_active', 'bp_email_customizer_hide_sections', 12, 2 ); 66 67 if ( is_customize_preview() ) { 68 /* 69 * Enqueue scripts/styles for the Customizer's preview window. 70 * 71 * Scripts can't be registered in bp_core_register_common_styles() etc because 72 * the Customizer loads very, very early. 73 */ 74 $bp = buddypress(); 75 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 76 77 wp_enqueue_script( 78 'bp-customizer-receiver-emails', 79 "{$bp->plugin_url}bp-core/admin/js/customizer-receiver-emails{$min}.js", 80 array( 'customize-preview' ), 81 bp_get_version(), 82 true 83 ); 84 } 85 } 86 add_action( 'bp_customize_register', 'bp_email_init_customizer' ); 87 88 /** 89 * Are we looking at the email customizer? 90 * 91 * @since 2.5.0 92 * 93 * @return bool 94 */ 95 function bp_is_email_customizer() { 96 return isset( $_GET['bp_customizer'] ) && $_GET['bp_customizer'] === 'email'; 97 } 98 99 /** 100 * Only show email sections in the Customizer. 101 * 102 * @since 2.5.0 103 * 104 * @param $active Whether the Customizer section is active. 105 * @param WP_Customize_Section $section {@see WP_Customize_Section} instance. 106 * @return bool 107 */ 108 function bp_email_customizer_hide_sections( $active, $section ) { 109 if ( ! bp_is_email_customizer() ) { 110 return $active; 111 } 112 113 return in_array( $section->id, array_keys( bp_email_get_customizer_sections() ), true ); 114 } 115 116 /** 117 * Get Customizer sections for emails. 118 * 119 * @since 2.5.0 120 * 121 * @return array 122 */ 123 function bp_email_get_customizer_sections() { 124 125 /** 126 * Filter Customizer sections for emails. 127 * 128 * @since 2.5.0 129 * 130 * @param array $sections Email Customizer sections to add. 131 */ 132 return apply_filters( 'bp_email_get_customizer_sections', array( 133 'section_bp_mailtpl_header' => array( 134 'capability' => 'bp_moderate', 135 'panel' => 'bp_mailtpl', 136 'title' => _x( 'Header', 'email', 'buddypress' ), 137 ), 138 'section_bp_mailtpl_body' => array( 139 'capability' => 'bp_moderate', 140 'panel' => 'bp_mailtpl', 141 'title' => _x( 'Body', 'email', 'buddypress' ), 142 ), 143 'section_bp_mailtpl_footer' => array( 144 'capability' => 'bp_moderate', 145 'panel' => 'bp_mailtpl', 146 'title' => _x( 'Footer', 'email', 'buddypress' ), 147 ), 148 ) ); 149 } 150 151 /** 152 * Get Customizer settings for emails. 153 * 154 * @since 2.5.0 155 * 156 * @return array 157 */ 158 function bp_email_get_customizer_settings() { 159 $defaults = bp_email_get_appearance_settings(); 160 161 /** 162 * Filter Customizer settings for emails. 163 * 164 * @since 2.5.0 165 * 166 * @param array $settings Email Customizer settings to add. 167 */ 168 return apply_filters( 'bp_email_get_customizer_settings', array( 169 'bp_email_options[email_bg]' => array( 170 'capability' => 'bp_moderate', 171 'default' => $defaults['email_bg'], 172 'sanitize_callback' => 'sanitize_hex_color', 173 'transport' => 'postMessage', 174 'type' => 'option', 175 ), 176 'bp_email_options[header_bg]' => array( 177 'capability' => 'bp_moderate', 178 'default' => $defaults['header_bg'], 179 'sanitize_callback' => 'sanitize_hex_color', 180 'transport' => 'postMessage', 181 'type' => 'option', 182 ), 183 'bp_email_options[header_text_size]' => array( 184 'capability' => 'bp_moderate', 185 'default' => $defaults['header_text_size'], 186 'sanitize_callback' => 'intval', 187 'transport' => 'postMessage', 188 'type' => 'option', 189 ), 190 'bp_email_options[header_text_color]' => array( 191 'capability' => 'bp_moderate', 192 'default' => $defaults['header_text_color'], 193 'sanitize_callback' => 'sanitize_hex_color', 194 'transport' => 'postMessage', 195 'type' => 'option', 196 ), 197 'bp_email_options[highlight_color]' => array( 198 'capability' => 'bp_moderate', 199 'default' => $defaults['highlight_color'], 200 'sanitize_callback' => 'sanitize_hex_color', 201 'transport' => 'postMessage', 202 'type' => 'option', 203 ), 204 'bp_email_options[body_bg]' => array( 205 'capability' => 'bp_moderate', 206 'default' => $defaults['body_bg'], 207 'sanitize_callback' => 'sanitize_hex_color', 208 'transport' => 'postMessage', 209 'type' => 'option', 210 ), 211 'bp_email_options[body_text_size]' => array( 212 'capability' => 'bp_moderate', 213 'default' => $defaults['body_text_size'], 214 'sanitize_callback' => 'intval', 215 'transport' => 'postMessage', 216 'type' => 'option', 217 ), 218 'bp_email_options[body_text_color]' => array( 219 'capability' => 'bp_moderate', 220 'default' => $defaults['body_text_color'], 221 'sanitize_callback' => 'sanitize_hex_color', 222 'transport' => 'postMessage', 223 'type' => 'option', 224 ), 225 'bp_email_options[footer_text]' => array( 226 'capability' => 'bp_moderate', 227 'default' => $defaults['footer_text'], 228 'sanitize_callback' => 'bp_sanitize_text_field_keep_linebreaks', 229 'transport' => 'postMessage', 230 'type' => 'option', 231 ), 232 'bp_email_options[footer_bg]' => array( 233 'capability' => 'bp_moderate', 234 'default' => $defaults['footer_bg'], 235 'sanitize_callback' => 'sanitize_hex_color', 236 'transport' => 'postMessage', 237 'type' => 'option', 238 ), 239 'bp_email_options[footer_text_size]' => array( 240 'capability' => 'bp_moderate', 241 'default' => $defaults['footer_text_size'], 242 'sanitize_callback' => 'intval', 243 'transport' => 'postMessage', 244 'type' => 'option', 245 ), 246 'bp_email_options[footer_text_color]' => array( 247 'capability' => 'bp_moderate', 248 'default' => $defaults['footer_text_color'], 249 'sanitize_callback' => 'sanitize_hex_color', 250 'transport' => 'postMessage', 251 'type' => 'option', 252 ), 253 ) ); 254 } 255 256 /** 257 * Get Customizer controls for emails. 258 * 259 * @since 2.5.0 260 * 261 * @return array 262 */ 263 function bp_email_get_customizer_controls() { 264 265 /** 266 * Filter Customizer controls for emails. 267 * 268 * @since 2.5.0 269 * 270 * @param array $controls Email Customizer controls to add. 271 */ 272 return apply_filters( 'bp_email_get_customizer_controls', array( 273 'bp_mailtpl_email_bg' => array( 274 'class' => 'WP_Customize_Color_Control', 275 'label' => __( 'Email background color', 'buddypress' ), 276 'section' => 'section_bp_mailtpl_header', 277 'settings' => 'bp_email_options[email_bg]', 278 ), 279 280 'bp_mailtpl_header_bg' => array( 281 'class' => 'WP_Customize_Color_Control', 282 'label' => __( 'Header background color', 'buddypress' ), 283 'section' => 'section_bp_mailtpl_header', 284 'settings' => 'bp_email_options[header_bg]', 285 ), 286 287 'bp_mailtpl_highlight_color' => array( 288 'class' => 'WP_Customize_Color_Control', 289 'description' => 'killer snack', 290 'label' => __( 'Highlight color', 'buddypress' ), 291 'section' => 'section_bp_mailtpl_header', 292 'settings' => 'bp_email_options[highlight_color]', 293 ), 294 295 'bp_mailtpl_header_text_color' => array( 296 'class' => 'WP_Customize_Color_Control', 297 'label' => __( 'Text color', 'buddypress' ), 298 'section' => 'section_bp_mailtpl_header', 299 'settings' => 'bp_email_options[header_text_color]', 300 ), 301 302 'bp_mailtpl_header_text_size' => array( 303 'class' => 'BP_Customizer_Control_Range', 304 'label' => __( 'Text size', 'buddypress' ), 305 'section' => 'section_bp_mailtpl_header', 306 'settings' => 'bp_email_options[header_text_size]', 307 308 'input_attrs' => array( 309 'max' => 100, 310 'min' => 1, 311 'step' => 1, 312 ), 313 ), 314 315 316 'bp_mailtpl_body_bg' => array( 317 'class' => 'WP_Customize_Color_Control', 318 'label' => __( 'Background color', 'buddypress' ), 319 'section' => 'section_bp_mailtpl_body', 320 'settings' => 'bp_email_options[body_bg]', 321 ), 322 323 324 'bp_mailtpl_body_text_color' => array( 325 'class' => 'WP_Customize_Color_Control', 326 'label' => __( 'Text color', 'buddypress' ), 327 'section' => 'section_bp_mailtpl_body', 328 'settings' => 'bp_email_options[body_text_color]', 329 ), 330 331 'bp_mailtpl_body_text_size' => array( 332 'class' => 'BP_Customizer_Control_Range', 333 'label' => __( 'Text size', 'buddypress' ), 334 'section' => 'section_bp_mailtpl_body', 335 'settings' => 'bp_email_options[body_text_size]', 336 337 'input_attrs' => array( 338 'max' => 24, 339 'min' => 8, 340 'step' => 1, 341 ), 342 ), 343 344 345 'bp_mailtpl_footer_text' => array( 346 'class' => 'WP_Customize_Control', 347 'description' => __('Change the email footer here', 'buddypress' ), 348 'label' => __( 'Footer text', 'buddypress' ), 349 'section' => 'section_bp_mailtpl_footer', 350 'settings' => 'bp_email_options[footer_text]', 351 'type' => 'textarea', 352 ), 353 354 'bp_mailtpl_footer_bg' => array( 355 'class' => 'WP_Customize_Color_Control', 356 'label' => __( 'Background color', 'buddypress' ), 357 'section' => 'section_bp_mailtpl_footer', 358 'settings' => 'bp_email_options[footer_bg]', 359 ), 360 361 'bp_mailtpl_footer_text_color' => array( 362 'class' => 'WP_Customize_Color_Control', 363 'label' => __( 'Text color', 'buddypress' ), 364 'section' => 'section_bp_mailtpl_footer', 365 'settings' => 'bp_email_options[footer_text_color]', 366 ), 367 368 'bp_mailtpl_footer_text_size' => array( 369 'class' => 'BP_Customizer_Control_Range', 370 'label' => __( 'Text size', 'buddypress' ), 371 'section' => 'section_bp_mailtpl_footer', 372 'settings' => 'bp_email_options[footer_text_size]', 373 374 'input_attrs' => array( 375 'max' => 24, 376 'min' => 8, 377 'step' => 1, 378 ), 379 ), 380 ) ); 381 } 382 383 /** 384 * Return email appearance settings. 385 * 386 * @since 2.5.0 387 * 388 * @return array 389 */ 390 function bp_email_get_appearance_settings() { 391 $default_args = array( 392 'body_bg' => '#FFFFFF', 393 'body_text_color' => '#555555', 394 'body_text_size' => 15, 395 'email_bg' => '#F7F3F0', 396 'footer_bg' => '#F7F3F0', 397 'footer_text_color' => '#525252', 398 'footer_text_size' => 12, 399 'header_bg' => '#F7F3F0', 400 'highlight_color' => '#D84800', 401 'header_text_color' => '#000000', 402 'header_text_size' => 30, 403 404 'footer_text' => sprintf( 405 /* translators: email disclaimer, e.g. "© 2016 Site Name". */ 406 _x( '© %s %s', 'email', 'buddypress' ), 407 date_i18n( 'Y' ), 408 bp_get_option( 'blogname' ) 409 ), 410 ); 411 412 return bp_parse_args( 413 get_option( 'bp_email_options', array() ), 414 $default_args, 415 'email_appearance_settings' 416 ); 417 } 418 419 /** 420 * Implements a JS redirect to the Customizer, previewing a randomly selected email. 421 * 422 * @since 2.5.0 423 */ 424 function bp_email_redirect_to_customizer() { 425 $email = get_posts( array( 426 'fields' => 'ids', 427 'orderby' => 'rand', 428 'post_status' => 'publish', 429 'post_type' => bp_get_email_post_type(), 430 'posts_per_page' => 1, 431 'suppress_filters' => false, 432 ) ); 433 434 $preview_url = admin_url(); 435 436 if ( $email ) { 437 $preview_url = get_post_permalink( $email[0] ) . '&bp_customizer=email'; 438 } 439 440 $redirect_url = add_query_arg( 441 array( 442 'autofocus[panel]' => 'bp_mailtpl', 443 'bp_customizer' => 'email', 444 'return' => rawurlencode( admin_url() ), 445 'url' => rawurlencode( $preview_url ), 446 ), 447 admin_url( 'customize.php' ) 448 ); 449 450 printf( 451 '<script type="text/javascript">window.location = "%s";</script>', 452 $redirect_url 453 ); 454 455 exit; 456 } -
src/bp-core/bp-core-filters.php
diff --git a/src/bp-core/bp-core-filters.php b/src/bp-core/bp-core-filters.php index 0d4b342..bb51373 100644
a b function _bp_core_inject_bp_widget_css_class( $params ) { 1038 1038 return $params; 1039 1039 } 1040 1040 add_filter( 'dynamic_sidebar_params', '_bp_core_inject_bp_widget_css_class' ); 1041 1042 /** 1043 * Add email link styles to rendered email template. 1044 * 1045 * This is only used when the email content has been merged into the email template. 1046 * 1047 * @since 2.5.0 1048 * 1049 * @param string $value Property value. 1050 * @param string $property_name 1051 * @param string $transform How the return value was transformed. 1052 * @return string Updated value. 1053 */ 1054 function bp_email_add_link_color_to_template( $value, $property_name, $transform ) { 1055 if ( $property_name !== 'template' || $transform !== 'add-content' ) { 1056 return $value; 1057 } 1058 1059 $settings = bp_email_get_appearance_settings(); 1060 $replacement = 'style="color: ' . esc_attr( $settings['highlight_color'] ) . ';'; 1061 1062 // Find all links. 1063 preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER ); 1064 foreach ( $links as $link ) { 1065 $new_link = $link = array_shift( $link ); 1066 1067 // Add/modify style property. 1068 if ( strpos( $link, 'style="' ) !== false ) { 1069 $new_link = str_replace( 'style="', $replacement, $link ); 1070 } else { 1071 $new_link = str_replace( '<a ', "<a {$replacement}\" ", $link ); 1072 } 1073 1074 if ( $new_link !== $link ) { 1075 $value = str_replace( $link, $new_link, $value ); 1076 } 1077 } 1078 1079 return $value; 1080 } 1081 add_filter( 'bp_email_get_property', 'bp_email_add_link_color_to_template', 6, 3 ); -
src/bp-core/bp-core-functions.php
diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php index 69a914e..c1c2316 100644
a b function bp_upload_dir() { 2591 2591 2592 2592 return $bp->upload_dir; 2593 2593 } 2594 2595 2596 /** Customizer *****************************************************************/ 2597 2598 /** 2599 * Utility function to sanitize text and strip all tags for Customiser callbacks. 2600 * 2601 * @since 2.5.0 2602 * 2603 * @param string $raw 2604 * @return string 2605 */ 2606 function bp_sanitize_text_field_keep_linebreaks( $raw ) { 2607 $input = str_replace( array( "\r", "\n", ), '%BPNEWLINE%', $raw ); 2608 $input = sanitize_text_field( $input ); // Strips tags. 2609 $input = str_replace( '%BPNEWLINE%', "\n", $input ); 2610 2611 /** 2612 * Filiters the sanitized text for Customiser callbacks. 2613 * 2614 * @since 2.5.0 2615 * 2616 * @param string $input Sanitized text. 2617 * @param string $raw Original text. 2618 */ 2619 return apply_filters( 'bp_sanitize_text_field_keep_linebreaks', $input, $raw ); 2620 } -
new file src/bp-core/classes/class-bp-customizer-control-range.php
diff --git a/src/bp-core/classes/class-bp-customizer-control-range.php b/src/bp-core/classes/class-bp-customizer-control-range.php new file mode 100644 index 0000000..c1252e9
- + 1 <?php 2 /** 3 * Core component class. 4 * 5 * @package BuddyPress 6 * @subpackage Core 7 */ 8 9 // Exit if accessed directly. 10 defined( 'ABSPATH' ) || exit; 11 12 /** 13 * BuddyPress Customizer font size control. 14 * 15 * @since 2.5.0 16 */ 17 class BP_Customizer_Control_Range extends WP_Customize_Control { 18 /** 19 * @var string 20 */ 21 public $type = 'range'; 22 23 /** 24 * Enqueue scripts/styles for the color picker. 25 * 26 * @since 2.5.0 27 */ 28 public function enqueue() { 29 wp_enqueue_script( 'bp-customizer-controls' ); 30 wp_enqueue_style( 'bp-customizer-controls' ); 31 } 32 33 /** 34 * Render the control. 35 * 36 * @since 2.5.0 37 */ 38 public function render_content() { 39 $id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); 40 $class = 'customize-control customize-control-' . $this->type; 41 42 ?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>"> 43 <?php if ( $this->label ) : ?> 44 <label for="<?php echo esc_attr( "{$id}-range" ); ?>"> 45 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> 46 </label> 47 <?php endif; ?> 48 49 <input type="range" id="<?php echo esc_attr( "{$id}-range" ); ?>" <?php $this->link(); $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" /> 50 <output for="<?php echo esc_attr( "{$id}-range" ); ?>"><?php echo esc_html( $this->value() ); ?></output> 51 52 <?php if ( $this->description ) : ?> 53 <p><span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span></p> 54 <?php endif; ?> 55 </li><?php 56 } 57 } -
src/bp-loader.php
diff --git a/src/bp-loader.php b/src/bp-loader.php index 77d5408..040cd1a 100644
a b class BuddyPress { 467 467 require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' ); 468 468 469 469 // Require all of the BuddyPress core libraries 470 require( $this->plugin_dir . 'bp-core/bp-core-dependency.php' ); 471 require( $this->plugin_dir . 'bp-core/bp-core-actions.php' ); 472 require( $this->plugin_dir . 'bp-core/bp-core-caps.php' ); 473 require( $this->plugin_dir . 'bp-core/bp-core-cache.php' ); 474 require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php' ); 475 require( $this->plugin_dir . 'bp-core/bp-core-update.php' ); 476 require( $this->plugin_dir . 'bp-core/bp-core-options.php' ); 477 require( $this->plugin_dir . 'bp-core/bp-core-classes.php' ); 478 require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php' ); 479 require( $this->plugin_dir . 'bp-core/bp-core-filters.php' ); 480 require( $this->plugin_dir . 'bp-core/bp-core-attachments.php' ); 481 require( $this->plugin_dir . 'bp-core/bp-core-avatars.php' ); 482 require( $this->plugin_dir . 'bp-core/bp-core-widgets.php' ); 483 require( $this->plugin_dir . 'bp-core/bp-core-template.php' ); 484 require( $this->plugin_dir . 'bp-core/bp-core-adminbar.php' ); 485 require( $this->plugin_dir . 'bp-core/bp-core-buddybar.php' ); 486 require( $this->plugin_dir . 'bp-core/bp-core-catchuri.php' ); 487 require( $this->plugin_dir . 'bp-core/bp-core-component.php' ); 488 require( $this->plugin_dir . 'bp-core/bp-core-functions.php' ); 489 require( $this->plugin_dir . 'bp-core/bp-core-moderation.php' ); 490 require( $this->plugin_dir . 'bp-core/bp-core-loader.php' ); 470 require( $this->plugin_dir . 'bp-core/bp-core-dependency.php' ); 471 require( $this->plugin_dir . 'bp-core/bp-core-actions.php' ); 472 require( $this->plugin_dir . 'bp-core/bp-core-caps.php' ); 473 require( $this->plugin_dir . 'bp-core/bp-core-cache.php' ); 474 require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php' ); 475 require( $this->plugin_dir . 'bp-core/bp-core-update.php' ); 476 require( $this->plugin_dir . 'bp-core/bp-core-options.php' ); 477 require( $this->plugin_dir . 'bp-core/bp-core-classes.php' ); 478 require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php' ); 479 require( $this->plugin_dir . 'bp-core/bp-core-filters.php' ); 480 require( $this->plugin_dir . 'bp-core/bp-core-attachments.php' ); 481 require( $this->plugin_dir . 'bp-core/bp-core-avatars.php' ); 482 require( $this->plugin_dir . 'bp-core/bp-core-widgets.php' ); 483 require( $this->plugin_dir . 'bp-core/bp-core-template.php' ); 484 require( $this->plugin_dir . 'bp-core/bp-core-adminbar.php' ); 485 require( $this->plugin_dir . 'bp-core/bp-core-buddybar.php' ); 486 require( $this->plugin_dir . 'bp-core/bp-core-catchuri.php' ); 487 require( $this->plugin_dir . 'bp-core/bp-core-component.php' ); 488 require( $this->plugin_dir . 'bp-core/bp-core-functions.php' ); 489 require( $this->plugin_dir . 'bp-core/bp-core-moderation.php' ); 490 require( $this->plugin_dir . 'bp-core/bp-core-loader.php' ); 491 require( $this->plugin_dir . 'bp-core/bp-core-customizer-email.php' ); 491 492 492 493 // Skip or load deprecated content 493 494 if ( false !== $this->load_deprecated ) {