= ( $attributes['minutes'] ?? 0 ); $elements = $this->transform_duration_to_string( $days, $hours, $minutes ); $elements_length = \count( $elements ); switch ( $elements_length ) { case 1: return $elements[0]; case 2: return \sprintf( /* translators: %s expands to a unit of time (e.g. 1 day). */ \__( '%1$s and %2$s', 'wordpress-seo' ), ...$elements ); case 3: return \sprintf( /* translators: %s expands to a unit of time (e.g. 1 day). */ \__( '%1$s, %2$s and %3$s', 'wordpress-seo' ), ...$elements ); default: return ''; } } /** * Presents the duration text of the How-To block in the site language. * * @param array $attributes The attributes. * @param string $content The content. * * @return string The content with the duration text in the site language. */ public function present_duration_text( $attributes, $content ) { $duration = $this->build_duration_string( $attributes ); // 'Time needed:' is the default duration text that will be shown if a user doesn't add one. $duration_text = \__( 'Time needed:', 'wordpress-seo' ); if ( isset( $attributes['durationText'] ) && $attributes['durationText'] !== '' ) { $duration_text = $attributes['durationText']; } return \preg_replace( '/(

)(.*<\/span>)(.[^\/p>]*)(<\/p>)/', '

' . $duration_text . ' ' . $duration . '

', $content, 1 ); } /** * Optimizes images in the How-To blocks. * * @param array $attributes The attributes. * @param string $content The content. * * @return string The content with images optimized. */ public function optimize_how_to_images( $attributes, $content ) { if ( ! isset( $attributes['steps'] ) ) { return $content; } $content = $this->present_duration_text( $attributes, $content ); return $this->optimize_images( $attributes['steps'], 'text', $content ); } /** * Optimizes images in structured data blocks. * * @param array $elements The list of elements from the block attributes. * @param string $key The key in the data to iterate over. * @param string $content The content. * * @return string The content with images optimized. */ private function optimize_images( $elements, $key, $content ) { global $post; if ( ! $post ) { return $content; } $this->add_images_from_attributes_to_used_cache( $post->ID, $elements, $key ); // Then replace all images with optimized versions in the content. $content = \preg_replace_callback( '/]+>/', function ( $matches ) { \preg_match( '/src="([^"]+)"/', $matches[0], $src_matches ); if ( ! $src_matches || ! isset( $src_matches[1] ) ) { return $matches[0]; } $attachment_id = $this->attachment_src_to_id( $src_matches[1] ); if ( $attachment_id === 0 ) { return $matches[0]; } $image_size = 'full'; $image_style = [ 'style' => 'max-width: 100%; height: auto;' ]; \preg_match( '/style="[^"]*width:\s*(\d+)px[^"]*"/', $matches[0], $style_matches ); if ( $style_matches && isset( $style_matches[1] ) ) { $width = (int) $style_matches[1]; $meta_data = \wp_get_attachment_metadata( $attachment_id ); if ( isset( $meta_data['height'] ) && isset( $meta_data['width'] ) && $meta_data['height'] > 0 && $meta_data['width'] > 0 ) { $aspect_ratio = ( $meta_data['height'] / $meta_data['width'] ); $height = ( $width * $aspect_ratio ); $image_size = [ $width, $height ]; } $image_style = ''; } /** * Filter: 'wpseo_structured_data_blocks_image_size' - Allows adjusting the image size in structured data blocks. * * @since 18.2 * * @param string|int[] $image_size The image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). * @param int $attachment_id The id of the attachment. * @param string $attachment_src The attachment src. */ $image_size = \apply_filters( 'wpseo_structured_data_blocks_image_size', $image_size, $attachment_id, $src_matches[1] ); $image_html = \wp_get_attachment_image( $attachment_id, $image_size, false, $image_style ); if ( empty( $image_html ) ) { return $matches[0]; } return $image_html; }, $content ); if ( ! $this->registered_shutdown_function ) { \register_shutdown_function( [ $this, 'maybe_save_used_caches' ] ); $this->registered_shutdown_function = true; } return $content; } /** * If the caches of structured data block images have been changed, saves them. * * @return void */ public function maybe_save_used_caches() { foreach ( $this->used_caches as $post_id => $used_cache ) { if ( isset( $this->caches[ $post_id ] ) && $used_cache === $this->caches[ $post_id ] ) { continue; } \update_post_meta( $post_id, 'yoast-structured-data-blocks-images-cache', $used_cache ); } } /** * Converts an attachment src to an attachment ID. * * @param string $src The attachment src. * * @return int The attachment ID. 0 if none was found. */ private function attachment_src_to_id( $src ) { global $post; if ( isset( $this->used_caches[ $post->ID ][ $src ] ) ) { return $this->used_caches[ $post->ID ][ $src ]; } $cache = $this->get_cache_for_post( $post->ID ); if ( isset( $cache[ $src ] ) ) { $this->used_caches[ $post->ID ][ $src ] = $cache[ $src ]; return $cache[ $src ]; } $this->used_caches[ $post->ID ][ $src ] = $this->image_helper->get_attachment_by_url( $src ); return $this->used_caches[ $post->ID ][ $src ]; } /** * Returns the cache from postmeta for a given post. * * @param int $post_id The post ID. * * @return array The images cache. */ private function get_cache_for_post( $post_id ) { if ( isset( $this->caches[ $post_id ] ) ) { return $this->caches[ $post_id ]; } $cache = \get_post_meta( $post_id, 'yoast-structured-data-blocks-images-cache', true ); if ( ! $cache ) { $cache = []; } $this->caches[ $post_id ] = $cache; return $cache; } /** * Adds any images that have their ID in the block attributes to the cache. * * @param int $post_id The post ID. * @param array $elements The elements. * @param string $key The key in the elements we should loop over. * * @return void */ private function add_images_from_attributes_to_used_cache( $post_id, $elements, $key ) { // First grab all image IDs from the attributes. $images = []; foreach ( $elements as $element ) { if ( ! isset( $element[ $key ] ) ) { continue; } if ( isset( $element[ $key ] ) && \is_array( $element[ $key ] ) ) { foreach ( $element[ $key ] as $part ) { if ( ! \is_array( $part ) || ! isset( $part['type'] ) || $part['type'] !== 'img' ) { continue; } if ( ! isset( $part['key'] ) || ! isset( $part['props']['src'] ) ) { continue; } $images[ $part['props']['src'] ] = (int) $part['key']; } } } if ( isset( $this->used_caches[ $post_id ] ) ) { $this->used_caches[ $post_id ] = \array_merge( $this->used_caches[ $post_id ], $images ); } else { $this->used_caches[ $post_id ] = $images; } } /* DEPRECATED METHODS */ /** * Enqueue Gutenberg block assets for backend editor. * * @deprecated 22.7 * @codeCoverageIgnore * * @return void */ public function enqueue_block_editor_assets() { \_deprecated_function( __METHOD__, 'Yoast SEO 22.7' ); } } {"id":2977,"count":1,"description":"","link":"https:\/\/justeinfos.net\/tag\/ournee-internationale-de-la-femme-africaine\/","name":"ourn\u00e9e Internationale de la Femme Africaine","slug":"ournee-internationale-de-la-femme-africaine","taxonomy":"post_tag","meta":[],"yoast_head":"\nourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale\" \/>\n<meta property=\"og:url\" content=\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/\" \/>\n<meta property=\"og:site_name\" content=\"JusteInfos- Information g\u00e9n\u00e9rale\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"CollectionPage\",\"@id\":\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/\",\"url\":\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/\",\"name\":\"ourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale\",\"isPartOf\":{\"@id\":\"https:\/\/justeinfos.net\/#website\"},\"breadcrumb\":{\"@id\":\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/#breadcrumb\"},\"inLanguage\":\"fr-FR\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/justeinfos.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ourn\u00e9e Internationale de la Femme Africaine\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/justeinfos.net\/#website\",\"url\":\"https:\/\/justeinfos.net\/\",\"name\":\"JusteInfos- Information g\u00e9n\u00e9rale\",\"description\":\"L'Information-Juste M\u00e9sur\u00e9e ett Sans Passion\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/justeinfos.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/","og_locale":"fr_FR","og_type":"article","og_title":"ourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale","og_url":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/","og_site_name":"JusteInfos- Information g\u00e9n\u00e9rale","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"CollectionPage","@id":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/","url":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/","name":"ourn\u00e9e Internationale de la Femme Africaine Archives - JusteInfos- Information g\u00e9n\u00e9rale","isPartOf":{"@id":"https:\/\/justeinfos.net\/#website"},"breadcrumb":{"@id":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/#breadcrumb"},"inLanguage":"fr-FR"},{"@type":"BreadcrumbList","@id":"https:\/\/justeinfos.net\/amp\/tag\/ournee-internationale-de-la-femme-africaine\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/justeinfos.net\/"},{"@type":"ListItem","position":2,"name":"ourn\u00e9e Internationale de la Femme Africaine"}]},{"@type":"WebSite","@id":"https:\/\/justeinfos.net\/#website","url":"https:\/\/justeinfos.net\/","name":"JusteInfos- Information g\u00e9n\u00e9rale","description":"L'Information-Juste M\u00e9sur\u00e9e ett Sans Passion","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/justeinfos.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"}]}},"_links":{"self":[{"href":"https:\/\/justeinfos.net\/wp-json\/wp\/v2\/tags\/2977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justeinfos.net\/wp-json\/wp\/v2\/tags"}],"about":[{"href":"https:\/\/justeinfos.net\/wp-json\/wp\/v2\/taxonomies\/post_tag"}],"wp:post_type":[{"href":"https:\/\/justeinfos.net\/wp-json\/wp\/v2\/posts?tags=2977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}