Current Path : /home/church/www/launch100ar.com/wp-content/themes/editor-blocks/inc/customizer/ |
Current File : /home/church/www/launch100ar.com/wp-content/themes/editor-blocks/inc/customizer/customizer.php |
<?php /** * Editor Blocks Theme Customizer * * @package editor-blocks * @copyright Copyright (c) 2018, Danny Cooper * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License */ /** * Add postMessage support for site title and description for the Theme Customizer. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. */ function editor_blocks_customize_register( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; } add_action( 'customize_register', 'editor_blocks_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function editor_blocks_customize_preview_js() { wp_enqueue_script( 'editor_blocks_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'editor_blocks_customize_preview_js' ); /** * Get lighter/darker color when given a hex value. * * @param string $hex The hex value to darken. * @param int $steps Steps should be between -255 and 255. Negative = darker, positive = lighter. */ function editor_blocks_brightness( $hex, $steps ) { $steps = max( -255, min( 255, $steps ) ); // Normalize into a six character long hex string. $hex = str_replace( '#', '', $hex ); if ( strlen( $hex ) === 3 ) { $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); } // Split into three parts: R, G and B. $color_parts = str_split( $hex, 2 ); $return = '#'; foreach ( $color_parts as $color ) { $color = hexdec( $color ); // Convert to decimal. $color = max( 0, min( 255, $color + $steps ) ); // Adjust color. $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code. } return sanitize_hex_color( $return ); }