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

Add hooks to support customize-concurrency plugin. #87

Merged
merged 3 commits into from
Aug 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/customize-snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
}
} );

request.done( function() {
request.done( function( response ) {
var url = api.previewer.previewUrl(),
regex = new RegExp( '([?&])customize_snapshot_uuid=.*?(&|$)', 'i' ),
notFound = -1,
Expand Down Expand Up @@ -590,7 +590,8 @@
api.trigger( 'customize-snapshots-update', {
previewUrl: url,
customizeUrl: customizeUrl,
uuid: component.data.uuid
uuid: component.data.uuid,
response: response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Adds parity with the save event.

} );
} );

Expand Down
7 changes: 7 additions & 0 deletions php/class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,11 @@ public function handle_update_snapshot_request() {
) );
}

/**
* Add any additional checks before saving snapshot.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing @param tags.

*/
do_action( 'customize_snapshot_save_before', $this->snapshot, $this->customize_manager );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this action is specific to snapshots, I think $this->customize_manager should be replaced with just $this, the Customize_Snapshot_Manager.


// Set the snapshot UUID.
$post_type = get_post_type_object( Post_Type::SLUG );
$authorized = ( $post ?
Expand Down Expand Up @@ -1181,6 +1186,8 @@ function( $value ) {
wp_send_json_error( $data );
}

/** This filter is documented in wp-includes/class-wp-customize-manager.php */
$data = apply_filters( 'customize_save_response', $data, $this );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite, as $this is CustomizeSnapshots\Customize_Snapshot_Manager not WP_Customize_Manager. So you should replace $this with $this->customize_manager.

wp_send_json_success( $data );
}

Expand Down