|
@@ 1261-1278 (lines=18) @@
|
| 1258 |
|
* Triggered when the user tries adds a new header image from the |
| 1259 |
|
* Media Manager, even if s/he doesn't save that change. |
| 1260 |
|
*/ |
| 1261 |
|
public function ajax_header_add() { |
| 1262 |
|
check_ajax_referer( 'header-add', 'nonce' ); |
| 1263 |
|
|
| 1264 |
|
if ( ! current_user_can( 'edit_theme_options' ) ) { |
| 1265 |
|
wp_send_json_error(); |
| 1266 |
|
} |
| 1267 |
|
|
| 1268 |
|
$attachment_id = absint( $_POST['attachment_id'] ); |
| 1269 |
|
if ( $attachment_id < 1 ) { |
| 1270 |
|
wp_send_json_error(); |
| 1271 |
|
} |
| 1272 |
|
|
| 1273 |
|
$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
| 1274 |
|
update_post_meta( $attachment_id, $key, time() ); |
| 1275 |
|
update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
| 1276 |
|
|
| 1277 |
|
wp_send_json_success(); |
| 1278 |
|
} |
| 1279 |
|
|
| 1280 |
|
/** |
| 1281 |
|
* Given an attachment ID for a header image, unsets it as a user-uploaded |
|
@@ 1287-1304 (lines=18) @@
|
| 1284 |
|
* Triggered when the user clicks the overlay "X" button next to each image |
| 1285 |
|
* choice in the Customizer's Header tool. |
| 1286 |
|
*/ |
| 1287 |
|
public function ajax_header_remove() { |
| 1288 |
|
check_ajax_referer( 'header-remove', 'nonce' ); |
| 1289 |
|
|
| 1290 |
|
if ( ! current_user_can( 'edit_theme_options' ) ) { |
| 1291 |
|
wp_send_json_error(); |
| 1292 |
|
} |
| 1293 |
|
|
| 1294 |
|
$attachment_id = absint( $_POST['attachment_id'] ); |
| 1295 |
|
if ( $attachment_id < 1 ) { |
| 1296 |
|
wp_send_json_error(); |
| 1297 |
|
} |
| 1298 |
|
|
| 1299 |
|
$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
| 1300 |
|
delete_post_meta( $attachment_id, $key ); |
| 1301 |
|
delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
| 1302 |
|
|
| 1303 |
|
wp_send_json_success(); |
| 1304 |
|
} |
| 1305 |
|
|
| 1306 |
|
/** |
| 1307 |
|
* |