Make WordPress Core

Ticket #12400: 12400.2.diff

File 12400.2.diff, 2.7 KB (added by Denis-de-Bernardy, 15 years ago)
  • wp-includes/link-template.php

     
    20152015        echo "<link rel='canonical' href='$link' />\n";
    20162016}
    20172017
    2018 ?>
     2018/**
     2019 * Prints the ajax url on the front end
     2020 *
     2021 * @since 3.0
     2022 **/
     2023function _wp_ajaxurl() {
     2024        echo '<script type="text/javascript">',
     2025                "var ajaxurl = '", site_url('wp-ajax.php'), "';",
     2026                '</script>';
     2027}
     2028
     2029/**
     2030 * Hooks _wp_ajaxurl() to wp_head
     2031 *
     2032 * @since 3.0
     2033 **/
     2034
     2035function wp_ajaxurl() {
     2036        add_action('wp_head', '_wp_ajaxurl', 1);
     2037}
     2038?>
     2039 No newline at end of file
  • wp-ajax.php

     
     1<?php
     2/**
     3 * Execute an AJAX action.
     4 *
     5 * To take full advantage of this file, call wp_ajaxurl(); in your theme
     6 * or plugin while registering your front-end scripts. Doing so will make
     7 * an ajaxurl variable available for use in javascripts. The ajaxurl
     8 * variable will point to this file's absolute URL.
     9 *
     10 * In the admin area, an ajaxurl variable is always available, and points
     11 * to wp-admin/admin-ajax.php instead - with slightly different hooks.
     12 *
     13 * @since 3.0
     14 */
     15define('DOING_AJAX', true);
     16require_once('wp-load.php');
     17
     18@header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     19
     20do_action('ajax_init');
     21
     22$action = !empty($_REQUEST['action']) ? stripslashes($_REQUEST['action']) : false;
     23
     24if ( !$action || ! has_action('ajax_' . $action) ) {
     25        status_header(400); // invalid request
     26        exit;
     27}
     28
     29do_action('ajax_' . $action);
     30?>
     31 No newline at end of file
  • wp-admin/admin-ajax.php

    Property changes on: wp-ajax.php
    ___________________________________________________________________
    Added: svn:eol-style
       + native
    
     
    4343        }
    4444
    4545        if ( !empty( $_REQUEST['action'] ) )
    46                 do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
     46                do_action( 'wp_ajax_nopriv_' . stripslashes($_REQUEST['action']) );
    4747
    4848        die('-1');
    4949}
     
    136136        die( $return );
    137137        break;
    138138default :
    139         do_action( 'wp_ajax_' . $_GET['action'] );
     139        if ( !empty($_GET['action']) )
     140                do_action( 'wp_ajax_' . stripslashes($_GET['action']) );
    140141        die('0');
    141142        break;
    142143endswitch;
     
    14141415        }
    14151416        die( '0' );
    14161417default :
    1417         do_action( 'wp_ajax_' . $_POST['action'] );
     1418        if ( !empty($_POST['action']) )
     1419                do_action( 'wp_ajax_' . stripslashes($_POST['action']) );
    14181420        die('0');
    14191421        break;
    14201422endswitch;