|
730 | 730 | break; |
731 | 731 | case 'inline-save': |
732 | 732 | check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); |
733 | | - |
734 | | - if ( ! isset($_POST['post_ID']) || ! ( $id = (int) $_POST['post_ID'] ) ) |
| 733 | + |
| 734 | + if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) ) |
735 | 735 | exit; |
736 | 736 |
|
737 | | - if ( $last = wp_check_post_lock( $id ) ) { |
| 737 | + if ( 'page' == $_POST['post_type'] ) { |
| 738 | + if ( ! current_user_can( 'edit_page', $post_ID ) ) |
| 739 | + die( __('You are not allowed to edit this page.') ); |
| 740 | + } else { |
| 741 | + if ( ! current_user_can( 'edit_post', $post_ID ) ) |
| 742 | + die( __('You are not allowed to edit this post.') ); |
| 743 | + } |
| 744 | + |
| 745 | + if ( $last = wp_check_post_lock( $post_ID ) ) { |
738 | 746 | $last_user = get_userdata( $last ); |
739 | 747 | $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); |
740 | | - echo '<tr><td colspan="8"><div class="error"><p>' . sprintf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), wp_specialchars( $last_user_name ) ) . '</p></div></td></tr>'; |
| 748 | + printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), wp_specialchars( $last_user_name ) ); |
741 | 749 | exit; |
742 | 750 | } |
743 | | - |
744 | | - inline_save_row( $_POST ); |
745 | | - |
| 751 | + |
| 752 | + $data = &$_POST; |
| 753 | + $post = get_post( $post_ID, ARRAY_A ); |
| 754 | + $data['content'] = $post['post_content']; |
| 755 | + $data['excerpt'] = $post['post_excerpt']; |
| 756 | + |
| 757 | + // rename |
| 758 | + $data['user_ID'] = $GLOBALS['user_ID']; |
| 759 | + $data['parent_id'] = $data['post_parent']; |
| 760 | + |
| 761 | + // status |
| 762 | + if ( 'private' == $data['keep_private'] ) |
| 763 | + $data['post_status'] = 'private'; |
| 764 | + else |
| 765 | + $data['post_status'] = $data['_status']; |
| 766 | + |
| 767 | + if ( empty($data['comment_status']) ) |
| 768 | + $data['comment_status'] = 'closed'; |
| 769 | + if ( empty($data['ping_status']) ) |
| 770 | + $data['ping_status'] = 'closed'; |
| 771 | + |
| 772 | + // update the post |
| 773 | + $_POST = $data; |
| 774 | + edit_post(); |
| 775 | + |
746 | 776 | $post = array(); |
747 | 777 | if ( 'page' == $_POST['post_type'] ) { |
748 | 778 | $post[] = get_post($_POST['post_ID']); |
|
752 | 782 | $post[] = get_post($_POST['post_ID']); |
753 | 783 | post_rows($post); |
754 | 784 | } |
755 | | - die(); |
| 785 | + |
| 786 | + exit; |
| 787 | + break; |
| 788 | +case 'inline-save-tax': |
| 789 | + check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); |
| 790 | + |
| 791 | + if ( ! current_user_can('manage_categories') ) |
| 792 | + die( '<tr colspan="6"><td>' . __('Cheatin’ uh?') . '</td></tr>' ); |
| 793 | + |
| 794 | + if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) ) |
| 795 | + exit; |
| 796 | + |
| 797 | + switch ($_POST['tax_type']) { |
| 798 | + case 'cat' : |
| 799 | + $data = array(); |
| 800 | + $data['cat_ID'] = $id; |
| 801 | + $data['cat_name'] = $_POST['name']; |
| 802 | + $data['category_nicename'] = $_POST['slug']; |
| 803 | + if ( isset($_POST['parent']) && (int) $_POST['parent'] > 0 ) |
| 804 | + $data['category_parent'] = $_POST['parent']; |
| 805 | + |
| 806 | + $updated = wp_update_category($data); |
| 807 | + |
| 808 | + if ( $updated && !is_wp_error($updated) ) |
| 809 | + echo _cat_row( $id, 0 ); |
| 810 | + else |
| 811 | + die( __('Category not updated.') ); |
| 812 | + |
| 813 | + break; |
| 814 | + case 'link-cat' : |
| 815 | + $updated = wp_update_term($id, 'link_category', $_POST); |
| 816 | + |
| 817 | + if ( $updated && !is_wp_error($updated) ) |
| 818 | + echo link_cat_row($id); |
| 819 | + else |
| 820 | + die( __('Category not updated.') ); |
| 821 | + |
| 822 | + break; |
| 823 | + case 'tag' : |
| 824 | + $updated = wp_update_term($id, 'post_tag', $_POST); |
| 825 | + |
| 826 | + if ( $updated && !is_wp_error($updated) ) { |
| 827 | + $tag = get_term( $id, 'post_tag' ); |
| 828 | + if ( !$tag || is_wp_error( $tag ) ) |
| 829 | + die( __('Tag not updated.') ); |
| 830 | + |
| 831 | + echo _tag_row($tag); |
| 832 | + } else { |
| 833 | + die( __('Tag not updated.') ); |
| 834 | + } |
| 835 | + |
| 836 | + break; |
| 837 | + } |
| 838 | + |
| 839 | + exit; |
756 | 840 | break; |
757 | 841 | case 'meta-box-order': |
758 | 842 | check_ajax_referer( 'meta-box-order' ); |
|
803 | 887 | $stat = __('Unpublished'); |
804 | 888 | break; |
805 | 889 | } |
806 | | - |
| 890 | + |
807 | 891 | if ( '0000-00-00 00:00:00' == $post->post_date ) { |
808 | 892 | $time = ''; |
809 | 893 | } else { |
|
0 commit comments