Last active
April 29, 2016 22:45
-
-
Save s-hiroshi/1dc18d5cbf4271a863291f27e8bbcc1a to your computer and use it in GitHub Desktop.
WordPressのカスタムヘッダー(custom header)登録サンプルです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* カスタム | |
* | |
* @package InfoTown | |
* @author Hiroshi Sawai <info@info-town.jp> | |
* @copyright Hiroshi Sawai | |
*/ | |
class MyTheme_SetUp { | |
/** | |
* Add custom header. | |
* | |
* @since 1.0 | |
*/ | |
function register_custom_header() { | |
$args = array( | |
'width' => 1140, | |
'height' => 330, | |
'header-text' => true, | |
'default-text-color' => '333333', | |
'default-image' => esc_url( get_stylesheet_directory_uri() . '/images/default.jpg' ), | |
'random-default' => false, | |
); | |
$args = apply_filters( 'custom_header_args', $args ); | |
if ( function_exists( 'get_custom_header' ) ) { | |
add_theme_support( 'custom-header', $args ); | |
} else { | |
define( 'NO_HEADER_TEXT', true ); | |
define( 'HEADER_TEXTCOLOR', $args['default-text-color'] ); | |
define( 'HEADER_IMAGE', $args['default-image'] ); | |
define( 'HEADER_IMAGE_WIDTH', $args['width'] ); | |
define( 'HEADER_IMAGE_HEIGHT', $args['height'] ); | |
$args['wp-head-callback']; | |
$args['admin-head-callback']; | |
add_theme_support( 'custom-background', $args ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Support custom header. | |
$setup = new MyTheme_SetUp(); | |
add_action( 'after_setup_theme', array($setup, 'register_custom_header' )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment