Make WordPress Core

Changeset 4042


Ignore:
Timestamp:
07/25/2006 07:01:52 PM (19 years ago)
Author:
ryan
Message:

Admin AJAX tweaks from mdawaffe. fixes #2969

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r4041 r4042  
    1313function get_out_now() { exit; }
    1414add_action( 'shutdown', 'get_out_now', -1 );
    15 
    16 function wp_clean_ajax_input( $i ) {
    17     global $wpdb;
    18     $i = is_array($i) ? array_map('wp_clean_ajax_input', $i) : $wpdb->escape( rawurldecode(stripslashes($i)) );
    19     return $i;
    20 }
    2115
    2216function wp_ajax_echo_meta( $pid, $mid, $key, $value ) {
     
    3630}
    3731
    38 $_POST = wp_clean_ajax_input( $_POST );
    3932$id = (int) $_POST['id'];
    4033switch ( $_POST['action'] ) :
     
    225218    break;
    226219default :
     220    do_action( 'wp_ajax_' . $_POST['action'] );
    227221    die('0');
    228222    break;
  • trunk/wp-admin/list-manipulation-js.php

    r3847 r4042  
    22require_once('admin.php');
    33header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
     4$handler =  get_settings( 'siteurl' ) . '/wp-admin/admin-ajax.php';
    45?>
    56addLoadEvent(function(){theList=new listMan();});
     
    2829    WPAjax.prototype.init=function(f,r){
    2930        this.encVar('cookie', document.cookie);
    30         this.requestFile=f;this.getResponseElement(r);this.method='POST';
     31        this.requestFile=f?f:'<?php echo $handler; ?>';this.getResponseElement(r);this.method='POST';
    3132        this.onLoading=function(){this.myResponseElement.innerHTML="<?php _e('Sending Data...'); ?>";};
    3233        this.onLoaded=function(){this.myResponseElement.innerHTML="<?php _e('Data Sent...'); ?>";};
     
    3536
    3637function listMan(theListId){
    37     this.theList=null;
    38     this.ajaxRespEl=null;
     38    this.theList=null;this.theListId=theListId;
     39    this.ajaxRespEl=null;this.ajaxHandler='<?php echo $handler; ?>';
    3940    this.inputData='';this.clearInputs=new Array();this.showLink=1;
    4041    this.topAdder=0;this.alt='alternate';this.recolorPos;this.reg_color='#FFFFFF';this.alt_color='#F1F1F1';
     
    4546    this.ajaxAdder=function(what,where,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it
    4647        if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
    47         this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
     48        this.ajaxAdd=new WPAjax(this.ajaxHandler,this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
    4849        if(this.ajaxAdd.failed)return true;
    4950        this.grabInputs(where);
     
    5455            if(tempObj.topAdder)tempObj.recolorPos=0;
    5556            if(newItems){for (c=0;c<newItems.length;c++){
    56                 var id=parseInt(getNodeValue(newItems[c],'id'),10);
     57                var id=getNodeValue(newItems[c],'id');
    5758                var exists=document.getElementById(what+'-'+id);
    5859                if(exists)tempObj.replaceListItem(exists.id,getNodeValue(newItems[c],'newitem'),newItems.length,update);
     
    7273    this.ajaxDelete=function(what,id){
    7374        if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
    74         this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
     75        this.ajaxDel=new WPAjax(this.ajaxHandler,this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
    7576        if(this.ajaxDel.failed)return true;
    7677        var tempObj=this;
     
    8182    this.ajaxDimmer=function(what,id,dimClass){
    8283        if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
    83         this.ajaxDim=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
     84        this.ajaxDim=new WPAjax(this.ajaxHandler,this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
    8485        if(this.ajaxDim.failed)return true;
    8586        var tempObj=this;
     
    138139        if(this.theList)return;
    139140        listItems=new Array();
    140         if(theListId){this.theList=document.getElementById(theListId);if(!this.theList)return false;}
    141         else{this.theList=document.getElementById('the-list');if(this.theList)theListId='the-list';}
     141        if(this.theListId){this.theList=document.getElementById(this.theListId);if(!this.theList)return false;}
     142        else{this.theList=document.getElementById('the-list');if(this.theList)this.theListId='the-list';}
    142143        if(this.theList){
    143144            var items=this.theList.getElementsByTagName('tr');listType='table';
     
    156157    this.getListItems();
    157158}
    158 //No submit unless eval(code) returns true.
    159 function killSubmit(code,e){if(!e){if(window.event)e=window.event;else return;}var t=e.target?e.target:e.srcElement;if(('text'==t.type&&e.keyCode==13)||('submit'==t.type&&'click'==e.type)){if(!eval(code)){e.returnValue=false;e.cancelBubble=true;return false;}}}
    160 //Pretty func from ALA http://www.alistapart.com/articles/gettingstartedwithajax
    161 function getNodeValue(tree,el){return tree.getElementsByTagName(el)[0].firstChild.nodeValue;}
     159//No submit unless code returns true.
     160function killSubmit ( code, e ) {
     161    e = e ? e : window.event;
     162    if ( !e ) return;
     163    var t = e.target ? e.target : e.srcElement;
     164    if ( ( 'text' == t.type && e.keyCode == 13 ) || ( 'submit' == t.type && 'click' == e.type ) ) {
     165        if ( ( 'string' == typeof code && !eval(code) ) || 'function' == typeof code && !code() ) {
     166            if ( !eval(code) ) { e.returnValue = false; e.cancelBubble = true; return false; }
     167        }
     168    }
     169}
     170//Pretty func adapted from ALA http://www.alistapart.com/articles/gettingstartedwithajax
     171function getNodeValue(tree,el){try { var r = tree.getElementsByTagName(el)[0].firstChild.nodeValue; } catch(err) { var r = null; } return r; }
    162172//Generic but lame JS closure
    163173function encloseFunc(f){var a=arguments[1];return function(){return f(a);}}
  • trunk/wp-includes/script-loader.php

    r3930 r4042  
    2020        if ( is_admin() ) {
    2121            $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
    22             $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3850' ); // Make changeset # the correct one
     22            $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '4042' ); // Make changeset # the correct one
    2323            $this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
    2424            $this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
Note: See TracChangeset for help on using the changeset viewer.