Caldera_Forms_Entry_Bulk

Bulk actions for entries.

Defined (1)

The class is defined in the following location(s).

/classes/entry/bulk.php  
  1. class Caldera_Forms_Entry_Bulk { 
  2.  
  3. /** 
  4. * Delete all entry data for an array of entries 
  5. * @since 1.4.0 
  6. * @param array $entry_ids Array of entries to delete 
  7. * @return false|int 
  8. */ 
  9. public static function delete_entries( $entry_ids ) { 
  10.  
  11. global $wpdb; 
  12. $result = $wpdb->query( "DELETE FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `id` IN (" . implode( ', ', $entry_ids ) . ");" ); 
  13. $result = $wpdb->query( "DELETE FROM `" . $wpdb->prefix . "cf_form_entry_values` WHERE `entry_id` IN (" . implode( ', ', $entry_ids ) . ");" ); 
  14. $result = $wpdb->query( "DELETE FROM `" . $wpdb->prefix . "cf_form_entry_meta` WHERE `entry_id` IN (" . implode( ', ', $entry_ids ) . ");" ); 
  15.  
  16. /** 
  17. * Fires after Caldera Forms entries are deleted 
  18. * @since 1.5.0.9 
  19. * @param array $entry_ids Array of entries that were deleted 
  20. */ 
  21. do_action( 'caldera_forms_delete_entries', $entry_ids ); 
  22.  
  23. return $result; 
  24.  
  25.  
  26. /** 
  27. * Update status for an array of entries 
  28. * @since 1.4.0 
  29. * @param array $entry_ids Array of entries to change 
  30. * @param string $status New status 
  31. * @return false|int 
  32. */ 
  33. public static function change_status( $entry_ids, $status ) { 
  34. global $wpdb; 
  35. $result = $wpdb->query( $wpdb->prepare( "UPDATE `" . $wpdb->prefix . "cf_form_entries` SET `status` = %s WHERE `id` IN (" . implode( ', ', $entry_ids ) . ");", $status ) ); 
  36.  
  37. /** 
  38. * Fires after selected entries' status is updated 
  39. * @since 1.5.0.9 
  40. * @param array $entry_ids Array of entries changed 
  41. * @param string $status New status 
  42. */ 
  43. do_action( 'caldera_forms_change_entry_status', $entry_ids, $status ); 
  44.  
  45. return $result; 
  46.  
  47.  
  48. /** 
  49. * Get entry count by status 
  50. * @since 1.4.0 
  51. * @param string $form_id Form ID 
  52. * @param string $status Status 
  53. * @return int 
  54. */ 
  55. public static function count( $form_id, $status = 'active' ) { 
  56. global $wpdb; 
  57. if ( false == $status ) { 
  58. $sql = $wpdb->prepare( "SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s", $form_id ); 
  59. }else{ 
  60. $sql = $wpdb->prepare( "SELECT COUNT(`id`) AS `total` FROM `" . $wpdb->prefix . "cf_form_entries` WHERE `form_id` = %s AND `status` = %s;", $form_id, $status ); 
  61. $total = $wpdb->get_var( $sql ); 
  62.  
  63. return (int) $total; 
  64.