예제 #1
0
 function x_enqueue_site_scripts()
 {
     wp_register_script('x-site-head', X_TEMPLATE_URL . '/framework/js/dist/site/x-head.min.js', array('jquery'), X_VERSION, false);
     wp_register_script('x-site-body', X_TEMPLATE_URL . '/framework/js/dist/site/x-body.min.js', array('jquery'), X_VERSION, true);
     wp_register_script('x-site-icon', X_TEMPLATE_URL . '/framework/js/dist/site/x-icon.min.js', array('jquery'), X_VERSION, true);
     wp_enqueue_script('x-site-head');
     wp_enqueue_script('x-site-body');
     if (x_get_stack() == 'icon') {
         wp_enqueue_script('x-site-icon');
     }
     if (is_singular()) {
         wp_enqueue_script('comment-reply');
     }
     if (X_BUDDYPRESS_IS_ACTIVE) {
         wp_dequeue_script('bp-legacy-js');
         wp_dequeue_script('bp-parent-js');
         wp_enqueue_script('x-site-buddypress', X_TEMPLATE_URL . '/framework/js/dist/site/x-buddypress.js', bp_core_get_js_dependencies(), X_VERSION, false);
         wp_localize_script('x-site-buddypress', 'BP_DTheme', x_buddypress_core_get_js_strings());
     }
 }
예제 #2
0
 /**
  * Enqueue the required JavaScript files
  *
  * @since BuddyPress (1.7)
  */
 public function enqueue_scripts()
 {
     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Locate the BP JS file
     $asset = $this->locate_asset_in_stack("buddypress{$min}.js", 'js');
     // Enqueue the global JS, if found - AJAX will not work
     // without it
     if (isset($asset['location'], $asset['handle'])) {
         wp_enqueue_script($asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version);
     }
     /**
      * Filters core JavaScript strings for internationalization before AJAX usage.
      *
      * @since BuddyPress (2.0.0)
      *
      * @param array $value Array of key/value pairs for AJAX usage.
      */
     $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress')));
     wp_localize_script($asset['handle'], 'BP_DTheme', $params);
     // Maybe enqueue comment reply JS
     if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
     // Maybe enqueue password verify JS (register page or user settings page)
     if (bp_is_register_page() || function_exists('bp_is_user_settings_general') && bp_is_user_settings_general()) {
         // Locate the Register Page JS file
         $asset = $this->locate_asset_in_stack("password-verify{$min}.js", 'js', 'bp-legacy-password-verify');
         $dependencies = array_merge(bp_core_get_js_dependencies(), array('password-strength-meter'));
         // Enqueue script
         wp_enqueue_script($asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version);
     }
     // Star private messages
     if (bp_is_active('messages', 'star') && bp_is_user_messages()) {
         wp_localize_script($asset['handle'], 'BP_PM_Star', array('strings' => array('text_unstar' => __('Unstar', 'buddypress'), 'text_star' => __('Star', 'buddypress'), 'title_unstar' => __('Starred', 'buddypress'), 'title_star' => __('Not starred', 'buddypress'), 'title_unstar_thread' => __('Remove all starred messages in this thread', 'buddypress'), 'title_star_thread' => __('Star the first message in this thread', 'buddypress')), 'is_single_thread' => (int) bp_is_messages_conversation(), 'star_counter' => 0, 'unstar_counter' => 0));
     }
 }
 /**
  * Enqueue the required Javascript files
  *
  * @since BuddyPress (1.7)
  */
 public function enqueue_scripts()
 {
     $file = 'buddypress.js';
     // Locate the BP JS file
     $asset = $this->locate_asset_in_stack($file, 'js');
     // Enqueue the global JS, if found - AJAX will not work
     // without it
     if (isset($asset['location'], $asset['handle'])) {
         wp_enqueue_script($asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version);
     }
     // Add words that we need to use in JS to the end of the page
     // so they can be translated and still used.
     $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress')));
     wp_localize_script($asset['handle'], 'BP_DTheme', $params);
     // Maybe enqueue comment reply JS
     if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
 }
예제 #4
0
 /**
  * Enqueue the required Javascript files
  *
  * @since BuddyPress (1.7)
  */
 public function enqueue_scripts()
 {
     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Locate the BP JS file
     $asset = $this->locate_asset_in_stack("buddypress{$min}.js", 'js');
     // Enqueue the global JS, if found - AJAX will not work
     // without it
     if (isset($asset['location'], $asset['handle'])) {
         wp_enqueue_script($asset['handle'], $asset['location'], bp_core_get_js_dependencies(), $this->version);
     }
     // Add words that we need to use in JS to the end of the page
     // so they can be translated and still used.
     $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress')));
     wp_localize_script($asset['handle'], 'BP_DTheme', $params);
     // Maybe enqueue comment reply JS
     if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
     // Maybe enqueue password verify JS (register page or user settings page)
     if (bp_is_register_page() || function_exists('bp_is_user_settings_general') && bp_is_user_settings_general()) {
         // Locate the Register Page JS file
         $asset = $this->locate_asset_in_stack("password-verify{$min}.js", 'js');
         $dependencies = array_merge(bp_core_get_js_dependencies(), array('password-strength-meter'));
         // Enqueue script
         wp_enqueue_script($asset['handle'] . '-password-verify', $asset['location'], $dependencies, $this->version);
     }
 }
예제 #5
0
 /**
  * Check version of buddypress and load js
  *
  *
  * @since  2.0.0
  * @return void
  * @author Francesco Licandro <*****@*****.**>
  */
 function yit_buddypress_scripts()
 {
     if (version_compare(preg_replace('/-beta-([0-9]+)/', '', bp_get_version()), '2.1', '<')) {
         wp_dequeue_script('bp-parent-js');
         wp_enqueue_script('yit-bp-js', YIT_URL . '/buddypress/js/buddypress-2.0.x/buddypress.js', bp_core_get_js_dependencies());
     }
 }
 /**
  * Enqueue template pack javascript
  *
  * @since BuddyPress Templates (1.0)
  */
 public function enqueue_scripts()
 {
     // LTR or RTL
     $file = 'js/buddypress.js';
     // Check child theme
     if (file_exists(trailingslashit(get_stylesheet_directory()) . $file)) {
         $location = trailingslashit(get_stylesheet_directory_uri());
         $handle = 'bp-child-js';
         // Check parent theme
     } elseif (file_exists(trailingslashit(get_template_directory()) . $file)) {
         $location = trailingslashit(get_template_directory_uri());
         $handle = 'bp-parent-js';
         // BuddyPress Theme Compatibility
     } else {
         $location = trailingslashit($this->url);
         $handle = 'bp-templatepack-js';
     }
     wp_enqueue_script($handle, $location . $file, bp_core_get_js_dependencies(), $this->version);
     // Add words that we need to use in JS to the end of the page
     // so they can be translated and still used.
     $params = apply_filters('bp_core_get_js_strings', array('accepted' => __('Accepted', 'buddypress'), 'close' => __('Close', 'buddypress'), 'comments' => __('comments', 'buddypress'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddypress'), 'mark_as_fav' => __('Favorite', 'buddypress'), 'my_favs' => __('My Favorites', 'buddypress'), 'rejected' => __('Rejected', 'buddypress'), 'remove_fav' => __('Remove Favorite', 'buddypress'), 'show_all' => __('Show all', 'buddypress'), 'show_all_comments' => __('Show all comments for this thread', 'buddypress'), 'show_x_comments' => __('Show all %d comments', 'buddypress'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress'), 'view' => __('View', 'buddypress')));
     wp_localize_script($handle, 'BP_DTheme', $params);
     // Maybe enqueue comment reply JS
     if (is_singular() && bp_is_blog_page() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
 }
예제 #7
0
/**
 * Enqueues scripts and styles for front-end.
 *
 * @since BuddyBoss 1.0
 */
function buddyboss_scripts_styles()
{
    /****************************** SCRIPTS ******************************/
    global $bp, $buddyboss, $buddyboss_js_params;
    /*
     * Modernizr
     */
    wp_enqueue_script('buddyboss-modernizr', get_template_directory_uri() . '/js/modernizr.min.js', false, '2.7.1', false);
    /*
     * Adds JavaScript to pages with the comment form to support
     * sites with threaded comments (when in use).
     */
    if (is_singular() && comments_open() && get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }
    /*
     * Adds mobile JavaScript functionality.
     */
    if (!is_admin()) {
        wp_enqueue_script('idangerous-swiper', get_template_directory_uri() . '/js/idangerous.swiper.js', array('jquery'), '1.9.2', true);
        wp_enqueue_script('buddyboss-mobile-main', get_template_directory_uri() . '/js/mobile-main.js', array('jquery'), '3.2.0', true);
    }
    /*
     * Load our BuddyPress JavaScript manually if plugin is active.
     * We need to deregister the BuddyPress JS first then load our own.
     * AJAX will not work without it.
     *
     * Referencing /plugins/buddypress/bp-templates/bp-legacy/buddypress-functions.php
     */
    if ($buddyboss->buddypress_active && !is_admin()) {
        // Older versions of BuddyPress don't have the function
        // bp_core_get_js_dependencies() so we need to check for
        // it even though we've already checked for BuddyPress
        $bp_js_dependencies = function_exists('bp_core_get_js_dependencies') ? bp_core_get_js_dependencies() : array('jquery');
        // Deregister the built-in BuddyPress JavaScript
        wp_dequeue_script('bp-legacy-js');
        wp_dequeue_script('bp-parent-js');
        // Activate our own BuddyPress JavaScript
        wp_enqueue_script('buddyboss-buddypress-js', get_template_directory_uri() . '/js/buddypress.js', $bp_js_dependencies, '3.2.0', true);
    }
    $user_profile = null;
    if (is_object($bp) && is_object($bp->displayed_user) && !empty($bp->displayed_user->domain)) {
        $user_profile = $bp->displayed_user->domain;
    }
    // Add BuddyPress plugin words that we need to use in JS to the end of the page
    // so they can be translated and still used.
    $buddypress_params = array('accepted' => __('Accepted', 'buddyboss'), 'close' => __('Close', 'buddyboss'), 'comments' => __('comments', 'buddyboss'), 'leave_group_confirm' => __('Are you sure you want to leave this group?', 'buddyboss'), 'mark_as_fav' => __('Favorite', 'buddyboss'), 'my_favs' => __('My Favorites', 'buddyboss'), 'rejected' => __('Rejected', 'buddyboss'), 'remove_fav' => __('Remove Favorite', 'buddyboss'), 'show_all' => __('Show all', 'buddyboss'), 'show_all_comments' => __('Show all comments for this thread', 'buddyboss'), 'show_x_comments' => __('Show all %d comments', 'buddyboss'), 'unsaved_changes' => __('Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddyboss'), 'view' => __('View', 'buddyboss'));
    if ($buddyboss->buddypress_active && !is_admin()) {
        $buddypress_params = (array) apply_filters('bp_core_get_js_strings', $buddypress_params);
    }
    wp_localize_script('buddyboss-buddypress-js', 'BP_DTheme', $buddypress_params);
    /*
     * Adds custom BuddyBoss JavaScript functionality.
     */
    if (!is_admin()) {
        wp_enqueue_script('buddyboss-main', get_template_directory_uri() . '/js/buddyboss.js', array('jquery'), '3.1.8');
    }
    // Add BuddyBoss words that we need to use in JS to the end of the page
    // so they can be translataed and still used.
    $buddyboss_js_vars = array('select_label' => __('Show:', 'buddyboss'), 'post_in_label' => __('Post in:', 'buddyboss'), 'tpl_url' => get_template_directory_uri(), 'child_url' => get_stylesheet_directory_uri(), 'user_profile' => $user_profile);
    $buddyboss_js_vars = (array) apply_filters('buddyboss_js_vars', $buddyboss_js_vars);
    wp_localize_script('buddyboss-main', 'BuddyBossOptions', $buddyboss_js_vars);
    /**
     * If we're on the BuddyPress messages component we need to load jQuery Migrate first
     * before bgiframe, so let's take care of that
     */
    if (function_exists('bp_is_messages_component') && bp_is_messages_component() && bp_is_current_action('compose')) {
        $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
        wp_dequeue_script('bp-jquery-bgiframe');
        wp_enqueue_script('bp-jquery-bgiframe', BP_PLUGIN_URL . "bp-messages/js/autocomplete/jquery.bgiframe{$min}.js", array(), bp_get_version());
    }
    // BuddyPress Activity Privacy plugin compatibility
    if (function_exists('bp_activity_privacy_add_js')) {
        wp_deregister_script('bp-activity-privacy-js');
    }
    /****************************** STYLES ******************************/
    // Main WordPress stylesheet
    if (!is_admin()) {
        // Activate our primary WordPress stylesheet. Load FontAwesome and GoogleFonts first.
        wp_enqueue_style('buddyboss-wp-frontend', get_template_directory_uri() . '/css/wordpress.css', array('fontawesome', 'googlefonts'), '3.1.8', 'all');
    }
    /*
     * Load our BuddyPress styles manually if plugin is active.
     * We need to deregister the BuddyPress styles first then load our own.
     * We need to do this for proper CSS load order.
     */
    if ($buddyboss->buddypress_active && !is_admin()) {
        // Deregister the built-in BuddyPress stylesheet
        wp_deregister_style('bp-child-css');
        wp_deregister_style('bp-parent-css');
        // Activate our own BuddyPress stylesheet. Load FontAwesome and GoogleFonts first.
        wp_enqueue_style('buddyboss-bp-frontend', get_template_directory_uri() . '/css/buddypress.css', array('fontawesome', 'googlefonts'), '3.1.8', 'all');
    }
    /*
     * Load our bbPress styles manually if plugin is active.
     * We need to deregister the bbPress style first then load our own.
     * We need to do this for proper CSS load order.
     */
    if ($buddyboss->bbpress_active && !is_admin()) {
        // Deregister the built-in bbPress stylesheet
        wp_deregister_style('bbp-child-bbpress');
        wp_deregister_style('bbp-parent-bbpress');
        wp_deregister_style('bbp-default');
        // Activate our own bbPress stylesheet. Load FontAwesome and GoogleFonts first.
        wp_enqueue_style('buddyboss-bbpress-frontend', get_template_directory_uri() . '/css/bbpress.css', array('fontawesome', 'googlefonts'), '3.1.4', 'all');
    }
    // Load our CSS support for 3rd party plugins here.
    if (!is_admin()) {
        wp_enqueue_style('buddyboss-wp-plugins', get_template_directory_uri() . '/css/plugins.css', array('fontawesome', 'googlefonts'), '3.1.8', 'all');
    }
    // Load our own adminbar (Toolbar) styles.
    if (!is_admin()) {
        // Deregister the built-in adminbar stylesheet
        wp_deregister_style('admin-bar');
        // Activate our own mobile adminbar stylesheet. Load FontAwesome and GoogleFonts first.
        wp_enqueue_style('buddyboss-wp-adminbar-mobile', get_template_directory_uri() . '/css/adminbar-mobile.css', array('fontawesome', 'googlefonts'), '3.1.8', 'all');
        // Activate our own Fixed or Floating (defaults to Fixed) adminbar stylesheet. Load DashIcons and GoogleFonts first.
        wp_enqueue_style('buddyboss-wp-adminbar-desktop-' . esc_attr(get_theme_mod('boss_adminbar_layout', 'fixed')), get_template_directory_uri() . '/css/adminbar-desktop-' . esc_attr(get_theme_mod('boss_adminbar_layout', 'fixed')) . '.css', array('dashicons', 'googlefonts'), '3.1.8', 'all');
    }
}