| 1 |
<?php |
| 2 |
|
| 3 |
namespace TUTOR; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) |
| 6 |
exit; |
| 7 |
|
| 8 |
|
| 9 |
class Tools { |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
add_action('tutor_once_in_day_run_schedule', array($this, 'delete_auto_draft_posts')); |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Delete draft question schedule basis |
| 17 |
*/ |
| 18 |
public function delete_auto_draft_posts() { |
| 19 |
global $wpdb; |
| 20 |
|
| 21 |
$draft_questions_ids = $wpdb->get_col("SELECT ID from {$wpdb->posts} WHERE post_type = 'tutor_question' AND post_status = 'auto-draft' "); |
| 22 |
if (is_array($draft_questions_ids) && count($draft_questions_ids)){ |
| 23 |
foreach ($draft_questions_ids as $draft_questions_id){ |
| 24 |
wp_delete_post($draft_questions_id, true); |
| 25 |
} |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
} |