Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge d22d95c into 856d135
Browse files Browse the repository at this point in the history
  • Loading branch information
lgedeon committed Aug 21, 2016
2 parents 856d135 + d22d95c commit 41a6b5d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions php/class-customize-snapshot.php
Expand Up @@ -294,10 +294,11 @@ public function save( array $args ) {
/**
* Filter the snapshot's data before it's saved to 'post_content'.
*
* @param array $data Customizer snapshot data, with setting IDs mapped to an array
* containing a `value` array item and potentially other metadata.
* @param array $data Customizer snapshot data, with setting IDs mapped to an array
* containing a `value` array item and potentially other metadata.
* @param Customize_Snapshot $this Snapshot object.
*/
$this->data = apply_filters( 'customize_snapshot_save', $this->data );
$this->data = apply_filters( 'customize_snapshot_save', $this->data, $this );

$result = $this->snapshot_manager->post_type->save( array_merge(
$args,
Expand Down
21 changes: 21 additions & 0 deletions tests/php/test-class-customize-snapshot.php
Expand Up @@ -323,4 +323,25 @@ function test_saved() {
'data' => array( 'foo' => array( 'value' => 'bar' ) ),
) );
}

/**
* Test that the snapshot object is passed as the second filter param.
*
* @see Customize_Snapshot::save()
*/
function test_filter_customize_snapshot_save() {
$manager = new Customize_Snapshot_Manager( $this->plugin );
$manager->init();

$snapshot = new Customize_Snapshot( $manager, self::UUID );

add_filter( 'customize_snapshot_save', function( $data, $test_snapshot ) use ( $snapshot ) {
$this->assertEquals( $test_snapshot, $snapshot );
}, 10, 2 );

$snapshot->save( array(
'uuid' => self::UUID,
'data' => array( 'foo' => array( 'value' => 'bar' ) ),
) );
}
}

0 comments on commit 41a6b5d

Please sign in to comment.