Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this slider(orbit slider http://foundation.zurb.com/docs/orbit.php ) and a wordpress plugin(event manager http://wp-events-plugin.com/ ) that loads all this jQuery-ui stuff(

/**
   * Enqueing public scripts and styles
   */
  function public_enqueue() {
    //Scripts
    wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js',__FILE__), array('jquery', 'jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-sortable','jquery-ui-datepicker','jquery-ui-autocomplete','jquery-ui-dialog')); //jQuery will load as dependency
    //Styles
    wp_enqueue_style('events-manager', plugins_url('includes/css/events_manager.css',__FILE__)); //main css
  }

  /**
   * Localize the script vars that require PHP intervention, removing the need for inline JS.
   */
  function localize_script(){
    global $em_localized_js;
    $locale_code = substr ( get_locale(), 0, 2 );
    //Localize
    $em_localized_js = array(
      'ajaxurl' => admin_url('admin-ajax.php'),
      'locationajaxurl' => admin_url('admin-ajax.php?action=locations_search'),
      'firstDay' => get_option('start_of_week'),
      'locale' => $locale_code,
      'dateFormat' => get_option('dbem_date_format_js'),
      'ui_css' => plugins_url('includes/css/ui-lightness.css', __FILE__),
      'show24hours' => get_option('dbem_time_24h'),
      'is_ssl' => is_ssl(),
    );

) on the very top of every page on the site(

<link rel='stylesheet' id='events-manager-css'  href='http://at.theplural.com/wp-content/plugins/events-manager/includes/css/events_manager.css?ver=3.4.2' type='text/css' media='all' />
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.core.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.widget.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.position.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.mouse.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.sortable.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.resizable.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.draggable.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.button.min.js?ver=1.8.20'></script>
<script type='text/javascript' src='http://at.theplural.com/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js?ver=1.8.20'></script>

) . I'm basically trying to block that javascript from loading on the front page, or ideally, loading on only the specific page it's needed on -> page('events'). I tried my best to 'dequeue' the js, but it's not working

share|improve this question
2  
Please use the "edit" link and format your code (The WYSIWG editor got buttons for that). –  kaiser Nov 22 '12 at 22:57
add comment

1 Answer

up vote 2 down vote accepted

If you want to enqueue the scripts only on the "Events" page, change the following code to include the conditional tag is_page()

function public_enqueue() {
    //Scripts
    wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js',__FILE__), array('jquery', 'jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-sortable','jquery-ui-datepicker','jquery-ui-autocomplete','jquery-ui-dialog')); //jQuery will load as dependency
    //Styles
    wp_enqueue_style('events-manager', plugins_url('includes/css/events_manager.css',__FILE__)); //main css
}

Change it to the following:

function public_enqueue() {
    if( is_page('events') ) { //Only load on the page "events"
        //Scripts
        wp_enqueue_script('events-manager', plugins_url('includes/js/events-manager.js',__FILE__), array('jquery', 'jquery-ui-core','jquery-ui-widget','jquery-ui-position','jquery-ui-sortable','jquery-ui-datepicker','jquery-ui-autocomplete','jquery-ui-dialog')); //jQuery will load as dependency
        //Styles
        wp_enqueue_style('events-manager', plugins_url('includes/css/events_manager.css',__FILE__)); //main css
    }
}
share|improve this answer
    
Thanks. The only problem with what I see above is that there are several 'events' pages(am i right?), and that I would have to modify the plugin code. This is what I have in functions.php right now. It works for now, but it is loading on litterally every page but home. pastie.org/5423274 –  Danny Michel Nov 23 '12 at 14:17
1  
Well, I don't know how your site is built up. But I thought you where asking to only show it on the page "events", which this code does. Maybe you could share a link? I haven't used that event-plugin. But I'm guessing that it creates some sort of Custom Post Type for the events, so you could extend the IF-statement to include that post type if( is_page('events') || is_singular( 'post-type-name' ) )(replace "post-type-name" with the name of the event post type name.) –  jzatt Nov 27 '12 at 15:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.