// Validate title.
$changeset_title = null;
if ( isset( $_POST['customize_changeset_title'
] ) ) { $changeset_title =
sanitize_text_field( wp_unslash( $_POST['customize_changeset_title'
] ) );
} // Validate changeset status param.
$is_publish = null;
$changeset_status = null;
if ( isset( $_POST['customize_changeset_status'
] ) ) { $changeset_status =
wp_unslash( $_POST['customize_changeset_status'
] );
if ( !
get_post_status_object( $changeset_status ) || !
in_array( $changeset_status, array
( 'draft', 'pending', 'publish', 'future'
), true
) ) { wp_send_json_error( 'bad_customize_changeset_status', 400
);
} $is_publish =
( 'publish' ===
$changeset_status || 'future' ===
$changeset_status );
if ( $is_publish && !
current_user_can( get_post_type_object( 'customize_changeset'
)->cap->publish_posts
) ) { wp_send_json_error( 'changeset_publish_unauthorized', 403
);
} } /*
* Validate changeset date param. Date is assumed to be in local time for
* the WP if in MySQL format (YYYY-MM-DD HH:MM:SS). Otherwise, the date
* is parsed with strtotime() so that ISO date format may be supplied
* or a string like "+10 minutes".
*/