Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/07/2008 07:16:51 AM (18 years ago)
Author:
apeatling
Message:

Bug fixes:

  • Fixed group avatar upload issues
  • Fixed validation on group name/desc/news
  • Fixed support for https://
  • Base support for upcoming home theme and widgets
  • Re-factored JS and CSS inclusion with wp_enqueue_script/styles
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-cssjs.php

    r309 r373  
    1010 */
    1111function bp_core_add_js() {
    12         echo '<script type="text/javascript">var ajaxurl = "' . get_option('siteurl') . '/wp-admin/admin-ajax.php";</script>';
    13         echo "<script type='text/javascript' src='" . get_option('siteurl') . "/wp-includes/js/jquery/jquery.js?ver=1.2.3'></script>";
    14         echo "
    15                 <script type='text/javascript' src='" . get_option('siteurl') . "/wp-content/mu-plugins/bp-core/js/jquery/jquery.livequery.pack.js'></script>";
     12        wp_enqueue_script( 'jquery' );
     13        wp_enqueue_script( 'jquery-livequery-pack', site_url() . "/wp-content/mu-plugins/bp-core/js/jquery/jquery.livequery.pack.js", 'jquery' );
     14        wp_enqueue_script( 'bp-general-js', site_url() . '/wp-content/mu-plugins/bp-core/js/general.js' );
     15}
     16add_action( 'template_redirect', 'bp_core_add_js' );
    1617
    17         echo '<script src="' . get_option('siteurl') . '/wp-content/mu-plugins/bp-core/js/general.js" type="text/javascript"></script>';
     18/**
     19 * bp_core_add_ajax_js()
     20 *
     21 * Add the reference to ajaxurl used by all ajax functionality in BuddyPress.
     22 *
     23 * @package BuddyPress Core
     24 * @uses get_option() Selects a site setting from the DB.
     25 */
     26function bp_core_add_ajax_js() {
     27        echo '<script type="text/javascript">var ajaxurl = "' . site_url() . '/wp-admin/admin-ajax.php";</script>';
    1828}
    19 add_action( 'wp_head', 'bp_core_add_js' );
     29add_action( 'wp_head', 'bp_core_add_ajax_js' );
    2030
    2131/**
     
    2838 */
    2939function bp_core_add_css() {
    30         if ( bp_core_user_has_home() && is_user_logged_in() )
    31                 echo '<link rel="stylesheet" href="' . get_option('siteurl') . '/wp-content/mu-plugins/bp-core/css/admin-bar.css" type="text/css" />';
     40        if ( is_user_logged_in() ) {
     41                wp_enqueue_style( 'bp-admin-bar', site_url() . '/wp-content/mu-plugins/bp-core/css/admin-bar.css' );
     42                wp_print_styles();
     43        }
    3244}
    3345add_action( 'wp_head', 'bp_core_add_css' );
    3446
     47
     48/**
     49 * bp_core_add_admin_js()
     50 *
     51 * Add the JS needed for all components in the admin area.
     52 *
     53 * @package BuddyPress Core
     54 * @uses get_option() Selects a site setting from the DB.
     55 */
    3556function bp_core_add_admin_js() {
    3657        if ( strpos( $_GET['page'], 'bp-core' ) !== false ) {
    37                 wp_enqueue_script( 'bp-account-admin-js', get_option('siteurl') . '/wp-content/mu-plugins/bp-core/js/account-admin.js' );
     58                wp_enqueue_script( 'bp-account-admin-js', site_url() . '/wp-content/mu-plugins/bp-core/js/account-admin.js' );
    3859        }
    39 }
    40 add_action( 'admin_menu', 'bp_core_add_admin_js' );
    41 
    42 function bp_core_enqueue_admin_js() {
     60       
    4361        if ( strpos( $_GET['page'], 'bp-core/admin-mods' ) !== false ) {
    4462                wp_enqueue_script('password-strength-meter');
     
    4664
    4765        if ( strpos( $_GET['page'], 'bp-core/homebase-creation' ) !== false ) {
     66                wp_enqueue_script('prototype');
     67                wp_enqueue_script('scriptaculous-root');
     68                wp_enqueue_script('cropper');
    4869                add_action( 'admin_head', 'bp_core_add_cropper_js' );
    4970        }
    5071}
    51 add_action( 'admin_menu', 'bp_core_enqueue_admin_js' );
     72add_action( 'admin_menu', 'bp_core_add_admin_js' );
    5273
    53 function bp_core_enqueue_admin_css() {
     74
     75/**
     76 * bp_core_add_admin_css()
     77 *
     78 * Add the CSS needed for all components in the admin area.
     79 *
     80 * @package BuddyPress Core
     81 * @uses get_option() Selects a site setting from the DB.
     82 */
     83function bp_core_add_admin_css() {
    5484        if ( strpos( $_GET['page'], 'bp-core/homebase-creation' ) !== false ) {
    55                 wp_enqueue_style( 'bp-core-home-base-css', get_option('siteurl') . '/wp-content/mu-plugins/bp-core/css/home-base.css' );
     85                wp_enqueue_style( 'bp-core-home-base-css', site_url() . '/wp-content/mu-plugins/bp-core/css/home-base.css' );
    5686        }
    5787}
    58 add_action( 'admin_menu', 'bp_core_enqueue_admin_css' );
     88add_action( 'admin_menu', 'bp_core_add_admin_css' );
     89
     90
     91/**
     92 * bp_core_add_cropper_js()
     93 *
     94 * Adds the JS needed for general avatar cropping.
     95 *
     96 * @package BuddyPress Core
     97 */
     98function bp_core_add_cropper_js() {
     99?>
     100        <script type="text/javascript">
     101                function cropAndContinue() {
     102                        jQuery('#avatar_v1').slideUp();
     103                        jQuery('#avatar_v2').slideDown('normal', function(){
     104                                v2Cropper();
     105                        });
     106                }
     107
     108                function v1Cropper() {
     109                        v1Crop = new Cropper.ImgWithPreview(
     110                                'crop-v1-img',
     111                                {
     112                                        ratioDim: { x: <?php echo round(CORE_AVATAR_V1_W / CORE_AVATAR_V1_H, 5); ?>, y: 1 },
     113                                        minWidth:   <?php echo CORE_AVATAR_V1_W; ?>,
     114                                        minHeight:  <?php echo CORE_AVATAR_V1_H; ?>,
     115                                        prevWidth:  <?php echo CORE_AVATAR_V1_W; ?>,
     116                                        prevHeight: <?php echo CORE_AVATAR_V1_H; ?>,
     117                                        onEndCrop: onEndCropv1,
     118                                        previewWrap: 'crop-preview-v1'
     119                                }
     120                        );
     121                }
     122
     123                function onEndCropv1(coords, dimensions) {
     124                        jQuery('#v1_x1').val(coords.x1);
     125                        jQuery('#v1_y1').val(coords.y1);
     126                        jQuery('#v1_x2').val(coords.x2);
     127                        jQuery('#v1_y2').val(coords.y2);
     128                        jQuery('#v1_w').val(dimensions.width);
     129                        jQuery('#v1_h').val(dimensions.height);
     130                }
     131
     132                <?php if (CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false) { ?>
     133                function v2Cropper() {
     134                        v1Crop = new Cropper.ImgWithPreview(
     135                                'crop-v2-img',
     136                                {
     137                                        ratioDim: { x: <?php echo round(CORE_AVATAR_V2_W / CORE_AVATAR_V2_H, 5); ?>, y: 1 },
     138                                        minWidth:   <?php echo CORE_AVATAR_V2_W; ?>,
     139                                        minHeight:  <?php echo CORE_AVATAR_V2_H; ?>,
     140                                        prevWidth:  <?php echo CORE_AVATAR_V2_W; ?>,
     141                                        prevHeight: <?php echo CORE_AVATAR_V2_H; ?>,
     142                                        onEndCrop: onEndCropv2,
     143                                        previewWrap: 'crop-preview-v2'
     144                                }
     145                        );
     146                }
     147                <?php } ?>
     148
     149                function onEndCropv2(coords, dimensions) {
     150                        jQuery('#v2_x1').val(coords.x1);
     151                        jQuery('#v2_y1').val(coords.y1);
     152                        jQuery('#v2_x2').val(coords.x2);
     153                        jQuery('#v2_y2').val(coords.y2);
     154                        jQuery('#v2_w').val(dimensions.width);
     155                        jQuery('#v2_h').val(dimensions.height);
     156                }
     157        </script>
     158<?php
     159}
Note: See TracChangeset for help on using the changeset viewer.