Beispiel #1
0
    function edutheme_lecturer_bio($user_id)
    {
        $author_posts_url = educator_theme_lecturer_link($user_id);
        $output = '<section class="author-bio lecturer-bio clearfix">';
        $output .= '<h1>' . __('Lecturer', 'ib-educator') . '</h1>';
        // Photo.
        $photo = educator_get_user_profile_photo($user_id);
        if ($photo) {
            $output .= '<div class="photo"><a href="' . esc_url($author_posts_url) . '">' . $photo . '</a></div>';
        }
        $output .= '<div class="summary">';
        ob_start();
        ?>
	<h2><?php 
        the_author();
        ?>
</h2>
	<?php 
        the_author_meta('description');
        $output .= ob_get_clean();
        $output .= '<div class="author-links"><a href="' . esc_url($author_posts_url) . '">' . __('View Profile', 'ib-educator') . ' <span class="fa fa-angle-double-right"></span></a></div>';
        $output .= '</div>';
        $output .= '</section>';
        return $output;
    }
 /**
  * Shortcode: educator_lecturers.
  *
  * @param array $atts
  * @param string $content
  * @return string
  */
 function educator_lecturers_shortcode($atts, $content = null)
 {
     $atts = shortcode_atts(array('ids' => '', 'layout' => 'carousel'), $atts);
     $params = array('role' => 'lecturer', 'orderby' => 'include');
     if ($atts['ids']) {
         $ids = explode(' ', $atts['ids']);
         $params['include'] = array();
         foreach ($ids as $id) {
             $params['include'][] = intval($id);
         }
     }
     $user_query = new WP_User_Query($params);
     $output = '';
     if (!empty($user_query->results)) {
         if (!empty($params['include'])) {
             $users = array();
             foreach ($user_query->results as $user) {
                 $order = array_search($user->ID, $params['include']);
                 $users[$order] = $user;
             }
             ksort($users);
         } else {
             $users = $user_query->results;
         }
         $pretty_permalinks = get_option('permalink_structure');
         if ('carousel' == $atts['layout']) {
             $output .= '<div class="lecturers-carousel owl-carousel">';
             foreach ($users as $user) {
                 $output .= '<div>';
                 $user_photo = educator_get_user_profile_photo($user->ID);
                 $author_posts_url = function_exists('educator_theme_lecturer_link') ? educator_theme_lecturer_link($user->ID) : get_author_posts_url($user->ID);
                 if ($user_photo) {
                     $output .= '<div class="author-photo"><a href="' . esc_url($author_posts_url) . '">' . $user_photo . '</a></div>';
                 }
                 $output .= '<h3>' . esc_html($user->display_name) . '</h3>';
                 $output .= '<div class="author-description">' . esc_html(get_user_meta($user->ID, '_educator_short_bio', true)) . '</div>';
                 $output .= '<div class="author-links"><a href="' . esc_url($author_posts_url) . '">' . __('View Profile', 'ib-educator-theme') . ' <span class="fa fa-angle-double-right"></span></a></div>';
                 $output .= '</div>';
             }
             $output .= '</div>';
         } else {
             $output .= '<div class="lecturers-grid clearfix">';
             $i = 0;
             $num_users = count($users);
             $is_even = $num_users % 2 == 0;
             foreach ($users as $user) {
                 $class = $i % 2 ? 'column-2' : 'column-1';
                 if ($i < 2) {
                     $class .= ' first-row';
                 }
                 if ($is_even && $i > $num_users - 3 || !$is_even && $i > $num_users - 2) {
                     $class .= ' last-row';
                 }
                 $output .= '<div class="lecturer ' . $class . '">';
                 $user_photo = educator_get_user_profile_photo($user->ID);
                 $author_posts_url = function_exists('educator_theme_lecturer_link') ? educator_theme_lecturer_link($user->ID) : get_author_posts_url($user->ID);
                 if ($user_photo) {
                     $output .= '<div class="author-photo"><a href="' . esc_url($author_posts_url) . '">' . $user_photo . '</a></div>';
                 }
                 $output .= '<div class="summary"><h3>' . esc_html($user->display_name) . '</h3>';
                 $output .= '<div class="author-description">' . esc_html(get_user_meta($user->ID, '_educator_short_bio', true)) . '</div>';
                 $output .= '<div class="author-links"><a href="' . esc_url($author_posts_url) . '">' . __('View Profile', 'ib-educator-theme') . ' <span class="fa fa-angle-double-right"></span></a></div>';
                 $output .= '</div></div>';
                 ++$i;
             }
             $output .= '</div>';
         }
     }
     return $output;
 }