On this page
WP_Customize_Manager::handle_override_changeset_lock_request()
Removes changeset lock when take over request is sent via Ajax.
Source
File: wp-includes/class-wp-customize-manager.php. View all references
public function handle_override_changeset_lock_request() {
if ( ! $this->is_preview() ) {
wp_send_json_error( 'not_preview', 400 );
}
if ( ! check_ajax_referer( 'customize_override_changeset_lock', 'nonce', false ) ) {
wp_send_json_error(
array(
'code' => 'invalid_nonce',
'message' => __( 'Security check failed.' ),
)
);
}
$changeset_post_id = $this->changeset_post_id();
if ( empty( $changeset_post_id ) ) {
wp_send_json_error(
array(
'code' => 'no_changeset_found_to_take_over',
'message' => __( 'No changeset found to take over' ),
)
);
}
if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) {
wp_send_json_error(
array(
'code' => 'cannot_remove_changeset_lock',
'message' => __( 'Sorry, you are not allowed to take over.' ),
)
);
}
$this->set_changeset_lock( $changeset_post_id, true );
wp_send_json_success( 'changeset_taken_over' );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Customize_Manager::set_changeset_lock() wp-includes/class-wp-customize-manager.php | Marks the changeset post as being currently edited by the current user. |
| WP_Customize_Manager::changeset_post_id() wp-includes/class-wp-customize-manager.php | Gets the changeset post ID for the loaded changeset. |
| WP_Customize_Manager::is_preview() wp-includes/class-wp-customize-manager.php | Determines whether it is a theme preview or not. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| check_ajax_referer() wp-includes/pluggable.php | Verifies the Ajax request to prevent processing requests external of the blog. |
| wp_send_json_error() wp-includes/functions.php | Sends a JSON response back to an Ajax request, indicating failure. |
| wp_send_json_success() wp-includes/functions.php | Sends a JSON response back to an Ajax request, indicating success. |
| get_post_type_object() wp-includes/post.php | Retrieves a post type object by name. |
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/handle_override_changeset_lock_request