golden hour
/var/www/html/wp-content/plugins/the-events-calendar/src/Tribe
⬆️ Go Up
Upload
File/Folder
Size
Actions
API.php
27.83 KB
Del
OK
Adjacent_Events.php
9.13 KB
Del
OK
Admin
-
Del
OK
Admin_List.php
14.59 KB
Del
OK
Aggregator
-
Del
OK
Aggregator.php
16.7 KB
Del
OK
Ajax
-
Del
OK
Amalgamator.php
8.86 KB
Del
OK
Assets.php
19.96 KB
Del
OK
Backcompat.php
2.79 KB
Del
OK
Bar.php
3.28 KB
Del
OK
Capabilities.php
5.56 KB
Del
OK
Collections
-
Del
OK
Constants.php
1.64 KB
Del
OK
Cost_Utils.php
4.81 KB
Del
OK
Customizer
-
Del
OK
Dates
-
Del
OK
Deactivation.php
1.31 KB
Del
OK
Default_Values.php
793 B
Del
OK
Editor
-
Del
OK
Editor.php
16.92 KB
Del
OK
Embedded_Maps.php
5.37 KB
Del
OK
Event_Cleaner.php
2.59 KB
Del
OK
Event_Cleaner_Scheduler.php
5.95 KB
Del
OK
Event_Tickets
-
Del
OK
Featured_Events
-
Del
OK
Featured_Events.php
1.75 KB
Del
OK
Front_Page_View.php
9.87 KB
Del
OK
Google
-
Del
OK
Gutenberg.php
2.71 KB
Del
OK
I18n.php
10.51 KB
Del
OK
Ignored_Events.php
31.25 KB
Del
OK
Importer
-
Del
OK
Integrations
-
Del
OK
JSON_LD
-
Del
OK
Linked_Posts
-
Del
OK
Linked_Posts.php
43.79 KB
Del
OK
List_Widget.php
7.64 KB
Del
OK
Main.php
195.46 KB
Del
OK
Meta
-
Del
OK
Models
-
Del
OK
Options_Exception.php
890 B
Del
OK
Organizer.php
22.22 KB
Del
OK
Plugin_Register.php
675 B
Del
OK
Post_Exception.php
859 B
Del
OK
Privacy.php
1.31 KB
Del
OK
Query.php
54.4 KB
Del
OK
REST
-
Del
OK
Recurring_Event_Cleanup.php
2.13 KB
Del
OK
Repositories
-
Del
OK
Revisions
-
Del
OK
Rewrite.php
30.31 KB
Del
OK
Service_Providers
-
Del
OK
Shortcode
-
Del
OK
Template
-
Del
OK
Template_Factory.php
17.79 KB
Del
OK
Templates.php
24.04 KB
Del
OK
Timezones.php
6.37 KB
Del
OK
Updater.php
8.13 KB
Del
OK
Utils
-
Del
OK
Validator
-
Del
OK
Venue.php
22.95 KB
Del
OK
Views
-
Del
OK
iCal.php
26.37 KB
Del
OK
Edit: Event_Cleaner_Scheduler.php
<?php /** * Class Event_Cleaner_Scheduler * * Uses cron to move old events to trash and/or permanently delete them. * * @since 4.6.13 */ class Tribe__Events__Event_Cleaner_Scheduler { /** * The name of the cron event to permanently delete past events. * @static $del_cron_hook */ public static $del_cron_hook = 'tribe_del_event_cron'; /** * The name of the cron event to move past events to trash. * @static $trash_cron_hook */ public static $trash_cron_hook = 'tribe_trash_event_cron'; /** * The new value for the $key_trash_events option. * * @var $trash_new_date * * @since 4.6.13 */ public $trash_new_date; /** * The new value for the $key_delete_events option. * * @var $del_new_date * * @since 4.6.13 */ public $del_new_date; /** * Receives the existing values for $key_trash_events and $key_delete_events options * and defines them as trash_new_date and del_new_date variables. * * @param mixed $move_to_trash * @param mixed $permanently_delete * * @since 4.6.13 */ public function __construct( $move_to_trash = null, $permanently_delete = null ) { $this->trash_new_date = $move_to_trash; $this->del_new_date = $permanently_delete; } /** * Receives the new user-defined value for $key_trash_events option * and defines it as the trash_new_date variable. * * @param mixed $trash_new_value - the value for the $key_trash_events option * * @since 4.6.13 */ public function set_trash_new_date( $trash_new_value ) { $this->trash_new_date = $trash_new_value; } /** * Receives the new user-defined value for $key_delete_events option * and defines it as the del_new_date variable. * * @param mixed $del_new_value - the value for the $key_delete_events option * * @since 4.6.13 */ public function set_delete_new_date( $del_new_value ) { $this->del_new_date = $del_new_value; } /** * Schedules the hooks to delete and move old events to trash * These hooks will be executed daily. * * @since 4.6.13 */ public function add_hooks() { if ( ! wp_next_scheduled( self::$trash_cron_hook ) && $this->trash_new_date != null ) { wp_schedule_event( time(), 'daily', self::$trash_cron_hook ); } if ( ! wp_next_scheduled( self::$del_cron_hook ) && $this->del_new_date != null ) { wp_schedule_event( time(), 'daily', self::$del_cron_hook ); } if ( null != $this->trash_new_date ) { add_action( self::$trash_cron_hook, [ $this, 'move_old_events_to_trash' ], 10, 0 ); } if ( null != $this->del_new_date ) { add_action( self::$del_cron_hook, [ $this, 'permanently_delete_old_events' ], 10, 0 ); } add_action( 'tribe_events_blog_deactivate', [ $this, 'trash_clear_scheduled_task' ] ); add_action( 'tribe_events_blog_deactivate', [ $this, 'delete_clear_scheduled_task' ] ); } /** * Removes the hooks * * @since 4.6.13 */ public function remove_hooks() { remove_action( self::$trash_cron_hook, [ $this, 'move_old_events_to_trash' ] ); remove_action( self::$del_cron_hook, [ $this, 'permanently_delete_old_events' ] ); } /** * Un-schedules all previously-scheduled cron jobs for tribe_trash_event_cron * * @since 4.6.13 */ public function trash_clear_scheduled_task() { wp_clear_scheduled_hook( self::$trash_cron_hook ); } /** * Un-schedules all previously-scheduled cron jobs for tribe_del_event_cron * * @since 4.6.13 */ public function delete_clear_scheduled_task() { wp_clear_scheduled_hook( self::$del_cron_hook ); } /** * Selects events to be moved to trash or permanently deleted. * * @since 4.6.13 * * @param int $month - The value chosen by user to purge all events older than x months * * @return array $post_ids - an array of event Post_IDs with the Event End Date older than $month */ public function select_events_to_purge( $month ) { /** @var wpdb $wpdb */ global $wpdb; $event_post_type = Tribe__Events__Main::POSTTYPE; $posts_with_parents_sql = " SELECT DISTINCT post_parent FROM {$wpdb->posts} WHERE post_type= '$event_post_type' AND post_parent <> 0 "; $sql = " SELECT post_id FROM {$wpdb->posts} AS t1 INNER JOIN {$wpdb->postmeta} AS t2 ON t1.ID = t2.post_id WHERE t1.post_type = %s AND t2.meta_key = '_EventEndDate' AND t2.meta_value <= DATE_SUB( CURDATE(), INTERVAL %d MONTH ) AND t2.meta_value != 0 AND t2.meta_value != '' AND t2.meta_value IS NOT NULL AND t1.post_parent = 0 AND t1.ID NOT IN ( $posts_with_parents_sql ) "; /** * Filter - Allows users to manipulate the cleanup query * * @param string $sql - The query statement * * @since 4.6.13 */ $sql = apply_filters( 'tribe_events_delete_old_events_sql', $sql ); $args = [ 'post_type' => $event_post_type, 'date' => $month, ]; /** * Filter - Allows users to modify the query's placeholders * * @param array $args - The array of variables * * @since 4.6.13 */ $args = apply_filters( 'tribe_events_delete_old_events_sql_args', $args ); /** * Returns an array of Post IDs (events) that ended before a specific date */ $post_ids = $wpdb->get_col( $wpdb->prepare( $sql, $args ) ); return $post_ids; } /** * Moves to trash events that ended before a date specified by user * * @since 4.6.13 * * @return mixed */ public function move_old_events_to_trash() { $month = $this->trash_new_date; $post_ids = $this->select_events_to_purge( $month ); if ( empty( $post_ids ) ) { return; } foreach ( $post_ids as $post_id ) { wp_trash_post( $post_id ); } } /** * Permanently deletes events that ended before a date specified by user * * @since 4.6.13 * * @return mixed - The post object (if it was deleted successfully) or false (failure) */ public function permanently_delete_old_events() { $month = $this->del_new_date; $post_ids = $this->select_events_to_purge( $month ); if ( empty( $post_ids ) ) { return; } foreach ( $post_ids as $post_id ) { wp_delete_post( $post_id, true ); } } }
Save