Custom_Image_Header::js_1() WordPress Method
The Custom_Image_Header::js_1() method is used to enqueue the necessary Javascript for the image header on the front-end of a WordPress site. This method is called by the Custom_Image_Header::init() method.
Custom_Image_Header::js_1() #
Display JavaScript based on Step 1 and 3.
Source
File: wp-admin/includes/class-custom-image-header.php
public function js_1() { $default_color = ''; if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { $default_color = get_theme_support( 'custom-header', 'default-text-color' ); if ( $default_color && false === strpos( $default_color, '#' ) ) { $default_color = '#' . $default_color; } } ?> <script type="text/javascript"> (function($){ var default_color = '<?php echo esc_js( $default_color ); ?>', header_text_fields; function pickColor(color) { $('#name').css('color', color); $('#desc').css('color', color); $('#text-color').val(color); } function toggle_text() { var checked = $('#display-header-text').prop('checked'), text_color; header_text_fields.toggle( checked ); if ( ! checked ) return; text_color = $('#text-color'); if ( '' === text_color.val().replace('#', '') ) { text_color.val( default_color ); pickColor( default_color ); } else { pickColor( text_color.val() ); } } $( function() { var text_color = $('#text-color'); header_text_fields = $('.displaying-header-text'); text_color.wpColorPicker({ change: function( event, ui ) { pickColor( text_color.wpColorPicker('color') ); }, clear: function() { pickColor( '' ); } }); $('#display-header-text').click( toggle_text ); <?php if ( ! display_header_text() ) : ?> toggle_text(); <?php endif; ?> } ); })(jQuery); </script> <?php }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |