next_tag( array( 'class_name' => 'wp-block-gutsliders-videos-carousel' ) ) ) {
$processor->set_attribute( 'data-embed-preview', 'true' );
$block_content = $processor->get_updated_html();
}
}
if ( ! empty( $attrs['videoSchema'] ) ) {
$block_content .= $this->get_schema( $attrs );
}
return $block_content;
}
/**
* VideoObject structured data for the carousel's videos (Google video results).
* Videos without a still image are left out: Google requires one.
*
* @since 3.1.1
*
* @param array $attrs Block attributes.
* @return string `';
}
/**
* A video's upload date (ISO 8601): the one set on the video, else the page's date.
*
* @since 3.1.1
*
* @param array $item Video item.
* @return string Date.
*/
private function get_upload_date( array $item ): string {
if ( ! empty( $item['uploadDate'] ) && preg_match( '/^\d{4}-\d{2}-\d{2}$/', (string) $item['uploadDate'] ) ) {
try {
return ( new \DateTimeImmutable( $item['uploadDate'] . ' 00:00:00', wp_timezone() ) )->format( 'c' );
} catch ( \Exception $e ) {
unset( $e );
}
}
$date = get_the_date( 'c' );
return $date ? (string) $date : gmdate( 'c' );
}
/**
* "4:12" or "1:02:03" as an ISO 8601 duration (PT4M12S); '' when unreadable.
*
* @since 3.1.1
*
* @param string $duration Duration as shown on the card.
* @return string ISO duration.
*/
private function get_iso_duration( string $duration ): string {
if ( ! preg_match( '/^(?:(\d+):)?(\d{1,2}):(\d{2})$/', trim( $duration ), $match ) ) {
return '';
}
$hours = (int) $match[1];
$minutes = (int) $match[2];
$seconds = (int) $match[3];
return 'PT' . ( $hours ? $hours . 'H' : '' ) . ( $minutes ? $minutes . 'M' : '' ) . $seconds . 'S';
}
/**
* Adjust the block's iframes and play buttons.
*
* @since 3.1.1
*
* @param string $block_content Rendered block HTML.
* @param array $block Parsed block.
* @return string Block HTML.
*/
public function tune_players( $block_content, $block = array() ): string {
$block_content = (string) $block_content;
if ( false === stripos( $block_content, '