Plugin Directory

Changeset 939811


Ignore:
Timestamp:
06/27/2014 07:26:25 PM (12 years ago)
Author:
timmcdaniels
Message:

version 1.9

Location:
combine-js
Files:
11 added
3 edited

Legend:

Unmodified
Added
Removed
  • combine-js/trunk/classes/combine-js-class.php

    r939305 r939811  
    88    const nspace = 'combine-js';
    99    const pname = 'Combine JS';
    10     const version = 1.8;
     10    const version = 1.9;
    1111
    1212    protected $_plugin_file;
     
    3030    var $settings_data = array();
    3131    var $js_files_ignore = array( 'admin-bar.js', 'admin-bar.min.js' );
     32
    3233    var $js_handles_found = array();
     34    var $js_handles_count_first = 0;
     35    var $js_handles_count_last = 0;
     36    var $js_handles_order = array();
    3337    var $js_footer_handles_found = array();
    34     var $debug = false;
    3538    var $footer = false;
    36     var $move_to_footer_top = array();
    37     var $move_to_footer_bottom = array();
     39    var $move_to_footer = array();
     40
    3841    var $combined = false;
    3942    var $paths_set = false;
     43    var $debug = false;
    4044
    4145    /**
     
    281285
    282286        global $wp_scripts;
     287        $handle_count = 0;
    283288        foreach ( $to_do as $key => $handle ) {
     289
     290            // keep order of all handles
     291
     292            $this->js_handles_order[$handle] = $handle_count++;
    284293
    285294            // keep track of footer files
     
    322331                $this->js_handles_found[$handle] = $js_src;
    323332                unset( $to_do[$key] );
     333                if ( ! $this->js_handles_count_first ) $this->js_handles_count_first = $handle_count;
     334                $this->js_handles_count_last = $handle_count;
    324335            }
    325336            elseif ( $this->footer && @strlen( $wp_scripts->registered[$handle]->src ) ) {
     
    327338                // keep track of external and/or ignored js files to move to footer
    328339
    329                 if ( array_keys( $this->js_handles_found ) ) $this->move_to_footer_bottom[$handle] = $wp_scripts->registered[$handle]->src;
    330                 else $this->move_to_footer_top[$handle] = $wp_scripts->registered[$handle]->src;
     340                $this->move_to_footer[$handle] = $wp_scripts->registered[$handle]->src;
    331341            }
    332342        }
     
    623633        }
    624634
    625         foreach ( $this->move_to_footer_top as $handle => $src ) {
     635        // if move to footer set to yes,
     636        // figure out what js should be above or below our combined file
     637
     638        $top = $bottom = array();
     639        if ( $this->footer && array_keys( $this->move_to_footer ) ) {
     640            foreach ( $this->move_to_footer as $handle => $src ) {
     641                if ( $this->js_handles_order[$handle] < $this->js_handles_count_first ) $top[$handle] = $src;
     642                else $bottom[$handle] = $src;
     643            }
     644        }
     645
     646        // add js above combined file
     647
     648        foreach ( $top as $handle => $src ) {
    626649            echo "\t\t" . '<script type="text/javascript" src="' . $src . '"></script>' . "\n";
    627650        }
     
    635658        }
    636659
    637         foreach ( $this->move_to_footer_bottom as $handle => $src ) {
     660        // add js below combined file
     661
     662        foreach ( $bottom as $handle => $src ) {
    638663            echo "\t\t" . '<script type="text/javascript" src="' . $src . '"></script>' . "\n";
    639664        }
  • combine-js/trunk/combine-js.php

    r939296 r939811  
    55Description: WordPress plugin that attempts to combine, minify, and compress JS.
    66Author: Convoy
    7 Version: 1.8
     7Version: 1.9
    88Author URI: http://www.weareconvoy.com
    99Requires at least: 3.0.0
  • combine-js/trunk/readme.txt

    r939296 r939811  
    55Requires at least: 3.0.1
    66Tested up to: 3.9.1
    7 Stable tag: 1.8
     7Stable tag: 1.9
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3838
    3939== Changelog ==
     40
     41= 1.9 =
     42* Continued improving of javascript ordering when "Move all JS to footer?" is set to yes.
    4043
    4144= 1.8 =
Note: See TracChangeset for help on using the changeset viewer.