Changeset 3126
- Timestamp:
- 05/12/2016 08:02:37 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-functions.php
r2898 r3126 112 112 $user = get_user_by( 'id', $entry['user_id'] ); 113 113 114 if ( $user ) { 115 $entry['user_display_name'] = $user->display_name; 116 } else { 117 // Assume that the action was performed during a cron job 118 $entry['user_display_name'] = 'WordCamp Bot'; 119 } 120 114 121 $entry['type'] = $entry_type; 115 $entry['user_display_name'] = $user->display_name;122 // todo realign 116 123 117 124 $entries[] = $entry; -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php
r2898 r3126 51 51 52 52 // Require admin files. 53 if ( is_admin() ) {53 if ( is_admin() || DOING_CRON ) { 54 54 require_once ( WCPT_DIR . 'wcpt-admin.php' ); 55 55 require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-admin.php' ); … … 59 59 function core_admin() { 60 60 // Quick admin check 61 if ( ! is_admin() )61 if ( ! is_admin() && ! DOING_CRON ) { 62 62 return; 63 } 63 64 64 65 // Create admin -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
r3122 r3126 51 51 add_action( 'admin_notices', array( $this, 'print_admin_notices' ) ); 52 52 add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 ); 53 54 // Cron jobs 55 add_action( 'plugins_loaded', array( $this, 'schedule_cron_jobs' ), 11 ); 56 add_action( 'wcpt_close_wordcamps_after_event', array( $this, 'close_wordcamps_after_event' ) ); 53 57 } 54 58 … … 924 928 require_once( WCPT_DIR . 'views/wordcamp/metabox-original-application.php' ); 925 929 } 930 931 /** 932 * Schedule cron jobs 933 */ 934 public function schedule_cron_jobs() { 935 if ( wp_next_scheduled( 'wcpt_close_wordcamps_after_event' ) ) { 936 return; 937 } 938 939 wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'wcpt_close_wordcamps_after_event' ); 940 } 941 942 /** 943 * Set WordCamp posts to the Closed status after the event is over 944 */ 945 public function close_wordcamps_after_event() { 946 $scheduled_wordcamps = get_posts( array( 947 'post_type' => WCPT_POST_TYPE_ID, 948 'post_status' => 'wcpt-scheduled', 949 'posts_per_page' => -1 950 ) ); 951 952 foreach ( $scheduled_wordcamps as $wordcamp ) { 953 $start_date = get_post_meta( $wordcamp->ID, 'Start Date (YYYY-mm-dd)', true ); 954 $end_date = get_post_meta( $wordcamp->ID, 'End Date (YYYY-mm-dd)', true ); 955 956 if ( empty( $start_date ) ) { 957 continue; 958 } 959 960 if ( empty( $end_date ) ) { 961 $end_date = $start_date; 962 } 963 964 $end_date_at_midnight = strtotime( '23:59', $end_date ); // $end_date is the date at time 00:00, but the event isn't over until 23:59 965 966 if ( $end_date_at_midnight > time() ) { 967 continue; 968 } 969 970 wp_update_post( array( 971 'ID' => $wordcamp->ID, 972 'post_status' => 'wcpt-closed', 973 ) ); 974 } 975 } 926 976 } 927 977 endif; // class_exists check
Note: See TracChangeset
for help on using the changeset viewer.