function bp_course_add_js()
{
global $bp;
if (!function_exists('vibe_logo_url')) {
return;
}
// Checks if WPLMS is active in current site in WP Multisite
wp_enqueue_script('bp-extras-js', plugins_url('/vibe-course-module/includes/js/course-module-js.min.js'), array('jquery'), bp_course_version(), true);
if (function_exists('vibe_get_option')) {
if (is_singular('unit') || is_singular('question') || is_singular('quiz') || is_singular('wplms-assignment') || is_page(vibe_get_option('take_course_page')) || is_page(vibe_get_option('create_course')) || isset($_GET['edit'])) {
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-sortable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('knob-js', plugins_url('/vibe-course-module/includes/js/jquery.knob.min.js'));
}
}
if (function_exists('bp_is_directory')) {
if (bp_is_directory() && bp_current_component() == 'course') {
wp_enqueue_script('jquery-ui-datepicker');
}
}
$action = bp_current_action();
if (isset($_GET['action'])) {
$action = $_GET['action'];
}
if (in_array($action, array('admin', 'submissions', 'stats'))) {
wp_enqueue_script('knob-js', plugins_url('/vibe-course-module/includes/js/jquery.knob.min.js'));
}
wp_enqueue_script('bp-course-js', plugins_url('/vibe-course-module/includes/js/course.js'), array('jquery', 'wp-mediaelement', 'buddypress-js'), bp_course_version(), true);
$color = bp_wplms_get_theme_color();
$single_dark_color = bp_wplms_get_theme_single_dark_color();
$translation_array = array('too_fast_answer' => _x('Too Fast or Answer not marked.', 'Quiz answer being marked very fast', 'vibe'), 'answer_saved' => _x('Answer Saved.', 'Save answer on every question, confirmation message', 'vibe'), 'processing' => _x('Processing...', 'Quiz question anwer save under progress', 'vibe'), 'saving_answer' => _x('Saving Answer...please wait', 'Saving quiz answers under progress', 'vibe'), 'remove_user_text' => __('This step is irreversible. Are you sure you want to remove the User from the course ?', 'vibe'), 'remove_user_button' => __('Confirm, Remove User from Course', 'vibe'), 'confirm' => _x('Confirm', 'Confirm button for various popup confirmation messages', 'vibe'), 'cancel' => _x('Cancel', 'Cancel button for various popup confirmation messages', 'vibe'), 'reset_user_text' => __('This step is irreversible. All Units, Quiz results would be reset for this user. Are you sure you want to Reset the Course for this User?', 'vibe'), 'reset_user_button' => __('Confirm, Reset Course for this User', 'vibe'), 'quiz_reset' => __('This step is irreversible. All Questions answers would be reset for this user. Are you sure you want to Reset the Quiz for this User? ', 'vibe'), 'quiz_reset_button' => __('Confirm, Reset Quiz for this User', 'vibe'), 'marks_saved' => __('Marks Saved', 'vibe'), 'quiz_marks_saved' => __('Quiz Marks Saved', 'vibe'), 'submit_quiz' => __('Submit Quiz', 'vibe'), 'sending_messages' => __('Sending Messages ...', 'vibe'), 'adding_students' => __('Adding Students to Course ...', 'vibe'), 'successfuly_added_students' => __('Students successfully added to Course', 'vibe'), 'unable_add_students' => __('Unable to Add students to Course', 'vibe'), 'select_fields' => __('Please select fields to download', 'vibe'), 'download' => __('Download', 'vibe'), 'timeout' => __('TIMEOUT', 'vibe'), 'theme_color' => $color, 'single_dark_color' => $single_dark_color, 'for_course' => __('for Course', 'vibe'), 'active_filters' => __('Active Filters', 'vibe'), 'clear_filters' => __('Clear all filters', 'vibe'), 'remove_comment' => __('Are you sure you want to remove this note?', 'vibe'), 'remove_comment_button' => __('Confirm, remove note', 'vibe'), 'private_comment' => __('Make Private', 'vibe'), 'add_comment' => __('Add your note', 'vibe'), 'submit_quiz_error' => __('Please add questions or retake the quiz !', 'vibe'), 'remove_announcement' => __('Are you sure you want to remove this Annoucement?', 'vibe'), 'start_quiz_notification' => __('You\'re about to start the Quiz. Please click confirm to begin the quiz.', 'vibe'), 'submit_quiz_notification' => __('Are you sure you want to submit the quiz. Submitting the quiz will freeze all your answers, you can not change them. Please confirm.', 'vibe'), 'check_results' => __('Check results', 'vibe'), 'correct' => __('Correct', 'vibe'), 'incorrect' => __('Incorrect', 'vibe'), 'confirm_apply' => _x('Are you sure you want to apply for this Course ?', 'confirmation message when user clicks on apply for course', 'vibe'), 'instructor_uncomplete_unit' => _x('Are you sure you want mark this unit "uncomplete" for the user ?', 'Popup confirmation message when instructor marks the unit uncomplete for the user.', 'vibe'), 'instructor_complete_unit' => _x('Are you sure you want to mark this unit "complete" for the user ?', 'Popup confirmation message ', 'vibe'), 'unanswered_questions' => __('You have few unanswered questions. Are you sure you want to continue ?', 'vibe'));
wp_localize_script('bp-course-js', 'vibe_course_module_strings', $translation_array);
}
/**
* Filter the page title for BuddyPress pages.
*
* @since BuddyPress (1.5.0)
*
* @see wp_title()
* @global object $bp BuddyPress global settings.
*
* @param string $title Original page title.
* @param string $sep How to separate the various items within the page title.
* @param string $seplocation Direction to display title.
* @return string New page title.
*/
function bp_modify_page_title( $title, $sep = '', $seplocation = '' ) {
global $bp;
// If this is not a BP page, just return the title produced by WP
if ( bp_is_blog_page() ) {
return $title;
}
// If this is a 404, let WordPress handle it
if ( is_404() ) {
return $title;
}
// If this is the front page of the site, return WP's title
if ( is_front_page() || is_home() ) {
return $title;
}
$title = '';
// Displayed user
if ( bp_get_displayed_user_fullname() && ! is_404() ) {
// Get the component's ID to try and get its name
$component_id = $component_name = bp_current_component();
// Use the component nav name
if ( ! empty( $bp->bp_nav[$component_id] ) ) {
// Remove counts that are added by the nav item
$span = strpos( $bp->bp_nav[ $component_id ]['name'], '<span' );
if ( false !== $span ) {
$component_name = substr( $bp->bp_nav[ $component_id ]['name'], 0, $span - 1 );
} else {
$component_name = $bp->bp_nav[ $component_id ]['name'];
}
// Fall back on the component ID
} elseif ( ! empty( $bp->{$component_id}->id ) ) {
$component_name = ucwords( $bp->{$component_id}->id );
}
// Append action name if we're on a member component sub-page
if ( ! empty( $bp->bp_options_nav[ $component_id ] ) && ! empty( $bp->canonical_stack['action'] ) ) {
$component_subnav_name = wp_filter_object_list( $bp->bp_options_nav[ $component_id ], array( 'slug' => bp_current_action() ), 'and', 'name' );
if ( $component_subnav_name ) {
$component_subnav_name = array_shift( $component_subnav_name );
} else {
$component_subnav_name = '';
}
} else {
$component_subnav_name = '';
}
// If on the user profile's landing page, just use the fullname
if ( bp_is_current_component( $bp->default_component ) && bp_get_requested_url() === bp_displayed_user_domain() ) {
$title = bp_get_displayed_user_fullname();
// Use component name on member pages
} else {
// If we have a subnav name, add it separately for localization
if ( ! empty( $component_subnav_name ) ) {
// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator, 4 = component subnav name
$title = strip_tags( sprintf( __( '%1$s %3$s %2$s %3$s %4$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep, $component_subnav_name ) );
} else {
// translators: construct the page title. 1 = user name, 2 = component name, 3 = separator
$title = strip_tags( sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), bp_get_displayed_user_fullname(), $component_name, $sep ) );
}
}
// A single group
} elseif ( bp_is_active( 'groups' ) && ! empty( $bp->groups->current_group ) && ! empty( $bp->bp_options_nav[ $bp->groups->current_group->slug ] ) ) {
$subnav = isset( $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] ) ? $bp->bp_options_nav[ $bp->groups->current_group->slug ][ bp_current_action() ]['name'] : '';
// translators: 1 = group name, 2 = group nav section name, 3 = separator
$title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $subnav, $sep );
// A single item from a component other than groups
} elseif ( bp_is_single_item() ) {
// translators: 1 = component item name, 2 = component nav section name, 3 = separator
$title = sprintf( __( '%1$s %3$s %2$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[ bp_current_item() ][ bp_current_action() ]['name'], $sep );
// An index or directory
} elseif ( bp_is_directory() ) {
$current_component = bp_current_component();
//.........这里部分代码省略.........
/**
* Render the navigation markup for the logged-in user.
*
* Each component adds to this navigation array within its own
* [component_name]setup_nav() function.
*
* This navigation array is the top level navigation, so it contains items such as:
* [Blog, Profile, Messages, Groups, Friends] ...
*
* The function will also analyze the current component the user is in, to
* determine whether or not to highlight a particular nav item.
*
* @todo Move to a back-compat file?
* @deprecated Does not seem to be called anywhere in BP core.
*/
function bp_get_loggedin_user_nav()
{
$bp = buddypress();
// Loop through each navigation item.
foreach ((array) $bp->bp_nav as $nav_item) {
$selected = '';
// If the current component matches the nav item id, then add a highlight CSS class.
if (!bp_is_directory() && !empty($bp->active_components[bp_current_component()]) && $bp->active_components[bp_current_component()] == $nav_item['css_id']) {
$selected = ' class="current selected"';
}
// If we are viewing another person (current_userid does not equal
// loggedin_user->id then check to see if the two users are friends.
// if they are, add a highlight CSS class to the friends nav item
// if it exists.
if (!bp_is_my_profile() && bp_displayed_user_id()) {
$selected = '';
if (bp_is_active('friends')) {
if ($nav_item['css_id'] == $bp->friends->id) {
if (friends_check_friendship(bp_loggedin_user_id(), bp_displayed_user_id())) {
$selected = ' class="current selected"';
}
}
}
}
// Echo out the final list item.
echo apply_filters_ref_array('bp_get_loggedin_user_nav_' . $nav_item['css_id'], array('<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item));
}
// Always add a log out list item to the end of the navigation.
$logout_link = '<li><a id="wp-logout" href="' . wp_logout_url(bp_get_root_domain()) . '">' . __('Log Out', 'buddypress') . '</a></li>';
echo apply_filters('bp_logout_nav_link', $logout_link);
}
/**
* Is this the Achievements Directory page?
*
* @global object $bp BuddyPress global settings
* @global bool $is_member_page If we are under anything with a members slug
* @return bool
* @since 2.0
*/
function dpa_is_directory_page()
{
global $bp, $is_member_page;
return apply_filters('dpa_is_directory_page', bp_is_current_component($bp->achievements->slug) && (bp_is_directory() || bp_is_current_component($bp->achievements->slug) && !$bp->current_action && !$bp->current_item && !$is_member_page));
}
/**
* Customizes the post CSS class according to BuddyPress content.
*
* Hooked to the 'post_class' filter.
*
* @since BuddyPress (2.1.0)
*
* @param array $wp_classes The post classes coming from WordPress.
* @return array
*/
function bp_get_the_post_class($wp_classes = array())
{
// don't do anything if we're not on a BP page
if (!is_buddypress()) {
return $wp_classes;
}
$bp_classes = array();
if (bp_is_user() || bp_is_single_activity()) {
$bp_classes[] = 'bp_members';
} elseif (bp_is_group()) {
$bp_classes[] = 'bp_group';
} elseif (bp_is_activity_component()) {
$bp_classes[] = 'bp_activity';
} elseif (bp_is_blogs_component()) {
$bp_classes[] = 'bp_blogs';
} elseif (bp_is_register_page()) {
$bp_classes[] = 'bp_register';
} elseif (bp_is_activation_page()) {
$bp_classes[] = 'bp_activate';
} elseif (bp_is_forums_component() && bp_is_directory()) {
$bp_classes[] = 'bp_forum';
}
if (empty($bp_classes)) {
return $wp_classes;
}
// emulate post type css class
foreach ($bp_classes as $bp_class) {
$bp_classes[] = "type-{$bp_class}";
}
// removes the 'page' and 'type-page' post classes
// we need to remove these classes since they did not exist before we switched
// theme compat to use the 'page' post type
$page_key = array_search('page', $wp_classes);
$page_type_key = array_search('type-page', $wp_classes);
unset($wp_classes[$page_key], $wp_classes[$page_type_key]);
// okay let's merge!
return array_unique(array_merge($bp_classes, $wp_classes));
}
请发表评论