Skip to:
Content

BuddyPress.org

Changeset 8091


Ignore:
Timestamp:
03/09/2014 02:53:15 PM (11 years ago)
Author:
boonebgorges
Message:

Move .confirm javascript to a separate, properly enqueued file

This improves our compliance with WP standards, improves our integration with
caching systems, and allows plugins to manage the conditional loading of
scripts.

Fixes #5209

Location:
trunk/bp-core
Files:
2 added
1 edited

Legend:

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

    r7571 r8091  
    1414 */
    1515function bp_core_confirmation_js() {
     16    if ( is_multisite() && ! bp_is_root_blog() ) {
     17        return false;
     18    }
    1619
    17     if ( is_multisite() && ! bp_is_root_blog() )
    18         return false;
     20    $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
     21    wp_enqueue_script( 'bp-confirm', buddypress()->plugin_url . "bp-core/js/confirm{$min}.js", array( 'jquery' ), bp_get_version() );
    1922
    20     if ( !wp_script_is( 'jquery' ) )
    21         wp_enqueue_script( 'jquery' );
     23    wp_localize_script( 'bp-confirm', 'BP_Confirm', array(
     24        'are_you_sure' => __( 'Are you sure?', 'buddypress' ),
     25    ) );
    2226
    23     if ( !wp_script_is( 'jquery', 'done' ) )
    24         wp_print_scripts( 'jquery' ); ?>
    25 
    26     <script type="text/javascript">
    27         jQuery( document ).ready( function() {
    28             jQuery( 'a.confirm').click( function() {
    29                 if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) )
    30                     return true; else return false;
    31             });
    32         });
    33     </script>
    34 
    35 <?php
    3627}
    37 add_action( 'wp_head',    'bp_core_confirmation_js', 100 );
    38 add_action( 'admin_head', 'bp_core_confirmation_js', 100 );
     28add_action( 'wp_enqueue_scripts',    'bp_core_confirmation_js' );
     29add_action( 'admin_enqueue_scripts', 'bp_core_confirmation_js' );
    3930
    4031/**
Note: See TracChangeset for help on using the changeset viewer.