post_title; $content = $post->post_content; } $link = amy_xmas_get_first_url( $content ); if ( ! empty( $link ) ) { $title = '' . $title . ''; $content = str_replace( $link, '', $content ); } else { $pattern = '/^\](.*?)>(.*?)<\/a>/i'; preg_match( $pattern, $content, $link ); if ( ! empty( $link[0] ) && ! empty( $link[2] ) ) { $title = $link[0]; $content = str_replace( $link[0], '', $content ); } else if ( ! empty( $link[0] ) && ! empty( $link[1] ) ) { $atts = shortcode_parse_atts( $link[1] ); $target = ! empty( $atts['target'] ) ? $atts['target'] : '_self'; $title = ! empty( $atts['title'] ) ? $atts['title'] : $title; $title = '' . $title . ''; $content = str_replace( $link[0], '', $content ); } else { $title = '' . $title . ''; } } return array( 'title' => '

' . $title . '

', 'content' => $content, ); } } /** * Get link attributes. */ if ( ! function_exists( 'amy_xmas_get_link_attributes' ) ) { function amy_xmas_get_link_attributes( $string ) { preg_match( '/]*>/i', $string, $atts ); return ! empty( $atts[1] ) ? $atts[1] : ''; } } /** * Get post video/audio. */ if ( ! function_exists( 'amy_xmas_get_post_media' ) ) { function amy_xmas_get_post_media( $content ) { $is_video = get_post_format() == 'video'; $media = amy_xmas_get_first_url( $content ); if ( ! empty( $media ) ) { global $wp_embed; $content = do_shortcode( $wp_embed->run_shortcode( '[embed]' . $media . '[/embed]' ) ); } else { $pattern = amy_xmas_get_shortcode_regex( amy_xmas_get_tagregex() ); preg_match( '/' . $pattern . '/s', $content, $media ); if ( ! empty( $media[2] ) ) { if ( $media[2] == 'embed' ) { global $wp_embed; $content = do_shortcode( $wp_embed->run_shortcode( $media[0] ) ); } else { $content = do_shortcode( $media[0] ); } } } if ( ! empty( $media ) ) { return '
' . ($is_video ? '
' : '') . $content . ($is_video ? '
' : '') . '
'; } return false; } } /** * Get post gallery. */ if ( ! function_exists( 'amy_xmas_get_post_gallery' ) ) { function amy_xmas_get_post_gallery( $content ) { $pattern = amy_xmas_get_shortcode_regex( 'gallery' ); preg_match( '/' . $pattern . '/s', $content, $media ); if ( ! empty( $media[2] ) ) { return '
' . do_shortcode( $media[0] ) . '
'; } return false; } }