*
* This function is attached to 'embed_oembed_html' filter hook.
*
* For overriding in child themes remove the filter hook:
* remove_filter( 'embed_oembed_html', 'ariel_embed_oembed_html', 99, 4 );
*
* @link https://wordpress.stackexchange.com/a/50781
*
* @param [type] $html oEmbed HTML
* @param string $url oEmbed URL
* @param array $attr Array of attributes
* @param int $post_id Post ID
* @return string Returns filtered oEmbed HTML
*/
function ariel_embed_oembed_html( $html, $url, $attr, $post_id ) {
return '
' . $html . '
';
}
add_filter( 'embed_oembed_html', 'ariel_embed_oembed_html', 99, 4 );
if ( ! function_exists( 'ariel_site_identity_text' ) ) :
/**
* Custom site text logo
*
* @return string Display custom text logo
*/
function ariel_site_identity_text() {
$ariel_text_logo = ariel_get_option( 'ariel_text_logo' );
if ( empty( $ariel_text_logo ) ) :
$ariel_text_logo = get_bloginfo( 'name' );
endif; ?>
or false
*/
function ariel_get_first_embed_media( $post_id ) {
$post = get_post( $post_id );
$content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
$embeds = get_media_embedded_in_content( $content );
if ( ! empty( $embeds ) ) :
//check what is the first embed containg video tag, youtube or vimeo
foreach ( $embeds as $embed ) :
if ( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) :
return $embed;
endif;
endforeach;
else :
return false;
endif;
}
endif;
if ( ! function_exists( 'ariel_get_first_post_image' ) ) :
/**
* Get first image in post content
*
* Scan post content for class wp-image-ID and get ID.
* If it exists return image markup for it.
*
* @return string Returns image markup or empty string
*/
function ariel_get_first_post_image() {
/* Get the post content. */
$post_content = get_post_field( 'post_content', get_the_ID() );
/* Apply filters to content. */
$post_content = apply_filters( 'get_the_image_post_content', $post_content );
/* Check the content for `id="wp-image-%d"`. */
preg_match( '/class=[\'"](.*?)wp-image-([\d]*)[\'"]/i', $post_content, $image_classes );
/* Loop through any found image IDs. */
if ( ! empty( $image_classes ) ) {
$image_id = $image_classes[2];
if ( (int) $image_id ) {
return wp_get_attachment_image( $image_id, 'post-thumbnail', '', array( 'class' => 'img-responsive' ) );
}
}
}
endif;
/**
* Filter tag chould args and set the same font size
* for all tags. This function is attached to
* 'widget_tag_cloud_args' filter hook.
*
* @param array $args Array of arguments
* @return array Returns array of filtered args
*/
function ariel_tag_cloud_filter( $args = array() ) {
$args['smallest'] = 11;
$args['largest'] = 11;
$args['unit'] = 'px';
return $args;
}
add_filter( 'widget_tag_cloud_args', 'ariel_tag_cloud_filter', 90 );
#https://jetpack.com/2013/06/10/moving-sharing-icons/
function jptweak_remove_share() {
remove_filter( 'the_content', 'sharing_display',19 );
remove_filter( 'the_excerpt', 'sharing_display',19 );
if ( class_exists( 'Jetpack_Likes' ) ) {
remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
}
}
add_action( 'init', 'jptweak_remove_share');
add_action( 'loop_start', 'jptweak_remove_share' );