Created
July 9, 2018 16:57
-
-
Save MrVibe/2992ca7297e992535f986d6243de0deb to your computer and use it in GitHub Desktop.
Custom Featured block example : http://prntscr.com/k4e4z9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('vibe_builder_thumb_styles',function($thumb_array){ | |
$thumb_array['custom_block']= 'https://i1.wp.com/i.imgur.com/gxrPvvJ.jpg?zoom=2&w=920'; | |
return $thumb_array; | |
}); | |
add_filter('vibe_featured_thumbnail_style',function($thumbnail_html,$post,$style){ | |
if($style == 'custom_block' && $post->post_type == 'course'){ //Custom block is the same name as added for the thumbnail in pagebuilder | |
$thumbnail_html =''; | |
$thumbnail_html .= '<div class="block customblock">'; | |
$thumbnail_html .= '<div class="block_media">'; | |
$thumbnail_html .= '<a href="'.get_permalink($post->ID).'">'.get_the_post_thumbnail($post->ID,'medium').'</a>'; | |
$thumbnail_html .= '</div>'; | |
$thumbnail_html .= '<div class="block_content">'; | |
$thumbnail_html .= '<h4 class="block_title"><a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'">'.$post->post_title.'</a></h4>'; | |
$thumbnail_html .= '<p class="block_description">'.get_the_excerpt($post->ID).'</p>'; | |
ob_start(); | |
the_course_button($post->ID); | |
$thumbnail_html .= ob_get_clean(); | |
if(is_user_logged_in()){ | |
$user_id = get_current_user_id(); | |
if(bp_course_is_member($post->ID,$user_id)){ | |
$progress = bp_course_get_user_progress($user_id,$post->ID); | |
if(empty($progress)){ | |
$progress = 0; | |
} | |
$thumbnail_html .= do_shortcode('[progressbar percentage="'.$progress.'" bg="#eee" bar_color="42a1f4"]'); | |
}else{ | |
$thumbnail_html .= bp_course_get_course_credits(array('id' => $post->ID)); | |
} | |
}else{ | |
$thumbnail_html .= bp_course_get_course_credits(array('id' => $post->ID)); | |
} | |
$thumbnail_html .= '</div>'; | |
} | |
return $thumbnail_html; | |
},10,3); | |
add_action('wp_footer',function(){ | |
?> | |
<style> | |
.block.customblock { | |
border: 2px solid #333 !important; | |
border-radius:15px; | |
} | |
.block.customblock .block_content { | |
padding: 15px 30px; | |
text-align: center; | |
} | |
.block.customblock .block_content a.button { | |
display: inline-block; | |
text-align: center; | |
font-size: 16px; | |
opacity: 0.6; | |
background: #aaa; | |
} | |
.block.customblock .block_content strong { | |
display: block; | |
} | |
.block.customblock h4.block_title { | |
font-size: 20px; | |
font-weight: 600; | |
margin: 10px 0 15px; | |
} | |
.block.customblock .block_content a.button:before { | |
content: "\f023"; | |
font-family: fontawesome; | |
margin-right: 5px; | |
} | |
.block.customblock .block_content input.button{padding-left:30px;} | |
.block.customblock .block_content form:before{ | |
content: "\f09c"; | |
font-family: fontawesome; | |
margin-right: 5px; | |
position:absolute; | |
z-index:99; | |
margin:18px 10px;color:#fff | |
} | |
</style> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment