Plugin Directory

Changeset 620031


Ignore:
Timestamp:
11/01/2012 10:00:58 PM (13 years ago)
Author:
bobbravo2
Message:

fixed js var localization bug by removing wp_localize_script dependency

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-fontsize/trunk/wp_fontsize.php

    r620025 r620031  
    55Description: Adds Stateful Fontsize Adjustment Classes to the body of the Website
    66Author: Circle Tree, LLC
    7 Version: 0.6.2
     7Version: 0.6.3
    88Author URI: http://mycircletree.com/
    99*/
     
    2525    }
    2626    function  init () {
    27         $js_vars = array(
    28                 'ajaxurl'=>admin_url('admin-ajax.php'),
    29                 'fontsize' => $this->getFontSize(),
    30                 'nonce' => wp_create_nonce('wp_fontsize'),
    31         );
    32         wp_localize_script('jquery', 'wp_fontsize', $js_vars);
    3327        wp_enqueue_script('jquery');
    3428        add_action('wp_footer', array($this, 'footer'));
     
    130124        </div>
    131125    <?php }
    132     private function js () { ?>
     126    private function js () {
     127        $js_vars = array(
     128                'ajaxurl'=>admin_url('admin-ajax.php'),
     129                'fontsize' => $this->getFontSize(),
     130                'nonce' => wp_create_nonce('wp_fontsize'),
     131            );
     132        $json_data = json_encode($js_vars);
     133        ?>
    133134        <script>
    134         var current_size = wp_fontsize.fontsize;
     135        /* <![CDATA[ */
     136            var wp_fontsize = <?php echo $json_data; ?>,
     137            current_size = wp_fontsize.fontsize;
     138        /* ]]> */
    135139        jQuery(function($) {
    136140            <?php //A named function is used in place of jQuery.ajaxSetup to avoid plugin conflicts; ?>
Note: See TracChangeset for help on using the changeset viewer.