/**
  * Delete Jetpack contact form messages
  *
  * @static
  * @since  5.3
  * @param array   $delete_options Options for deleting
  * @return int                   Number of posts that were deleted
  */
 public static function delete_jetpack_messages($delete_options)
 {
     $count = 0;
     $use_filter = $delete_options['use_filter'];
     $options = array('post_status' => 'publish', 'post_type' => self::FEEDBACK_POST_TYPE);
     $limit_to = $delete_options['limit_to'];
     if ($limit_to > 0) {
         $options['showposts'] = $limit_to;
     } else {
         $options['nopaging'] = 'true';
     }
     $force_delete = $delete_options['force_delete'];
     if ('true' == $force_delete) {
         $force_delete = true;
     } else {
         $force_delete = false;
     }
     if ('true' == $delete_options['restrict']) {
         $options['op'] = $delete_options['feedback_op'];
         $options['days'] = $delete_options['feedback_days'];
         if (!class_exists('Bulk_Delete_By_Days')) {
             require_once Bulk_Delete::$PLUGIN_DIR . '/include/util/class-bulk-delete-by-days.php';
         }
         new Bulk_Delete_By_Days();
     }
     $post_ids = bd_query($options);
     foreach ($post_ids as $post_id) {
         if ('true' == $use_filter) {
             /**
              * Process additional filters for deleting jetpack messages
              *
              * @since 5.3
              */
             $can_delete = apply_filters('bd_delete_jetpack_messages_can_delete', $delete_options, $post_id);
             if (!$can_delete) {
                 continue;
             }
         }
         // $force delete parameter to custom post types doesn't work
         if ($force_delete) {
             wp_delete_post($post_id, true);
         } else {
             wp_trash_post($post_id);
         }
         $count++;
     }
     return $count;
 }
 /**
  * Delete posts by custom post type.
  *
  * @static
  * @since  5.0
  * @param  array $delete_options Options for deleting posts
  * @return int   $posts_deleted  Number of posts that were deleted
  */
 public static function delete_posts_by_post_type($delete_options)
 {
     // Backward compatibility code. Will be removed in Bulk Delete v6.0
     if (array_key_exists('types_op', $delete_options)) {
         $delete_options['date_op'] = $delete_options['types_op'];
         $delete_options['days'] = $delete_options['types_days'];
     }
     $delete_options = apply_filters('bd_delete_options', $delete_options);
     $count = 0;
     $selected_types = $delete_options['selected_types'];
     foreach ($selected_types as $selected_type) {
         $type_status = BD_Util::split_post_type_status($selected_type);
         $type = $type_status['type'];
         $status = $type_status['status'];
         $options = array('post_status' => $status, 'post_type' => $type);
         $options = bd_build_query_options($delete_options, $options);
         $post_ids = bd_query($options);
         foreach ($post_ids as $post_id) {
             // $force delete parameter to custom post types doesn't work
             if ($delete_options['force_delete']) {
                 wp_delete_post($post_id, true);
             } else {
                 wp_trash_post($post_id);
             }
         }
         $count += count($post_ids);
     }
     return $count;
 }
 /**
  * Delete Post Meta.
  *
  * @static
  * @since  5.4
  * @param array   $delete_options Options for deleting
  * @return int                   Number of posts that were deleted
  */
 public static function delete_post_meta($delete_options)
 {
     $count = 0;
     $post_type = $delete_options['post_type'];
     $limit_to = $delete_options['limit_to'];
     $meta_key = $delete_options['meta_key'];
     $use_value = $delete_options['use_value'];
     $restrict = $delete_options['restrict'];
     $days = $delete_options['days'];
     $op = $delete_options['op'];
     $options = array('post_status' => 'publish', 'post_type' => $post_type);
     if ($limit_to > 0) {
         $options['showposts'] = $limit_to;
     } else {
         $options['nopaging'] = 'true';
     }
     if ($restrict) {
         $options['date_query'] = array(array('column' => 'post_date', $op => "{$days} day ago"));
     }
     if ($use_value) {
         $options['meta_query'] = apply_filters('bd_delete_post_meta_query', array(), $delete_options);
     } else {
         $options['meta_key'] = $meta_key;
     }
     $post_ids = bd_query($options);
     foreach ($post_ids as $post_id) {
         if (delete_post_meta($post_id, $meta_key)) {
             $count++;
         }
     }
     return $count;
 }