Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MrVibe
MrVibe / functions.php
Created February 27, 2024 14:13
Exclude delay in course renewal Drip timer check
class Drip_Expired_Check{
public static $instance;
public $time_to_adjust = 0;
public static function init(){
if ( is_null( self::$instance ) )
self::$instance = new Drip_Expired_Check();
return self::$instance;
}
@MrVibe
MrVibe / functions.php
Created June 13, 2022 05:44
Verify if App page is loaded in correct language.
add_action('template_redirect',function(){
global $post;
if(is_page(vibebp_get_setting('bp_single_page'))){
$wpml_page_id = apply_filters('wplm_object_id',$post_id,'page');
if($post->ID != $wpml_page_id){
$new_url = str_replace(get_permalink($post->ID),get_permalink($wpml_page_id),$_SERVER['REQUEST_URI']);
wp_redirect($new_url);
exit;
}
}
@MrVibe
MrVibe / functions.php
Created June 1, 2022 12:36
create a static widget in boilerplate.
<?php
add_action( 'widgets_init', 'Sample_Widget' );
function Sample_Widget() {
register_widget('Sample_Widget');
}
class Sample_Widget extends WP_Widget {
add_filter('wplms_get_student_mmy_course_tabs',function($tabs){
$tabs['custom'] = 'My Custom Tab';
return $tabs;
});
add_filter('wplms_course_tab_data',function($data,$args,$course_id){
if($args['tab'] == 'custom'){
// Add content to $data
}
@MrVibe
MrVibe / test.php
Last active February 26, 2022 08:26
add_action('wp_footer',function(){
?>
<script>var ajaxurl = '<?php echo admin_url( 'admin-ajax.php' ); ?>'; </script>
<?php
});
@MrVibe
MrVibe / functions.php
Last active February 19, 2022 15:26
Digital Goods API v2 in WPLMS
add_action('wp_head',function(){
if(is_page_template('barebones.php')){
?>
<meta http-equiv="origin-trial" content="DIGITAL GOODS API V2 TOKEN">
<?php
}
});
@MrVibe
MrVibe / functions.php
Created November 25, 2021 04:25
WPLMS My Courses shortcode
add_shortcode('my_courses',function($atts,$content=null){
if(empty($atts['user_id'])){
$user_id = get_current_user_id();
}else{
$user_id = $atts['user_id'];
}
$course_ids = bp_course_get_user_courses($user_id);
@MrVibe
MrVibe / functions.php
Last active October 28, 2021 08:55
Direct checkout WPLMS pluign
add_action('template_redirect',function(){
if( is_single() && get_post_type() == 'product' && isset($_GET['redirect'])){
global $woocommerce;
$found = false;
$product_id = get_the_ID();
$courses = vibe_sanitize(get_post_meta(get_the_ID(),'vibe_courses',false));
if(isset($courses) && is_array($courses) && count($courses)){
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
@MrVibe
MrVibe / functions.php
Created October 9, 2021 07:20
Add start date in Batch list in Courses [ v3 & v4 ]
add_action('wplms_batches_extras',function($batch_id){
$start_batch_date = groups_get_groupmeta($batch_id,'start_batch_date');
if(!empty($start_batch_date)){
echo 'STARTS '.wp_date( get_option( 'date_format' ), $start_batch_date );
}
},10,1);
@MrVibe
MrVibe / functions.php
Created October 4, 2021 07:03
Show quiz stats in single quiz page
add_action('wplms_front_end_quiz_end',function($quiz_id){
?>
<div class="container">
<ul class="data_stats" style="position:relative" data-id="<?php echo $quiz_id; ?>" data-type="quiz">
<li><a id="download_Stats" class="button full">View quiz stats</a></li>
</ul>
<div class="main_content">
</div>