示例#1
0
 private function _displayAuthor($args, $instance)
 {
     global $authordata;
     extract($args);
     // extract arguments
     if ((is_single() || is_page()) && $authordata->ID) {
         if ($instance['seq'] == 1) {
             echo $before_widget;
             echo $before_title . $instance['title'] . $after_title;
         }
         echo '<div id="author-spotlight">';
         echo '<div id="author-profile">';
         //Display author name
         echo '<h2>' . get_the_author_firstname() . ' ' . get_the_author_lastname() . '</h2>';
         //Display the social icons
         $socialDiv = "";
         $iconCount = 0;
         $style = "height:12px";
         foreach ($this->_getIconsAsArray() as $key => $data) {
             $print_img = false;
             $social_url = get_the_author_meta($key, $authordata->ID);
             //The Website or Homepahge URL should be read from Author-Data
             if ($data['img_title'] == 'Homepage' && $authordata->user_url) {
                 $socialDiv .= '<a href="' . $authordata->user_url . '" target="_blank" title="' . $data['img_title'] . '">';
                 $print_img = true;
             } else {
                 if ($social_url != "") {
                     $socialDiv .= '<a href="' . $social_url . '" target="_blank" title="' . $data['img_title'] . '">';
                     $print_img = true;
                 }
             }
             //If the URL is available & the Icon is enabled from Widget Admin, display it
             if ($print_img && $instance[$key]) {
                 $socialDiv .= '<img src="' . $data['img_src'] . '" title="' . $data['img_title'] . '" alt="' . $data['img_title'] . '" /></a>';
                 ++$iconCount;
             }
         }
         if ($iconCount <= 0) {
             $style = "display:none;";
         } else {
             if ($iconCount / 2 >= 6) {
                 $style = "height: 36px";
             }
         }
         printf('<div id="social-icons" style="%s">', $style);
         echo $socialDiv;
         echo "</div><!--#social-icons-->";
         //Display User photo OR the Gravatar
         if (function_exists('userphoto_exists') && userphoto_exists($authordata)) {
             userphoto_thumbnail($authordata);
         } else {
             echo get_avatar($authordata->ID, 96);
         }
         //Display author profile, with link to full profile
         $author_posts_link = get_author_posts_url($authordata->ID, $authordata->user_nicename);
         echo '<div id="author-description">';
         echo $this->_getSnippet(get_the_author_description(), $instance['charlimit'], '...') . '&nbsp;<i><a href="' . $author_posts_link . '" title="Read full Profile">' . $instance['readfulltext'] . '</a></i>';
         echo "</div><!--#author-description-->";
         echo '<div id="author-link"><a href="' . $author_posts_link . '" title="More articles by this author">' . $instance['moretext'] . '</a></div>';
         echo "</div><!--#author-profile-->";
         echo "</div><!--#author-spotlight-->";
         if ($instance['isLast']) {
             echo $after_widget;
         }
     }
 }
/**
 * Shortcode function for displaying the current post author last name
 * Uses the get_the_author_lastname() function
 * @link http://codex.wordpress.org/Template_Tags/the_author_lastname
 *
 * @since 0.1
 */
function shortcode_the_author_lastname()
{
    return get_the_author_lastname();
}
示例#3
0
<?php

get_header();
echo '<div class="wrapper single-post" id="content">';
echo '<div class="fluid">';
echo '<div class="grid9">';
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $title = get_the_title();
        $tags = get_the_tags();
        $date = get_the_date();
        $author = get_the_author_firstname() . ' ' . get_the_author_lastname();
        if (has_post_thumbnail()) {
            $feat_image = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            echo '<img src="' . $feat_image . '" alt="' . $title . '" class="single-post-featured"/>';
        }
        if ($tags) {
            echo '<div class="tags">';
            foreach ($tags as $tag) {
                echo '<a href="/tag/' . $tag->slug . '">' . $tag->name . '</a> / ';
            }
            echo '</div>';
        }
        echo '<h1>' . $title . '</h1>';
        echo '<div class="date">Author: <b>' . $author . '</b> / Date: ' . $date . '</div>';
        the_content();
    }
}
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
示例#4
0
/**
 * Display the last name of the author of the current post.
 *
 * @link http://codex.wordpress.org/Template_Tags/the_author_lastname
 * @since 0.71
 * @uses get_the_author_lastname()
 */
function the_author_lastname()
{
    echo get_the_author_lastname();
}
示例#5
0
function bab_manual()
{
    if (is_single()) {
        $bab_showauttxt = get_option('bab_showauttxt');
        $bab_auttxt1 = get_option('bab_auttxt1');
        $bab_auttxt2 = get_option('bab_auttxt2');
        $bab_showautbio = get_option('bab_showautbio');
        $bab_showautintro = get_option('bab_showautintro');
        $bab_showautgra = get_option('bab_showautgra');
        $author = array();
        $author['name'] = get_the_author();
        $author['twitter'] = get_the_author_meta('twitter');
        $author['facebook'] = get_the_author_meta('facebook');
        $author['gplus'] = get_the_author_meta('gplus');
        $author['posts'] = (int) get_the_author_posts();
        $email = get_the_author_meta('email');
        ob_start();
        ?>
			<div id="better-author-bio-div" style="background:#F7F7F7; margin:20px 0px 0px 0px; padding:10px 0; border:1px solid #E6E6E6; overflow:hidden; width:100%;" >
				<div class="better-author-bio-div-info">
				        <?php 
        if ($bab_showautgra == 'y') {
            ?>
					<?php 
            echo bab_gravatar($email);
            ?>
					<?php 
        }
        ?>
					<h4 style"margin:0 0 4px 90px; padding:0;" ><?php 
        printf(esc_attr__('%s %s'), $bab_showautintro, get_the_author());
        ?>
</h4>
					
					<?php 
        if ($bab_showauttxt == 'y') {
            ?>
					<p style="margin:0 0 0 90px; padding:0;" class="better-author-bio-div-text"><?php 
            echo esc_attr(sprintf(__ngettext('%s %s %d %s', '%s %s %d %s', $author['posts'], $bab_auttxt1, $bab_auttxt2, 'better-author-bio-div'), get_the_author_firstname() . ' ' . get_the_author_lastname(), $bab_auttxt1, $author['posts'], $bab_auttxt2));
            ?>
.</p>
					<?php 
        } else {
            echo "<br />";
        }
        ?>
					<?php 
        if ($bab_showautbio == 'y') {
            ?>
					<p style="margin:0 0 0 90px; padding:0;" class="better-author-bio-div-meta"><?php 
            echo get_the_author_meta('description');
            ?>
</p>
					<?php 
        } else {
            echo "<br />";
        }
        ?>
					<ul style="overflow:hidden; margin:0 0 0 90px; padding:0;" >
						<li style="list-style-type:none; float:left; margin:8px 6px 0 0; padding:0 0 0 6px; line-height:120%; border-left:1px solid #ccc;" class="first" ><a href="<?php 
        echo get_author_posts_url(get_the_author_meta('ID'));
        ?>
">
									<?php 
        printf(__('View all posts by %s <span class="meta-nav">&rarr;</span>'), get_the_author());
        ?>
								</a></li>
						<li style="list-style-type:none; float:left; margin:8px 6px 0 0; padding:0 0 0 6px; line-height:120%; border-left:1px solid #ccc;" class="first" ><a href="<?php 
        echo get_the_author_meta('url');
        ?>
" title="<?php 
        echo esc_attr(sprintf(__('Read %s&#8217;s blog', 'better-author-bio-div'), $author['name']));
        ?>
"><?php 
        echo __("Blog");
        ?>
</a></li>
						<?php 
        if (!empty($author['twitter'])) {
            ?>
						<li style="list-style-type:none; float:left; margin:8px 6px 0 0; padding:0 0 0 6px; line-height:120%; border-left:1px solid #ccc;" class="first" ><a href="<?php 
            echo $author['twitter'];
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Follow %s on Twitter', 'better-author-bio-div'), $author['name']));
            ?>
" rel="external">Twitter</a></li>
						<?php 
        }
        ?>
						<?php 
        if (!empty($author['facebook'])) {
            ?>
						<li style="list-style-type:none; float:left; margin:8px 6px 0 0; padding:0 0 0 6px; line-height:120%; border-left:1px solid #ccc;" class="first" ><a href="<?php 
            echo $author['facebook'];
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Be %s&#8217;s friend on Facebook', 'better-author-bio-div'), $author['name']));
            ?>
" rel="external">Facebook</a></li><?php 
        }
        ?>
                        <?php 
        if (!empty($author['gplus'])) {
            ?>
<li style="list-style-type:none; float:left; margin:8px 6px 0 0; padding:0 0 0 6px; line-height:120%; border-left:1px solid #ccc;" class="first" ><a href="<?php 
            echo $author['gplus'];
            ?>
" rel="me" title="<?php 
            echo esc_attr(sprintf(__('Add %s in your circle', 'better-author-bio-div'), $author['name']));
            ?>
" rel="external">Google+</a></li>
						<?php 
        }
        ?>
                          <?php 
        if (!empty($author['lknin'])) {
            ?>
<li><a href="<?php 
            echo $author['lnkin'];
            ?>
"  title="<?php 
            echo esc_attr(sprintf(__('Connect with %s', 'better-author-bio-div'), $author['name']));
            ?>
" rel="external">LinkedIn</a></li>
						<?php 
        }
        ?>
					</ul>
				</div>
			</div>
<?php 
    }
    $bab_bio = ob_get_clean();
    echo $bab_bio;
}