Ticket #2426: future.diff
File future.diff, 13.6 KB (added by , 19 years ago) |
---|
-
wp-includes/default-filters.php
84 84 // Actions 85 85 add_action('publish_post', 'generic_ping'); 86 86 add_action('wp_head', 'rsd_link'); 87 add_action('publish_future_post', 'wp_publish_post', 10, 1); 87 88 88 89 ?> 90 No newline at end of file -
wp-includes/template-functions-general.php
327 327 $add_hours = intval(get_settings('gmt_offset')); 328 328 $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours)); 329 329 330 $now = current_time('mysql');331 332 330 if ( 'monthly' == $type ) { 333 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_ date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);331 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 334 332 if ( $arcresults ) { 335 333 $afterafter = $after; 336 334 foreach ( $arcresults as $arcresult ) { … … 345 343 } 346 344 } 347 345 } elseif ( 'daily' == $type ) { 348 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_ date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);346 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 349 347 if ( $arcresults ) { 350 348 foreach ( $arcresults as $arcresult ) { 351 349 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); … … 356 354 } 357 355 } elseif ( 'weekly' == $type ) { 358 356 $start_of_week = get_settings('start_of_week'); 359 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_ date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);357 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 360 358 $arc_w_last = ''; 361 359 if ( $arcresults ) { 362 360 foreach ( $arcresults as $arcresult ) { … … 373 371 } 374 372 } 375 373 } elseif ( 'postbypost' == $type ) { 376 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_ date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);374 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 377 375 if ( $arcresults ) { 378 376 foreach ( $arcresults as $arcresult ) { 379 377 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { -
wp-includes/version.php
3 3 // This just holds the version number, in a separate file so we can bump it without cluttering the SVN 4 4 5 5 $wp_version = '2.1-aplha1'; 6 $wp_db_version = 351 3;6 $wp_db_version = 3514; 7 7 8 8 ?> 9 No newline at end of file -
wp-includes/functions-post.php
72 72 $post_date_gmt = get_gmt_from_date($post_date); 73 73 } 74 74 75 if ( 'publish' == $post_status && (mysql2date('U', $post_date_gmt) > time()) ) 76 $post_status = 'future'; 77 75 78 if ( empty($comment_status) ) { 76 79 if ( $update ) 77 80 $comment_status = 'closed'; … … 204 207 add_post_meta($post_ID, '_wp_page_template', $page_template, true); 205 208 } 206 209 210 if ( 'future' == $post_status ) 211 wp_schedule_event(mysql2date('U', $post_date_gmt), 'once', 'publish_future_post', $post_ID); 212 207 213 do_action('save_post', $post_ID); 208 214 do_action('wp_insert_post', $post_ID); 209 215 … … 455 461 return wp_insert_post($postarr); 456 462 } 457 463 464 function wp_publish_post($post_id) { 465 $post = get_post($post_id); 466 467 if ( empty($post) ) 468 return; 469 470 if ( 'publish' == $post->post_status ) 471 return; 472 473 return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id)); 474 } 475 458 476 function wp_get_post_cats($blogid = '1', $post_ID = 0) { 459 477 global $wpdb; 460 478 -
wp-includes/classes.php
571 571 } 572 572 } 573 573 574 $now = gmdate('Y-m-d H:i:59');574 //$now = gmdate('Y-m-d H:i:59'); 575 575 576 576 //only select past-dated posts, except if a logged in user is viewing a single: then, if they 577 577 //can edit the post, we let them through 578 if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {579 $where .= " AND post_date_gmt <= '$now'";580 $distinct = 'DISTINCT';581 }578 //if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) { 579 // $where .= " AND post_date_gmt <= '$now'"; 580 // $distinct = 'DISTINCT'; 581 //} 582 582 583 583 if ( $this->is_attachment ) { 584 584 $where .= ' AND (post_type = "attachment")'; … … 589 589 } else { 590 590 $where .= ' AND (post_type = "post" AND post_status = "publish"'; 591 591 592 if (isset($user_ID) && ('' != intval($user_ID))) 592 if ( $pagenow == 'post.php' || $pagenow == 'edit.php' ) 593 $where .= " OR post_status = 'future'"; 594 else 595 $distinct = 'DISTINCT'; 596 597 if ( is_user_logged_in() ) 593 598 $where .= " OR post_author = $user_ID AND post_status = 'private')"; 594 599 else 595 600 $where .= ')'; … … 641 646 // Check post status to determine if post should be displayed. 642 647 if ($this->is_single || $this->is_page) { 643 648 $status = get_post_status($this->posts[0]); 649 //$type = get_post_type($this->posts[0]); 644 650 if ( ('publish' != $status) ) { 645 651 if ( ! is_user_logged_in() ) { 646 652 // User must be logged in to view unpublished posts. … … 654 660 $this->is_preview = true; 655 661 $this->posts[0]->post_date = current_time('mysql'); 656 662 } 663 } else if ('future' == $status) { 664 $this->is_preview = true; 665 if (!current_user_can('edit_post', $this->posts[0]->ID)) { 666 $this->posts = array ( ); 667 } 657 668 } else { 658 669 if (! current_user_can('read_post', $this->posts[0]->ID)) 659 670 $this->posts = array(); 660 671 } 661 672 } 662 } else {663 if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated664 $this->is_preview = true;665 if (!current_user_can('edit_post', $this->posts[0]->ID)) {666 $this->posts = array ( );667 }668 }669 673 } 670 674 } 671 675 -
wp-includes/template-functions-links.php
294 294 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 295 295 } 296 296 297 $now = current_time('mysql'); 298 299 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 297 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 300 298 } 301 299 302 300 -
wp-includes/functions.php
110 110 global $cache_lastpostdate, $pagenow, $wpdb; 111 111 $add_seconds_blog = get_settings('gmt_offset') * 3600; 112 112 $add_seconds_server = date('Z'); 113 $now = current_time('mysql', 1);114 113 if ( !isset($cache_lastpostdate[$timezone]) ) { 115 114 switch(strtolower($timezone)) { 116 115 case 'gmt': 117 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_ date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");116 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 118 117 break; 119 118 case 'blog': 120 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_ date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");119 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 121 120 break; 122 121 case 'server': 123 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_ date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");122 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1"); 124 123 break; 125 124 } 126 125 $cache_lastpostdate[$timezone] = $lastpostdate; … … 134 133 global $cache_lastpostmodified, $pagenow, $wpdb; 135 134 $add_seconds_blog = get_settings('gmt_offset') * 3600; 136 135 $add_seconds_server = date('Z'); 137 $now = current_time('mysql', 1);138 136 if ( !isset($cache_lastpostmodified[$timezone]) ) { 139 137 switch(strtolower($timezone)) { 140 138 case 'gmt': 141 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_ modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");139 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 142 140 break; 143 141 case 'blog': 144 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_ modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");142 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 145 143 break; 146 144 case 'server': 147 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_ modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");145 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1"); 148 146 break; 149 147 } 150 148 $lastpostdate = get_lastpostdate($timezone); … … 1350 1348 if ( !isset($r['order']) ) 1351 1349 $r['order'] = 'DESC'; 1352 1350 1353 $now = current_time('mysql');1354 1355 1351 $posts = $wpdb->get_results( 1356 1352 "SELECT DISTINCT * FROM $wpdb->posts " . 1357 1353 ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) . 1358 " WHERE post_date <= '$now' AND(post_type = 'post' AND post_status = 'publish') ".1354 " WHERE (post_type = 'post' AND post_status = 'publish') ". 1359 1355 ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) . 1360 1356 " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] ); 1361 1357 -
wp-settings.php
217 217 218 218 function shutdown_action_hook() { 219 219 do_action('shutdown'); 220 wp_cron(); 220 221 wp_cache_close(); 221 222 } 222 223 register_shutdown_function('shutdown_action_hook'); -
wp-admin/upgrade-functions.php
33 33 if ( $wp_current_db_version < 3308 ) 34 34 upgrade_160(); 35 35 36 if ( $wp_current_db_version < 351 3)36 if ( $wp_current_db_version < 3514 ) 37 37 upgrade_210(); 38 38 39 39 $wp_rewrite->flush_rules(); -
wp-admin/upgrade-schema.php
106 106 post_title text NOT NULL, 107 107 post_category int(4) NOT NULL default '0', 108 108 post_excerpt text NOT NULL, 109 post_status enum('publish','draft','private','static','object','attachment','inherit' ) NOT NULL default 'publish',109 post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish', 110 110 comment_status enum('open','closed','registered_only') NOT NULL default 'open', 111 111 ping_status enum('open','closed') NOT NULL default 'open', 112 112 post_password varchar(20) NOT NULL default '',