Skip to content
Snippets Groups Projects

Unit tests and coding standards

Merged Erick Hitter requested to merge fix/2-phpcs-phpunit into master
Files
4
@@ -290,7 +290,7 @@ class WP_Revisions_Control {
// A bit of JS for us.
$handle = 'wp-revisions-control-post';
wp_enqueue_script( $handle, plugins_url( 'js/post.js', __FILE__ ), array( 'jquery' ), '20131205', true );
wp_enqueue_script( $handle, plugins_url( 'js/post.js', __DIR__ ), array( 'jquery' ), '20131205', true );
wp_localize_script(
$handle,
$this->settings_section,
@@ -362,29 +362,43 @@ class WP_Revisions_Control {
// Request is valid if $response is still empty, as no errors arose above.
if ( empty( $response ) ) {
$revisions = wp_get_post_revisions( $post_id );
$response = $this->do_purge_all( $post_id );
}
$count = count( $revisions );
// Pass the response back to JS.
echo json_encode( $response );
exit;
}
foreach ( $revisions as $revision ) {
wp_delete_post_revision( $revision->ID );
}
/**
* Remove all revisions from a given post ID.
*
* @param int $post_id Post ID to purge of revisions.
* @return array
*/
public function do_purge_all( $post_id ) {
$response = array();
$response['success'] = sprintf(
/* translators: 1. Number of removed revisions, already formatted for locale. */
esc_html__(
'Removed %1$s revisions associated with this post.',
'wp_revisions_control'
),
number_format_i18n( $count, 0 )
);
$revisions = wp_get_post_revisions( $post_id );
$count = count( $revisions );
$response['count'] = $count;
foreach ( $revisions as $revision ) {
wp_delete_post_revision( $revision->ID );
}
// Pass the response back to JS.
echo json_encode( $response );
exit;
$response['success'] = sprintf(
/* translators: 1. Number of removed revisions, already formatted for locale. */
esc_html__(
'Removed %1$s revisions associated with this post.',
'wp_revisions_control'
),
number_format_i18n( $count, 0 )
);
$response['count'] = $count;
return $response;
}
/**
Loading