auto-patch 638-dev-dev01-2024-05-14T20_44_36

This commit is contained in:
root
2024-05-14 20:44:36 +00:00
parent a941559057
commit 5dbb0b284e
1812 changed files with 29671 additions and 14588 deletions

View File

@@ -129,13 +129,7 @@ class Current_Page_Helper {
public function get_term_id() {
$wp_query = $this->wp_query_wrapper->get_main_query();
if ( $wp_query->is_category() ) {
return $wp_query->get( 'cat' );
}
if ( $wp_query->is_tag() ) {
return $wp_query->get( 'tag_id' );
}
if ( $wp_query->is_tax() ) {
if ( $wp_query->is_tax() || $wp_query->is_tag() || $wp_query->is_category() ) {
$queried_object = $wp_query->get_queried_object();
if ( $queried_object && ! \is_wp_error( $queried_object ) ) {
return $queried_object->term_id;

View File

@@ -304,7 +304,8 @@ class Image_Helper {
*/
public function get_attachment_by_url( $url, $use_link_table = true ) {
// Don't try to do this for external URLs.
if ( $this->url_helper->get_link_type( $url ) === SEO_Links::TYPE_EXTERNAL ) {
$parsed_url = \wp_parse_url( $url );
if ( $this->url_helper->get_link_type( $parsed_url ) === SEO_Links::TYPE_EXTERNAL ) {
return 0;
}
@@ -332,8 +333,15 @@ class Image_Helper {
if ( ! $use_link_table ) {
return WPSEO_Image_Utils::get_attachment_by_url( $url );
}
$cache_key = 'attachment_seo_link_object_' . \md5( $url );
$link = $this->seo_links_repository->find_one_by_url( $url );
$found = false;
$link = \wp_cache_get( $cache_key, 'yoast-seo-attachment-link', false, $found );
if ( $found === false ) {
$link = $this->seo_links_repository->find_one_by_url( $url );
\wp_cache_set( $cache_key, $link, 'yoast-seo-attachment-link', \MINUTE_IN_SECONDS );
}
if ( ! \is_a( $link, SEO_Links::class ) ) {
return WPSEO_Image_Utils::get_attachment_by_url( $url );
}

View File

@@ -40,11 +40,16 @@ class Image_Helper {
/**
* Determines whether the passed URL is considered valid.
*
* @param array $image The image array.
* @deprecated 22.4
* @codeCoverageIgnore
*
* @param array<array<string,string|int>> $image The image array.
*
* @return bool Whether or not the URL is a valid image.
*/
public function is_image_url_valid( array $image ) {
\_deprecated_function( __METHOD__, 'Yoast SEO 22.4' );
if ( empty( $image['url'] ) || ! \is_string( $image['url'] ) ) {
return false;
}
@@ -89,7 +94,7 @@ class Image_Helper {
*
* @param int $attachment_id The attachment id.
*
* @return array|false The image data when found, `false` when not.
* @return array<string,string|int>|false The image data when found, `false` when not.
*/
public function get_image_by_id( $attachment_id ) {
if ( ! $this->image->is_valid_attachment( $attachment_id ) ) {

View File

@@ -71,6 +71,6 @@ class HTML_Helper {
* @return bool
*/
private function is_non_empty_string_or_stringable( $html ) {
return ( \is_string( $html ) || \is_object( $html ) && \method_exists( $html, '__toString' ) ) && ! empty( $html );
return ( \is_string( $html ) || ( \is_object( $html ) && \method_exists( $html, '__toString' ) ) ) && ! empty( $html );
}
}

View File

@@ -112,7 +112,7 @@ class Social_Profiles_Helper {
/**
* Gets the organization social profiles stored in the database.
*
* @return array The social profiles for the organization.
* @return array<string, string> The social profiles for the organization.
*/
public function get_organization_social_profiles() {
$organization_social_profiles_fields = \array_keys( $this->get_organization_social_profile_fields() );
@@ -132,7 +132,7 @@ class Social_Profiles_Helper {
}
if ( $field_name === 'twitter_site' && $social_profile_value !== '' ) {
$organization_social_profiles[ $field_name ] = 'https://twitter.com/' . $social_profile_value;
$organization_social_profiles[ $field_name ] = 'https://x.com/' . $social_profile_value;
continue;
}

View File

@@ -44,13 +44,15 @@ class Image_Helper {
/**
* Retrieves an image url by its id.
*
* @codeCoverageIgnore It is a wrapper method.
*
* @param int $image_id The image id.
*
* @return string The image url.
* @return string The image url. Empty string if the attachment is not valid.
*/
public function get_by_id( $image_id ) {
if ( ! $this->image->is_valid_attachment( $image_id ) ) {
return '';
}
return $this->image->get_attachment_image_source( $image_id, $this->get_image_size() );
}
}

View File

@@ -106,8 +106,7 @@ class Url_Helper {
*/
public function get_url_path( $url ) {
if ( \is_string( $url ) === false
&& \is_object( $url ) === false
|| ( \is_object( $url ) === true && \method_exists( $url, '__toString' ) === false )
&& ( \is_object( $url ) === false || \method_exists( $url, '__toString' ) === false )
) {
return '';
}
@@ -124,8 +123,7 @@ class Url_Helper {
*/
public function get_url_host( $url ) {
if ( \is_string( $url ) === false
&& \is_object( $url ) === false
|| ( \is_object( $url ) === true && \method_exists( $url, '__toString' ) === false )
&& ( \is_object( $url ) === false || \method_exists( $url, '__toString' ) === false )
) {
return '';
}