wp_ajax_get_revision_diffs

Ajax handler for getting revision diffs.

Description

wp_ajax_get_revision_diffs(); 

Usage

  1. if ( !function_exists( 'wp_ajax_get_revision_diffs' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_get_revision_diffs(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_get_revision_diffs() { 
  2. require ABSPATH . 'wp-admin/includes/revision.php'; 
  3.  
  4. if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) 
  5.  
  6. if ( ! current_user_can( 'edit_post', $post->ID ) ) 
  7.  
  8. // Really just pre-loading the cache here. 
  9. if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) 
  10.  
  11. $return = array(); 
  12. @set_time_limit( 0 ); 
  13.  
  14. foreach ( $_REQUEST['compare'] as $compare_key ) { 
  15. list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to 
  16.  
  17. $return[] = array( 
  18. 'id' => $compare_key,  
  19. 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ),  
  20. ); 
  21. wp_send_json_success( $return );