]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blobdiff - wp-admin/js/custom-fields.js
Wordpress 3.5
[autoinstallsdev/wordpress.git] / wp-admin / js / custom-fields.js
index 8f2b1a59cf81d3df6376b7dc47800b433dccb38a..9eab214553ddacb770d4465c02a4273b19810da9 100644 (file)
@@ -1,27 +1,28 @@
-jQuery( function($) {
-       var before = function() {
-               var nonce = $('#newmeta [@name=_ajax_nonce]').val();
-               var postId = $('#post_ID').val();
+jQuery(document).ready( function($) {
+       var before, addBefore, addAfter, delBefore;
+
+       before = function() {
+               var nonce = $('#newmeta [name="_ajax_nonce"]').val(), postId = $('#post_ID').val();
                if ( !nonce || !postId ) { return false; }
                return [nonce,postId];
        }
 
-       var addBefore = function( s ) {
+       addBefore = function( s ) {
                var b = before();
                if ( !b ) { return false; }
                s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1];
                return s;
        };
 
-       var addAfter = function( r, s ) {
-               var postId = $('postid', r).text();
+       addAfter = function( r, s ) {
+               var postId = $('postid', r).text(), h;
                if ( !postId ) { return; }
                $('#post_ID').attr( 'name', 'post_ID' ).val( postId );
-               var h = $('#hiddenaction');
+               h = $('#hiddenaction');
                if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); }
        };
 
-       var delBefore = function( s ) {
+       delBefore = function( s ) {
                var b = before(); if ( !b ) return false;
                s.data._ajax_nonce = b[0]; s.data.post_id = b[1];
                return s;