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.../www/clone/wp-admin/includes
File: class-custom-image-header.php
}
[1500] Fix | Delete
[1501] Fix | Delete
/**
[1502] Fix | Delete
* Updates the last-used postmeta on a header image attachment after saving a new header image via the Customizer.
[1503] Fix | Delete
*
[1504] Fix | Delete
* @since 3.9.0
[1505] Fix | Delete
*
[1506] Fix | Delete
* @param WP_Customize_Manager $wp_customize Customize manager.
[1507] Fix | Delete
*/
[1508] Fix | Delete
public function customize_set_last_used( $wp_customize ) {
[1509] Fix | Delete
[1510] Fix | Delete
$header_image_data_setting = $wp_customize->get_setting( 'header_image_data' );
[1511] Fix | Delete
[1512] Fix | Delete
if ( ! $header_image_data_setting ) {
[1513] Fix | Delete
return;
[1514] Fix | Delete
}
[1515] Fix | Delete
[1516] Fix | Delete
$data = $header_image_data_setting->post_value();
[1517] Fix | Delete
[1518] Fix | Delete
if ( ! isset( $data['attachment_id'] ) ) {
[1519] Fix | Delete
return;
[1520] Fix | Delete
}
[1521] Fix | Delete
[1522] Fix | Delete
$attachment_id = $data['attachment_id'];
[1523] Fix | Delete
$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
[1524] Fix | Delete
update_post_meta( $attachment_id, $key, time() );
[1525] Fix | Delete
}
[1526] Fix | Delete
[1527] Fix | Delete
/**
[1528] Fix | Delete
* Gets the details of default header images if defined.
[1529] Fix | Delete
*
[1530] Fix | Delete
* @since 3.9.0
[1531] Fix | Delete
*
[1532] Fix | Delete
* @return array Default header images.
[1533] Fix | Delete
*/
[1534] Fix | Delete
public function get_default_header_images() {
[1535] Fix | Delete
$this->process_default_headers();
[1536] Fix | Delete
[1537] Fix | Delete
// Get the default image if there is one.
[1538] Fix | Delete
$default = get_theme_support( 'custom-header', 'default-image' );
[1539] Fix | Delete
[1540] Fix | Delete
if ( ! $default ) { // If not, easy peasy.
[1541] Fix | Delete
return $this->default_headers;
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
[1545] Fix | Delete
[1546] Fix | Delete
$already_has_default = false;
[1547] Fix | Delete
[1548] Fix | Delete
foreach ( $this->default_headers as $k => $h ) {
[1549] Fix | Delete
if ( $h['url'] === $default ) {
[1550] Fix | Delete
$already_has_default = true;
[1551] Fix | Delete
break;
[1552] Fix | Delete
}
[1553] Fix | Delete
}
[1554] Fix | Delete
[1555] Fix | Delete
if ( $already_has_default ) {
[1556] Fix | Delete
return $this->default_headers;
[1557] Fix | Delete
}
[1558] Fix | Delete
[1559] Fix | Delete
// If the one true image isn't included in the default set, prepend it.
[1560] Fix | Delete
$header_images = array();
[1561] Fix | Delete
$header_images['default'] = array(
[1562] Fix | Delete
'url' => $default,
[1563] Fix | Delete
'thumbnail_url' => $default,
[1564] Fix | Delete
'description' => 'Default',
[1565] Fix | Delete
);
[1566] Fix | Delete
[1567] Fix | Delete
// The rest of the set comes after.
[1568] Fix | Delete
return array_merge( $header_images, $this->default_headers );
[1569] Fix | Delete
}
[1570] Fix | Delete
[1571] Fix | Delete
/**
[1572] Fix | Delete
* Gets the previously uploaded header images.
[1573] Fix | Delete
*
[1574] Fix | Delete
* @since 3.9.0
[1575] Fix | Delete
*
[1576] Fix | Delete
* @return array Uploaded header images.
[1577] Fix | Delete
*/
[1578] Fix | Delete
public function get_uploaded_header_images() {
[1579] Fix | Delete
$header_images = get_uploaded_header_images();
[1580] Fix | Delete
$timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
[1581] Fix | Delete
$alt_text_key = '_wp_attachment_image_alt';
[1582] Fix | Delete
[1583] Fix | Delete
foreach ( $header_images as &$header_image ) {
[1584] Fix | Delete
$header_meta = get_post_meta( $header_image['attachment_id'] );
[1585] Fix | Delete
$header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : '';
[1586] Fix | Delete
$header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : '';
[1587] Fix | Delete
}
[1588] Fix | Delete
[1589] Fix | Delete
return $header_images;
[1590] Fix | Delete
}
[1591] Fix | Delete
[1592] Fix | Delete
/**
[1593] Fix | Delete
* Gets the ID of a previous crop from the same base image.
[1594] Fix | Delete
*
[1595] Fix | Delete
* @since 4.9.0
[1596] Fix | Delete
*
[1597] Fix | Delete
* @param array $attachment An array with a cropped attachment object data.
[1598] Fix | Delete
* @return int|false An attachment ID if one exists. False if none.
[1599] Fix | Delete
*/
[1600] Fix | Delete
public function get_previous_crop( $attachment ) {
[1601] Fix | Delete
$header_images = $this->get_uploaded_header_images();
[1602] Fix | Delete
[1603] Fix | Delete
// Bail early if there are no header images.
[1604] Fix | Delete
if ( empty( $header_images ) ) {
[1605] Fix | Delete
return false;
[1606] Fix | Delete
}
[1607] Fix | Delete
[1608] Fix | Delete
$previous = false;
[1609] Fix | Delete
[1610] Fix | Delete
foreach ( $header_images as $image ) {
[1611] Fix | Delete
if ( $image['attachment_parent'] === $attachment['post_parent'] ) {
[1612] Fix | Delete
$previous = $image['attachment_id'];
[1613] Fix | Delete
break;
[1614] Fix | Delete
}
[1615] Fix | Delete
}
[1616] Fix | Delete
[1617] Fix | Delete
return $previous;
[1618] Fix | Delete
}
[1619] Fix | Delete
}
[1620] Fix | Delete
[1621] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function