Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-admin/includes
File: class-custom-image-header.php
[500] Fix | Delete
/**
[501] Fix | Delete
* Displays first step of custom header image page.
[502] Fix | Delete
*
[503] Fix | Delete
* @since 2.1.0
[504] Fix | Delete
*/
[505] Fix | Delete
public function step_1() {
[506] Fix | Delete
$this->process_default_headers();
[507] Fix | Delete
?>
[508] Fix | Delete
[509] Fix | Delete
<div class="wrap">
[510] Fix | Delete
<h1><?php _e( 'Custom Header' ); ?></h1>
[511] Fix | Delete
[512] Fix | Delete
<?php
[513] Fix | Delete
if ( current_user_can( 'customize' ) ) {
[514] Fix | Delete
$message = sprintf(
[515] Fix | Delete
/* translators: %s: URL to header image configuration in Customizer. */
[516] Fix | Delete
__( 'You can now manage and live-preview Custom Header in the <a href="%s">Customizer</a>.' ),
[517] Fix | Delete
admin_url( 'customize.php?autofocus[control]=header_image' )
[518] Fix | Delete
);
[519] Fix | Delete
wp_admin_notice(
[520] Fix | Delete
$message,
[521] Fix | Delete
array(
[522] Fix | Delete
'type' => 'info',
[523] Fix | Delete
'additional_classes' => array( 'hide-if-no-customize' ),
[524] Fix | Delete
)
[525] Fix | Delete
);
[526] Fix | Delete
}
[527] Fix | Delete
[528] Fix | Delete
if ( ! empty( $this->updated ) ) {
[529] Fix | Delete
$updated_message = sprintf(
[530] Fix | Delete
/* translators: %s: Home URL. */
[531] Fix | Delete
__( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ),
[532] Fix | Delete
esc_url( home_url( '/' ) )
[533] Fix | Delete
);
[534] Fix | Delete
wp_admin_notice(
[535] Fix | Delete
$updated_message,
[536] Fix | Delete
array(
[537] Fix | Delete
'id' => 'message',
[538] Fix | Delete
'additional_classes' => array( 'updated' ),
[539] Fix | Delete
)
[540] Fix | Delete
);
[541] Fix | Delete
}
[542] Fix | Delete
?>
[543] Fix | Delete
[544] Fix | Delete
<h2><?php _e( 'Header Image' ); ?></h2>
[545] Fix | Delete
[546] Fix | Delete
<table class="form-table" role="presentation">
[547] Fix | Delete
<tbody>
[548] Fix | Delete
[549] Fix | Delete
<?php if ( get_custom_header() || display_header_text() ) : ?>
[550] Fix | Delete
<tr>
[551] Fix | Delete
<th scope="row"><?php _e( 'Preview' ); ?></th>
[552] Fix | Delete
<td>
[553] Fix | Delete
<?php
[554] Fix | Delete
if ( $this->admin_image_div_callback ) {
[555] Fix | Delete
call_user_func( $this->admin_image_div_callback );
[556] Fix | Delete
} else {
[557] Fix | Delete
$custom_header = get_custom_header();
[558] Fix | Delete
$header_image = get_header_image();
[559] Fix | Delete
[560] Fix | Delete
if ( $header_image ) {
[561] Fix | Delete
$header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');';
[562] Fix | Delete
} else {
[563] Fix | Delete
$header_image_style = '';
[564] Fix | Delete
}
[565] Fix | Delete
[566] Fix | Delete
if ( $custom_header->width ) {
[567] Fix | Delete
$header_image_style .= 'max-width:' . $custom_header->width . 'px;';
[568] Fix | Delete
}
[569] Fix | Delete
if ( $custom_header->height ) {
[570] Fix | Delete
$header_image_style .= 'height:' . $custom_header->height . 'px;';
[571] Fix | Delete
}
[572] Fix | Delete
?>
[573] Fix | Delete
<div id="headimg" style="<?php echo $header_image_style; ?>">
[574] Fix | Delete
<?php
[575] Fix | Delete
if ( display_header_text() ) {
[576] Fix | Delete
$style = ' style="color:#' . get_header_textcolor() . ';"';
[577] Fix | Delete
} else {
[578] Fix | Delete
$style = ' style="display:none;"';
[579] Fix | Delete
}
[580] Fix | Delete
?>
[581] Fix | Delete
<h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo( 'url' ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
[582] Fix | Delete
<div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
[583] Fix | Delete
</div>
[584] Fix | Delete
<?php } ?>
[585] Fix | Delete
</td>
[586] Fix | Delete
</tr>
[587] Fix | Delete
<?php endif; ?>
[588] Fix | Delete
[589] Fix | Delete
<?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?>
[590] Fix | Delete
<tr>
[591] Fix | Delete
<th scope="row"><?php _e( 'Select Image' ); ?></th>
[592] Fix | Delete
<td>
[593] Fix | Delete
<p><?php _e( 'You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.' ); ?><br />
[594] Fix | Delete
<?php
[595] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-height' )
[596] Fix | Delete
&& ! current_theme_supports( 'custom-header', 'flex-width' )
[597] Fix | Delete
) {
[598] Fix | Delete
printf(
[599] Fix | Delete
/* translators: 1: Image width in pixels, 2: Image height in pixels. */
[600] Fix | Delete
__( 'Images of exactly <strong>%1$d &times; %2$d pixels</strong> will be used as-is.' ) . '<br />',
[601] Fix | Delete
get_theme_support( 'custom-header', 'width' ),
[602] Fix | Delete
get_theme_support( 'custom-header', 'height' )
[603] Fix | Delete
);
[604] Fix | Delete
} elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) {
[605] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
[606] Fix | Delete
printf(
[607] Fix | Delete
/* translators: %s: Size in pixels. */
[608] Fix | Delete
__( 'Images should be at least %s wide.' ) . ' ',
[609] Fix | Delete
sprintf(
[610] Fix | Delete
/* translators: %d: Custom header width. */
[611] Fix | Delete
'<strong>' . __( '%d pixels' ) . '</strong>',
[612] Fix | Delete
get_theme_support( 'custom-header', 'width' )
[613] Fix | Delete
)
[614] Fix | Delete
);
[615] Fix | Delete
}
[616] Fix | Delete
} elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
[617] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
[618] Fix | Delete
printf(
[619] Fix | Delete
/* translators: %s: Size in pixels. */
[620] Fix | Delete
__( 'Images should be at least %s tall.' ) . ' ',
[621] Fix | Delete
sprintf(
[622] Fix | Delete
/* translators: %d: Custom header height. */
[623] Fix | Delete
'<strong>' . __( '%d pixels' ) . '</strong>',
[624] Fix | Delete
get_theme_support( 'custom-header', 'height' )
[625] Fix | Delete
)
[626] Fix | Delete
);
[627] Fix | Delete
}
[628] Fix | Delete
}
[629] Fix | Delete
[630] Fix | Delete
if ( current_theme_supports( 'custom-header', 'flex-height' )
[631] Fix | Delete
|| current_theme_supports( 'custom-header', 'flex-width' )
[632] Fix | Delete
) {
[633] Fix | Delete
if ( current_theme_supports( 'custom-header', 'width' ) ) {
[634] Fix | Delete
printf(
[635] Fix | Delete
/* translators: %s: Size in pixels. */
[636] Fix | Delete
__( 'Suggested width is %s.' ) . ' ',
[637] Fix | Delete
sprintf(
[638] Fix | Delete
/* translators: %d: Custom header width. */
[639] Fix | Delete
'<strong>' . __( '%d pixels' ) . '</strong>',
[640] Fix | Delete
get_theme_support( 'custom-header', 'width' )
[641] Fix | Delete
)
[642] Fix | Delete
);
[643] Fix | Delete
}
[644] Fix | Delete
[645] Fix | Delete
if ( current_theme_supports( 'custom-header', 'height' ) ) {
[646] Fix | Delete
printf(
[647] Fix | Delete
/* translators: %s: Size in pixels. */
[648] Fix | Delete
__( 'Suggested height is %s.' ) . ' ',
[649] Fix | Delete
sprintf(
[650] Fix | Delete
/* translators: %d: Custom header height. */
[651] Fix | Delete
'<strong>' . __( '%d pixels' ) . '</strong>',
[652] Fix | Delete
get_theme_support( 'custom-header', 'height' )
[653] Fix | Delete
)
[654] Fix | Delete
);
[655] Fix | Delete
}
[656] Fix | Delete
}
[657] Fix | Delete
?>
[658] Fix | Delete
</p>
[659] Fix | Delete
<form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ); ?>">
[660] Fix | Delete
<p>
[661] Fix | Delete
<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
[662] Fix | Delete
<input type="file" id="upload" name="import" />
[663] Fix | Delete
<input type="hidden" name="action" value="save" />
[664] Fix | Delete
<?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?>
[665] Fix | Delete
<?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
[666] Fix | Delete
</p>
[667] Fix | Delete
<?php
[668] Fix | Delete
$modal_update_href = add_query_arg(
[669] Fix | Delete
array(
[670] Fix | Delete
'page' => 'custom-header',
[671] Fix | Delete
'step' => 2,
[672] Fix | Delete
'_wpnonce-custom-header-upload' => wp_create_nonce( 'custom-header-upload' ),
[673] Fix | Delete
),
[674] Fix | Delete
admin_url( 'themes.php' )
[675] Fix | Delete
);
[676] Fix | Delete
?>
[677] Fix | Delete
<p>
[678] Fix | Delete
<label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br />
[679] Fix | Delete
<button id="choose-from-library-link" class="button"
[680] Fix | Delete
data-update-link="<?php echo esc_url( $modal_update_href ); ?>"
[681] Fix | Delete
data-choose="<?php esc_attr_e( 'Choose a Custom Header' ); ?>"
[682] Fix | Delete
data-update="<?php esc_attr_e( 'Set as header' ); ?>"><?php _e( 'Choose Image' ); ?></button>
[683] Fix | Delete
</p>
[684] Fix | Delete
</form>
[685] Fix | Delete
</td>
[686] Fix | Delete
</tr>
[687] Fix | Delete
<?php endif; ?>
[688] Fix | Delete
</tbody>
[689] Fix | Delete
</table>
[690] Fix | Delete
[691] Fix | Delete
<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ); ?>">
[692] Fix | Delete
<?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?>
[693] Fix | Delete
<table class="form-table" role="presentation">
[694] Fix | Delete
<tbody>
[695] Fix | Delete
<?php if ( get_uploaded_header_images() ) : ?>
[696] Fix | Delete
<tr>
[697] Fix | Delete
<th scope="row"><?php _e( 'Uploaded Images' ); ?></th>
[698] Fix | Delete
<td>
[699] Fix | Delete
<p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ); ?></p>
[700] Fix | Delete
<?php
[701] Fix | Delete
$this->show_header_selector( 'uploaded' );
[702] Fix | Delete
?>
[703] Fix | Delete
</td>
[704] Fix | Delete
</tr>
[705] Fix | Delete
<?php
[706] Fix | Delete
endif;
[707] Fix | Delete
if ( ! empty( $this->default_headers ) ) :
[708] Fix | Delete
?>
[709] Fix | Delete
<tr>
[710] Fix | Delete
<th scope="row"><?php _e( 'Default Images' ); ?></th>
[711] Fix | Delete
<td>
[712] Fix | Delete
<?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?>
[713] Fix | Delete
<p><?php _e( 'If you do not want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p>
[714] Fix | Delete
<?php else : ?>
[715] Fix | Delete
<p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ); ?></p>
[716] Fix | Delete
<?php endif; ?>
[717] Fix | Delete
<?php
[718] Fix | Delete
$this->show_header_selector( 'default' );
[719] Fix | Delete
?>
[720] Fix | Delete
</td>
[721] Fix | Delete
</tr>
[722] Fix | Delete
<?php
[723] Fix | Delete
endif;
[724] Fix | Delete
if ( get_header_image() ) :
[725] Fix | Delete
?>
[726] Fix | Delete
<tr>
[727] Fix | Delete
<th scope="row"><?php _e( 'Remove Image' ); ?></th>
[728] Fix | Delete
<td>
[729] Fix | Delete
<p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ); ?></p>
[730] Fix | Delete
<?php submit_button( __( 'Remove Header Image' ), '', 'removeheader', false ); ?>
[731] Fix | Delete
</td>
[732] Fix | Delete
</tr>
[733] Fix | Delete
<?php
[734] Fix | Delete
endif;
[735] Fix | Delete
[736] Fix | Delete
$default_image = sprintf(
[737] Fix | Delete
get_theme_support( 'custom-header', 'default-image' ),
[738] Fix | Delete
get_template_directory_uri(),
[739] Fix | Delete
get_stylesheet_directory_uri()
[740] Fix | Delete
);
[741] Fix | Delete
[742] Fix | Delete
if ( $default_image && get_header_image() !== $default_image ) :
[743] Fix | Delete
?>
[744] Fix | Delete
<tr>
[745] Fix | Delete
<th scope="row"><?php _e( 'Reset Image' ); ?></th>
[746] Fix | Delete
<td>
[747] Fix | Delete
<p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ); ?></p>
[748] Fix | Delete
<?php submit_button( __( 'Restore Original Header Image' ), '', 'resetheader', false ); ?>
[749] Fix | Delete
</td>
[750] Fix | Delete
</tr>
[751] Fix | Delete
<?php endif; ?>
[752] Fix | Delete
</tbody>
[753] Fix | Delete
</table>
[754] Fix | Delete
[755] Fix | Delete
<?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?>
[756] Fix | Delete
[757] Fix | Delete
<h2><?php _e( 'Header Text' ); ?></h2>
[758] Fix | Delete
[759] Fix | Delete
<table class="form-table" role="presentation">
[760] Fix | Delete
<tbody>
[761] Fix | Delete
<tr>
[762] Fix | Delete
<th scope="row"><?php _e( 'Header Text' ); ?></th>
[763] Fix | Delete
<td>
[764] Fix | Delete
<p>
[765] Fix | Delete
<label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked( display_header_text() ); ?> /> <?php _e( 'Show header text with your image.' ); ?></label>
[766] Fix | Delete
</p>
[767] Fix | Delete
</td>
[768] Fix | Delete
</tr>
[769] Fix | Delete
[770] Fix | Delete
<tr class="displaying-header-text">
[771] Fix | Delete
<th scope="row"><?php _e( 'Text Color' ); ?></th>
[772] Fix | Delete
<td>
[773] Fix | Delete
<p>
[774] Fix | Delete
<?php
[775] Fix | Delete
$default_color = '';
[776] Fix | Delete
if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
[777] Fix | Delete
$default_color = get_theme_support( 'custom-header', 'default-text-color' );
[778] Fix | Delete
if ( $default_color && ! str_contains( $default_color, '#' ) ) {
[779] Fix | Delete
$default_color = '#' . $default_color;
[780] Fix | Delete
}
[781] Fix | Delete
}
[782] Fix | Delete
[783] Fix | Delete
$default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : '';
[784] Fix | Delete
[785] Fix | Delete
$header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' );
[786] Fix | Delete
if ( $header_textcolor && ! str_contains( $header_textcolor, '#' ) ) {
[787] Fix | Delete
$header_textcolor = '#' . $header_textcolor;
[788] Fix | Delete
}
[789] Fix | Delete
[790] Fix | Delete
echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />';
[791] Fix | Delete
if ( $default_color ) {
[792] Fix | Delete
/* translators: %s: Default text color. */
[793] Fix | Delete
echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>';
[794] Fix | Delete
}
[795] Fix | Delete
?>
[796] Fix | Delete
</p>
[797] Fix | Delete
</td>
[798] Fix | Delete
</tr>
[799] Fix | Delete
</tbody>
[800] Fix | Delete
</table>
[801] Fix | Delete
<?php
[802] Fix | Delete
endif;
[803] Fix | Delete
[804] Fix | Delete
/**
[805] Fix | Delete
* Fires just before the submit button in the custom header options form.
[806] Fix | Delete
*
[807] Fix | Delete
* @since 3.1.0
[808] Fix | Delete
*/
[809] Fix | Delete
do_action( 'custom_header_options' );
[810] Fix | Delete
[811] Fix | Delete
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' );
[812] Fix | Delete
?>
[813] Fix | Delete
[814] Fix | Delete
<?php submit_button( null, 'primary', 'save-header-options' ); ?>
[815] Fix | Delete
</form>
[816] Fix | Delete
</div>
[817] Fix | Delete
[818] Fix | Delete
<?php
[819] Fix | Delete
}
[820] Fix | Delete
[821] Fix | Delete
/**
[822] Fix | Delete
* Displays second step of custom header image page.
[823] Fix | Delete
*
[824] Fix | Delete
* @since 2.1.0
[825] Fix | Delete
*/
[826] Fix | Delete
public function step_2() {
[827] Fix | Delete
check_admin_referer( 'custom-header-upload', '_wpnonce-custom-header-upload' );
[828] Fix | Delete
[829] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
[830] Fix | Delete
wp_die(
[831] Fix | Delete
'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
[832] Fix | Delete
'<p>' . __( 'The active theme does not support uploading a custom header image.' ) . '</p>',
[833] Fix | Delete
403
[834] Fix | Delete
);
[835] Fix | Delete
}
[836] Fix | Delete
[837] Fix | Delete
if ( empty( $_POST ) && isset( $_GET['file'] ) ) {
[838] Fix | Delete
$attachment_id = absint( $_GET['file'] );
[839] Fix | Delete
$file = get_attached_file( $attachment_id, true );
[840] Fix | Delete
$url = wp_get_attachment_image_src( $attachment_id, 'full' );
[841] Fix | Delete
$url = $url[0];
[842] Fix | Delete
} elseif ( isset( $_POST ) ) {
[843] Fix | Delete
$data = $this->step_2_manage_upload();
[844] Fix | Delete
$attachment_id = $data['attachment_id'];
[845] Fix | Delete
$file = $data['file'];
[846] Fix | Delete
$url = $data['url'];
[847] Fix | Delete
}
[848] Fix | Delete
[849] Fix | Delete
if ( file_exists( $file ) ) {
[850] Fix | Delete
list( $width, $height, $type, $attr ) = wp_getimagesize( $file );
[851] Fix | Delete
} else {
[852] Fix | Delete
$data = wp_get_attachment_metadata( $attachment_id );
[853] Fix | Delete
$height = isset( $data['height'] ) ? (int) $data['height'] : 0;
[854] Fix | Delete
$width = isset( $data['width'] ) ? (int) $data['width'] : 0;
[855] Fix | Delete
unset( $data );
[856] Fix | Delete
}
[857] Fix | Delete
[858] Fix | Delete
$max_width = 0;
[859] Fix | Delete
[860] Fix | Delete
// For flex, limit size of image displayed to 1500px unless theme says otherwise.
[861] Fix | Delete
if ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
[862] Fix | Delete
$max_width = 1500;
[863] Fix | Delete
}
[864] Fix | Delete
[865] Fix | Delete
if ( current_theme_supports( 'custom-header', 'max-width' ) ) {
[866] Fix | Delete
$max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) );
[867] Fix | Delete
}
[868] Fix | Delete
[869] Fix | Delete
$max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) );
[870] Fix | Delete
[871] Fix | Delete
// If flexible height isn't supported and the image is the exact right size.
[872] Fix | Delete
if ( ! current_theme_supports( 'custom-header', 'flex-height' )
[873] Fix | Delete
&& ! current_theme_supports( 'custom-header', 'flex-width' )
[874] Fix | Delete
&& (int) get_theme_support( 'custom-header', 'width' ) === $width
[875] Fix | Delete
&& (int) get_theme_support( 'custom-header', 'height' ) === $height
[876] Fix | Delete
) {
[877] Fix | Delete
// Add the metadata.
[878] Fix | Delete
if ( file_exists( $file ) ) {
[879] Fix | Delete
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
[880] Fix | Delete
}
[881] Fix | Delete
[882] Fix | Delete
$this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) );
[883] Fix | Delete
[884] Fix | Delete
/**
[885] Fix | Delete
* Filters the attachment file path after the custom header or background image is set.
[886] Fix | Delete
*
[887] Fix | Delete
* Used for file replication.
[888] Fix | Delete
*
[889] Fix | Delete
* @since 2.1.0
[890] Fix | Delete
*
[891] Fix | Delete
* @param string $file Path to the file.
[892] Fix | Delete
* @param int $attachment_id Attachment ID.
[893] Fix | Delete
*/
[894] Fix | Delete
$file = apply_filters( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
[895] Fix | Delete
[896] Fix | Delete
return $this->finished();
[897] Fix | Delete
} elseif ( $width > $max_width ) {
[898] Fix | Delete
$oitar = $width / $max_width;
[899] Fix | Delete
[900] Fix | Delete
$image = wp_crop_image(
[901] Fix | Delete
$attachment_id,
[902] Fix | Delete
0,
[903] Fix | Delete
0,
[904] Fix | Delete
$width,
[905] Fix | Delete
$height,
[906] Fix | Delete
$max_width,
[907] Fix | Delete
$height / $oitar,
[908] Fix | Delete
false,
[909] Fix | Delete
str_replace( wp_basename( $file ), 'midsize-' . wp_basename( $file ), $file )
[910] Fix | Delete
);
[911] Fix | Delete
[912] Fix | Delete
if ( ! $image || is_wp_error( $image ) ) {
[913] Fix | Delete
wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
[914] Fix | Delete
}
[915] Fix | Delete
[916] Fix | Delete
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */
[917] Fix | Delete
$image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication.
[918] Fix | Delete
[919] Fix | Delete
$url = str_replace( wp_basename( $url ), wp_basename( $image ), $url );
[920] Fix | Delete
$width = $width / $oitar;
[921] Fix | Delete
$height = $height / $oitar;
[922] Fix | Delete
} else {
[923] Fix | Delete
$oitar = 1;
[924] Fix | Delete
}
[925] Fix | Delete
?>
[926] Fix | Delete
[927] Fix | Delete
<div class="wrap">
[928] Fix | Delete
<h1><?php _e( 'Crop Header Image' ); ?></h1>
[929] Fix | Delete
[930] Fix | Delete
<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 3 ) ); ?>">
[931] Fix | Delete
<p class="hide-if-no-js"><?php _e( 'Choose the part of the image you want to use as your header.' ); ?></p>
[932] Fix | Delete
<p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.' ); ?></strong></p>
[933] Fix | Delete
[934] Fix | Delete
<div id="crop_image" style="position: relative">
[935] Fix | Delete
<img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo esc_attr( $width ); ?>" height="<?php echo esc_attr( $height ); ?>" alt="" />
[936] Fix | Delete
</div>
[937] Fix | Delete
[938] Fix | Delete
<input type="hidden" name="x1" id="x1" value="0" />
[939] Fix | Delete
<input type="hidden" name="y1" id="y1" value="0" />
[940] Fix | Delete
<input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>" />
[941] Fix | Delete
<input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>" />
[942] Fix | Delete
<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $attachment_id ); ?>" />
[943] Fix | Delete
<input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" />
[944] Fix | Delete
<?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?>
[945] Fix | Delete
<input type="hidden" name="create-new-attachment" value="true" />
[946] Fix | Delete
<?php } ?>
[947] Fix | Delete
<?php wp_nonce_field( 'custom-header-crop-image' ); ?>
[948] Fix | Delete
[949] Fix | Delete
<p class="submit">
[950] Fix | Delete
<?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?>
[951] Fix | Delete
<?php
[952] Fix | Delete
if ( isset( $oitar ) && 1 === $oitar
[953] Fix | Delete
&& ( current_theme_supports( 'custom-header', 'flex-height' )
[954] Fix | Delete
|| current_theme_supports( 'custom-header', 'flex-width' ) )
[955] Fix | Delete
) {
[956] Fix | Delete
submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false );
[957] Fix | Delete
}
[958] Fix | Delete
?>
[959] Fix | Delete
</p>
[960] Fix | Delete
</form>
[961] Fix | Delete
</div>
[962] Fix | Delete
<?php
[963] Fix | Delete
}
[964] Fix | Delete
[965] Fix | Delete
[966] Fix | Delete
/**
[967] Fix | Delete
* Uploads the file to be cropped in the second step.
[968] Fix | Delete
*
[969] Fix | Delete
* @since 3.4.0
[970] Fix | Delete
*/
[971] Fix | Delete
public function step_2_manage_upload() {
[972] Fix | Delete
$overrides = array( 'test_form' => false );
[973] Fix | Delete
[974] Fix | Delete
$uploaded_file = $_FILES['import'];
[975] Fix | Delete
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] );
[976] Fix | Delete
[977] Fix | Delete
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
[978] Fix | Delete
wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) );
[979] Fix | Delete
}
[980] Fix | Delete
[981] Fix | Delete
$file = wp_handle_upload( $uploaded_file, $overrides );
[982] Fix | Delete
[983] Fix | Delete
if ( isset( $file['error'] ) ) {
[984] Fix | Delete
wp_die( $file['error'], __( 'Image Upload Error' ) );
[985] Fix | Delete
}
[986] Fix | Delete
[987] Fix | Delete
$url = $file['url'];
[988] Fix | Delete
$type = $file['type'];
[989] Fix | Delete
$file = $file['file'];
[990] Fix | Delete
$filename = wp_basename( $file );
[991] Fix | Delete
[992] Fix | Delete
// Construct the attachment array.
[993] Fix | Delete
$attachment = array(
[994] Fix | Delete
'post_title' => $filename,
[995] Fix | Delete
'post_content' => $url,
[996] Fix | Delete
'post_mime_type' => $type,
[997] Fix | Delete
'guid' => $url,
[998] Fix | Delete
'context' => 'custom-header',
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function