From 82b2d6ebf4c7a86ef1136f661855adba515c82c0 Mon Sep 17 00:00:00 2001 From: Juliette <663378+jrfnl@users.noreply.github.com> Date: Wed, 1 May 2019 16:13:50 +0200 Subject: [PATCH] Docs: fix comment punctuation (#54) --- tests/test-meta-revisions.php | 82 +++++++++++++++++------------------ wp-post-meta-revisions.php | 10 ++--- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/tests/test-meta-revisions.php b/tests/test-meta-revisions.php index 46e8cfe..2626d91 100644 --- a/tests/test-meta-revisions.php +++ b/tests/test-meta-revisions.php @@ -13,7 +13,7 @@ class MetaRevisionTests extends WP_UnitTestCase { /** - * Callback function to add the revisioned keys + * Callback function to add the revisioned keys. */ public function add_revisioned_keys( $keys ) { $keys[] = 'meta_revision_test'; @@ -28,11 +28,11 @@ public function add_revisioned_keys( $keys ) { * @dataProvider slashed_data_provider */ public function test_revisions_stores_meta_values_with_slashes( $passed, $expected ) { - // Set up a new post + // Set up a new post. $post_id = $this->factory->post->create(); $original_post_id = $post_id; - // And update to store an initial revision + // And update to store an initial revision. wp_update_post( array( 'post_content' => 'some initial content', @@ -41,11 +41,11 @@ public function test_revisions_stores_meta_values_with_slashes( $passed, $expect ); add_filter( 'wp_post_revision_meta_keys', array( $this, 'add_revisioned_keys' ) ); - // Store a custom meta value, which is not revisioned by default + // Store a custom meta value, which is not revisioned by default. update_post_meta( $post_id, 'meta_revision_test', wp_slash( $passed ) ); $this->assertEquals( $expected, get_post_meta( $post_id, 'meta_revision_test', true ) ); - // Update the post, storing a revision + // Update the post, storing a revision. wp_update_post( array( 'post_content' => 'some more content', @@ -53,9 +53,9 @@ public function test_revisions_stores_meta_values_with_slashes( $passed, $expect ) ); - // Overwrite + // Overwrite. update_post_meta( $post_id, 'meta_revision_test', 'original' ); - // Update the post, storing a revision + // Update the post, storing a revision. wp_update_post( array( 'post_content' => 'some more content again', @@ -63,10 +63,10 @@ public function test_revisions_stores_meta_values_with_slashes( $passed, $expect ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = (array) wp_get_post_revisions( $post_id ); - // Go back two to load the previous revision + // Go back two to load the previous revision. array_shift( $revisions ); $last_revision = array_shift( $revisions ); @@ -99,7 +99,7 @@ public function slashed_data_provider() { } /** - * Test the revisions system for storage of meta values + * Test the revisions system for storage of meta values. * * @group revision */ @@ -108,11 +108,11 @@ public function test_revisions_stores_meta_values() { * Set Up. */ - // Set up a new post + // Set up a new post. $post_id = $this->factory->post->create(); $original_post_id = $post_id; - // And update to store an initial revision + // And update to store an initial revision. wp_update_post( array( 'post_content' => 'some initial content', @@ -125,13 +125,13 @@ public function test_revisions_stores_meta_values() { $this->assertCount( 1, $revisions ); /* - * First set up a meta value + * First set up a meta value. */ - // Store a custom meta value, which is not revisioned by default + // Store a custom meta value, which is not revisioned by default. update_post_meta( $post_id, 'meta_revision_test', 'original' ); - // Update the post, storing a revision + // Update the post, storing a revision. wp_update_post( array( 'post_content' => 'some more content', @@ -142,7 +142,7 @@ public function test_revisions_stores_meta_values() { $revisions = wp_get_post_revisions( $post_id ); $this->assertCount( 2, $revisions ); - // Next, store some updated meta values for the same key. + // Next, store some updated meta values for the same key. update_post_meta( $post_id, 'meta_revision_test', 'update1' ); // Save the post, changing content to force a revision. @@ -157,13 +157,13 @@ public function test_revisions_stores_meta_values() { $this->assertCount( 3, $revisions ); /* - * Now restore the original revision + * Now restore the original revision. */ - // Restore the previous revision + // Restore the previous revision. $revisions = (array) wp_get_post_revisions( $post_id ); - // Go back two to load the previous revision + // Go back two to load the previous revision. array_shift( $revisions ); $last_revision = array_shift( $revisions ); @@ -178,19 +178,19 @@ public function test_revisions_stores_meta_values() { * Check the meta values to verify they are NOT revisioned - they are not revisioned by default. */ - // Custom post meta should NOT be restored, orignal value should not be restored, value still 'update1' + // Custom post meta should NOT be restored, orignal value should not be restored, value still 'update1'. $this->assertEquals( 'update1', get_post_meta( $post_id, 'meta_revision_test', true ) ); update_post_meta( $post_id, 'meta_revision_test', 'update2' ); /* - * Test the revisioning of custom meta when enabled by the wp_post_revision_meta_keys filter + * Test the revisioning of custom meta when enabled by the wp_post_revision_meta_keys filter. */ - // Add the custom field to be revised via the wp_post_revision_meta_keys filter + // Add the custom field to be revised via the wp_post_revision_meta_keys filter. add_filter( 'wp_post_revision_meta_keys', array( $this, 'add_revisioned_keys' ) ); - // Save the post, changing content to force a revision + // Save the post, changing content to force a revision. wp_update_post( array( 'post_content' => 'more updated content', @@ -201,14 +201,14 @@ public function test_revisions_stores_meta_values() { $revisions = wp_get_post_revisions( $post_id ); $this->assertCount( 5, $revisions ); - // Store custom meta values, which should now be revisioned + // Store custom meta values, which should now be revisioned. update_post_meta( $post_id, 'meta_revision_test', 'update3' ); /* - * Save the post again, custom meta should now be revisioned + * Save the post again, custom meta should now be revisioned. * * Note that a revision is saved even though there is no change - * in post content, because the revisioned post_meta has changed + * in post content, because the revisioned post_meta has changed. */ wp_update_post( array( @@ -216,17 +216,17 @@ public function test_revisions_stores_meta_values() { ) ); - // This revision contains the existing post meta ('update3') + // This revision contains the existing post meta ('update3'). $revisions = wp_get_post_revisions( $post_id ); $this->assertCount( 6, $revisions ); - // Verify that previous post meta is set + // Verify that previous post meta is set. $this->assertEquals( 'update3', get_post_meta( $post_id, 'meta_revision_test', true ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = wp_get_post_revisions( $post_id ); - // Go back two to load the previous revision + // Go back two to load the previous revision. array_shift( $revisions ); $last_revision = array_shift( $revisions ); wp_restore_post_revision( $last_revision->ID ); @@ -236,7 +236,7 @@ public function test_revisions_stores_meta_values() { */ $this->assertEquals( 'update2', get_post_meta( $post_id, 'meta_revision_test', true ) ); - // Try storing a blank meta + // Try storing a blank meta. update_post_meta( $post_id, 'meta_revision_test', '' ); wp_update_post( array( @@ -251,14 +251,14 @@ public function test_revisions_stores_meta_values() { ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = wp_get_post_revisions( $post_id ); array_shift( $revisions ); $last_revision = array_shift( $revisions ); wp_restore_post_revision( $last_revision->ID ); /* - * Verify that previous blank post meta is restored + * Verify that previous blank post meta is restored. */ $this->assertEquals( '', get_post_meta( $post_id, 'meta_revision_test', true ) ); @@ -267,7 +267,7 @@ public function test_revisions_stores_meta_values() { */ remove_all_filters( 'wp_post_revision_meta_keys' ); - // Meta should no longer be revisioned + // Meta should no longer be revisioned. update_post_meta( $post_id, 'meta_revision_test', 'update 5' ); wp_update_post( array( @@ -283,7 +283,7 @@ public function test_revisions_stores_meta_values() { ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = wp_get_post_revisions( $post_id ); array_shift( $revisions ); $last_revision = array_shift( $revisions ); @@ -294,26 +294,26 @@ public function test_revisions_stores_meta_values() { */ $this->assertEquals( 'update 6', get_post_meta( $post_id, 'meta_revision_test', true ) ); - // Add the custom field to be revised via the wp_post_revision_meta_keys filter + // Add the custom field to be revised via the wp_post_revision_meta_keys filter. add_filter( 'wp_post_revision_meta_keys', array( $this, 'add_revisioned_keys' ) ); /* - * Test the revisioning of multiple meta keys + * Test the revisioning of multiple meta keys. */ - // Add three values for meta + // Add three values for meta. update_post_meta( $post_id, 'meta_revision_test', 'update 7' ); add_post_meta( $post_id, 'meta_revision_test', 'update 7 number 2' ); add_post_meta( $post_id, 'meta_revision_test', 'update 7 number 3' ); wp_update_post( array( 'ID' => $post_id ) ); - // Update all three values + // Update all three values. update_post_meta( $post_id, 'meta_revision_test', 'update 8', 'update 7' ); update_post_meta( $post_id, 'meta_revision_test', 'update 8 number 2', 'update 7 number 2' ); update_post_meta( $post_id, 'meta_revision_test', 'update 8 number 3', 'update 7 number 3' ); wp_update_post( array( 'ID' => $post_id ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = wp_get_post_revisions( $post_id ); array_shift( $revisions ); $last_revision = array_shift( $revisions ); @@ -359,7 +359,7 @@ public function test_revisions_stores_meta_values() { // Update to save. wp_update_post( array( 'ID' => $post_id ) ); - // Restore the previous revision + // Restore the previous revision. $revisions = wp_get_post_revisions( $post_id ); array_shift( $revisions ); $last_revision = array_shift( $revisions ); diff --git a/wp-post-meta-revisions.php b/wp-post-meta-revisions.php index f1ba24c..f5d7e2c 100644 --- a/wp-post-meta-revisions.php +++ b/wp-post-meta-revisions.php @@ -22,11 +22,11 @@ class WP_Post_Meta_Revisioning { /** - * Set up the plugin actions + * Set up the plugin actions. */ public function __construct() { - // Actions + // Actions. // // When restoring a revision, also restore that revisions's revisioned meta. add_action( 'wp_restore_post_revision', array( $this, '_wp_restore_post_revision_meta' ), 10, 2 ); @@ -38,7 +38,7 @@ public function __construct() { // When creating a revision, also save any revisioned meta. add_action( '_wp_put_post_revision', array( $this, '_wp_save_revisioned_meta_fields' ) ); - //Filters + // Filters. // When revisioned post meta has changed, trigger a revision save. add_filter( 'wp_save_post_revision_post_has_changed', array( $this, '_wp_check_revisioned_meta_fields_have_changed' ), 10, 3 ); @@ -166,9 +166,9 @@ public function _wp_restore_post_revision_meta( $post_id, $revision_id ) { $metas_revisioned = $this->_wp_post_revision_meta_keys(); if ( isset( $metas_revisioned ) && 0 !== count( $metas_revisioned ) ) { foreach ( $metas_revisioned as $meta_key ) { - // Clear any existing metas + // Clear any existing metas. delete_post_meta( $post_id, $meta_key ); - // Get the stored meta, not stored === blank + // Get the stored meta, not stored === blank. $meta_values = get_post_meta( $revision_id, $meta_key, true ); if ( 0 !== count( $meta_values ) && is_array( $meta_values ) ) { foreach ( $meta_values as $meta_value ) {