Example #1
0
function author_meta_info($auth_id)
{
    $img_url = get_author_avatar_url($auth_id);
    $short_desc = author_excerpt($auth_id);
    return array('img_url' => $img_url, 'short_desc' => $short_desc);
}
function get_post_bg($bg, $size)
{
    KC::debug('----');
    KC::debug($bg);
    KC::debug($size);
    KC::debug(get_attachment_image_url(false, $size));
    switch ($bg) {
        // get featured image from page/post
        case '':
            $bg = get_attachment_image_url(false, $size);
            break;
        case 'featured':
            $bg = get_attachment_image_url(false, $size);
            if (!$bg) {
                $bg = KC::$default_header_image;
            }
            break;
            // display featured image from blog's 1st post.
        // display featured image from blog's 1st post.
        case 'post1':
            $args = array('numberposts' => '1', 'order' => 'DESC', 'post_status' => 'publish');
            $recent_posts = wp_get_recent_posts($args);
            $recent_post = $recent_posts[0];
            $post_id = $recent_post["ID"];
            $thumb_id = get_post_thumbnail_id($post_id);
            $bg = get_attachment_image_url($thumb_id, $size);
            if (!$bg) {
                $bg = KC::$default_header_image;
            }
            break;
            // display the author's bio image
        // display the author's bio image
        case 'author':
            $bg = get_author_avatar_url();
            if (!$bg) {
                $bg = KC::$default_header_image;
            }
            break;
        case 'default':
            $bg = KC::$default_header_image;
            break;
    }
    //if (!$bg) $bg = KC::$default_header_image;
    return $bg;
}
/**
 * 
 * @param type $author
 * @param type $bio - 'short' = short bio
 * @param type $avatar - 0 = no avatar
 * @return string Content with shortcodes filtered out
 */
function get_author_markup($author, $bio = 'true', $avatar = '', $linkType = '')
{
    //KC::debug("!!");
    //KC::debug(esc_attr(get_option('kc_default_image')));
    //global $post;
    $author_slug = KC::$author_slug;
    $code = '';
    $author_id = $author->ID;
    $display_name = $author->display_name;
    $display_name_slug = getSlug($display_name);
    //$author_link       = get_permalink(get_page_by_path('about-us')->ID) . '#' . $display_name_slug;
    $author_link = site_url(KC::$author_slug . '/#' . $display_name_slug);
    $job = esc_attr($author->job_title);
    // (get_the_author_meta('job-title', $author_id));
    //$twitter = $author->twitter; // get_user_meta($author->ID, 'twitter', true);
    //$facebook = $author->facebook;
    //do_shortcode("[button link='$posts_url'] $posts_link_text [/button]"); //("[button link='$posts_url']$posts_link_text[/button]");
    //admin_label = "Person" facebook_url = ""
    if ($avatar == "0") {
        $avatar = '';
    } elseif (!$avatar) {
        $avatar = get_author_avatar_url($author_id);
    }
    $bioContent = '';
    if ($bio) {
        if ($bio === "short") {
            $bioContent = wpautop($author->wp_biographia_short_bio);
        } elseif ($bio === "true") {
            $bioContent = wpautop($author->description ? $author->description : $author->wp_biographia_short_bio);
        } else {
            $bioContent = $bio;
        }
    }
    $posts_url = get_author_posts_url($author_id);
    $readPostsContent = count_user_posts($author_id) == 0 ? '' : '' . '<div class="read-author-posts">' . '<a href="' . $posts_url . '" class="et_pb_more_button et_pb_button et_pb_button_one">' . 'Read posts' . '</a>' . '</div>';
    $code .= <<<EOT
        <article class="et_pb_post status-publish format-standard hentry et_pb_module et_pb_toggle  et_pb_toggle_2 et_pb_toggle_item et_pb_toggle_open">
            
            [et_pb_team_member name = "{$display_name}" position = "{$job}" image_url = "{$avatar}" animation 
            module_id="{$display_name_slug}" module_class="author" background_layout = "light" use_border_color = "off" border_color = "" border_style]

                [et_pb_toggle admin_label="Toggle" title="" open="off" use_border_color="off"]

                    <div class="bio_content">
                    {$bioContent}
                    </div>
                    {$readPostsContent}
            
                [/et_pb_toggle] 
            
            [/et_pb_team_member]
            
            <script>
            jQuery( document ).ready(function( \$ ) {
                \$("#{$display_name_slug} h4").wrap("<a href=\\"{$author_link}\\"></a>");
            });
            </script>

        </article>
EOT;
    return do_shortcode($code);
}