umbnail_id( $post ); if ( ! $post_thumbnail_id ) { return false; } $thumbnail_url = wp_get_attachment_image_url( $post_thumbnail_id, $size ); /** * Filters the post thumbnail URL. * * @since 5.9.0 * * @param string|false $thumbnail_url Post thumbnail URL or false if the post does not exist. * @param int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`. * @param string|int[] $size Registered image size to retrieve the source for or a flat array * of height and width dimensions. Default 'post-thumbnail'. */ return apply_filters( 'post_thumbnail_url', $thumbnail_url, $post, $size ); } /** * Displays the post thumbnail URL. * * @since 4.4.0 * * @param string|int[] $size Optional. Image size to use. Accepts any valid image size, * or an array of width and height values in pixels (in that order). * Default 'post-thumbnail'. */ function the_post_thumbnail_url( $size = 'post-thumbnail' ) { $url = get_the_post_thumbnail_url( null, $size ); if ( $url ) { echo esc_url( $url ); } } /** * Returns the post thumbnail caption. * * @since 4.6.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. * @return string Post thumbnail caption. */ function get_the_post_thumbnail_caption( $post = null ) { $post_thumbnail_id = get_post_thumbnail_id( $post ); if ( ! $post_thumbnail_id ) { return ''; } $caption = wp_get_attachment_caption( $post_thumbnail_id ); if ( ! $caption ) { $caption = ''; } return $caption; } /** * Displays the post thumbnail caption. * * @since 4.6.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. */ function the_post_thumbnail_caption( $post = null ) { /** * Filters the displayed post thumbnail caption. * * @since 4.6.0 * * @param string $caption Caption for the given attachment. */ echo apply_filters( 'the_post_thumbnail_caption', get_the_post_thumbnail_caption( $post ) ); } bstr( $m[0], 1, -1 ); } $tag = $m[2]; $attr = shortcode_parse_atts( $m[3] ); if ( ! is_callable( $shortcode_tags[ $tag ] ) ) { _doing_it_wrong( __FUNCTION__, /* translators: %s: Shortcode tag. */ sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ), '4.3.0' ); return $m[0]; } /** * Filters whether to call a shortcode callback. * * Returning a non-false value from filter will short-circuit the * shortcode generation process, returning that value instead. * * @since 4.7.0 * * @param false|string $output Short-circuit return value. Either false or the value to replace the shortcode with. * @param string $tag Shortcode name. * @param array|string $attr Shortcode attributes array or the original arguments string if it cannot be parsed. * @param array $m Regular expression match array. */ $return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m ); if ( false !== $return ) { return $return; } $content = isset( $m[5] ) ? $m[5] : null; $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; /** * Filters the output created by a shortcode callback. * * @since 4.7.0 * * @param string $output Shortcode output. * @param string $tag Shortcode name. * @param array|string $attr Shortcode attributes array or the original arguments string if it cannot be parsed. * @param array $m Regular expression match array. */ return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m ); } /** * Searches only inside HTML elements for shortcodes and process them. * * Any [ or ] characters remaining inside elements will be HTML encoded * to prevent interference with shortcodes that are outside the elements. * Assumes $content processed by KSES already. Users with unfiltered_html * capability may get unexpected output if angle braces are nested in tags. * * @since 4.2.3 * * @param string $content Content to search for shortcodes. * @param bool $ignore_html When true, all square braces inside elements will be encoded. * @param array $tagnames List of shortcodes to find. * @return string Content with shortcodes filtered out. */ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { // Normalize entities in unfiltered HTML before adding placeholders. $trans = array( '[' => '[', ']' => ']', ); $content = strtr( $content, $trans ); $trans = array( '[' => '[', ']' => ']', ); $pattern = get_shortcode_regex( $tagnames ); $textarr = wp_html_split( $content ); foreach ( $textarr as &$element ) { if ( '' === $element || '<' !== $element[0] ) { continue; } $noopen = ! str_contains( $element, '[' ); $noclose = ! str_contains( $element, ']' ); if ( $noopen || $noclose ) { // This element does not contain shortcodes. if ( $noopen xor $noclose ) { // Need to encode stray '[' or ']' chars. $element = strtr( $element, $trans ); } continue; } if ( $ignore_html || str_starts_with( $element, '