<?php
// Customize mce editor font sizes
// Enable font size & font family selects in the editor
if ( ! function_exists( 'wpex_mce_buttons' ) ) {
	function wpex_mce_buttons( $buttons ) {
		array_unshift( $buttons, 'fontsizeselect' ); // Add Font Size Select
		return $buttons;
	}
}
add_filter( 'mce_buttons_2', 'wpex_mce_buttons' );

if ( ! function_exists( 'wpex_mce_text_sizes' ) ) {
    function wpex_mce_text_sizes( $initArray ){
        $initArray['fontsize_formats'] = "0.9rem 10rem 1.2rem 1.3rem 1.4rem 1.6rem 1.8rem 2.1rem 2.4rem 2.8rem 3.2rem 3.6rem";
        return $initArray;
    }
}
add_filter( 'tiny_mce_before_init', 'wpex_mce_text_sizes' );

function changeMceDefaults($in) {

    // customize the buttons
    $in['theme_advanced_buttons1'] = 'bold,italic,underline,bullist,numlist,hr,blockquote,link,unlink,justifyleft,justifycenter,justifyright,justifyfull,outdent,indent';         
    $in['theme_advanced_buttons2'] = 'formatselect,pastetext,pasteword,charmap,undo,redo';

    // Keep the "kitchen sink" open
    $in[ 'megax_adv_hidden' ] = FALSE;
    return $in;
}
add_filter( 'tiny_mce_before_init', 'changeMceDefaults' );



add_filter('mce_external_plugins', 'my_custom_mce_plugin');
function my_custom_mce_plugin($plugin_array) {
    $plugin_array['custom_dynamic_button'] = DS1CDNBucket . '/admin/tinymce-custom-button.js?v3';
    return $plugin_array;
}

add_filter('mce_buttons', 'my_custom_mce_button');
function my_custom_mce_button($buttons) {
    array_push($buttons, 'custom_dynamic_button');
    return $buttons;
}
