Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter bsteinlo

    (@bsteinlo)

    If anyone is interested, I changed the enqueue_scripts function to check for the shortcode

    public function enqueue_scripts() {
    
    		/**
    		 * This function is provided for demonstration purposes only.
    		 *
    		 * An instance of this class should be passed to the run() function
    		 * defined in Greenhouse_Job_Board_Loader as all of the hooks are defined
    		 * in that particular class.
    		 *
    		 * The Greenhouse_Job_Board_Loader will then create the relationship
    		 * between the defined hooks and the functions defined in this
    		 * class.
    		 */
    
    		global $post;
    
    		$content = $post->post_content;
    
    		if ( has_shortcode( $content, 'greenhouse' ) ) {
    
    			wp_enqueue_script( $this->greenhouse_job_board + '_handlebars', plugin_dir_url( __FILE__ ) . 'js/handlebars-v3.0.0.js', array( 'jquery' ), null, false );
    			wp_enqueue_script( 'cycle2', plugin_dir_url( __FILE__ ) . 'js/jquery.cycle2.min.js', array( 'jquery' ), '20141007', false );
    			wp_enqueue_script( $this->greenhouse_job_board, plugin_dir_url( __FILE__ ) . 'js/greenhouse-job-board-public.js', array( 'jquery' ), '1.7.0', false );
    		}
    	}
    Plugin Author brownbagmarketing

    (@brownbagmarketing)

    Thanks @bsteinlo! We’ll test on it and include this in our next release!

    Thread Starter bsteinlo

    (@bsteinlo)

    Thanks for the update! Works great,

    I changed the logic to do the same for the CSS, so something like:
    wp_register_style( 'greenhouse-job-board-css', plugin_dir_url( __FILE__ ) . 'css/greenhouse-job-board-public.css', array(), $this->version, 'all' );

    and then when you enqueue the scripts:

    wp_enqueue_script('ghjbp');
    wp_enqueue_style('greenhouse-job-board-css');

    Plugin Author brownbagmarketing

    (@brownbagmarketing)

    Right on, this is fixed in 2.0.1

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditionally load scripts?’ is closed to new replies.