themes and plugins but that is not recommended.
* The size "names" reflect the image dimensions, so changing the sizes would be quite misleading.
*
* @since 5.3.0
* @access private
*/
function _wp_add_additional_image_sizes() {
// 2x medium_large size.
add_image_size( '1536x1536', 1536, 1536 );
// 2x large size.
add_image_size( '2048x2048', 2048, 2048 );
}
/**
* Callback to enable showing of the user error when uploading .heic images.
*
* @since 5.5.0
*
* @param array[] $plupload_settings The settings for Plupload.js.
* @return array[] Modified settings for Plupload.js.
*/
function wp_show_heic_upload_error( $plupload_settings ) {
$plupload_settings['heic_upload_error'] = true;
return $plupload_settings;
}
/**
* Allows PHP's getimagesize() to be debuggable when necessary.
*
* @since 5.7.0
* @since 5.8.0 Added support for WebP images.
*
* @param string $filename The file path.
* @param array $image_info Optional. Extended image information (passed by reference).
* @return array|false Array of image information or false on failure.
*/
function wp_getimagesize( $filename, array &$image_info = null ) {
// Don't silence errors when in debug mode, unless running unit tests.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG
&& ! defined( 'WP_RUN_CORE_TESTS' )
) {
if ( 2 === func_num_args() ) {
$info = getimagesize( $filename, $image_info );
} else {
$info = getimagesize( $filename );
}
} else {
/*
* Silencing notice and warning is intentional.
*
* getimagesize() has a tendency to generate errors, such as
* "corrupt JPEG data: 7191 extraneous bytes before marker",
* even when it's able to provide image size information.
*
* See https://core.trac.wordpress.org/ticket/42480
*/
if ( 2 === func_num_args() ) {
// phpcs:ignore WordPress.PHP.NoSilencedErrors
$info = @getimagesize( $filename, $image_info );
} else {
// phpcs:ignore WordPress.PHP.NoSilencedErrors
$info = @getimagesize( $filename );
}
}
if ( false !== $info ) {
return $info;
}
// For PHP versions that don't support WebP images,
// extract the image size info from the file headers.
if ( 'image/webp' === wp_get_image_mime( $filename ) ) {
$webp_info = wp_get_webp_info( $filename );
$width = $webp_info['width'];
$height = $webp_info['height'];
// Mimic the native return format.
if ( $width && $height ) {
return array(
$width,
$height,
IMAGETYPE_WEBP,
sprintf(
'width="%d" height="%d"',
$width,
$height
),
'mime' => 'image/webp',
);
}
}
// The image could not be parsed.
return false;
}
/**
* Extracts meta information about a WebP file: width, height, and type.
*
* @since 5.8.0
*
* @param string $filename Path to a WebP file.
* @return array {
* An array of WebP image information.
*
* @type int|false $width Image width on success, false on failure.
* @type int|false $height Image height on success, false on failure.
* @type string|false $type The WebP type: one of 'lossy', 'lossless' or 'animated-alpha'.
* False on failure.
* }
*/
function wp_get_webp_info( $filename ) {
$width = false;
$height = false;
$type = false;
if ( 'image/webp' !== wp_get_image_mime( $filename ) ) {
return compact( 'width', 'height', 'type' );
}
$magic = file_get_contents( $filename, false, null, 0, 40 );
if ( false === $magic ) {
return compact( 'width', 'height', 'type' );
}
// Make sure we got enough bytes.
if ( strlen( $magic ) < 40 ) {
return compact( 'width', 'height', 'type' );
}
// The headers are a little different for each of the three formats.
// Header values based on WebP docs, see https://developers.google.com/speed/webp/docs/riff_container.
switch ( substr( $magic, 12, 4 ) ) {
// Lossy WebP.
case 'VP8 ':
$parts = unpack( 'v2', substr( $magic, 26, 4 ) );
$width = (int) ( $parts[1] & 0x3FFF );
$height = (int) ( $parts[2] & 0x3FFF );
$type = 'lossy';
break;
// Lossless WebP.
case 'VP8L':
$parts = unpack( 'C4', substr( $magic, 21, 4 ) );
$width = (int) ( $parts[1] | ( ( $parts[2] & 0x3F ) << 8 ) ) + 1;
$height = (int) ( ( ( $parts[2] & 0xC0 ) >> 6 ) | ( $parts[3] << 2 ) | ( ( $parts[4] & 0x03 ) << 10 ) ) + 1;
$type = 'lossless';
break;
// Animated/alpha WebP.
case 'VP8X':
// Pad 24-bit int.
$width = unpack( 'V', substr( $magic, 24, 3 ) . "\x00" );
$width = (int) ( $width[1] & 0xFFFFFF ) + 1;
// Pad 24-bit int.
$height = unpack( 'V', substr( $magic, 27, 3 ) . "\x00" );
$height = (int) ( $height[1] & 0xFFFFFF ) + 1;
$type = 'animated-alpha';
break;
}
return compact( 'width', 'height', 'type' );
}
/**
* Gets the default value to use for a `loading` attribute on an element.
*
* This function should only be called for a tag and context if lazy-loading is generally enabled.
*
* The function usually returns 'lazy', but uses certain heuristics to guess whether the current element is likely to
* appear above the fold, in which case it returns a boolean `false`, which will lead to the `loading` attribute being
* omitted on the element. The purpose of this refinement is to avoid lazy-loading elements that are within the initial
* viewport, which can have a negative performance impact.
*
* Under the hood, the function uses {@see wp_increase_content_media_count()} every time it is called for an element
* within the main content. If the element is the very first content element, the `loading` attribute will be omitted.
* This default threshold of 1 content element to omit the `loading` attribute for can be customized using the
* {@see 'wp_omit_loading_attr_threshold'} filter.
*
* @since 5.9.0
*
* @param string $context Context for the element for which the `loading` attribute value is requested.
* @return string|bool The default `loading` attribute value. Either 'lazy', 'eager', or a boolean `false`, to indicate
* that the `loading` attribute should be skipped.
*/
function wp_get_loading_attr_default( $context ) {
// Skip lazy-loading for the overall block template, as it is handled more granularly.
if ( 'template' === $context ) {
return false;
}
// Do not lazy-load images in the header block template part, as they are likely above the fold.
$header_area = WP_TEMPLATE_PART_AREA_HEADER;
if ( "template_part_{$header_area}" === $context ) {
return false;
}
/*
* The first elements in 'the_content' or 'the_post_thumbnail' should not be lazy-loaded,
* as they are likely above the fold.
*/
if ( 'the_content' === $context || 'the_post_thumbnail' === $context ) {
// Only elements within the main query loop have special handling.
if ( is_admin() || ! in_the_loop() || ! is_main_query() ) {
return 'lazy';
}
// Increase the counter since this is a main query content element.
$content_media_count = wp_increase_content_media_count();
// If the count so far is below the threshold, return `false` so that the `loading` attribute is omitted.
if ( $content_media_count <= wp_omit_loading_attr_threshold() ) {
return false;
}
// For elements after the threshold, lazy-load them as usual.
return 'lazy';
}
// Lazy-load by default for any unknown context.
return 'lazy';
}
/**
* Gets the threshold for how many of the first content media elements to not lazy-load.
*
* This function runs the {@see 'wp_omit_loading_attr_threshold'} filter, which uses a default threshold value of 1.
* The filter is only run once per page load, unless the `$force` parameter is used.
*
* @since 5.9.0
*
* @param bool $force Optional. If set to true, the filter will be (re-)applied even if it already has been before.
* Default false.
* @return int The number of content media elements to not lazy-load.
*/
function wp_omit_loading_attr_threshold( $force = false ) {
static $omit_threshold;
// This function may be called multiple times. Run the filter only once per page load.
if ( ! isset( $omit_threshold ) || $force ) {
/**
* Filters the threshold for how many of the first content media elements to not lazy-load.
*
* For these first content media elements, the `loading` attribute will be omitted. By default, this is the case
* for only the very first content media element.
*
* @since 5.9.0
*
* @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 1.
*/
$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 1 );
}
return $omit_threshold;
}
/**
* Increases an internal content media count variable.
*
* @since 5.9.0
* @access private
*
* @param int $amount Optional. Amount to increase by. Default 1.
* @return int The latest content media count, after the increase.
*/
function wp_increase_content_media_count( $amount = 1 ) {
static $content_media_count = 0;
$content_media_count += $amount;
return $content_media_count;
}
Fatal error: Uncaught Error: Failed opening required '/home/kharjhom/public_html/wp-includes/http.php' (include_path='.:/opt/cpanel/ea-php81/root/usr/share/pear') in /home/kharjhom/public_html/wp-settings.php:236
Stack trace:
#0 /home/kharjhom/public_html/wp-config.php(65): require_once()
#1 /home/kharjhom/public_html/wp-load.php(50): require_once('/home/kharjhom/...')
#2 /home/kharjhom/public_html/wp-blog-header.php(13): require_once('/home/kharjhom/...')
#3 /home/kharjhom/public_html/index.php(17): require('/home/kharjhom/...')
#4 {main}
thrown in /home/kharjhom/public_html/wp-settings.php on line 236
Fatal error: Uncaught Error: Call to a member function set() on null in /home/kharjhom/public_html/wp-includes/l10n.php:786
Stack trace:
#0 /home/kharjhom/public_html/wp-includes/l10n.php(874): load_textdomain('default', '/home/kharjhom/...', 'ar_SA')
#1 /home/kharjhom/public_html/wp-includes/class-wp-fatal-error-handler.php(47): load_default_textdomain()
#2 [internal function]: WP_Fatal_Error_Handler->handle()
#3 {main}
thrown in /home/kharjhom/public_html/wp-includes/l10n.php on line 786