Edit File by line
/home/zeestwma/redstone.../wp-admin/includes
File: class-custom-image-header.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* The custom header image script.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* The custom header image class.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 2.1.0
[11] Fix | Delete
*/
[12] Fix | Delete
#[AllowDynamicProperties]
[13] Fix | Delete
class Custom_Image_Header {
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Callback for administration header.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 2.1.0
[19] Fix | Delete
* @var callable
[20] Fix | Delete
*/
[21] Fix | Delete
public $admin_header_callback;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Callback for header div.
[25] Fix | Delete
*
[26] Fix | Delete
* @since 3.0.0
[27] Fix | Delete
* @var callable
[28] Fix | Delete
*/
[29] Fix | Delete
public $admin_image_div_callback;
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* Holds default headers.
[33] Fix | Delete
*
[34] Fix | Delete
* @since 3.0.0
[35] Fix | Delete
* @var array
[36] Fix | Delete
*/
[37] Fix | Delete
public $default_headers = array();
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Used to trigger a success message when settings updated and set to true.
[41] Fix | Delete
*
[42] Fix | Delete
* @since 3.0.0
[43] Fix | Delete
* @var bool
[44] Fix | Delete
*/
[45] Fix | Delete
private $updated;
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Constructor - Registers administration header callback.
[49] Fix | Delete
*
[50] Fix | Delete
* @since 2.1.0
[51] Fix | Delete
*
[52] Fix | Delete
* @param callable $admin_header_callback Administration header callback.
[53] Fix | Delete
* @param callable $admin_image_div_callback Optional. Custom image div output callback.
[54] Fix | Delete
* Default empty string.
[55] Fix | Delete
*/
[56] Fix | Delete
public function __construct( $admin_header_callback, $admin_image_div_callback = '' ) {
[57] Fix | Delete
$this->admin_header_callback = $admin_header_callback;
[58] Fix | Delete
$this->admin_image_div_callback = $admin_image_div_callback;
[59] Fix | Delete
[60] Fix | Delete
add_action( 'admin_menu', array( $this, 'init' ) );
[61] Fix | Delete
[62] Fix | Delete
add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) );
[63] Fix | Delete
add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) );
[64] Fix | Delete
add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) );
[65] Fix | Delete
add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Sets up the hooks for the Custom Header admin page.
[70] Fix | Delete
*
[71] Fix | Delete
* @since 2.1.0
[72] Fix | Delete
*/
[73] Fix | Delete
public function init() {
[74] Fix | Delete
$page = add_theme_page(
[75] Fix | Delete
_x( 'Header', 'custom image header' ),
[76] Fix | Delete
_x( 'Header', 'custom image header' ),
[77] Fix | Delete
'edit_theme_options',
[78] Fix | Delete
'custom-header',
[79] Fix | Delete
array( $this, 'admin_page' )
[80] Fix | Delete
);
[81] Fix | Delete
[82] Fix | Delete
if ( ! $page ) {
[83] Fix | Delete
return;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
add_action( "admin_print_scripts-{$page}", array( $this, 'js_includes' ) );
[87] Fix | Delete
add_action( "admin_print_styles-{$page}", array( $this, 'css_includes' ) );
[88] Fix | Delete
add_action( "admin_head-{$page}", array( $this, 'help' ) );
[89] Fix | Delete
add_action( "admin_head-{$page}", array( $this, 'take_action' ), 50 );
[90] Fix | Delete
add_action( "admin_head-{$page}", array( $this, 'js' ), 50 );
[91] Fix | Delete
[92] Fix | Delete
if ( $this->admin_header_callback ) {
[93] Fix | Delete
add_action( "admin_head-{$page}", $this->admin_header_callback, 51 );
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Adds contextual help.
[99] Fix | Delete
*
[100] Fix | Delete
* @since 3.0.0
[101] Fix | Delete
*/
[102] Fix | Delete
public function help() {
[103] Fix | Delete
get_current_screen()->add_help_tab(
[104] Fix | Delete
array(
[105] Fix | Delete
'id' => 'overview',
[106] Fix | Delete
'title' => __( 'Overview' ),
[107] Fix | Delete
'content' =>
[108] Fix | Delete
'<p>' . __( 'This screen is used to customize the header section of your theme.' ) . '</p>' .
[109] Fix | Delete
'<p>' . __( 'You can choose from the theme&#8217;s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.' ) . '<p>',
[110] Fix | Delete
)
[111] Fix | Delete
);
[112] Fix | Delete
[113] Fix | Delete
get_current_screen()->add_help_tab(
[114] Fix | Delete
array(
[115] Fix | Delete
'id' => 'set-header-image',
[116] Fix | Delete
'title' => __( 'Header Image' ),
[117] Fix | Delete
'content' =>
[118] Fix | Delete
'<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the &#8220;Choose Image&#8221; button.' ) . '</p>' .
[119] Fix | Delete
'<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you would like and click the &#8220;Save Changes&#8221; button.' ) . '</p>' .
[120] Fix | Delete
'<p>' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the &#8220;Random&#8221; radio button next to the Uploaded Images or Default Images section to enable this feature.' ) . '</p>' .
[121] Fix | Delete
'<p>' . __( 'If you do not want a header image to be displayed on your site at all, click the &#8220;Remove Header Image&#8221; button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click &#8220;Save Changes&#8221;.' ) . '</p>',
[122] Fix | Delete
)
[123] Fix | Delete
);
[124] Fix | Delete
[125] Fix | Delete
get_current_screen()->add_help_tab(
[126] Fix | Delete
array(
[127] Fix | Delete
'id' => 'set-header-text',
[128] Fix | Delete
'title' => __( 'Header Text' ),
[129] Fix | Delete
'content' =>
[130] Fix | Delete
'<p>' . sprintf(
[131] Fix | Delete
/* translators: %s: URL to General Settings screen. */
[132] Fix | Delete
__( 'For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%s">General Settings</a> section.' ),
[133] Fix | Delete
admin_url( 'options-general.php' )
[134] Fix | Delete
) .
[135] Fix | Delete
'</p>' .
[136] Fix | Delete
'<p>' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
[137] Fix | Delete
'<p>' . __( 'Do not forget to click &#8220;Save Changes&#8221; when you are done!' ) . '</p>',
[138] Fix | Delete
)
[139] Fix | Delete
);
[140] Fix | Delete
[141] Fix | Delete
get_current_screen()->set_help_sidebar(
[142] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[143] Fix | Delete
'<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Header_Screen">Documentation on Custom Header</a>' ) . '</p>' .
[144] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
[145] Fix | Delete
);
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Gets the current step.
[150] Fix | Delete
*
[151] Fix | Delete
* @since 2.6.0
[152] Fix | Delete
*
[153] Fix | Delete
* @return int Current step.
[154] Fix | Delete
*/
[155] Fix | Delete
public function step() {
[156] Fix | Delete
if ( ! isset( $_GET['step'] ) ) {
[157] Fix | Delete
return 1;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
$step = (int) $_GET['step'];
[161] Fix | Delete
if ( $step < 1 || 3 < $step ||
[162] Fix | Delete
( 2 === $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) ||
[163] Fix | Delete
( 3 === $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) )
[164] Fix | Delete
) {
[165] Fix | Delete
return 1;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
return $step;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Sets up the enqueue for the JavaScript files.
[173] Fix | Delete
*
[174] Fix | Delete
* @since 2.1.0
[175] Fix | Delete
*/
[176] Fix | Delete
public function js_includes() {
[177] Fix | Delete
$step = $this->step();
[178] Fix | Delete
[179] Fix | Delete
if ( ( 1 === $step || 3 === $step ) ) {
[180] Fix | Delete
wp_enqueue_media();
[181] Fix | Delete
wp_enqueue_script( 'custom-header' );
[182] Fix | Delete
if ( current_theme_supports( 'custom-header', 'header-text' ) ) {
[183] Fix | Delete
wp_enqueue_script( 'wp-color-picker' );
[184] Fix | Delete
}
[185] Fix | Delete
} elseif ( 2 === $step ) {
[186] Fix | Delete
wp_enqueue_script( 'imgareaselect' );
[187] Fix | Delete
}
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
/**
[191] Fix | Delete
* Sets up the enqueue for the CSS files.
[192] Fix | Delete
*
[193] Fix | Delete
* @since 2.7.0
[194] Fix | Delete
*/
[195] Fix | Delete
public function css_includes() {
[196] Fix | Delete
$step = $this->step();
[197] Fix | Delete
[198] Fix | Delete
if ( ( 1 === $step || 3 === $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) {
[199] Fix | Delete
wp_enqueue_style( 'wp-color-picker' );
[200] Fix | Delete
} elseif ( 2 === $step ) {
[201] Fix | Delete
wp_enqueue_style( 'imgareaselect' );
[202] Fix | Delete
}
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Executes custom header modification.
[207] Fix | Delete
*
[208] Fix | Delete
* @since 2.6.0
[209] Fix | Delete
*/
[210] Fix | Delete
public function take_action() {
[211] Fix | Delete
if ( ! current_user_can( 'edit_theme_options' ) ) {
[212] Fix | Delete
return;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
if ( empty( $_POST ) ) {
[216] Fix | Delete
return;
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
$this->updated = true;
[220] Fix | Delete
[221] Fix | Delete
if ( isset( $_POST['resetheader'] ) ) {
[222] Fix | Delete
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
[223] Fix | Delete
[224] Fix | Delete
$this->reset_header_image();
[225] Fix | Delete
[226] Fix | Delete
return;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
if ( isset( $_POST['removeheader'] ) ) {
[230] Fix | Delete
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
[231] Fix | Delete
[232] Fix | Delete
$this->remove_header_image();
[233] Fix | Delete
[234] Fix | Delete
return;
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) {
[238] Fix | Delete
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
[239] Fix | Delete
[240] Fix | Delete
set_theme_mod( 'header_textcolor', 'blank' );
[241] Fix | Delete
} elseif ( isset( $_POST['text-color'] ) ) {
[242] Fix | Delete
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
[243] Fix | Delete
[244] Fix | Delete
$_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );
[245] Fix | Delete
[246] Fix | Delete
$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );
[247] Fix | Delete
[248] Fix | Delete
if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) {
[249] Fix | Delete
set_theme_mod( 'header_textcolor', $color );
[250] Fix | Delete
} elseif ( ! $color ) {
[251] Fix | Delete
set_theme_mod( 'header_textcolor', 'blank' );
[252] Fix | Delete
}
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
if ( isset( $_POST['default-header'] ) ) {
[256] Fix | Delete
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
[257] Fix | Delete
[258] Fix | Delete
$this->set_header_image( $_POST['default-header'] );
[259] Fix | Delete
[260] Fix | Delete
return;
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
/**
[265] Fix | Delete
* Processes the default headers.
[266] Fix | Delete
*
[267] Fix | Delete
* @since 3.0.0
[268] Fix | Delete
*
[269] Fix | Delete
* @global array $_wp_default_headers
[270] Fix | Delete
*/
[271] Fix | Delete
public function process_default_headers() {
[272] Fix | Delete
global $_wp_default_headers;
[273] Fix | Delete
[274] Fix | Delete
if ( ! isset( $_wp_default_headers ) ) {
[275] Fix | Delete
return;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
if ( ! empty( $this->default_headers ) ) {
[279] Fix | Delete
return;
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
$this->default_headers = $_wp_default_headers;
[283] Fix | Delete
$template_directory_uri = get_template_directory_uri();
[284] Fix | Delete
$stylesheet_directory_uri = get_stylesheet_directory_uri();
[285] Fix | Delete
[286] Fix | Delete
foreach ( array_keys( $this->default_headers ) as $header ) {
[287] Fix | Delete
$this->default_headers[ $header ]['url'] = sprintf(
[288] Fix | Delete
$this->default_headers[ $header ]['url'],
[289] Fix | Delete
$template_directory_uri,
[290] Fix | Delete
$stylesheet_directory_uri
[291] Fix | Delete
);
[292] Fix | Delete
[293] Fix | Delete
$this->default_headers[ $header ]['thumbnail_url'] = sprintf(
[294] Fix | Delete
$this->default_headers[ $header ]['thumbnail_url'],
[295] Fix | Delete
$template_directory_uri,
[296] Fix | Delete
$stylesheet_directory_uri
[297] Fix | Delete
);
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Displays UI for selecting one of several default headers.
[303] Fix | Delete
*
[304] Fix | Delete
* Shows the random image option if this theme has multiple header images.
[305] Fix | Delete
* Random image option is on by default if no header has been set.
[306] Fix | Delete
*
[307] Fix | Delete
* @since 3.0.0
[308] Fix | Delete
*
[309] Fix | Delete
* @param string $type The header type. One of 'default' (for the Uploaded Images control)
[310] Fix | Delete
* or 'uploaded' (for the Uploaded Images control).
[311] Fix | Delete
*/
[312] Fix | Delete
public function show_header_selector( $type = 'default' ) {
[313] Fix | Delete
if ( 'default' === $type ) {
[314] Fix | Delete
$headers = $this->default_headers;
[315] Fix | Delete
} else {
[316] Fix | Delete
$headers = get_uploaded_header_images();
[317] Fix | Delete
$type = 'uploaded';
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
if ( 1 < count( $headers ) ) {
[321] Fix | Delete
echo '<div class="random-header">';
[322] Fix | Delete
echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />';
[323] Fix | Delete
_e( '<strong>Random:</strong> Show a different image on each page.' );
[324] Fix | Delete
echo '</label>';
[325] Fix | Delete
echo '</div>';
[326] Fix | Delete
}
[327] Fix | Delete
[328] Fix | Delete
echo '<div class="available-headers">';
[329] Fix | Delete
[330] Fix | Delete
foreach ( $headers as $header_key => $header ) {
[331] Fix | Delete
$header_thumbnail = $header['thumbnail_url'];
[332] Fix | Delete
$header_url = $header['url'];
[333] Fix | Delete
$header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text'];
[334] Fix | Delete
[335] Fix | Delete
echo '<div class="default-header">';
[336] Fix | Delete
echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
[337] Fix | Delete
$width = '';
[338] Fix | Delete
if ( ! empty( $header['attachment_id'] ) ) {
[339] Fix | Delete
$width = ' width="230"';
[340] Fix | Delete
}
[341] Fix | Delete
echo '<img src="' . esc_url( set_url_scheme( $header_thumbnail ) ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
[342] Fix | Delete
echo '</div>';
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
echo '<div class="clear"></div></div>';
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Executes JavaScript depending on step.
[350] Fix | Delete
*
[351] Fix | Delete
* @since 2.1.0
[352] Fix | Delete
*/
[353] Fix | Delete
public function js() {
[354] Fix | Delete
$step = $this->step();
[355] Fix | Delete
[356] Fix | Delete
if ( ( 1 === $step || 3 === $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) {
[357] Fix | Delete
$this->js_1();
[358] Fix | Delete
} elseif ( 2 === $step ) {
[359] Fix | Delete
$this->js_2();
[360] Fix | Delete
}
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
/**
[364] Fix | Delete
* Displays JavaScript based on Step 1 and 3.
[365] Fix | Delete
*
[366] Fix | Delete
* @since 2.6.0
[367] Fix | Delete
*/
[368] Fix | Delete
public function js_1() {
[369] Fix | Delete
$default_color = '';
[370] Fix | Delete
if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
[371] Fix | Delete
$default_color = get_theme_support( 'custom-header', 'default-text-color' );
[372] Fix | Delete
if ( $default_color && ! str_contains( $default_color, '#' ) ) {
[373] Fix | Delete
$default_color = '#' . $default_color;
[374] Fix | Delete
}
[375] Fix | Delete
}
[376] Fix | Delete
?>
[377] Fix | Delete
<script type="text/javascript">
[378] Fix | Delete
(function($){
[379] Fix | Delete
var default_color = '<?php echo esc_js( $default_color ); ?>',
[380] Fix | Delete
header_text_fields;
[381] Fix | Delete
[382] Fix | Delete
function pickColor(color) {
[383] Fix | Delete
$('#name').css('color', color);
[384] Fix | Delete
$('#desc').css('color', color);
[385] Fix | Delete
$('#text-color').val(color);
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
function toggle_text() {
[389] Fix | Delete
var checked = $('#display-header-text').prop('checked'),
[390] Fix | Delete
text_color;
[391] Fix | Delete
header_text_fields.toggle( checked );
[392] Fix | Delete
if ( ! checked )
[393] Fix | Delete
return;
[394] Fix | Delete
text_color = $('#text-color');
[395] Fix | Delete
if ( '' === text_color.val().replace('#', '') ) {
[396] Fix | Delete
text_color.val( default_color );
[397] Fix | Delete
pickColor( default_color );
[398] Fix | Delete
} else {
[399] Fix | Delete
pickColor( text_color.val() );
[400] Fix | Delete
}
[401] Fix | Delete
}
[402] Fix | Delete
[403] Fix | Delete
$( function() {
[404] Fix | Delete
var text_color = $('#text-color');
[405] Fix | Delete
header_text_fields = $('.displaying-header-text');
[406] Fix | Delete
text_color.wpColorPicker({
[407] Fix | Delete
change: function( event, ui ) {
[408] Fix | Delete
pickColor( text_color.wpColorPicker('color') );
[409] Fix | Delete
},
[410] Fix | Delete
clear: function() {
[411] Fix | Delete
pickColor( '' );
[412] Fix | Delete
}
[413] Fix | Delete
});
[414] Fix | Delete
$('#display-header-text').click( toggle_text );
[415] Fix | Delete
<?php if ( ! display_header_text() ) : ?>
[416] Fix | Delete
toggle_text();
[417] Fix | Delete
<?php endif; ?>
[418] Fix | Delete
} );
[419] Fix | Delete
})(jQuery);
[420] Fix | Delete
</script>
[421] Fix | Delete
<?php
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
/**
[425] Fix | Delete
* Displays JavaScript based on Step 2.
[426] Fix | Delete
*
[427] Fix | Delete
* @since 2.6.0
[428] Fix | Delete
*/
[429] Fix | Delete
public function js_2() {
[430] Fix | Delete
[431] Fix | Delete
?>
[432] Fix | Delete
<script type="text/javascript">
[433] Fix | Delete
function onEndCrop( coords ) {
[434] Fix | Delete
jQuery( '#x1' ).val(coords.x);
[435] Fix | Delete
jQuery( '#y1' ).val(coords.y);
[436] Fix | Delete
jQuery( '#width' ).val(coords.w);
[437] Fix | Delete
jQuery( '#height' ).val(coords.h);
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
jQuery( function() {
[441] Fix | Delete
var xinit = <?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?>;
[442] Fix | Delete
var yinit = <?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?>;
[443] Fix | Delete
var ratio = xinit / yinit;
[444] Fix | Delete
var ximg = jQuery('img#upload').width();
[445] Fix | Delete
var yimg = jQuery('img#upload').height();
[446] Fix | Delete
[447] Fix | Delete
if ( yimg < yinit || ximg < xinit ) {
[448] Fix | Delete
if ( ximg / yimg > ratio ) {
[449] Fix | Delete
yinit = yimg;
[450] Fix | Delete
xinit = yinit * ratio;
[451] Fix | Delete
} else {
[452] Fix | Delete
xinit = ximg;
[453] Fix | Delete
yinit = xinit / ratio;
[454] Fix | Delete
}
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
jQuery('img#upload').imgAreaSelect({
[458] Fix | Delete
handles: true,
[459] Fix | Delete
keys: true,
[460] Fix | Delete
show: true,
[461] Fix | Delete
x1: 0,
[462] Fix | Delete
y1: 0,
[463] Fix | Delete
x2: xinit,
[464] Fix | Delete
y2: yinit,
[465] Fix | Delete
<?php
[466] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-height' )
[467] Fix | Delete
&& ! current_theme_supports( 'custom-header', 'flex-width' )
[468] Fix | Delete
) {
[469] Fix | Delete
?>
[470] Fix | Delete
aspectRatio: xinit + ':' + yinit,
[471] Fix | Delete
<?php
[472] Fix | Delete
}
[473] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
[474] Fix | Delete
?>
[475] Fix | Delete
maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>,
[476] Fix | Delete
<?php
[477] Fix | Delete
}
[478] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
[479] Fix | Delete
?>
[480] Fix | Delete
maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>,
[481] Fix | Delete
<?php
[482] Fix | Delete
}
[483] Fix | Delete
?>
[484] Fix | Delete
onInit: function () {
[485] Fix | Delete
jQuery('#width').val(xinit);
[486] Fix | Delete
jQuery('#height').val(yinit);
[487] Fix | Delete
},
[488] Fix | Delete
onSelectChange: function(img, c) {
[489] Fix | Delete
jQuery('#x1').val(c.x1);
[490] Fix | Delete
jQuery('#y1').val(c.y1);
[491] Fix | Delete
jQuery('#width').val(c.width);
[492] Fix | Delete
jQuery('#height').val(c.height);
[493] Fix | Delete
}
[494] Fix | Delete
});
[495] Fix | Delete
} );
[496] Fix | Delete
</script>
[497] Fix | Delete
<?php
[498] Fix | Delete
}
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function