wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
wp_ajax_get_revision_diffs › WordPress Function
Depuis3.6.0
Dépréciéen/a
› wp_ajax_get_revision_diffs ( Pas de paramètres )
Défini(e) dans: |
|
Codex: |
Handles getting revision diffs via AJAX.
Fonctions en relation: wp_get_revision_ui_diff, wp_get_post_revisions, wp_ajax_destroy_sessions, wp_ajax_get_comments, wp_ajax_imgedit_preview
Source
function wp_ajax_get_revision_diffs() { require ABSPATH . 'wp-admin/includes/revision.php'; $post = get_post( (int) $_REQUEST['post_id'] ); if ( ! $post ) { wp_send_json_error(); } if ( ! current_user_can( 'edit_post', $post->ID ) ) { wp_send_json_error(); } // Really just pre-loading the cache here. $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ); if ( ! $revisions ) { wp_send_json_error(); } $return = array(); if ( function_exists( 'set_time_limit' ) ) { set_time_limit( 0 ); } foreach ( $_REQUEST['compare'] as $compare_key ) { list( $compare_from, $compare_to ) = explode( ':', $compare_key ); // from:to $return[] = array( 'id' => $compare_key, 'fields' => wp_get_revision_ui_diff( $post, $compare_from, $compare_to ), ); } wp_send_json_success( $return ); }