<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][10475] trunk/src: Emails: add Customizer integration.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/10475">10475</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10475","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>djpaul</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-01-27 20:56:27 +0000 (Wed, 27 Jan 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Emails: add Customizer integration.

This integration allows appearance changes to be easily made to emails, and previewed. For example, font size, background and font colors, and more.

A new submenu has been added under wp-admin's "Appearance" menu that takes the current priviledged user directly to the Customizer preview for a randomly-selected email.

See <a href="http://buddypress.trac.wordpress.org/ticket/6592">#6592</a>. Props timersys, mercime, boonebgorges, hnla, DJPaul.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcorebpcoreadminphp">trunk/src/bp-core/bp-core-admin.php</a></li>
<li><a href="#trunksrcbploaderphp">trunk/src/bp-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcbpcoreadmincsscustomizercontrolsrtlcss">trunk/src/bp-core/admin/css/customizer-controls-rtl.css</a></li>
<li><a href="#trunksrcbpcoreadmincsscustomizercontrolscss">trunk/src/bp-core/admin/css/customizer-controls.css</a></li>
<li>trunk/src/bp-core/admin/js/</li>
<li><a href="#trunksrcbpcoreadminjscustomizercontrolsjs">trunk/src/bp-core/admin/js/customizer-controls.js</a></li>
<li><a href="#trunksrcbpcoreadminjscustomizerreceiveremailsjs">trunk/src/bp-core/admin/js/customizer-receiver-emails.js</a></li>
<li><a href="#trunksrcbpcorebpcorecustomizeremailphp">trunk/src/bp-core/bp-core-customizer-email.php</a></li>
<li><a href="#trunksrcbpcoreclassesclassbpcustomizercontrolrangephp">trunk/src/bp-core/classes/class-bp-customizer-control-range.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcoreadmincsscustomizercontrolsrtlcss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/admin/css/customizer-controls-rtl.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/css/customizer-controls-rtl.css                           (rev 0)
+++ trunk/src/bp-core/admin/css/customizer-controls-rtl.css     2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,10 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.customize-control-range output {
+       background-color: #FFF;
+       border: 1px solid #DDD;
+       box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 );
+       float: right;
+       margin-left: 10px;
+       margin-top: -4px;
+       min-width: 16px;
+       padding: 5px;
+}
</ins></span></pre></div>
<a id="trunksrcbpcoreadmincsscustomizercontrolscss"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/admin/css/customizer-controls.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/css/customizer-controls.css                               (rev 0)
+++ trunk/src/bp-core/admin/css/customizer-controls.css 2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,10 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.customize-control-range output {
+       background-color: #FFF;
+       border: 1px solid #DDD;
+       box-shadow: inset 0 1px 2px rgba( 0, 0, 0, 0.07 );
+       float: left;
+       margin-right: 10px;
+       margin-top: -4px;
+       min-width: 16px;
+       padding: 5px;
+}
</ins></span></pre></div>
<a id="trunksrcbpcoreadminjscustomizercontrolsjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/admin/js/customizer-controls.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/js/customizer-controls.js                         (rev 0)
+++ trunk/src/bp-core/admin/js/customizer-controls.js   2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,22 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Customizer controls implementation.
+ *
+ * If you're looking to add JS for a specific panel or control, don't add it here.
+ * The file only implements generic Customizer control implementations.
+ *
+ * @since 2.5.0
+ */
+
+(function( $ ) {
+       $( window ).on( 'load', function() {
+               /**
+                * <range> element: update label when value changes.
+                *
+                * @since 2.5.0
+                */
+               $( '.customize-control-range input' ).on( 'input', function() {
+                       var $this = $( this );
+                       $this.siblings( 'output' ).text( $this.val() );
+               });
+       });
+})( jQuery );
</ins></span></pre></div>
<a id="trunksrcbpcoreadminjscustomizerreceiveremailsjs"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/admin/js/customizer-receiver-emails.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/js/customizer-receiver-emails.js                          (rev 0)
+++ trunk/src/bp-core/admin/js/customizer-receiver-emails.js    2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,115 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Customizer implementation for Email.
+ *
+ * If you're looking to add JS for every instance of a control, don't add it here.
+ * The file only implements the Customizer controls for Emails.
+ *
+ * @since 2.5.0
+ */
+
+(function( $ ) {
+       wp.customize( 'bp_email_options[email_bg]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.email_bg' ).attr( 'bgcolor', newval );
+                               $( 'hr' ).attr( 'color', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[header_bg]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.header_bg' ).attr( 'bgcolor', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[header_text_size]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.header_text_size' ).css( 'font-size', newval + 'px' );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[header_text_color]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.header_text_color' ).css( 'color', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[highlight_color]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.header_bg' ).css( 'border-top-color', newval );
+                               $( 'a' ).css( 'color', newval );
+                               $( 'hr' ).attr( 'color', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[body_bg]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.body_bg' ).attr( 'bgcolor', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[body_text_size]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               // 1.618 = golden mean.
+                               $( '.body_text_size' )
+                                       .css( 'font-size', newval + 'px' )
+                                       .css( 'line-height', Math.floor( newval * 1.618 ) + 'px' );
+
+                               // 1.35 = default body_text_size multipler. Gives default heading of 20px.
+                               $( '.welcome' ).css( 'font-size', Math.floor( newval * 1.35 ) + 'px' );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[body_text_color]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.body_text_color' ).css( 'color', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[footer_bg]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.footer_bg' ).attr( 'bgcolor', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[footer_text_size]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.footer_text_size' )
+                                       .css( 'font-size', newval + 'px' )
+                                       .css( 'line-height', Math.floor( newval * 1.618 ) + 'px' );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[footer_text_color]', function( value ) {
+               value.bind(function( newval ) {
+                       if ( newval.length ) {
+                               $( '.footer_text_color' ).css( 'color', newval );
+                       }
+               });
+       });
+
+       wp.customize( 'bp_email_options[footer_text]', function( value ) {
+               value.bind(function( newval ) {
+                       $( '.footer_text' ).text( newval );
+               });
+       });
+})( jQuery );
</ins></span></pre></div>
<a id="trunksrcbpcorebpcoreadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/bp-core-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-admin.php       2016-01-27 20:23:37 UTC (rev 10474)
+++ trunk/src/bp-core/bp-core-admin.php 2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -935,6 +935,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'file'         => $common_css,
</span><span class="cx" style="display: block; padding: 0 10px">                                'dependencies' => array(),
</span><span class="cx" style="display: block; padding: 0 10px">                        ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       // 2.5
+                       'bp-customizer-controls' => array(
+                               'file'         => "{$url}customizer-controls{$min}.css",
+                               'dependencies' => array(),
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -967,9 +973,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param array $value Array of admin JS file information to register.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                $scripts = apply_filters( 'bp_core_admin_register_scripts', array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // 2.5
+                       'bp-customizer-controls' => array(
+                               'file'         => "{$url}customizer-controls{$min}.js",
+                               'dependencies' => array( 'jquery' ),
+                               'footer'       => true,
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $version = bp_get_version();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                foreach ( $scripts as $id => $script ) {
</span></span></pre></div>
<a id="trunksrcbpcorebpcorecustomizeremailphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/bp-core-customizer-email.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/bp-core-customizer-email.php                            (rev 0)
+++ trunk/src/bp-core/bp-core-customizer-email.php      2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,426 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * BuddyPress Customizer implementation for email.
+ *
+ * @since 2.5.0
+ *
+ * @package BuddyPress
+ * @subpackage Core
+ */
+
+// Exit if accessed directly.
+defined( 'ABSPATH' ) || exit;
+
+/**
+ * Initialize the Customizer for emails.
+ *
+ * @since 2.5.0
+ *
+ * @param WP_Customize_Manager $wp_customize The Customizer object.
+ */
+function bp_email_init_customizer( WP_Customize_Manager $wp_customize ) {
+
+       // Require WP 4.0+.
+       if ( ! method_exists( $wp_customize, 'add_panel' ) ) {
+               return;
+       }
+
+       if ( ! bp_is_email_customizer() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
+               return;
+       }
+
+       $wp_customize->add_panel( 'bp_mailtpl', array(
+               'description' => __( 'Customize the appearance of emails sent by BuddyPress.', 'buddypress' ),
+               'title'       => _x( 'Emails', 'screen heading', 'buddypress' ),
+       ) );
+
+       $sections = bp_email_get_customizer_sections();
+       foreach( $sections as $section_id => $args ) {
+               $wp_customize->add_section( $section_id, $args );
+       }
+
+       $settings = bp_email_get_customizer_settings();
+       foreach( $settings as $setting_id => $args ) {
+               $wp_customize->add_setting( $setting_id, $args );
+       }
+
+       /**
+        * BP_Customizer_Control_Range class.
+        */
+       require_once dirname( __FILE__ ) . '/classes/class-bp-customizer-control-range.php';
+
+       /**
+        * Fires to let plugins register extra Customizer controls for emails.
+        *
+        * @since 2.5.0
+        *
+        * @param WP_Customize_Manager $wp_customize The Customizer object.
+        */
+       do_action( 'bp_email_customizer_register_sections', $wp_customize );
+
+       $controls = bp_email_get_customizer_controls();
+       foreach ( $controls as $control_id => $args ) {
+               $wp_customize->add_control( new $args['class']( $wp_customize, $control_id, $args ) );
+       }
+
+
+       /*
+        * Hook actions/filters for further configuration.
+        */
+
+       add_filter( 'customize_section_active', 'bp_email_customizer_hide_sections', 12, 2 );
+
+       if ( is_customize_preview() ) {
+               /*
+                * Enqueue scripts/styles for the Customizer's preview window.
+                *
+                * Scripts can't be registered in bp_core_register_common_styles() etc because
+                * the Customizer loads very, very early.
+                */
+               $bp  = buddypress();
+               $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
+
+               wp_enqueue_script(
+                       'bp-customizer-receiver-emails',
+                       "{$bp->plugin_url}bp-core/admin/js/customizer-receiver-emails{$min}.js",
+                       array( 'customize-preview' ),
+                       bp_get_version(),
+                       true
+               );
+       }
+}
+add_action( 'bp_customize_register', 'bp_email_init_customizer' );
+
+/**
+ * Are we looking at the email customizer?
+ *
+ * @since 2.5.0
+ *
+ * @return bool
+ */
+function bp_is_email_customizer() {
+       return isset( $_GET['bp_customizer'] ) && $_GET['bp_customizer'] === 'email';
+}
+
+/**
+ * Only show email sections in the Customizer.
+ *
+ * @since 2.5.0
+ *
+ * @param $active Whether the Customizer section is active.
+ * @param WP_Customize_Section $section {@see WP_Customize_Section} instance.
+ * @return bool
+ */
+function bp_email_customizer_hide_sections( $active, $section ) {
+       if ( ! bp_is_email_customizer() ) {
+               return $active;
+       }
+
+       return in_array( $section->id, array_keys( bp_email_get_customizer_sections() ), true );
+}
+
+/**
+ * Get Customizer sections for emails.
+ *
+ * @since 2.5.0
+ *
+ * @return array
+ */
+function bp_email_get_customizer_sections() {
+
+       /**
+        * Filter Customizer sections for emails.
+        *
+        * @since 2.5.0
+        *
+        * @param array $sections Email Customizer sections to add.
+        */
+       return apply_filters( 'bp_email_get_customizer_sections', array(
+               'section_bp_mailtpl_header' => array(
+                       'capability' => 'bp_moderate',
+                       'panel'      => 'bp_mailtpl',
+                       'title'      => _x( 'Header', 'email', 'buddypress' ),
+               ),
+               'section_bp_mailtpl_body' => array(
+                       'capability' => 'bp_moderate',
+                       'panel'      => 'bp_mailtpl',
+                       'title'      => _x( 'Body', 'email', 'buddypress' ),
+               ),
+               'section_bp_mailtpl_footer' => array(
+                       'capability' => 'bp_moderate',
+                       'panel'      => 'bp_mailtpl',
+                       'title'      => _x( 'Footer', 'email', 'buddypress' ),
+               ),
+       ) );
+}
+
+/**
+ * Get Customizer settings for emails.
+ *
+ * @since 2.5.0
+ *
+ * @return array
+ */
+function bp_email_get_customizer_settings() {
+       $defaults = bp_email_get_appearance_settings();
+
+       /**
+        * Filter Customizer settings for emails.
+        *
+        * @since 2.5.0
+        *
+        * @param array $settings Email Customizer settings to add.
+        */
+       return apply_filters( 'bp_email_get_customizer_settings', array(
+               'bp_email_options[email_bg]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['email_bg'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[header_bg]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['header_bg'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[header_text_size]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['header_text_size'],
+                       'sanitize_callback' => 'intval',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[header_text_color]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['header_text_color'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[highlight_color]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['highlight_color'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[body_bg]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['body_bg'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[body_text_size]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['body_text_size'],
+                       'sanitize_callback' => 'intval',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[body_text_color]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['body_text_color'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[footer_text]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['footer_text'],
+                       'sanitize_callback' => 'wp_filter_post_kses',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[footer_bg]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['footer_bg'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[footer_text_size]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['footer_text_size'],
+                       'sanitize_callback' => 'intval',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+               'bp_email_options[footer_text_color]' => array(
+                       'capability'        => 'bp_moderate',
+                       'default'           => $defaults['footer_text_color'],
+                       'sanitize_callback' => 'sanitize_hex_color',
+                       'transport'         => 'postMessage',
+                       'type'              => 'option',
+               ),
+       ) );
+}
+
+/**
+ * Get Customizer controls for emails.
+ *
+ * @since 2.5.0
+ *
+ * @return array
+ */
+function bp_email_get_customizer_controls() {
+
+       /**
+        * Filter Customizer controls for emails.
+        *
+        * @since 2.5.0
+        *
+        * @param array $controls Email Customizer controls to add.
+        */
+       return apply_filters( 'bp_email_get_customizer_controls', array(
+               'bp_mailtpl_email_bg' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Email background color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_header',
+                       'settings' => 'bp_email_options[email_bg]',
+               ),
+
+               'bp_mailtpl_header_bg' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Header background color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_header',
+                       'settings' => 'bp_email_options[header_bg]',
+               ),
+
+               'bp_mailtpl_highlight_color' => array(
+                       'class'       => 'WP_Customize_Color_Control',
+                       'description' => __( 'Applied to links and other decorative areas.', 'buddypress' ),
+                       'label'       => __( 'Highlight color', 'buddypress' ),
+                       'section'     => 'section_bp_mailtpl_header',
+                       'settings'    => 'bp_email_options[highlight_color]',
+               ),
+
+               'bp_mailtpl_header_text_color' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Text color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_header',
+                       'settings' => 'bp_email_options[header_text_color]',
+               ),
+
+               'bp_mailtpl_header_text_size' => array(
+                       'class'    => 'BP_Customizer_Control_Range',
+                       'label'    => __( 'Text size', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_header',
+                       'settings' => 'bp_email_options[header_text_size]',
+
+                       'input_attrs' => array(
+                               'max'  => 100,
+                               'min'  => 1,
+                               'step' => 1,
+                       ),
+               ),
+
+
+               'bp_mailtpl_body_bg' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Background color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_body',
+                       'settings' => 'bp_email_options[body_bg]',
+               ),
+
+
+               'bp_mailtpl_body_text_color' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Text color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_body',
+                       'settings' => 'bp_email_options[body_text_color]',
+               ),
+
+               'bp_mailtpl_body_text_size' => array(
+                       'class'    => 'BP_Customizer_Control_Range',
+                       'label'    => __( 'Text size', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_body',
+                       'settings' => 'bp_email_options[body_text_size]',
+
+                       'input_attrs' => array(
+                               'max'  => 24,
+                               'min'  => 8,
+                               'step' => 1,
+                       ),
+               ),
+
+
+               'bp_mailtpl_footer_text' => array(
+                       'class'       => 'WP_Customize_Control',
+                       'description' => __('Change the email footer here', 'buddypress' ),
+                       'label'       => __( 'Footer text', 'buddypress' ),
+                       'section'     => 'section_bp_mailtpl_footer',
+                       'settings'    => 'bp_email_options[footer_text]',
+                       'type'        => 'textarea',
+               ),
+
+               'bp_mailtpl_footer_bg' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Background color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_footer',
+                       'settings' => 'bp_email_options[footer_bg]',
+               ),
+
+               'bp_mailtpl_footer_text_color' => array(
+                       'class'    => 'WP_Customize_Color_Control',
+                       'label'    => __( 'Text color', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_footer',
+                       'settings' => 'bp_email_options[footer_text_color]',
+               ),
+
+               'bp_mailtpl_footer_text_size' => array(
+                       'class'    => 'BP_Customizer_Control_Range',
+                       'label'    => __( 'Text size', 'buddypress' ),
+                       'section'  => 'section_bp_mailtpl_footer',
+                       'settings' => 'bp_email_options[footer_text_size]',
+
+                       'input_attrs' => array(
+                               'max'  => 24,
+                               'min'  => 8,
+                               'step' => 1,
+                       ),
+               ),
+       ) );
+}
+
+/**
+ * Implements a JS redirect to the Customizer, previewing a randomly selected email.
+ *
+ * @since 2.5.0
+ */
+function bp_email_redirect_to_customizer() {
+       $email = get_posts( array(
+               'fields'           => 'ids',
+               'orderby'          => 'rand',
+               'post_status'      => 'publish',
+               'post_type'        => bp_get_email_post_type(),
+               'posts_per_page'   => 1,
+               'suppress_filters' => false,
+       ) );
+
+       $preview_url = admin_url();
+
+       if ( $email ) {
+               $preview_url = get_post_permalink( $email[0] ) . '&bp_customizer=email';
+       }
+
+       $redirect_url = add_query_arg(
+               array(
+                       'autofocus[panel]' => 'bp_mailtpl',
+                       'bp_customizer'    => 'email',
+                       'return'           => rawurlencode( admin_url() ),
+                       'url'              => rawurlencode( $preview_url ),
+               ),
+               admin_url( 'customize.php' )
+       );
+
+       printf(
+               '<script type="text/javascript">window.location = "%s";</script>',
+               esc_url_raw( $redirect_url )
+       );
+
+       exit;
+}
</ins></span></pre></div>
<a id="trunksrcbpcoreclassesclassbpcustomizercontrolrangephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/classes/class-bp-customizer-control-range.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/classes/class-bp-customizer-control-range.php                           (rev 0)
+++ trunk/src/bp-core/classes/class-bp-customizer-control-range.php     2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,57 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Core component class.
+ *
+ * @package BuddyPress
+ * @subpackage Core
+ */
+
+// Exit if accessed directly.
+defined( 'ABSPATH' ) || exit;
+
+/**
+ * BuddyPress Customizer font size control.
+ *
+ * @since 2.5.0
+ */
+class BP_Customizer_Control_Range extends WP_Customize_Control {
+       /**
+        * @var string
+        */
+       public $type = 'range';
+
+       /**
+        * Enqueue scripts/styles for the color picker.
+        *
+        * @since 2.5.0
+        */
+       public function enqueue() {
+               wp_enqueue_script( 'bp-customizer-controls' );
+               wp_enqueue_style( 'bp-customizer-controls' );
+       }
+
+       /**
+        * Render the control.
+        *
+        * @since 2.5.0
+        */
+       public function render_content() {
+               $id    = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) );
+               $class = 'customize-control customize-control-' . $this->type;
+
+               ?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
+                       <?php if ( $this->label ) : ?>
+                               <label for="<?php echo esc_attr( "{$id}-range" ); ?>">
+                                       <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
+                               </label>
+                       <?php endif; ?>
+
+                       <input type="range" id="<?php echo esc_attr( "{$id}-range" ); ?>" <?php $this->link(); $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" />
+                       <output for="<?php echo esc_attr( "{$id}-range" ); ?>"><?php echo esc_html( $this->value() ); ?></output>
+
+                       <?php if ( $this->description ) : ?>
+                               <p><span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span></p>
+                       <?php endif; ?>
+               </li><?php
+       }
+}
</ins></span></pre></div>
<a id="trunksrcbploaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-loader.php   2016-01-27 20:23:37 UTC (rev 10474)
+++ trunk/src/bp-loader.php     2016-01-27 20:56:27 UTC (rev 10475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -471,27 +471,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">                require( $this->plugin_dir . 'bp-core/bp-core-theme-compatibility.php' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Require all of the BuddyPress core libraries
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                require( $this->plugin_dir . 'bp-core/bp-core-dependency.php'  );
-               require( $this->plugin_dir . 'bp-core/bp-core-actions.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-caps.php'        );
-               require( $this->plugin_dir . 'bp-core/bp-core-cache.php'       );
-               require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php'       );
-               require( $this->plugin_dir . 'bp-core/bp-core-update.php'      );
-               require( $this->plugin_dir . 'bp-core/bp-core-options.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-classes.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php'    );
-               require( $this->plugin_dir . 'bp-core/bp-core-filters.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-attachments.php' );
-               require( $this->plugin_dir . 'bp-core/bp-core-avatars.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-widgets.php'     );
-               require( $this->plugin_dir . 'bp-core/bp-core-template.php'    );
-               require( $this->plugin_dir . 'bp-core/bp-core-adminbar.php'    );
-               require( $this->plugin_dir . 'bp-core/bp-core-buddybar.php'    );
-               require( $this->plugin_dir . 'bp-core/bp-core-catchuri.php'    );
-               require( $this->plugin_dir . 'bp-core/bp-core-component.php'   );
-               require( $this->plugin_dir . 'bp-core/bp-core-functions.php'   );
-               require( $this->plugin_dir . 'bp-core/bp-core-moderation.php'  );
-               require( $this->plugin_dir . 'bp-core/bp-core-loader.php'      );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         require( $this->plugin_dir . 'bp-core/bp-core-dependency.php'       );
+               require( $this->plugin_dir . 'bp-core/bp-core-actions.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-caps.php'             );
+               require( $this->plugin_dir . 'bp-core/bp-core-cache.php'            );
+               require( $this->plugin_dir . 'bp-core/bp-core-cssjs.php'            );
+               require( $this->plugin_dir . 'bp-core/bp-core-update.php'           );
+               require( $this->plugin_dir . 'bp-core/bp-core-options.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-classes.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-taxonomy.php'         );
+               require( $this->plugin_dir . 'bp-core/bp-core-filters.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-attachments.php'      );
+               require( $this->plugin_dir . 'bp-core/bp-core-avatars.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-widgets.php'          );
+               require( $this->plugin_dir . 'bp-core/bp-core-template.php'         );
+               require( $this->plugin_dir . 'bp-core/bp-core-adminbar.php'         );
+               require( $this->plugin_dir . 'bp-core/bp-core-buddybar.php'         );
+               require( $this->plugin_dir . 'bp-core/bp-core-catchuri.php'         );
+               require( $this->plugin_dir . 'bp-core/bp-core-component.php'        );
+               require( $this->plugin_dir . 'bp-core/bp-core-functions.php'        );
+               require( $this->plugin_dir . 'bp-core/bp-core-moderation.php'       );
+               require( $this->plugin_dir . 'bp-core/bp-core-loader.php'           );
+               require( $this->plugin_dir . 'bp-core/bp-core-customizer-email.php' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Skip or load deprecated content
</span><span class="cx" style="display: block; padding: 0 10px">                if ( false !== $this->load_deprecated ) {
</span></span></pre>
</div>
</div>

</body>
</html>