| 25 | | {{{#!php |
| 26 | | <?php |
| 27 | | |
| 28 | | if ( !defined( 'ABSPATH' ) ) exit; |
| 29 | | |
| 30 | | add_action( 'bp_setup_nav', 'vibe_bp_hide_tabs', 15 ); |
| 31 | | function vibe_bp_hide_tabs(){ |
| 32 | | |
| 33 | | $flag=1; |
| 34 | | $hide=vibe_get_option('activity_tab'); |
| 35 | | if(isset($hide)){ |
| 36 | | $flag=0; |
| 37 | | switch($hide){ |
| 38 | | case 1: |
| 39 | | if(is_user_logged_in()) $flag=1; |
| 40 | | break; |
| 41 | | case 2: |
| 42 | | if(current_user_can('edit_posts')) $flag=1; |
| 43 | | break; |
| 44 | | case 3: |
| 45 | | if(current_user_can('manage_options')) $flag=1; |
| 46 | | break; |
| 47 | | case 0: $flag=1; |
| 48 | | break; |
| 49 | | } |
| 50 | | } |
| 51 | | if(!$flag && bp_is_active( 'activity' ) && !bp_is_my_profile()){ |
| 52 | | bp_core_remove_nav_item('activity'); |
| 53 | | } |
| 54 | | |
| 55 | | $flag=1; |
| 56 | | $hide=vibe_get_option('groups_tab'); |
| 57 | | if(isset($hide)){ |
| 58 | | $flag=0; |
| 59 | | switch($hide){ |
| 60 | | case 1: |
| 61 | | if(is_user_logged_in()) $flag=1; |
| 62 | | break; |
| 63 | | case 2: |
| 64 | | if(current_user_can('edit_posts')) $flag=1; |
| 65 | | break; |
| 66 | | case 3: |
| 67 | | if(current_user_can('manage_options')) $flag=1; |
| 68 | | break; |
| 69 | | case 0: $flag=1; |
| 70 | | break; |
| 71 | | } |
| 72 | | } |
| 73 | | if(!$flag && bp_is_active( 'groups' ) && !bp_is_my_profile()){ |
| 74 | | bp_core_remove_nav_item('groups'); |
| 75 | | } |
| 76 | | |
| 77 | | $flag=1; |
| 78 | | $hide=vibe_get_option('forums_tab'); |
| 79 | | if(isset($hide)){ |
| 80 | | $flag=0; |
| 81 | | switch($hide){ |
| 82 | | case 1: |
| 83 | | if(is_user_logged_in()) $flag=1; |
| 84 | | break; |
| 85 | | case 2: |
| 86 | | if(current_user_can('edit_posts')) $flag=1; |
| 87 | | break; |
| 88 | | case 3: |
| 89 | | if(current_user_can('manage_options')) $flag=1; |
| 90 | | break; |
| 91 | | case 0: $flag=1; |
| 92 | | break; |
| 93 | | } |
| 94 | | } |
| 95 | | if(!$flag && !bp_is_my_profile()){ |
| 96 | | bp_core_remove_nav_item('forums'); |
| 97 | | } |
| 98 | | } |
| 99 | | |
| 100 | | add_action('bp_before_profile_content','wplms_show_instructor_courses',11); |
| 101 | | function wplms_show_instructor_courses(){ |
| 102 | | global $bp; |
| 103 | | $user_id=bp_displayed_user_id(); |
| 104 | | if(function_exists('bp_current_action') && bp_current_action() !== 'public') |
| 105 | | return; |
| 106 | | |
| 107 | | if(!user_can($user_id,'edit_posts')){ |
| 108 | | return; |
| 109 | | } |
| 110 | | |
| 111 | | $block_style = vibe_get_option('default_course_block_style'); |
| 112 | | $n = vibe_get_option('loop_number'); |
| 113 | | if($n<4){$n=4;} |
| 114 | | if ( function_exists('get_coauthors')) { |
| 115 | | $user = get_user_by('ID',$user_id); |
| 116 | | $args = array( |
| 117 | | 'post_type' => 'course', |
| 118 | | 'posts_per_page' => $n, |
| 119 | | 'post_status' => 'publish', |
| 120 | | 'author_name' => $user->user_nicename, |
| 121 | | ); |
| 122 | | }else{ |
| 123 | | $args = array( |
| 124 | | 'post_type'=>'course', |
| 125 | | 'post_status'=>'publish', |
| 126 | | 'posts_per_page' => $n, |
| 127 | | 'author'=> $user_id, |
| 128 | | ); |
| 129 | | } |
| 130 | | |
| 131 | | $args = apply_filters('wplms_show_instructor_courses',$args); |
| 132 | | |
| 133 | | $query = new WP_Query($args); |
| 134 | | if($query->have_posts()){ |
| 135 | | |
| 136 | | $instructing_courses=apply_filters('wplms_instructing_courses_endpoint','instructing-courses'); |
| 137 | | |
| 138 | | echo '<div class="instructor_courses"> |
| 139 | | <h3 class="heading"><span>'._x('Courses by Instructor','courses by instructor title in profile','vibe').'</span><a href="'.get_author_posts_url($user_id).$instructing_courses.'/" class="tip" title="'.sprintf(_x('Check all Courses created by %s','link help text in instructor profile','vibe'),bp_core_get_user_displayname($user_id)).'"><i class="icon-plus-1"></i></a></h3> |
| 140 | | </div>'; |
| 141 | | |
| 142 | | |
| 143 | | echo '<div class="vibe_carousel flexslider" data-controlnav="1" data-block-width="240" data-block-max="4" data-block-min="1"><ul class="slides">'; |
| 144 | | $block_style = vibe_get_option('default_course_block_style'); |
| 145 | | if(empty($block_style)){$block_style = 'course';} |
| 146 | | while($query->have_posts()){ |
| 147 | | $query->the_post(); |
| 148 | | global $post; |
| 149 | | echo '<li>'; |
| 150 | | echo thumbnail_generator($post,$block_style,4,0); |
| 151 | | echo '</li>'; |
| 152 | | } |
| 153 | | wp_reset_postdata(); |
| 154 | | echo '</ul></div><br><hr>'; |
| 155 | | } |
| 156 | | |
| 157 | | } |
| 158 | | add_action('bp_before_profile_content','wplms_show_profile_snapshot'); |
| 159 | | |
| 160 | | function wplms_show_profile_snapshot(){ |
| 161 | | global $bp; |
| 162 | | |
| 163 | | $user_id=bp_displayed_user_id(); |
| 164 | | |
| 165 | | if(function_exists('bp_current_action') && bp_current_action() !== 'public') |
| 166 | | return; |
| 167 | | |
| 168 | | if(function_exists('bp_course_get_user_badges')){ |
| 169 | | $bids=bp_course_get_user_badges($user_id); |
| 170 | | }else{ |
| 171 | | $bids=vibe_sanitize(get_user_meta($user_id,'badges',false)); |
| 172 | | } |
| 173 | | |
| 174 | | if(isset($bids) && is_Array($bids) && count($bids)){ |
| 175 | | $badges_html = array(); |
| 176 | | |
| 177 | | foreach($bids as $bid){ |
| 178 | | $b=''; |
| 179 | | if(function_exists('bp_get_course_badge')){ |
| 180 | | $b=bp_get_course_badge($bid); |
| 181 | | if(!empty($b)){ |
| 182 | | if(is_numeric($b)){ |
| 183 | | if(function_exists('bp_course_get_badge')){ |
| 184 | | $badges_html[]= bp_course_get_badge($b,$bid); |
| 185 | | }else{ |
| 186 | | $badge=wp_get_attachment_info($b); |
| 187 | | $badge_url=wp_get_attachment_image_src($b,'full'); |
| 188 | | $badges_html[]='<a class="tip ajax-badge" data-course="'.get_the_title($bid).'" title="'.get_post_meta($bid,'vibe_course_badge_title',true).'"><img src="'.$badge_url[0].'" title="'.$badge['title'].'"/></a>'; |
| 189 | | } |
| 190 | | } |
| 191 | | } |
| 192 | | } |
| 193 | | } |
| 194 | | |
| 195 | | if(!empty($badges_html)){ |
| 196 | | echo '<div class="badges"><h6>'.__('Badges','vibe').'</h6>'; |
| 197 | | echo '<ul>'; |
| 198 | | foreach($badges_html as $b_html){ |
| 199 | | echo '<li>'; |
| 200 | | echo vibe_sanitizer($b_html); |
| 201 | | echo '</li>'; |
| 202 | | } |
| 203 | | echo '</ul>'; |
| 204 | | echo '</div>'; |
| 205 | | } |
| 206 | | } |
| 207 | | |
| 208 | | |
| 209 | | $certis=vibe_sanitize(get_user_meta($user_id,'certificates',false)); |
| 210 | | |
| 211 | | if(isset($certis) && is_Array($certis) && count($certis)){ |
| 212 | | echo '<div class="certifications"><h6>'.__('Certifications','vibe').'</h6><ul class="slides">'; |
| 213 | | if(isset($certis) && is_Array($certis)) |
| 214 | | foreach($certis as $certi){ |
| 215 | | if(function_exists('bp_get_course_certificate')){ |
| 216 | | |
| 217 | | if(!empty($certi) && get_post_type($certi) == 'course'){ |
| 218 | | |
| 219 | | $url = bp_get_course_certificate('user_id='.$user_id.'&course_id='.$certi); |
| 220 | | $class = ''; |
| 221 | | $class = apply_filters('bp_course_certificate_class','',array('course_id'=>$certi,'user_id'=>$user_id)); |
| 222 | | if(isset($_GET['regenerate_certificate']) || (strpos($url, 'jpeg') === false) ) { |
| 223 | | $class .=' regenerate_certificate'; |
| 224 | | } |
| 225 | | |
| 226 | | echo '<li><a href="'.$url.'" class="ajax-certificate '.$class.'" data-user="'.$user_id.'" data-course="'.$certi.'" data-security="'.wp_create_nonce($user_id).'"><i class="icon-certificate-file"></i><span>'.get_the_title($certi).'</span></a></li>'; |
| 227 | | } |
| 228 | | } |
| 229 | | } |
| 230 | | echo '</ul></div>'; |
| 231 | | } |
| 232 | | |
| 233 | | } |
| 234 | | |
| 235 | | add_action('bp_group_options_nav','vibe_course_group_link',1,1); |
| 236 | | |
| 237 | | function vibe_course_group_link(){ |
| 238 | | global $bp,$wpdb; |
| 239 | | $course_query= $wpdb->get_results( $wpdb->prepare("SELECT post_id from {$wpdb->postmeta} WHERE meta_key='vibe_group' AND meta_value='%d'",$bp->groups->current_group->id)); |
| 240 | | if(is_array($course_query) && isset($course_query[0]->post_id)) |
| 241 | | echo '<li id="course-li"><a id="admin" href="'.get_permalink($course_query[0]->post_id).'" title="'.get_the_title($course_query[0]->post_id).'">'.__('Course ','vibe').'</a></li>'; |
| 242 | | } |
| 243 | | |
| 244 | | function bp_dtheme_setup() { |
| 245 | | if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
| 246 | | // Group buttons |
| 247 | | if ( bp_is_active( 'groups' ) ) { |
| 248 | | $groups_check = vibe_get_option('enable_groups_join_button'); |
| 249 | | |
| 250 | | if(isset($groups_check) && $groups_check) |
| 251 | | add_action( 'bp_directory_groups_actions', 'bp_group_join_button' ); |
| 252 | | } |
| 253 | | |
| 254 | | } |
| 255 | | } |
| 256 | | |
| 257 | | add_action( 'after_setup_theme', 'bp_dtheme_setup' ); |
| 258 | | |
| 259 | | |
| 260 | | /* === Course Specific ===== */ |
| 261 | | |
| 262 | | class WPLMS_BP_Cover_Image{ |
| 263 | | |
| 264 | | function __construct(){ |
| 265 | | add_action( 'bp_after_setup_theme',array($this,'cover_image')); |
| 266 | | add_action('wp_enqueue_scripts',array($this,'display_cover_image')); |
| 267 | | } |
| 268 | | |
| 269 | | function cover_image() { |
| 270 | | if(function_exists('bp_set_theme_compat_feature')){ |
| 271 | | bp_set_theme_compat_feature( 'legacy', array( |
| 272 | | 'name' => 'cover_image', |
| 273 | | 'settings' => array( |
| 274 | | 'components' => array( 'xprofile','groups' ), |
| 275 | | 'width' => 1300, |
| 276 | | 'height' => 500, |
| 277 | | 'callback' => array($this,'record_cover_image'), // See line 845 |
| 278 | | 'theme_handle' => 'bp-default-main', |
| 279 | | ), |
| 280 | | ) ); |
| 281 | | } |
| 282 | | } |
| 283 | | function record_cover_image( $params = array() ) { |
| 284 | | if ( empty( $params ) ) { |
| 285 | | return; |
| 286 | | } |
| 287 | | |
| 288 | | // avatar height - padding - 1/2 avatar height |
| 289 | | $avatar_offset = $params['height'] - 5 - round( (int) bp_core_avatar_full_height() / 2 ); |
| 290 | | |
| 291 | | // header content offset + spacing |
| 292 | | $top_offset = bp_core_avatar_full_height() - 10; |
| 293 | | $left_offset = bp_core_avatar_full_width() + 20; |
| 294 | | |
| 295 | | $this->cover_image = $params['cover_image']; |
| 296 | | } |
| 297 | | |
| 298 | | function display_cover_image(){ |
| 299 | | global $bp; |
| 300 | | |
| 301 | | if(bp_is_user() || bp_is_group()){ |
| 302 | | if(!empty($this->cover_image)){ |
| 303 | | echo '<style> |
| 304 | | #item-header{background:url("'.$this->cover_image.'") !important;} |
| 305 | | #buddypress div#item-header.light div#item-header-content, |
| 306 | | #buddypress div#item-header.light #latest-update h6, |
| 307 | | #buddypress div#item-header.light div#item-header-content a, |
| 308 | | #buddypress div#item-header.light div#item-header-content h3 a |
| 309 | | { |
| 310 | | color:#FFF !important; |
| 311 | | } |
| 312 | | #buddypress div#item-header.dark div#item-header-content, |
| 313 | | #buddypress div#item-header.dark #latest-update h6, |
| 314 | | #buddypress div#item-header.dark div#item-header-content a, |
| 315 | | #buddypress div#item-header.dark div#item-header-content h3 a |
| 316 | | { |
| 317 | | color:#222 !important; |
| 318 | | } |
| 319 | | </style>'; |
| 320 | | } |
| 321 | | } |
| 322 | | } |
| 323 | | } |
| 324 | | |
| 325 | | new WPLMS_BP_Cover_Image; |
| 326 | | }}} |
| | 25 | see attached bp-custom.php |