Custom_Background::ajax_background_add()
最后更新于:2021-11-25 19:27:00
Custom_Background::ajax_background_add()Ajax handler for adding custom background context to an attachment.
源文件
文件: gc-admin/includes/class-custom-background.php
public function ajax_background_add() {
check_ajax_referer( 'background-add', 'nonce' );
if ( ! current_user_can( 'edit_theme_options' ) ) {
gc_send_json_error();
}
$attachment_id = absint( $_POST['attachment_id'] );
if ( $attachment_id < 1 ) {
gc_send_json_error();
}
update_post_meta( $attachment_id, '_gc_attachment_is_custom_background', get_stylesheet() );
gc_send_json_success();
}