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.

Iam writing a wordpress widget with the following pages 1) I have master page (master.php) - is the main plugin page - Loads a second page (slave.php) with jQuery 2) The slave page - has php, jquery, css etc. - is an external page

Below is part of master.php

<?php
    add_action('init', 'register_masterscript');
    function register_masterscript() {
        wp_register_script( 'master_jquery', plugins_url('/js/master-script.js', __FILE__), array('jquery'), '2.5.1' );
            wp_register_script( 'master_jquery2', plugins_url('/js/master.js', __FILE__), array('jquery'), '2.5.1' );
        wp_register_style( 'master_style', plugins_url('/css/master_style.css', __FILE__), false, '1.0.0', 'all');
    }

    // using the registered jquery and style above
    add_action('wp_enqueue_scripts', 'enqueue_masterstyle');

    function enqueue_masterstyle(){
       wp_enqueue_script('master_jquery');
       wp_enqueue_script('master_jquery2');
       wp_enqueue_style( 'master_style' );
    }
    ?>

master.php loads slave.ph successfully but my problem is non of the jquery actions or links work. As slave.php is external I have tried

define('WP_USE_THEMES', false);
    require('../../../wp-blog-header.php');

then

 <?php 
    add_action('init', 'register_slavescript');
    function register_slavescript() {
        wp_register_script( 'slave_jquery', plugins_url('/js/jQuery1.7.1.js', __FILE__), array('jquery'), '2.5.1' );
            wp_register_script( 'slave_jquery2', plugins_url('/js/highlight.pack.js', __FILE__), array('jquery'), '2.5.1' );
            wp_register_script( 'slave_jquery3', plugins_url('/js/combined.js', __FILE__), array('jquery'), '2.5.1' );
        wp_register_style( 'slave_style', plugins_url('/css/slave_style.css', __FILE__), false, '1.0.0', 'all');
             wp_register_script( 'slave_jquery4', plugins_url('/js/jquery.mousewheel.js', __FILE__), array('jquery'), '2.5.1' );
             wp_register_script( 'slave_jquery5', plugins_url('/js/jquery.jscrollpane.min.js', __FILE__), array('jquery'), '2.5.1' ); 
    }       
    // use the registered jquery and style above
    add_action('wp_enqueue_scripts', 'enqueue_slavestyle');

    function enqueue_slavestyle(){
       wp_enqueue_script('slave_jquery');
       wp_enqueue_script('slave_jquery2');
       wp_enqueue_script('slave_jquery3');
       wp_enqueue_style( 'slave_style' );
       wp_enqueue_script('slave_jquery4');
       wp_enqueue_script('slave_jquery5');
    }
    ?>

If running the pages without wordpress and without enqueue - ing scripts, the whole code is working fine It looks like for slave.php enqueue -ing is not working, how can i do this the right way ?

share|improve this question
    
Do you use the correct jQuery variable in your script? –  toscho Dec 15 '13 at 14:55

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.