WordPress.org

Make WordPress Core

Changeset 16282


Ignore:
Timestamp:
11/10/10 21:53:30 (4 years ago)
Author:
westi
Message:

Move the l10n helper function into a seperate js file so we can always output it first.
Fixes #15124.

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/utils.dev.js

    r11450 r16282  
    11// utility functions 
    2 function convertEntities(o) { 
    3     var c, v; 
    4     c = function(s) { 
    5         if (/&[^;]+;/.test(s)) { 
    6             var e = document.createElement("div"); 
    7             e.innerHTML = s; 
    8             return !e.firstChild ? s : e.firstChild.nodeValue; 
    9         } 
    10         return s; 
    11     } 
    12  
    13     if ( typeof o === 'string' ) { 
    14         return c(o); 
    15     } else if ( typeof o === 'object' ) { 
    16         for (v in o) { 
    17             if ( typeof o[v] === 'string' ) { 
    18                 o[v] = c(o[v]); 
    19             } 
    20         } 
    21     } 
    22     return o; 
    23 } 
    242 
    253var wpCookies = { 
  • trunk/wp-admin/js/utils.js

    r10348 r16282  
    1 function convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return !f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b}var wpCookies={each:function(d,a,c){var e,b;if(!d){return 0}c=c||d;if(typeof(d.length)!="undefined"){for(e=0,b=d.length;e<b;e++){if(a.call(c,d[e],e,d)===false){return 0}}}else{for(e in d){if(d.hasOwnProperty(e)){if(a.call(c,d[e],e,d)===false){return 0}}}}return 1},getHash:function(c){var a=this.get(c),b;if(a){this.each(a.split("&"),function(d){d=d.split("=");b=b||{};b[d[0]]=d[1]})}return b},setHash:function(i,a,f,c,h,b){var g="";this.each(a,function(e,d){g+=(!g?"":"&")+d+"="+e});this.set(i,g,f,c,h,b)},get:function(h){var g=document.cookie,f,d=h+"=",a;if(!g){return}a=g.indexOf("; "+d);if(a==-1){a=g.indexOf(d);if(a!=0){return null}}else{a+=2}f=g.indexOf(";",a);if(f==-1){f=g.length}return decodeURIComponent(g.substring(a+d.length,f))},set:function(h,a,f,c,g,b){document.cookie=h+"="+encodeURIComponent(a)+((f)?"; expires="+f.toGMTString():"")+((c)?"; path="+c:"")+((g)?"; domain="+g:"")+((b)?"; secure":"")},remove:function(c,a){var b=new Date();b.setTime(b.getTime()-1000);this.set(c,"",b,a,b)}};function getUserSetting(a,b){var c=getAllUserSettings();if(c.hasOwnProperty(a)){return c[a]}if(typeof b!="undefined"){return b}return""}function setUserSetting(a,i,k){if("object"!==typeof userSettings){return false}var h="wp-settings-"+userSettings.uid,e=wpCookies.getHash(h)||{},g=new Date(),b,f=a.toString().replace(/[^A-Za-z0-9_]/,""),j=i.toString().replace(/[^A-Za-z0-9_]/,"");if(k){delete e[f]}else{e[f]=j}g.setTime(g.getTime()+31536000000);b=userSettings.url;wpCookies.setHash(h,e,g,b);wpCookies.set("wp-settings-time-"+userSettings.uid,userSettings.time,g,b);return a}function deleteUserSetting(a){return setUserSetting(a,"",1)}function getAllUserSettings(){if("object"!==typeof userSettings){return{}}return wpCookies.getHash("wp-settings-"+userSettings.uid)||{}}; 
     1var wpCookies={each:function(d,a,c){var e,b;if(!d){return 0}c=c||d;if(typeof(d.length)!="undefined"){for(e=0,b=d.length;e<b;e++){if(a.call(c,d[e],e,d)===false){return 0}}}else{for(e in d){if(d.hasOwnProperty(e)){if(a.call(c,d[e],e,d)===false){return 0}}}}return 1},getHash:function(c){var a=this.get(c),b;if(a){this.each(a.split("&"),function(d){d=d.split("=");b=b||{};b[d[0]]=d[1]})}return b},setHash:function(i,a,f,c,h,b){var g="";this.each(a,function(e,d){g+=(!g?"":"&")+d+"="+e});this.set(i,g,f,c,h,b)},get:function(h){var g=document.cookie,f,d=h+"=",a;if(!g){return}a=g.indexOf("; "+d);if(a==-1){a=g.indexOf(d);if(a!=0){return null}}else{a+=2}f=g.indexOf(";",a);if(f==-1){f=g.length}return decodeURIComponent(g.substring(a+d.length,f))},set:function(h,a,f,c,g,b){document.cookie=h+"="+encodeURIComponent(a)+((f)?"; expires="+f.toGMTString():"")+((c)?"; path="+c:"")+((g)?"; domain="+g:"")+((b)?"; secure":"")},remove:function(c,a){var b=new Date();b.setTime(b.getTime()-1000);this.set(c,"",b,a,b)}};function getUserSetting(a,b){var c=getAllUserSettings();if(c.hasOwnProperty(a)){return c[a]}if(typeof b!="undefined"){return b}return""}function setUserSetting(a,i,k){if("object"!==typeof userSettings){return false}var h="wp-settings-"+userSettings.uid,e=wpCookies.getHash(h)||{},g=new Date(),b,f=a.toString().replace(/[^A-Za-z0-9_]/,""),j=i.toString().replace(/[^A-Za-z0-9_]/,"");if(k){delete e[f]}else{e[f]=j}g.setTime(g.getTime()+31536000000);b=userSettings.url;wpCookies.setHash(h,e,g,b);wpCookies.set("wp-settings-time-"+userSettings.uid,userSettings.time,g,b);return a}function deleteUserSetting(a){return setUserSetting(a,"",1)}function getAllUserSettings(){if("object"!==typeof userSettings){return{}}return wpCookies.getHash("wp-settings-"+userSettings.uid)||{}}; 
  • trunk/wp-includes/class.wp-scripts.php

    r12559 r16282  
    184184            return true; 
    185185 
     186        if ( 0 === strpos( $src, '/wp-includes/js/l10n' ) ) 
     187            return false; 
     188             
    186189        foreach ( (array) $this->default_dirs as $test ) { 
    187190            if ( 0 === strpos($src, $test) ) 
  • trunk/wp-includes/script-loader.php

    r16274 r16282  
    5959    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; 
    6060 
    61     $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); 
     61    // Always ensure that we have the convertEntities function 
     62    $scripts->add( 'l10n', "/wp-includes/js/l10n$suffix.js", false, '20101110' ); 
     63    $scripts->enqueue( 'l10n' ); 
     64     
     65    $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' ); 
    6266 
    6367    $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20101007' ); 
     
    623627 
    624628    script_concat_settings(); 
     629    $wp_scripts->do_item( 'l10n' ); 
    625630    $wp_scripts->do_concat = $concatenate_scripts; 
    626631    $wp_scripts->do_head_items(); 
Note: See TracChangeset for help on using the changeset viewer.