'; } } } add_action( 'wp_head', 'blogger_light_pingback_header' ); // define content filter for post and project details. Paragraphs containing text have added extra class if ( !function_exists('blogger_light_content_filter') ) { function blogger_light_content_filter ($string) { // (maybe) modify $string $string = apply_filters('the_content', $string); if ( $string && $string != '' ) { $doc = new DOMDocument(); libxml_use_internal_errors( true ); $doc->loadHTML( mb_convert_encoding( $string, 'HTML-ENTITIES', 'UTF-8' ) ); // new xpath $xpath = new DOMXpath($doc); $nodes = $xpath->query('/html/body/p[not(descendant::img or descendant::iframe)]|/html/body/a[not(contains(@class, "button"))]'); if ( $nodes->length ) { foreach ( $nodes as $node ) { $class = $node->getAttribute( 'class'); ($class != '') ? $class = $class.' text-paragraph' : $class = 'text-paragraph'; $node->setAttribute( 'class', $class); } } // remove
$string = preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $doc->saveHTML($doc->documentElement)); } return $string; } } add_filter( 'detail_content', 'blogger_light_content_filter'); /** * Display icons in social links menu. * * @param string $item_output The menu item output. * @param WP_Post $item Menu item object. * @param int $depth Depth of the menu. * @param array $args wp_nav_menu() arguments. * @return string $item_output The menu item output with social icon. */ if ( !function_exists('blogger_light_nav_menu_social_icons') ) { function blogger_light_nav_menu_social_icons( $item_output, $item, $depth, $args ) { // Change SVG icon inside social links menu if there is supported URL. if ( 'social-menu-footer' === $args->theme_location || 'social-menu-header' === $args->theme_location ) { // Get supported social icons. $social_icons = blogger_light_social_links_icons(); foreach ( $social_icons as $attr => $value ) { // Replace text by FA icon if in FA array if ( false !== strpos( $item_output, $attr ) ) { $item_output = str_replace( $args->link_after, '', $item_output ); } } } return $item_output; } } add_filter( 'walker_nav_menu_start_el', 'blogger_light_nav_menu_social_icons', 10, 4 ); /** * Returns an array of supported social links (URL and icon name). * * @return array $social_links_icons */ if ( !function_exists('blogger_light_social_links_icons') ) { function blogger_light_social_links_icons() { // Supported social links icons. $social_links_icons = array( 'behance.net' => 'behance', 'codepen.io' => 'codepen', 'deviantart.com' => 'deviantart', 'digg.com' => 'digg', 'dribbble.com' => 'dribbble', 'dropbox.com' => 'dropbox', 'facebook.com' => 'facebook', 'flickr.com' => 'flickr', 'foursquare.com' => 'foursquare', 'plus.google.com' => 'google-plus', 'github.com' => 'github', 'instagram.com' => 'instagram', 'linkedin.com' => 'linkedin', 'mailto:' => 'envelope-o', 'medium.com' => 'medium', 'pinterest.com' => 'pinterest-p', 'getpocket.com' => 'get-pocket', 'reddit.com' => 'reddit-alien', 'skype.com' => 'skype', 'skype:' => 'skype', 'slideshare.net' => 'slideshare', 'snapchat.com' => 'snapchat-ghost', 'soundcloud.com' => 'soundcloud', 'spotify.com' => 'spotify', 'stumbleupon.com' => 'stumbleupon', 'tumblr.com' => 'tumblr', 'twitch.tv' => 'twitch', 'twitter.com' => 'twitter', 'vimeo.com' => 'vimeo', 'vine.co' => 'vine', 'vk.com' => 'vk', 'wordpress.org' => 'wordpress', 'wordpress.com' => 'wordpress', 'yelp.com' => 'yelp', 'youtube.com' => 'youtube', ); /** * * @param array $social_links_icons Array of social links icons. */ return apply_filters( 'blogger_light_social_links_icons', $social_links_icons ); } } if ( !function_exists('blogger_light_move_comment_field_to_bottom') ) { function blogger_light_move_comment_field_to_bottom( $fields ) { $comment_field = $fields['comment']; unset( $fields['comment'] ); $fields['comment'] = ''; return $fields; } } /** * Returns featured image with fallback to first image and then to default image * @param string ID, string size, string type * @return html string */ if ( !function_exists('blogger_light_feat_image') ) { function blogger_light_feat_image( $id, $size, $type ) { if ( (function_exists('has_post_thumbnail')) && ( has_post_thumbnail()) ) { if ( $type == 'img' ) { $img = get_the_post_thumbnail( $id, $size ); } else { $img = get_the_post_thumbnail_url( $id, $size ); } } else { preg_match('~
';
}
if ( !isset( $img ) && $type != 'img' ) {
$img = get_template_directory_uri().'/img/default.jpg';
}
return $img;
}
}
/**
* Add metabox to the posts and pages
*/
if ( !function_exists( 'blogger_light_add_post_meta' ) ) {
function blogger_light_add_post_meta() {
add_meta_box( 'blogger_light_post_layout', 'Header Image', 'blogger_light_post_layout', array('post', 'page'), 'side', 'low' );
}
}
add_action( 'add_meta_boxes', 'blogger_light_add_post_meta' );
if ( !function_exists( 'blogger_light_post_layout' ) ) {
function blogger_light_post_layout( $post ) {
// Add an nonce field so we can check for it later.
wp_nonce_field( 'post_layout', 'layout-nonce' );
/*
* Use get_post_meta() to retrieve an existing value
* from the database and use the value for the form.
*/
$post_header = get_post_meta( $post->ID, 'post-header', true );
$post_header_img_id = get_post_meta( $post->ID, 'post-header-img-id', true );
$post_header = ( $post_header == '' ) ? 'featured-image' : $post_header;
$display_custom = ( $post_header == 'custom-image' ) ? 'block' : 'none';
?>
name="post-header"/>
name="post-header"/>
name="post-header"/>