tag based on what is being viewed. * * @param string $title Default title text for current view. * @param string $sep Optional separator. * @return string The filtered title. */ function lsx_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() ) { return $title; } // Add the blog name $title .= get_bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) { $title .= " $sep $site_description"; } // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) { $title .= " $sep " . sprintf( __( 'Page %s', 'lsx' ), max( $paged, $page ) ); } return $title; } add_filter( 'wp_title', 'lsx_wp_title', 10, 2 ); /** * Wrap embedded media as suggested by Readability * * @link https://gist.github.com/965956 * @link http://www.readability.com/publishers/guidelines#publisher */ function lsx_embed_wrap($cache, $url, $attr = '', $post_id = '') { return '
' . $cache . '
'; } add_filter('embed_oembed_html', 'lsx_embed_wrap', 10, 4); /** * Remove unnecessary self-closing tags */ function lsx_remove_self_closing_tags($input) { return str_replace(' />', '>', $input); } add_filter('get_avatar', 'lsx_remove_self_closing_tags'); // add_filter('comment_id_fields', 'lsx_remove_self_closing_tags'); // add_filter('post_thumbnail_html', 'lsx_remove_self_closing_tags'); // if (!function_exists('lsx_get_attachment_id')) { /** * Get the Attachment ID for a given image URL. * * @link http://wordpress.stackexchange.com/a/7094 * @param string $url * @return boolean|integer */ function lsx_get_attachment_id($url) { $dir = wp_upload_dir(); // baseurl never has a trailing slash if (false === strpos($url, $dir['baseurl'].'/')) { // URL points to a place outside of upload directory return false; } $file = basename($url); $query = array( 'post_type' => 'attachment', 'fields' => 'ids', 'meta_query' => array( array( 'value' => $file, 'compare' => 'LIKE', ), ) ); $query['meta_query'][0]['key'] = '_wp_attached_file'; // query attachments $ids = get_posts($query); if (!empty($ids)) { foreach ($ids as $id) { // first entry of returned array is the URL $temp_url = wp_get_attachment_image_src( $id, 'full' ); if ( array_shift( $temp_url ) === $url ) { return $id; } } } $query['meta_query'][0]['key'] = '_wp_attachment_metadata'; // query attachments again $ids = get_posts($query); if (empty($ids)) { return false; } foreach ($ids as $id) { $meta = wp_get_attachment_metadata($id); foreach ( $meta['sizes'] as $size => $values ) { if ( $values['file'] === $file && array_shift( wp_get_attachment_image_src( $id, $size ) ) === $url ) { return $id; } } } return false; } } /** * Get the Avatar Url */ function lsx_get_avatar_url($author_id, $size) { $get_avatar = get_avatar($author_id, $size); preg_match("/src='(.*?)'/i", $get_avatar, $matches); return ($matches[1]); } /** * Checks if a Nav $element is empty or not */ function lsx_is_element_empty($element) { $element = trim($element); return empty($element)?false:true; } /** * return the responsive images. * * @package lsx * @subpackage extras * @category thumbnails */ function lsx_get_thumbnail($size,$image_src = false){ if(false === $image_src){ $post_id = get_the_ID(); $post_thumbnail_id = get_post_thumbnail_id( $post_id ); }elseif(false != $image_src ){ if(is_numeric($image_src)){ $post_thumbnail_id = $image_src; }else{ $post_thumbnail_id = lsx_get_attachment_id_from_src($image_src); } } $size = apply_filters('lsx_thumbnail_size',$size); $img = false; if ( 'lsx-thumbnail-wide' === $size || 'thumbnail' === $size ) { $srcset = false; $img = wp_get_attachment_image_src($post_thumbnail_id,$size); $img = $img[0]; } else { $srcset = true; $img = wp_get_attachment_image_srcset($post_thumbnail_id,$size); if ( false == $img ) { $srcset = false; $img = wp_get_attachment_image_src($post_thumbnail_id,$size); $img = $img[0]; } } if ( $srcset ) { $img = ''.get_the_title(get_the_ID()).''; } else { $img = ''.get_the_title(get_the_ID()).''; } $img = apply_filters('lsx_lazyload_filter_images',$img); return $img; } /** * Output the Resonsive Images * * @package lsx * @subpackage extras * @category thumbnails */ function lsx_thumbnail( $size = 'thumbnail', $image_src = false ) { echo wp_kses_post( lsx_get_thumbnail( $size, $image_src ) ); } /** * Gets the attachments ID from the src * @package lsx * @subpackage extras * @category thumbnails */ function lsx_get_attachment_id_from_src( $image_src ) { $post_id = wp_cache_get( $image_src, 'lsx_get_attachment_id_from_src' ); if ( false === $post_id ) { global $wpdb; $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE guid='%s' LIMIT 1", $image_src ) ); wp_cache_set( $image_src, $post_id, 'lsx_get_attachment_id_from_src', 3600 ); } return $post_id; } /** * Add Featured Image as Banner on Single Pages. * * @package lsx * @subpackage extras * @category banner */ if (!function_exists('lsx_page_banner')) { function lsx_page_banner() { $post_types = array('page','post'); $post_types = apply_filters('lsx_allowed_post_type_banners',$post_types); if ( (is_singular($post_types) && has_post_thumbnail()) || (is_singular('jetpack-portfolio')) ) { ?>
Submit"; } add_filter("gform_submit_button", "lsx_form_submit_button", 10, 2); /** * Replaces the excerpt "more" text by a link */ function lsx_excerpt_more($more) { global $post; //return ' ... '.esc_html__('Continue reading','lsx').''; return '...'; } add_filter( 'excerpt_more', 'lsx_excerpt_more' ); /** * Add a continue reading link to the excerpt */ function lsx_the_excerpt_filter($excerpt) { $show_full_content = has_post_format(apply_filters('lsx_the_excerpt_filter_post_types', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio'))); if (!$show_full_content) { if ('' !== $excerpt && !stristr($excerpt, 'moretag')) { $pagination = wp_link_pages( array( 'before' => '
', 'after' => '
', 'link_before' => '', 'link_after' => '', 'echo' => 0 ) ); if ( ! empty( $pagination ) ) { $excerpt .= $pagination; } else { $excerpt .= '

'.esc_html__('Continue reading','lsx').'

'; } } } return $excerpt; } add_filter( 'the_excerpt', 'lsx_the_excerpt_filter' , 1 , 20 ); /** * Allow HTML tags in excerpt */ if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) { function wpse_custom_wp_trim_excerpt($wpse_excerpt) { global $post; $raw_excerpt = $wpse_excerpt; if ( '' == $wpse_excerpt ) { $wpse_excerpt = get_the_content(''); $show_full_content = has_post_format(array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio')); if (!$show_full_content) { $wpse_excerpt = strip_shortcodes( $wpse_excerpt ); $wpse_excerpt = apply_filters('the_content', $wpse_excerpt); $wpse_excerpt = str_replace(']]>', ']]>', $wpse_excerpt); $wpse_excerpt = strip_tags($wpse_excerpt, '
,

,
,,,,,