[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-content/themes/twentyfourteen/inc/ -> custom-header.php (source)

   1  <?php
   2  /**
   3   * Implement Custom Header functionality for Twenty Fourteen
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Fourteen
   7   * @since Twenty Fourteen 1.0
   8   */
   9  
  10  /**
  11   * Set up the WordPress core custom header settings.
  12   *
  13   * @since Twenty Fourteen 1.0
  14   *
  15   * @uses twentyfourteen_header_style()
  16   * @uses twentyfourteen_admin_header_style()
  17   * @uses twentyfourteen_admin_header_image()
  18   */
  19  function twentyfourteen_custom_header_setup() {
  20      /**
  21       * Filter Twenty Fourteen custom-header support arguments.
  22       *
  23       * @since Twenty Fourteen 1.0
  24       *
  25       * @param array $args {
  26       *     An array of custom-header support arguments.
  27       *
  28       *     @type bool   $header_text            Whether to display custom header text. Default false.
  29       *     @type int    $width                  Width in pixels of the custom header image. Default 1260.
  30       *     @type int    $height                 Height in pixels of the custom header image. Default 240.
  31       *     @type bool   $flex_height            Whether to allow flexible-height header images. Default true.
  32       *     @type string $admin_head_callback    Callback function used to style the image displayed in
  33       *                                          the Appearance > Header screen.
  34       *     @type string $admin_preview_callback Callback function used to create the custom header markup in
  35       *                                          the Appearance > Header screen.
  36       * }
  37       */
  38      add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array(
  39          'default-text-color'     => 'fff',
  40          'width'                  => 1260,
  41          'height'                 => 240,
  42          'flex-height'            => true,
  43          'wp-head-callback'       => 'twentyfourteen_header_style',
  44          'admin-head-callback'    => 'twentyfourteen_admin_header_style',
  45          'admin-preview-callback' => 'twentyfourteen_admin_header_image',
  46      ) ) );
  47  }
  48  add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' );
  49  
  50  if ( ! function_exists( 'twentyfourteen_header_style' ) ) :
  51  /**
  52   * Styles the header image and text displayed on the blog
  53   *
  54   * @see twentyfourteen_custom_header_setup().
  55   *
  56   */
  57  function twentyfourteen_header_style() {
  58      $text_color = get_header_textcolor();
  59  
  60      // If no custom color for text is set, let's bail.
  61      if ( display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) )
  62          return;
  63  
  64      // If we get this far, we have custom styles.
  65      ?>
  66      <style type="text/css" id="twentyfourteen-header-css">
  67      <?php
  68          // Has the text been hidden?
  69          if ( ! display_header_text() ) :
  70      ?>
  71          .site-title,
  72          .site-description {
  73              clip: rect(1px 1px 1px 1px); /* IE7 */
  74              clip: rect(1px, 1px, 1px, 1px);
  75              position: absolute;
  76          }
  77      <?php
  78          // If the user has set a custom color for the text, use that.
  79          elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
  80      ?>
  81          .site-title a {
  82              color: #<?php echo esc_attr( $text_color ); ?>;
  83          }
  84      <?php endif; ?>
  85      </style>
  86      <?php
  87  }
  88  endif; // twentyfourteen_header_style
  89  
  90  
  91  if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) :
  92  /**
  93   * Style the header image displayed on the Appearance > Header screen.
  94   *
  95   * @see twentyfourteen_custom_header_setup()
  96   *
  97   * @since Twenty Fourteen 1.0
  98   */
  99  function twentyfourteen_admin_header_style() {
 100  ?>
 101      <style type="text/css" id="twentyfourteen-admin-header-css">
 102      .appearance_page_custom-header #headimg {
 103          background-color: #000;
 104          border: none;
 105          max-width: 1260px;
 106          min-height: 48px;
 107      }
 108      #headimg h1 {
 109          font-family: Lato, sans-serif;
 110          font-size: 18px;
 111          line-height: 48px;
 112          margin: 0 0 0 30px;
 113      }
 114      #headimg h1 a {
 115          color: #fff;
 116          text-decoration: none;
 117      }
 118      #headimg img {
 119          vertical-align: middle;
 120      }
 121      </style>
 122  <?php
 123  }
 124  endif; // twentyfourteen_admin_header_style
 125  
 126  if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) :
 127  /**
 128   * Create the custom header image markup displayed on the Appearance > Header screen.
 129   *
 130   * @see twentyfourteen_custom_header_setup()
 131   *
 132   * @since Twenty Fourteen 1.0
 133   */
 134  function twentyfourteen_admin_header_image() {
 135  ?>
 136      <div id="headimg">
 137          <?php if ( get_header_image() ) : ?>
 138          <img src="<?php header_image(); ?>" alt="">
 139          <?php endif; ?>
 140          <h1 class="displaying-header-text"><a id="name"<?php echo sprintf( ' style="color:#%s;"', get_header_textcolor() ); ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
 141      </div>
 142  <?php
 143  }
 144  endif; // twentyfourteen_admin_header_image


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu