~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-includes/js/wp-util.js

  • Committer: Barry Price
  • Date: 2016-08-17 04:49:28 UTC
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: barry.price@canonical.com-20160817044928-viijiwb4tl8jwzmp
new upstream release 4.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
                        };
31
31
 
32
32
                return function ( data ) {
33
 
                        compiled = compiled || _.template( $( '#tmpl-' + id ).html(), null, options );
 
33
                        compiled = compiled || _.template( $( '#tmpl-' + id ).html(),  options );
34
34
                        return compiled( data );
35
35
                };
36
36
        });
48
48
                 *
49
49
                 * Sends a POST request to WordPress.
50
50
                 *
51
 
                 * @param  {string} action The slug of the action to fire in WordPress.
52
 
                 * @param  {object} data   The data to populate $_POST with.
 
51
                 * @param  {(string|object)} action  The slug of the action to fire in WordPress or options passed
 
52
                 *                                   to jQuery.ajax.
 
53
                 * @param  {object=}         data    Optional. The data to populate $_POST with.
53
54
                 * @return {$.promise}     A jQuery promise that represents the request,
54
55
                 *                         decorated with an abort() method.
55
56
                 */
64
65
                 *
65
66
                 * Sends a POST request to WordPress.
66
67
                 *
67
 
                 * @param  {string} action  The slug of the action to fire in WordPress.
68
 
                 * @param  {object} options The options passed to jQuery.ajax.
 
68
                 * @param  {(string|object)} action  The slug of the action to fire in WordPress or options passed
 
69
                 *                                   to jQuery.ajax.
 
70
                 * @param  {object=}         options Optional. The options passed to jQuery.ajax.
69
71
                 * @return {$.promise}      A jQuery promise that represents the request,
70
72
                 *                          decorated with an abort() method.
71
73
                 */
96
98
 
97
99
                                // Use with PHP's wp_send_json_success() and wp_send_json_error()
98
100
                                deferred.jqXHR = $.ajax( options ).done( function( response ) {
99
 
                                        // Treat a response of `1` as successful for backwards
100
 
                                        // compatibility with existing handlers.
 
101
                                        // Treat a response of 1 as successful for backward compatibility with existing handlers.
101
102
                                        if ( response === '1' || response === 1 )
102
103
                                                response = { success: true };
103
104