Make WordPress Core

Ticket #3824: dashboard-users-01.diff

File dashboard-users-01.diff, 8.5 KB (added by aercolino, 18 years ago)

replaces jQuery to Prototype in pages: Dashboard; Users / Authors & Users - (based on trunk)

  • wp-admin/admin-ajax.php

     
    201201        die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
    202202        break;
    203203case 'add-user' :
    204         if ( !current_user_can('edit_users') )
    205                 die('-1');
     204        if ( !current_user_can('edit_users') ) {
     205                $x = new WP_Ajax_Response( array(
     206                        'what' => 'user',
     207                        'data' => new WP_Error( 'add_user', __( 'You are not allowed to add users to this blog.' ) )
     208                ) );
     209                $x->send();
     210                break;
     211        }       
    206212        require_once(ABSPATH . WPINC . '/registration.php');
    207         if ( !$user_id = add_user() )
    208                 die('0');
     213        if ( !$user_id = add_user() ) {
     214                $x = new WP_Ajax_Response( array(
     215                        'what' => 'user',
     216                        'data' => new WP_Error( 'add_user', __( 'Something strange happened.  Try refreshing the page.' ) )
     217                ) );
     218                $x->send();
     219                break;
     220        }
    209221        elseif ( is_wp_error( $user_id ) ) {
    210                 foreach( $user_id->get_error_messages() as $message )
    211                         echo "<p>$message<p>";
    212                 exit;
     222                $x = new WP_Ajax_Response( array(
     223                        'what' => 'user',
     224                        'data' => $user_id
     225                ) );
     226                $x->send();
     227                break;
    213228        }
    214229        $user_object = new WP_User( $user_id );
    215230        $x = new WP_Ajax_Response( array(
     
    220235        ) );
    221236        $x->send();
    222237        break;
     238       
    223239case 'autosave' : // The name of this action is hardcoded in edit_post()
    224240        $_POST['post_content'] = $_POST['content'];
    225241        $_POST['post_excerpt'] = $_POST['excerpt'];
  • wp-admin/admin-header.php

     
    2121<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
    2222<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
    2323<?php endif; ?>
    24 <script type="text/javascript">
    25 //<![CDATA[
    26 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
    27 //]]>
    28 </script>
    2924<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
    3025<style type="text/css">* html { overflow-x: hidden; }</style>
    3126<?php endif;
  • wp-admin/admin.php

     
    2828
    2929wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
    3030
     31wp_enqueue_script( 'jqwp' );
    3132wp_enqueue_script( 'fat' );
    3233
    3334$editing = false;
  • wp-admin/index.php

     
    44function index_js() {
    55?>
    66<script type="text/javascript">
    7 Event.observe( window, 'load', dashboard_init, false );
    8 function dashboard_init() {
    9         var update1 = new Ajax.Updater( 'incominglinks', 'index-extra.php?jax=incominglinks' );
    10         var update2 = new Ajax.Updater( 'devnews', 'index-extra.php?jax=devnews' );
    11         var update3 = new Ajax.Updater( 'planetnews', 'index-extra.php?jax=planetnews'  );
    12 }
     7jQuery( function() {
     8        jQuery( '#incominglinks' ).load( 'index-extra.php?jax=incominglinks' );
     9        jQuery( '#devnews' ).load( 'index-extra.php?jax=devnews' );
     10        jQuery( '#planetnews' ).load( 'index-extra.php?jax=planetnews' );
     11} );
    1312</script>
    1413<?php
    1514}
    1615add_action( 'admin_head', 'index_js' );
    17 wp_enqueue_script('prototype');
    18 wp_enqueue_script('interface');
    1916
    2017$title = __('Dashboard');
    2118$parent_file = 'index.php';
  • wp-admin/users-js.php

     
     1<?php
     2        @require_once('../wp-config.php');
     3        cache_javascript_headers();
     4?>
     5jQuery( function() {
     6        jQuery( '#adduser' ).submit( function() {
     7                var $role = jQuery( '#role-' + jQuery( '#role :selected' ).attr( 'value' ) );
     8                if( 0 == $role.length ) {
     9                        //html look and feel
     10                        return true;
     11                }
     12                else {
     13                        //ajax look and feel
     14                        jQuery(this)
     15                        .ajaxSubmit( {
     16                                url:          'admin-ajax.php',
     17                                dataType:     'XML',
     18                                beforeSubmit: function( data ) {
     19                                        for( var i = 0, top = data.length; i < top; i++ ) {
     20                                                if( data[ i ].name == 'action' ) {
     21                                                        data[ i ].value = 'add-user';
     22                                                        break;
     23                                                }
     24                                        }
     25                                        data.push( { name: 'cookie', value: encodeURIComponent(document.cookie) } );
     26                                        return true;
     27                                },
     28                                success:      function( responseXML ) {
     29                                        var     data = jQuery.wp.cdata( "wp_error", responseXML );
     30                                        if( 0 == data.length ) {
     31                                                data = jQuery.wp.cdata( "response_data", responseXML );
     32                                                if( data[0] && ( '' != data[0] ) ) {
     33                                                        var $item = jQuery( data[0] ).appendTo( $role );
     34                                                        if( $item.prev().attr( 'class' ) != 'alternate' ) {
     35                                                                $item.attr( 'class', 'alternate' );
     36                                                        }
     37                                                        jQuery( '#adduser' ).resetForm();
     38                                                        jQuery( '#ajax-response' ).html( '' );
     39                                                }
     40                                                else {
     41                                                        if( isNaN( responseXML ) ) {
     42                                                                jQuery( '#ajax-response' )
     43                                                                .html( "<div class='error'><p>" + responseXML + "</p></div>" );
     44                                                        }
     45                                                        var r = parseInt( responseXML, 10 );
     46                                                        if( -1 == r ) {
     47                                                                jQuery( '#ajax-response' )
     48                                                                .html( "<div class='error'><p><?php _e("You don't have permission to do that."); ?></p></div>" );
     49                                                        }
     50                                                        else if( 0 == r ) {
     51                                                                jQuery( '#ajax-response' )
     52                                                                .html( "<div class='error'><p><?php _e("Something strange happened.  Try refreshing the page."); ?></p></div>" );
     53                                                        }
     54                                                }
     55                                        }
     56                                        else {
     57                                                jQuery( '#ajax-response' )
     58                                                .html( "<div class='error'><p>" + data.join( "</p><p>" ) + "</p></div>" );
     59                                        }
     60                                }
     61                        } );
     62                        return false;
     63                }
     64    } );
     65} )
  • wp-includes/js/jquery/wp-glue.js

     
     1/*
     2this file glues jQuery to WordPress
     3*/
     4
     5//jQuery can coexist with other $ libraries
     6jQuery.noConflict();
     7
     8//the call of addLoadEvent( function ) and its semantics are the same as jQuery( function )
     9addLoadEvent = jQuery;
     10
     11jQuery.wp = {
     12        cdata: function( elementToFind, xml ) {
     13                var data = [];
     14                var re = /\<([\w-]+)(?:\w|\W)*?\>\<\!\[CDATA\[((?:\w|\W)*?)\]\]\>\<\/\1\s*\>/ig;
     15                xml.replace( re, function( all, elementFound, content ) {
     16                        if( elementFound == elementToFind ) {
     17                                data.push( content );
     18                        }
     19                } );
     20                return data;
     21        }
     22};
  • wp-includes/script-loader.php

     
    3030                $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0');
    3131                $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0');
    3232                $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118');
    33                 $this->add( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.1.1');
    34                 $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.1.1');
     33        $this->add( 'jquery', '/wp-includes/js/jquery/jquery-latest.pack.js', false, '1.1.2');
     34                $this->add( 'jqwp', '/wp-includes/js/jquery/wp-glue.js', array( 'jquery' ), '20070303' );
     35                $this->add( 'jqform', '/wp-includes/js/jquery/jquery.form.js', array( 'jqwp' ), '0.9' );
    3536                if ( is_admin() ) {
    3637                        $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
    3738                        $this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '20070118' );
    3839                        $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
    3940                        $this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
    4041                        $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
    41                         $this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' );
     42                        $this->add( 'admin-users', '/wp-admin/users-js.php', array('jqform'), '20070301' );
    4243                        $this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
    4344                        $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '20070118' );
    4445                }