Changes from trunk/wp-admin/includes/post.php at r17457 to branches/3.0/wp-admin/includes/post.php at r17401
- File:
-
- 1 edited
-
branches/3.0/wp-admin/includes/post.php (modified) (45 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-admin/includes/post.php
r17457 r17401 16 16 * 17 17 * @param bool $update Are we updating a pre-existing post? 18 * @param array $post_dataArray of post data. Defaults to the contents of $_POST.18 * @param post_data array Array of post data. Defaults to the contents of $_POST. 19 19 * @return object|bool WP_Error on failure, true on success. 20 20 */ … … 126 126 * Update an existing post with values provided in $_POST. 127 127 * 128 * @since 1.5.0128 * @since unknown 129 129 * 130 130 * @param array $post_data Optional. … … 137 137 138 138 $post_ID = (int) $post_data['post_ID']; 139 $post = get_post( $post_ID );140 $post_data['post_type'] = $post->post_type;141 139 142 140 $ptype = get_post_type_object($post_data['post_type']); … … 159 157 160 158 $post_data = _wp_translate_postdata( true, $post_data ); 159 if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] ) 160 $post_data['post_status'] = 'draft'; 161 161 if ( is_wp_error($post_data) ) 162 162 wp_die( $post_data->get_error_message() ); 163 if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] )164 $post_data['post_status'] = 'draft';165 163 166 164 if ( isset($post_data['visibility']) ) { … … 180 178 } 181 179 182 // Post Formats183 if ( current_theme_supports( 'post-formats' ) && isset( $post_data['post_format'] ) ) {184 $formats = get_theme_support( 'post-formats' );185 if ( is_array( $formats ) ) {186 $formats = $formats[0];187 if ( in_array( $post_data['post_format'], $formats ) ) {188 set_post_format( $post_ID, $post_data['post_format'] );189 } elseif ( '0' == $post_data['post_format'] ) {190 set_post_format( $post_ID, false );191 }192 }193 }194 195 180 // Meta Stuff 196 181 if ( isset($post_data['meta']) && $post_data['meta'] ) { 197 foreach ( $post_data['meta'] as $key => $value ) { 198 if ( !$meta = get_post_meta_by_id( $key ) ) 199 continue; 200 if ( $meta->post_id != $post_ID ) 201 continue; 182 foreach ( $post_data['meta'] as $key => $value ) 202 183 update_meta( $key, $value['key'], $value['value'] ); 203 }204 184 } 205 185 206 186 if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) { 207 foreach ( $post_data['deletemeta'] as $key => $value ) { 208 if ( !$meta = get_post_meta_by_id( $key ) ) 209 continue; 210 if ( $meta->post_id != $post_ID ) 211 continue; 187 foreach ( $post_data['deletemeta'] as $key => $value ) 212 188 delete_meta( $key ); 213 }214 189 } 215 190 … … 231 206 wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID ); 232 207 233 if ( current_user_can( $ptype->cap->edit_others_posts) ) {234 if ( ! empty( $post_data['sticky']) )235 stick_post( $post_ID);208 if ( current_user_can( 'edit_others_posts' ) ) { 209 if ( !empty($post_data['sticky']) ) 210 stick_post($post_ID); 236 211 else 237 unstick_post( $post_ID);212 unstick_post($post_ID); 238 213 } 239 214 … … 362 337 $updated[] = wp_update_post( $post_data ); 363 338 364 if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts) ) {339 if ( isset( $post_data['sticky'] ) && current_user_can( 'edit_others_posts' ) ) { 365 340 if ( 'sticky' == $post_data['sticky'] ) 366 341 stick_post( $post_ID ); … … 377 352 * Default post information to use when populating the "Write Post" form. 378 353 * 379 * @since 2.0.0380 * 381 * @param string $post_typeA post type string, defaults to 'post'.354 * @since unknown 355 * 356 *@param string A post type string, defaults to 'post'. 382 357 * @return object stdClass object containing all the default post data as attributes 383 358 */ … … 404 379 $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); 405 380 $post = get_post( $post_id ); 406 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )407 set_post_format( $post, get_option( 'default_post_format' ) );408 381 } else { 409 382 $post->ID = 0; … … 449 422 * Get an existing post and format it for editing. 450 423 * 451 * @since 2.0.0424 * @since unknown 452 425 * 453 426 * @param unknown_type $id … … 467 440 * Determine if a post exists based on title, content, and date 468 441 * 469 * @since 2.0.0442 * @since unknown 470 443 * 471 444 * @param string $title Post title … … 508 481 * Creates a new post from the "Write Post" form using $_POST information. 509 482 * 510 * @since 2.1.0483 * @since unknown 511 484 * 512 485 * @return unknown … … 605 578 * Calls wp_write_post() and handles the errors. 606 579 * 607 * @since 2.0.0580 * @since unknown 608 581 * 609 582 * @return unknown … … 624 597 * {@internal Missing Short Description}} 625 598 * 626 * @since 1.2.0599 * @since unknown 627 600 * 628 601 * @param unknown_type $post_ID … … 656 629 wp_cache_delete($post_ID, 'post_meta'); 657 630 $wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_ID, 'meta_key' => $metakey, 'meta_value' => $metavalue ) ); 658 $meta_id = $wpdb->insert_id; 659 do_action( 'added_postmeta', $meta_id, $post_ID, $metakey, $metavalue ); 660 661 return $meta_id; 631 do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, $metakey, $metavalue ); 632 633 return $wpdb->insert_id; 662 634 } 663 635 return false; … … 667 639 * {@internal Missing Short Description}} 668 640 * 669 * @since 1.2.0641 * @since unknown 670 642 * 671 643 * @param unknown_type $mid … … 689 661 * Get a list of previously defined keys. 690 662 * 691 * @since 1.2.0663 * @since unknown 692 664 * 693 665 * @return unknown … … 708 680 * {@internal Missing Short Description}} 709 681 * 710 * @since 2.1.0682 * @since unknown 711 683 * 712 684 * @param unknown_type $mid … … 730 702 * Some postmeta stuff. 731 703 * 732 * @since 1.2.0704 * @since unknown 733 705 * 734 706 * @param unknown_type $postid … … 747 719 * {@internal Missing Short Description}} 748 720 * 749 * @since 1.2.0721 * @since unknown 750 722 * 751 723 * @param unknown_type $meta_id … … 790 762 * Replace hrefs of attachment anchors with up-to-date permalinks. 791 763 * 792 * @since 2.3.0764 * @since unknown 793 765 * @access private 794 766 * … … 846 818 * Move child posts to a new parent. 847 819 * 848 * @since 2.3.0820 * @since unknown 849 821 * @access private 850 822 * … … 911 883 } 912 884 913 if ( isset($q['orderby']) ) 914 $orderby = $q['orderby']; 915 elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) ) 885 if ( isset($q['post_status']) && 'pending' === $q['post_status'] ) { 886 $order = 'ASC'; 916 887 $orderby = 'modified'; 917 918 if ( isset($q['order']) ) 919 $order = $q['order']; 920 elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] ) 921 $order = 'ASC'; 888 } elseif ( isset($q['post_status']) && 'draft' === $q['post_status'] ) { 889 $order = 'DESC'; 890 $orderby = 'modified'; 891 } else { 892 $order = 'DESC'; 893 $orderby = 'date'; 894 } 922 895 923 896 $per_page = 'edit_' . $post_type . '_per_page'; … … 932 905 933 906 // Hierarchical types require special args. 934 if ( is_post_type_hierarchical( $post_type ) && !isset($orderby)) {907 if ( is_post_type_hierarchical( $post_type ) ) { 935 908 $query['orderby'] = 'menu_order title'; 936 909 $query['order'] = 'asc'; … … 938 911 $query['posts_per_archive_page'] = -1; 939 912 } 940 941 if ( ! empty( $q['show_sticky'] ) )942 $query['post__in'] = (array) get_option( 'sticky_posts' );943 913 944 914 wp( $query ); … … 967 937 * {@internal Missing Short Description}} 968 938 * 969 * @since 2.5.0939 * @since unknown 970 940 * 971 941 * @param unknown_type $type … … 982 952 * {@internal Missing Short Description}} 983 953 * 984 * @since 2.5.0954 * @since unknown 985 955 * 986 956 * @param unknown_type $q … … 1006 976 unset($q['post_mime_type']); 1007 977 1008 if ( isset($q['detached']) ) 1009 add_filter('posts_where', '_edit_attachments_query_helper'); 1010 1011 wp( $q ); 1012 1013 if ( isset($q['detached']) ) 1014 remove_filter('posts_where', '_edit_attachments_query_helper'); 978 wp($q); 1015 979 1016 980 return array($post_mime_types, $avail_post_mime_types); 1017 981 } 1018 982 1019 function _edit_attachments_query_helper($where) {1020 return $where .= ' AND post_parent < 1';1021 }1022 1023 983 /** 1024 984 * {@internal Missing Short Description}} 1025 985 * 1026 986 * @uses get_user_option() 1027 * @since 2.5.0987 * @since unknown 1028 988 * 1029 989 * @param unknown_type $id … … 1048 1008 * {@internal Missing Short Description}} 1049 1009 * 1050 * @since 2.5.01010 * @since unknown 1051 1011 * 1052 1012 * @param int|object $id Post ID or post object. … … 1095 1055 if ( !empty($uri) ) 1096 1056 $uri .= '/'; 1097 $permalink = str_replace('%pagename%', " {$uri}%pagename%", $permalink);1057 $permalink = str_replace('%pagename%', "${uri}%pagename%", $permalink); 1098 1058 } 1099 1059 … … 1112 1072 * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor. 1113 1073 * 1114 * @since 2.5.01074 * @since unknown 1115 1075 * 1116 1076 * @param int|object $id Post ID or post object. … … 1135 1095 if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) { 1136 1096 $return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n"; 1137 if ( '' == get_option( 'permalink_structure' ) &¤t_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )1097 if ( current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) ) 1138 1098 $return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n"; 1139 1099 if ( isset($view_post) ) … … 1218 1178 return false; 1219 1179 1220 if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) ) 1221 return false; 1222 1223 $lock = explode( ':', $lock ); 1224 $time = $lock[0]; 1225 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1180 $lock = get_post_meta( $post->ID, '_edit_lock', true ); 1181 $last = get_post_meta( $post->ID, '_edit_last', true ); 1226 1182 1227 1183 $time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ); 1228 1184 1229 if ( $ time && $time > time() - $time_window && $user!= get_current_user_id() )1230 return $ user;1185 if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() ) 1186 return $last; 1231 1187 return false; 1232 1188 } … … 1243 1199 if ( !$post = get_post( $post_id ) ) 1244 1200 return false; 1245 if ( 0 == ($user_id = get_current_user_id()) )1201 if ( 0 == get_current_user_id() ) 1246 1202 return false; 1247 1203 1248 1204 $now = time(); 1249 $lock = "$now:$user_id"; 1250 1251 update_post_meta( $post->ID, '_edit_lock', $lock ); 1205 1206 update_post_meta( $post->ID, '_edit_lock', $now ); 1252 1207 } 1253 1208 … … 1260 1215 function _admin_notice_post_locked() { 1261 1216 global $post; 1262 1263 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1264 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1265 $last_user = get_userdata( $user ); 1217 $last_user = get_userdata( get_post_meta( $post->ID, '_edit_last', true ) ); 1266 1218 $last_user_name = $last_user ? $last_user->display_name : __('Somebody'); 1267 1219 … … 1408 1360 1409 1361 if ( $teeny ) { 1410 $plugins = apply_filters( 'teeny_mce_plugins', array(' inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs') );1362 $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'fullscreen', 'wordpress') ); 1411 1363 $ext_plugins = ''; 1412 1364 } else { 1413 $plugins = array( ' inlinepopups', 'spellchecker', 'paste', 'wordpress', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink', 'wpdialogs' );1365 $plugins = array( 'safari', 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus' ); 1414 1366 1415 1367 /* … … 1492 1444 } 1493 1445 1446 $plugins = implode($plugins, ','); 1447 1494 1448 if ( $teeny ) { 1495 1449 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') ); … … 1500 1454 $mce_buttons = implode($mce_buttons, ','); 1501 1455 1502 $mce_buttons_2 = array( 'formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ); 1456 $mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ); 1457 if ( is_multisite() ) 1458 unset( $mce_buttons_2[ array_search( 'media', $mce_buttons_2 ) ] ); 1503 1459 $mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2); 1504 1460 $mce_buttons_2 = implode($mce_buttons_2, ','); … … 1531 1487 'theme_advanced_resize_horizontal' => false, 1532 1488 'dialog_type' => 'modal', 1533 'formats' => "{1534 alignleft : [1535 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},1536 {selector : 'img,table', classes : 'alignleft'}1537 ],1538 aligncenter : [1539 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},1540 {selector : 'img,table', classes : 'aligncenter'}1541 ],1542 alignright : [1543 {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},1544 {selector : 'img,table', classes : 'alignright'}1545 ],1546 strikethrough : {inline : 'del'}1547 }",1548 1489 'relative_urls' => false, 1549 1490 'remove_script_host' => false, … … 1559 1500 'paste_remove_spans' => true, 1560 1501 'paste_strip_class_attributes' => 'all', 1561 'paste_text_use_dialog' => true,1562 1502 'wpeditimage_disable_captions' => $no_captions, 1563 'plugins' => implode( ',', $plugins ),1503 'plugins' => $plugins 1564 1504 ); 1565 1505 … … 1567 1507 $mce_css = array(); 1568 1508 $style_uri = get_stylesheet_directory_uri(); 1569 if ( ! is_child_theme()) {1509 if ( TEMPLATEPATH == STYLESHEETPATH ) { 1570 1510 foreach ( $editor_styles as $file ) 1571 1511 $mce_css[] = "$style_uri/$file"; … … 1575 1515 $template_dir = get_template_directory(); 1576 1516 foreach ( $editor_styles as $file ) { 1517 if ( file_exists( "$style_dir/$file" ) ) 1518 $mce_css[] = "$style_uri/$file"; 1577 1519 if ( file_exists( "$template_dir/$file" ) ) 1578 1520 $mce_css[] = "$template_uri/$file"; 1579 if ( file_exists( "$style_dir/$file" ) )1580 $mce_css[] = "$style_uri/$file";1581 1521 } 1582 1522 } … … 1631 1571 1632 1572 $mce_options = ''; 1633 foreach ( $initArray as $k => $v ) { 1634 if ( is_bool($v) ) { 1635 $val = $v ? 'true' : 'false'; 1636 $mce_options .= $k . ':' . $val . ', '; 1637 continue; 1638 } elseif ( !empty($v) && is_string($v) && ( '{' == $v{0} || '[' == $v{0} ) ) { 1639 $mce_options .= $k . ':' . $v . ', '; 1640 continue; 1641 } 1642 1643 $mce_options .= $k . ':"' . $v . '", '; 1644 } 1573 foreach ( $initArray as $k => $v ) 1574 $mce_options .= $k . ':"' . $v . '", '; 1645 1575 1646 1576 $mce_options = rtrim( trim($mce_options), '\n\r,' ); ?> … … 1672 1602 <script type="text/javascript"> 1673 1603 /* <![CDATA[ */ 1674 <?php 1675 if ( $ext_plugins ) 1676 echo "$ext_plugins\n"; 1677 1678 if ( ! $compressed ) { 1679 ?> 1604 <?php if ( $ext_plugins ) echo "$ext_plugins\n"; ?> 1605 <?php if ( $compressed ) { ?> 1606 tinyMCEPreInit.go(); 1607 <?php } else { ?> 1680 1608 (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})(); 1681 1609 <?php } ?> … … 1684 1612 </script> 1685 1613 <?php 1686 1687 // Load additional inline scripts based on active plugins. 1688 if ( in_array( 'wpdialogs', $plugins ) ) { 1689 wp_print_scripts( array( 'wpdialogs-popup' ) ); 1690 wp_print_styles('wp-jquery-ui-dialog'); 1691 } 1692 if ( in_array( 'wplink', $plugins ) ) { 1693 require_once ABSPATH . 'wp-admin/includes/internal-linking.php'; 1694 add_action('tiny_mce_preload_dialogs', 'wp_link_dialog'); 1695 wp_print_scripts('wplink'); 1696 wp_print_styles('wplink'); 1697 } 1698 } 1699 function wp_tiny_mce_preload_dialogs() { ?> 1700 <div id="preloaded-dialogs" style="display:none;"> 1701 <?php do_action('tiny_mce_preload_dialogs'); ?> 1702 </div> 1703 <?php } 1614 }
Note: See TracChangeset
for help on using the changeset viewer.