@@ 1269-1286 (lines=18) @@ | ||
1266 | * |
|
1267 | * @since 3.9.0 |
|
1268 | */ |
|
1269 | public function ajax_header_add() { |
|
1270 | check_ajax_referer( 'header-add', 'nonce' ); |
|
1271 | ||
1272 | if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1273 | wp_send_json_error(); |
|
1274 | } |
|
1275 | ||
1276 | $attachment_id = absint( $_POST['attachment_id'] ); |
|
1277 | if ( $attachment_id < 1 ) { |
|
1278 | wp_send_json_error(); |
|
1279 | } |
|
1280 | ||
1281 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1282 | update_post_meta( $attachment_id, $key, time() ); |
|
1283 | update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1284 | ||
1285 | wp_send_json_success(); |
|
1286 | } |
|
1287 | ||
1288 | /** |
|
1289 | * Given an attachment ID for a header image, unsets it as a user-uploaded |
|
@@ 1297-1314 (lines=18) @@ | ||
1294 | * |
|
1295 | * @since 3.9.0 |
|
1296 | */ |
|
1297 | public function ajax_header_remove() { |
|
1298 | check_ajax_referer( 'header-remove', 'nonce' ); |
|
1299 | ||
1300 | if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1301 | wp_send_json_error(); |
|
1302 | } |
|
1303 | ||
1304 | $attachment_id = absint( $_POST['attachment_id'] ); |
|
1305 | if ( $attachment_id < 1 ) { |
|
1306 | wp_send_json_error(); |
|
1307 | } |
|
1308 | ||
1309 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
|
1310 | delete_post_meta( $attachment_id, $key ); |
|
1311 | delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1312 | ||
1313 | wp_send_json_success(); |
|
1314 | } |
|
1315 | ||
1316 | /** |
|
1317 | * Updates the last-used postmeta on a header image attachment after saving a new header image via the Customizer. |