Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Implements an optional custom header for A THEME.
- * See http://codex.wordpress.org/Custom_Headers
- *
- * Sets up the WordPress core custom header arguments and settings.
- *
- * @uses add_theme_support() to register support for 3.4 and up.
- * @uses a_theme_admin_header_style() to style wp-admin form.
- * @uses a_theme_admin_header_image() to add custom markup to wp-admin form.
- *
- */
- function a_theme_custom_header_setup() {
- $args = array(
- // image (empty to use none).
- 'default-image' => '',
- // Set height and width, with a maximum value for the width.
- 'height' => 192,
- 'width' => 740,
- 'max-width' => 740,
- // Support flexible height and width.
- 'flex-height' => true,
- 'flex-width' => true,
- 'default-text-color' => '',
- 'header-text' => false,
- // Random image rotation off by default.
- 'random-default' => false,
- // Callbacks for styling the header and the admin preview.
- 'admin-head-callback' => 'a_theme_admin_header_style',
- 'admin-preview-callback' => 'a_theme_admin_header_image',
- );
- add_theme_support( 'custom-header', $args );
- }
- add_action( 'after_setup_theme', 'a_theme_custom_header_setup' );
- /**
- * Styles the header image displayed on the Appearance > Header admin panel.
- *
- * @since A THEME 1.0
- */
- function a_theme_admin_header_style() {
- ?>
- <style type="text/css">
- .appearance_page_custom-header #headimg {
- border: none;
- }
- #headimg h1,
- #headimg h2 {
- line-height: 1.6;
- margin: 0;
- padding: 0;
- }
- #headimg h1 {
- font-size: 30px;
- }
- #headimg h1 a {
- color: #515151;
- text-decoration: none;
- }
- #headimg h1 a:hover {
- color: #21759b;
- }
- #headimg h2 {
- color: #757575;
- font: normal 13px/1.8 "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
- margin-bottom: 24px;
- }
- #headimg img {
- max-width: <?php echo get_theme_support( 'custom-header', 'max-width' ); ?>px;
- }
- </style>
- <?php
- }
- /**
- * Outputs markup to be displayed on the Appearance > Header admin panel.
- * This callback overrides the default markup displayed there.
- */
- function a_theme_admin_header_image() {
- ?>
- <div id="headimg">
- <?php
- if ( ! display_header_text() )
- $style = ' style="display:none;"';
- else
- $style = ' style="color:#' . get_header_textcolor() . ';"';
- ?>
- <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
- <h2 id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></h2>
- <?php $header_image = get_header_image();
- if ( ! empty( $header_image ) ) : ?>
- <img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
- <?php endif; ?>
- </div>
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement