コード例 #1
0
ファイル: post.php プロジェクト: hungtran0203/he-ib
    return $post ? get_permalink() : '';
}, 'post');
//////////////////// post_link ///////////////////////////
//////////////////// post_category_list ///////////////////////////
/* 
	return post category list 
*/
HEIBShortcode::add_shortcode('post_category_list', function ($attr) {
    $atts = HEIBShortcode::get_atts($attr);
    $post = heib_get_post();
    $content = '';
    if ($post) {
        $content = __(get_the_category_list($atts['separator'], $atts['parents']));
    }
    return $content ? $content : $atts['empty'];
}, 'post', array('separator' => null, 'parents' => '', 'empty' => __('N/A')));
//////////////////// post_category_list ///////////////////////////
//////////////////// post_tag_list ///////////////////////////
/* 
	return post tag list 
*/
HEIBShortcode::add_shortcode('post_tag_list', function ($attr) {
    $atts = HEIBShortcode::get_atts($attr);
    $post = heib_get_post();
    $content = '';
    if ($post) {
        $content = __(get_the_tag_list($atts['separator'], $atts['parents']));
    }
    return $content ? $content : $atts['empty'];
}, 'post', array('separator' => null, 'parents' => '', 'empty' => __('N/A')));
//////////////////// post_tag_list ///////////////////////////
コード例 #2
0
ファイル: user.php プロジェクト: hungtran0203/he-ib
        $displayName = heib_truncate($displayName, $atts['length'], array('ending' => $atts['ending']));
    }
    return '<a href="' . get_author_posts_url($user->ID) . '">' . $displayName . '</a>';
}, 'user', array('length' => null, 'ending' => ' ...'));
//////////////////// user_link ///////////////////////////
//////////////////// user_url ///////////////////////////
/* 
	return user display link
*/
HEIBShortcode::add_shortcode('user_url', function ($attr) {
    $user = heib_get_user();
    return get_author_posts_url($user->ID);
}, 'user');
//////////////////// user_url ///////////////////////////
//////////////////// user_recent_posts ///////////////////////////
/* 
	return user recent posts
*/
HEIBShortcode::add_shortcode('user_recent_posts', function ($attr) {
    //setup default atts
    $atts = HEIBShortcode::get_atts($attr);
    $user = heib_get_user();
    $authors_posts = get_posts(array('author' => $user->ID, 'posts_per_page' => $atts['count']));
    $output = '<ul>';
    foreach ($authors_posts as $authors_post) {
        $output .= '<li><a href="' . get_permalink($authors_post->ID) . '">' . apply_filters('the_title', $authors_post->post_title, $authors_post->ID) . '</a></li>';
    }
    $output .= '</ul>';
    return $output;
}, 'user', array('count' => 3));
//////////////////// user_recent_posts ///////////////////////////