예제 #1
0
 /**
  * AJAX handler for adding custom background context to an attachment.
  *
  * Triggered when the user adds a new background image from the
  * Media Manager.
  *
  * @since 0.0.1
  */
 public function ajax_background_add()
 {
     check_ajax_referer('background-add', 'nonce');
     if (!current_user_can('edit_theme_options')) {
         hq_send_json_error();
     }
     $attachment_id = absint($_POST['attachment_id']);
     if ($attachment_id < 1) {
         hq_send_json_error();
     }
     update_post_meta($attachment_id, '_hq_attachment_is_custom_background', get_stylesheet());
     hq_send_json_success();
 }
예제 #2
0
 /**
  * Given an attachment ID for a header image, unsets it as a user-uploaded
  * header image for the current theme.
  *
  * Triggered when the user clicks the overlay "X" button next to each image
  * choice in the Customizer's Header tool.
  */
 public function ajax_header_remove()
 {
     check_ajax_referer('header-remove', 'nonce');
     if (!current_user_can('edit_theme_options')) {
         hq_send_json_error();
     }
     $attachment_id = absint($_POST['attachment_id']);
     if ($attachment_id < 1) {
         hq_send_json_error();
     }
     $key = '_hq_attachment_custom_header_last_used_' . get_stylesheet();
     delete_post_meta($attachment_id, $key);
     delete_post_meta($attachment_id, '_hq_attachment_is_custom_header', get_stylesheet());
     hq_send_json_success();
 }