Ticket #12706: 12706.diff
File 12706.diff, 77.5 KB (added by , 13 years ago) |
---|
-
.
-
wp-comments-post.php
Property changes on: . ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +wp-content/plugins/
37 37 } elseif ( 'trash' == $status ) { 38 38 do_action('comment_on_trash', $comment_post_ID); 39 39 exit; 40 } elseif ( !$status_obj->public && !$status_obj->private) {40 } elseif ( empty($status_obj->public) && empty($status_obj->private) ) { 41 41 do_action('comment_on_draft', $comment_post_ID); 42 42 exit; 43 43 } elseif ( post_password_required($comment_post_ID) ) { -
wp-includes/post-template.php
107 107 $id = isset($post->ID) ? $post->ID : (int) $id; 108 108 109 109 if ( !is_admin() ) { 110 if ( ! empty($post->post_password) ) {111 $protected_title_format = apply_filters( 'protected_title_format', __('Protected: %s'));110 if ( ! empty($post->post_password) ) { 111 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 112 112 $title = sprintf($protected_title_format, $title); 113 } else if ( isset($post->post_status) && 'private' == $post->post_status ) { 114 $private_title_format = apply_filters('private_title_format', __('Private: %s')); 115 $title = sprintf($private_title_format, $title); 113 } elseif ( isset($post->post_status) ) { 114 $post_status_obj = get_post_status_object( $post->post_status ); 115 if ( $post_status_obj && $post_status_obj->private ) { 116 if ( 'private' == $post->post_status ) { 117 $format_string = __( 'Private: %s' ); // preserve existing translation string 118 $private_title_format = apply_filters( 'private_title_format', $format_string ); 119 $title = sprintf( $private_title_format, $title ); 120 } else { 121 $format_string = _x( '%1$s: %2$s', 'post status: title' ); 122 $private_title_format = apply_filters( 'post_title_format', $format_string, $_status ); 123 $title = sprintf( $private_title_format, $post_status_obj->labels->name, $title ); 124 } 125 } 116 126 } 117 127 } 118 128 return apply_filters( 'the_title', $title, $id ); … … 700 710 if ( 1 == $i ) { 701 711 $url = get_permalink(); 702 712 } else { 703 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'pending')))713 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) 704 714 $url = add_query_arg( 'page', $i, get_permalink() ); 705 715 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 706 716 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); -
wp-includes/taxonomy.php
132 132 133 133 $field = ('names' == $output) ? 'name' : false; 134 134 135 if ( isset( $args['object_type'] ) ) 136 $args['object_type'] = (array) $args['object_type']; 137 135 138 return wp_filter_object_list($wp_taxonomies, $args, $operator, $field); 136 139 } 137 140 … … 2839 2842 // Get the object and term ids and stick them in a lookup table 2840 2843 $tax_obj = get_taxonomy($taxonomy); 2841 2844 $object_types = esc_sql($tax_obj->object_type); 2842 $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status = 'publish'"); 2845 2846 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $tax_obj->object_type ) ) ); 2847 $public_csv = implode( "', '", $public_stati ); 2848 2849 $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM $wpdb->term_relationships INNER JOIN $wpdb->posts ON object_id = ID WHERE term_taxonomy_id IN (" . implode(',', array_keys($term_ids)) . ") AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status IN ('$public_csv')"); 2843 2850 foreach ( $results as $row ) { 2844 2851 $id = $term_ids[$row->term_taxonomy_id]; 2845 2852 $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1; … … 2900 2907 if ( $object_types ) 2901 2908 $object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) ); 2902 2909 2910 $public_stati = apply_filters( 'term_count_stati', get_post_stati( array( 'public' => true, 'object_type' => $taxonomy->object_type ) ) ); 2911 $public_csv = implode( "', '", $public_stati ); 2912 2903 2913 foreach ( (array) $terms as $term ) { 2914 2904 2915 $count = 0; 2905 2916 2906 2917 // Attachments can be 'inherit' status, we need to base count off the parent's status if so 2907 2918 if ( $check_attachments ) 2908 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish') ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );2919 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status IN ('$public_csv') OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) IN ('$public_csv') ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); 2909 2920 2910 2921 if ( $object_types ) 2911 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish'AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );2922 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status IN ('$public_csv') AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) ); 2912 2923 2913 2924 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 2914 2925 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); -
wp-includes/default-widgets.php
562 562 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) 563 563 $number = 10; 564 564 565 $public_stati = apply_filters( 'recent_posts_stati', get_post_stati( array( 'public' => true ) ) ); 566 $status_arg = implode( ',', $public_stati ); 567 565 568 $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); 566 569 if ($r->have_posts()) : 567 570 ?> -
wp-includes/link-template.php
114 114 115 115 $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); 116 116 117 if ( '' != $permalink && ! in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) {117 if ( '' != $permalink && ! in_array( $post->post_status, array('draft', 'auto-draft', 'pending') ) && empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) { 118 118 $unixtime = strtotime($post->post_date); 119 119 120 120 $category = ''; … … 185 185 186 186 $slug = $post->post_name; 187 187 188 $draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) ;188 $draft_or_pending = isset($post->post_status) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ! empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ); 189 189 190 190 $post_type = get_post_type_object($post->post_type); 191 191 … … 275 275 276 276 $link = $wp_rewrite->get_page_permastruct(); 277 277 278 if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample )) {278 if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) && empty( $GLOBALS['wp_post_statuses'][$post->post_status]->moderation ) ) || $sample ) { 279 279 if ( ! $leavename ) { 280 280 $link = str_replace('%pagename%', get_page_uri($id), $link); 281 281 } -
wp-includes/nav-menu.php
482 482 if ( empty( $items ) ) 483 483 return $items; 484 484 485 $public_stati = apply_filters( 'nav_menu_stati', get_post_stati( array( 'public' => true ) ), $menu ); 486 $public_csv = implode( ',', $public_stati ); 487 485 488 $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 486 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true,489 'post_status' => $public_csv, 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, 487 490 'update_post_term_cache' => false ); 488 491 $args = wp_parse_args( $args, $defaults ); 489 492 if ( count( $items ) > 1 ) -
wp-includes/post.php
95 95 ) ); 96 96 97 97 register_post_status( 'publish', array( 98 'label' => _x( 'Published', 'post' ), 98 'labels' => array( 99 'name' => _x( 'Published', 'post' ), 100 'publish' => esc_attr__('Publish'), 101 'count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ), 102 ), 99 103 'public' => true, 100 104 '_builtin' => true, /* internal use only. */ 101 'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),102 105 ) ); 103 106 104 107 register_post_status( 'future', array( 105 'label' => _x( 'Scheduled', 'post' ), 108 'labels' => array( 109 'name' => _x( 'Scheduled', 'post' ), 110 'publish' => esc_attr__('Schedule'), 111 'count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ), 112 ), 106 113 'protected' => true, 107 114 '_builtin' => true, /* internal use only. */ 108 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),109 115 ) ); 110 116 111 117 register_post_status( 'draft', array( 112 'label' => _x( 'Draft', 'post' ), 118 'labels' => array( 119 'name' => _x( 'Draft', 'post' ), 120 'save_as' => esc_attr__('Save Draft'), 121 'count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ), 122 ), 113 123 'protected' => true, 114 124 '_builtin' => true, /* internal use only. */ 115 'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),116 125 ) ); 117 126 118 127 register_post_status( 'pending', array( 119 'label' => _x( 'Pending', 'post' ), 128 'labels' => array( 129 'name' => _x( 'Pending', 'post' ), 130 'caption' => __( 'Pending Review' ), 131 'publish' => esc_attr__('Submit for Review'), 132 'count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ), 133 ), 120 134 'protected' => true, 121 135 '_builtin' => true, /* internal use only. */ 122 ' label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),136 'moderation' => true, 123 137 ) ); 124 138 125 139 register_post_status( 'private', array( 126 'label' => _x( 'Private', 'post' ), 140 'labels' => array( 141 'name' => _x( 'Private', 'post' ), 142 'caption' => __( 'Privately Published' ), 143 'count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ), 144 ), 127 145 'private' => true, 128 146 '_builtin' => true, /* internal use only. */ 129 'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),130 147 ) ); 131 148 132 149 register_post_status( 'trash', array( 133 'label' => _x( 'Trash', 'post' ), 150 'labels' => array( 151 'name' => _x( 'Trash', 'post' ), 152 'count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ), 153 ), 134 154 'internal' => true, 135 155 '_builtin' => true, /* internal use only. */ 136 'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),137 156 'show_in_admin_status_list' => true, 138 157 ) ); 139 158 140 159 register_post_status( 'auto-draft', array( 141 'label' => 'auto-draft', 160 'labels' => array( 161 'name' => 'auto-draft', 162 'caption' => __( 'Draft' ), 163 ), 142 164 'internal' => true, 143 165 '_builtin' => true, /* internal use only. */ 166 'show_in_admin_all_list' => false, 167 'show_in_admin_status_list' => false, 144 168 ) ); 145 169 146 170 register_post_status( 'inherit', array( 147 'label' => 'inherit', 171 'labels' => array( 172 'name' => 'inherit', 173 ), 148 174 'internal' => true, 149 175 '_builtin' => true, /* internal use only. */ 150 176 'exclude_from_search' => false, … … 632 658 } 633 659 634 660 /** 661 * Add an already registered post status to an object type. 662 * 663 * @package WordPress 664 * @subpackage Taxonomy 665 * @since 3.1.0 666 * @uses $wp_post_statuses Modifies post_type object 667 * 668 * @param string $post_status Name of post_status object 669 * @param array|string $object_type Name of the object type 670 * @return bool True if successful, false if not 671 */ 672 function register_status_for_object_type( $post_status, $object_type) { 673 global $wp_post_statuses; 674 675 if ( ! isset( $wp_post_statuses[$post_status] ) ) 676 return false; 677 678 if ( ! get_post_type_object($object_type) ) 679 return false; 680 681 $wp_post_statuses[$post_status]->object_type[] = $object_type; 682 683 return true; 684 } 685 686 /** 635 687 * Register a post type. Do not use before init. 636 688 * 637 689 * A simple function for creating or modifying a post status based on the … … 665 717 $wp_post_statuses = array(); 666 718 667 719 // Args prefixed with an underscore are reserved for internal use. 668 $defaults = array('label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'show_in_admin_all' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null); 720 $defaults = array( 'object_type' => null, 'labels' => array(), 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => null, 'internal' => null, 'protected' => null, 'private' => null, 'moderation' => null, 'publicly_queryable' => null, 'show_in_admin_status_list' => null, 'show_in_admin_all_list' => null, 'single_view_cap' => null); 721 669 722 $args = wp_parse_args($args, $defaults); 670 723 $args = (object) $args; 671 724 672 725 $post_status = sanitize_key($post_status); 673 726 $args->name = $post_status; 674 727 728 if ( null == $args->object_type ) { 729 $args->object_type = array_values( get_post_types( array( 'public' => true, 'show_ui' => true ) ) ); 730 } else { 731 $args->object_type = (array) $args->object_type; 732 } 733 675 734 if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private ) 676 735 $args->internal = true; 677 736 … … 681 740 if ( null === $args->private ) 682 741 $args->private = false; 683 742 743 if ( null === $args->moderation ) 744 $args->moderation = false; 745 684 746 if ( null === $args->protected ) 685 747 $args->protected = false; 686 748 … … 702 764 if ( null === $args->single_view_cap ) 703 765 $args->single_view_cap = $args->public ? '' : 'edit'; 704 766 705 if ( false === $args->label ) 706 $args->label = $post_status; 767 $args->labels = (object) $args->labels; 707 768 708 if ( false === $args->label_count ) 709 $args->label_count = array( $args->label, $args->label ); 769 if ( empty( $args->labels->name ) ) 770 $args->labels->name = ( ! empty( $args->label ) ) ? $args->label : $post_status; 771 772 if ( empty( $args->label ) ) 773 $args->label = $args->labels->name; 774 775 if ( empty( $args->labels->caption ) ) 776 $args->labels->caption = $args->label; 710 777 778 if ( empty( $args->labels->count ) ) 779 $args->labels->count = ( ! empty( $args->label_count ) ) ? $args->label_count : array( $args->label, $args->label ); 780 781 if ( empty( $args->label_count ) ) // TODO: need to support this for external API? 782 $args->label_count = $args->labels->count; 783 784 if ( empty( $args->labels->publish ) ) 785 $args->labels->publish = esc_attr( sprintf( __( 'Set %s' ), $args->label ) ); 786 787 if ( empty( $args->labels->save_as ) ) 788 $args->labels->save_as = esc_attr( sprintf( __( 'Save as %s' ), $args->label ) ); 789 790 if ( empty( $args->labels->visibility ) ) { 791 if ( 'publish' == $post_status ) 792 $args->labels->visibility =__( 'Public' ); 793 elseif ( $args->public ) 794 $args->labels->visibility = esc_attr( sprintf( __( 'Public (%s)' ), $args->label ) ); 795 elseif ( $args->private ) 796 $args->labels->visibility = $args->label; 797 } 798 711 799 $wp_post_statuses[$post_status] = $args; 712 800 713 801 return $args; … … 753 841 */ 754 842 function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { 755 843 global $wp_post_statuses; 844 845 $post_statuses = $wp_post_statuses; 756 846 757 847 $field = ('names' == $output) ? 'name' : false; 848 849 //wp_filter_object_list doesn't like nested arrays, 850 //so grab a subset of post stati that match the query, and THEN run through wp_list_filter 851 if ( ! empty( $args['object_type'] ) ) { 852 $post_statuses = get_object_stati( $args['object_type'], 'objects' ); 853 unset( $args['object_type'] ); 854 } 758 855 759 return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field);856 return wp_filter_object_list( $post_statuses, $args, $operator, $field ); 760 857 } 761 858 762 859 /** 860 * Return all of the post_statuses that are of $object_type. 861 * * 862 * <code><?php $taxonomies = get_object_stati('post'); ?></code> Should 863 * result in <code>Array('publish', 'future', 'pending', etc. )</code> 864 * 865 * @package WordPress 866 * @subpackage Taxonomy 867 * @since 3.5 868 * 869 * @uses $wp_post_statuses 870 * 871 * @param array|string|object $object Name of the type of post_status object, or an object (row from posts) 872 * @param string $output The type of output to return, either status 'names' or 'objects'. 'names' is the default. 873 * @return array The names of all statuses of $object_type. 874 */ 875 876 function get_object_stati($object, $output = 'names') { 877 global $wp_post_statuses; 878 879 if ( is_object($object) ) 880 $object = $object->post_type; 881 882 $object = (array) $object; 883 884 $stati = array(); 885 foreach ( (array) $wp_post_statuses as $status_name => $status_obj ) { 886 if ( array_intersect($object, (array) $status_obj->object_type) ) { 887 if ( 'names' == $output ) 888 $stati[] = $status_name; 889 else 890 $stati[ $status_name ] = $status_obj; 891 } 892 } 893 894 return $stati; 895 } 896 897 /** 763 898 * Whether the post type is hierarchical. 764 899 * 765 900 * A false return value might also mean that the post type does not exist. … … 928 1063 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 929 1064 'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true, 930 1065 'supports' => array(), 'register_meta_box_cb' => null, 931 'taxonomies' => array(), 's how_ui' => null, 'menu_position' => null, 'menu_icon' => null,1066 'taxonomies' => array(), 'statuses' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 932 1067 'can_export' => true, 933 1068 'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, 934 1069 ); … … 1049 1184 foreach ( $args->taxonomies as $taxonomy ) { 1050 1185 register_taxonomy_for_object_type( $taxonomy, $post_type ); 1051 1186 } 1187 1188 foreach ( $args->statuses as $post_status ) { 1189 register_status_for_object_type( $post_status, $post_type ); 1190 } 1052 1191 1053 1192 do_action( 'registered_post_type', $post_type, $args ); 1054 1193 … … 1823 1962 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1824 1963 if ( 'readable' == $perm && is_user_logged_in() ) { 1825 1964 $post_type_object = get_post_type_object($type); 1826 if ( !current_user_can( $post_type_object->cap->read_private_posts ) ) { 1827 $cache_key .= '_' . $perm . '_' . $user->ID; 1828 $query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))"; 1965 foreach( get_post_stati( array( 'private' => true, 'object_type' => $type ) ) as $_status ) { 1966 $cap_name = "read_{$_status}_posts"; 1967 if ( ! empty($post_type_object->cap->$cap_name) && ! current_user_can( $post_type_object->cap->$cap_name ) ) { 1968 $suffix = ( 'private' == $_status ) ? '' : $_status; 1969 $cache_key .= '_' . $perm . $suffix . '_' . $user->ID; 1970 $query .= " AND (post_status != '$_status' OR ( post_author = '$user->ID' AND post_status = '$_status' ))"; 1971 } 1829 1972 } 1830 1973 } 1831 1974 $query .= ' GROUP BY post_status'; 1832 1975 1833 1976 $count = wp_cache_get($cache_key, 'counts'); 1834 1977 if ( false !== $count ) 1835 1978 return $count; … … 1837 1980 $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 1838 1981 1839 1982 $stats = array(); 1840 foreach ( get_post_stati( ) as $state )1983 foreach ( get_post_stati( array( 'object_type' => $type ) ) as $state ) 1841 1984 $stats[$state] = 0; 1842 1985 1843 1986 foreach ( (array) $count as $row ) … … 2320 2463 $args = array( 'numberposts' => absint( $args ) ); 2321 2464 } 2322 2465 2466 $status_names = get_post_stati( array( 'public' => true, 'object_type' => 'post' ) ); 2467 $status_names_csv = "'" . implode( "', '", $status_names ) . "'"; 2468 2323 2469 // Set default arguments 2324 2470 $defaults = array( 2325 2471 'numberposts' => 10, 'offset' => 0, 2326 2472 'category' => 0, 'orderby' => 'post_date', 2327 2473 'order' => 'DESC', 'include' => '', 2328 2474 'exclude' => '', 'meta_key' => '', 2329 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',2475 'meta_value' =>'', 'post_type' => 'post', 'post_status' => $status_names_csv, 2330 2476 'suppress_filters' => true 2331 2477 ); 2332 2478 … … 2493 2639 } 2494 2640 2495 2641 // Don't allow contributors to set the post slug for pending review posts 2496 if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) 2642 $post_status_obj = get_post_status_object( $post_status ); 2643 $draft_or_pending = in_array( $post_status, array( 'draft', 'auto-draft' ) ) || ! empty( $post_status_obj->moderation ); 2644 2645 if ( ! empty( $post_status_obj->moderation ) && ! current_user_can( 'publish_posts' ) ) 2497 2646 $post_name = ''; 2498 2647 2499 2648 // Create a valid post name. Drafts and pending posts are allowed to have an empty 2500 2649 // post name. 2501 2650 if ( empty($post_name) ) { 2502 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2651 if ( ! $draft_or_pending ) 2503 2652 $post_name = sanitize_title($post_title); 2504 2653 else 2505 2654 $post_name = ''; … … 2517 2666 $post_date = current_time('mysql'); 2518 2667 2519 2668 if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { 2520 if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ))2669 if ( ! $draft_or_pending ) 2521 2670 $post_date_gmt = get_gmt_from_date($post_date); 2522 2671 else 2523 2672 $post_date_gmt = '0000-00-00 00:00:00'; … … 2531 2680 $post_modified_gmt = $post_date_gmt; 2532 2681 } 2533 2682 2534 if ( 'publish' == $post_status ) { 2683 $set_status = $post_status; 2684 2685 if ( $post_status_obj->public || $post_status_obj->private ) { 2535 2686 $now = gmdate('Y-m-d H:i:59'); 2536 2687 if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) ) 2537 2688 $post_status = 'future'; … … 2541 2692 $post_status = 'publish'; 2542 2693 } 2543 2694 2695 if ( ( 'future' == $post_status ) && ( 'publish' != $set_status ) ) { 2696 update_post_meta( $post_ID, '_scheduled_status', $set_status ); 2697 } else 2698 delete_post_meta( $post_ID, '_scheduled_status' ); 2699 2544 2700 if ( empty($comment_status) ) { 2545 2701 if ( $update ) 2546 2702 $comment_status = 'closed'; … … 2571 2727 else 2572 2728 $menu_order = 0; 2573 2729 2574 if ( ! isset($post_password) || 'private' == $post_status)2730 if ( ! isset($post_password) || $post_status_obj->private ) 2575 2731 $post_password = ''; 2576 2732 2577 2733 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); … … 2612 2768 $where = array( 'ID' => $post_ID ); 2613 2769 } 2614 2770 2615 if ( empty($data['post_name']) && !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { 2771 $post_status_obj = get_post_status_object( $data['post_status'] ); 2772 $draft_or_pending = in_array( $data['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2773 2774 if ( empty($data['post_name']) && ! $draft_or_pending ) { 2616 2775 $data['post_name'] = sanitize_title($data['post_title'], $post_ID); 2617 2776 $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 2618 2777 } … … 2702 2861 $post_cats = $post['post_category']; 2703 2862 2704 2863 // Drafts shouldn't be assigned a date unless explicitly done so by the user 2705 if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) && 2706 ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) 2707 $clear_date = true; 2708 else 2864 if ( isset( $post['post_status'] ) && empty($postarr['edit_date']) && ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) { 2865 $post_status_obj = get_post_status_object( $post['post_status'] ); 2866 2867 $clear_date = in_array( $post['post_status'], array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation); 2868 } else 2709 2869 $clear_date = false; 2710 2870 2711 2871 // Merge old and new fields with new fields overwriting old ones. … … 2743 2903 if ( 'publish' == $post->post_status ) 2744 2904 return; 2745 2905 2746 $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) ); 2906 if ( 'future' == $post->post_status ) { 2907 if ( ! $post_status = get_post_meta( $post_id, '_scheduled_status', true ) ) 2908 $post_status = 'publish'; 2909 } else 2910 $post_status = 'publish'; 2747 2911 2912 $wpdb->update( $wpdb->posts, array( 'post_status' => $post_status ), array( 'ID' => $post_id ) ); 2913 2748 2914 $old_status = $post->post_status; 2749 2915 $post->post_status = 'publish'; 2750 2916 wp_transition_post_status('publish', $old_status, $post); … … 2801 2967 * @return string unique slug for the post, based on $post_name (with a -1, -2, etc. suffix) 2802 2968 */ 2803 2969 function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) { 2804 if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) 2970 $post_status_obj = get_post_status_object( $post_status ); 2971 2972 if ( in_array( $post_status, array('draft', 'auto-draft') ) || ! empty($post_status_obj->moderation) ) 2805 2973 return $slug; 2806 2974 2807 2975 global $wpdb, $wp_rewrite; … … 3365 3533 // Make sure we have a valid post status 3366 3534 if ( !is_array( $post_status ) ) 3367 3535 $post_status = explode( ',', $post_status ); 3368 if ( array_diff( $post_status, get_post_stati() ) ) 3536 if ( array_diff( $post_status, get_post_stati( array( 'object_type' => $post_type ) ) ) ) 3537 3369 3538 return false; 3370 3539 3371 3540 $cache = array(); -
wp-includes/query.php
2402 2402 $post_type_object = get_post_type_object ( 'post' ); 2403 2403 } 2404 2404 2405 $_post_type = ( $post_type ) ? $post_type : 'post'; // corresponds to hardcoded default for POST_TYPE clause 2406 $type_arg = ( 'any' == $_post_type ) ? array() : array( 'object_type' => $_post_type ); 2407 2405 2408 if ( ! empty( $post_type_object ) ) { 2409 $post_type_cap = $post_type_object->capability_type; 2406 2410 $edit_cap = $post_type_object->cap->edit_post; 2407 2411 $read_cap = $post_type_object->cap->read_post; 2408 2412 $edit_others_cap = $post_type_object->cap->edit_others_posts; 2409 $read_private_cap = $post_type_object->cap->read_private_posts;2410 2413 } else { 2411 2414 $edit_cap = 'edit_' . $post_type_cap; 2412 2415 $read_cap = 'read_' . $post_type_cap; 2413 2416 $edit_others_cap = 'edit_others_' . $post_type_cap . 's'; 2414 $read_private_cap = 'read_private_' . $post_type_cap . 's';2415 2417 } 2416 2418 2417 2419 if ( ! empty( $q['post_status'] ) ) { … … 2421 2423 $q_status = explode(',', $q_status); 2422 2424 $r_status = array(); 2423 2425 $p_status = array(); 2426 $p_status_owner = array(); 2424 2427 $e_status = array(); 2425 2428 if ( in_array('any', $q_status) ) { 2426 2429 foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status ) 2427 2430 $e_status[] = "$wpdb->posts.post_status <> '$status'"; 2428 2431 } else { 2429 foreach ( get_post_stati() as $status ) { 2432 $_args = array_merge( array(), $type_arg ); 2433 foreach ( get_post_stati( $_args, 'object' ) as $status => $status_obj ) { 2430 2434 if ( in_array( $status, $q_status ) ) { 2431 if ( 'private' == $status ) 2432 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2433 else 2435 if ( $status_obj->private ) { 2436 if ( ! empty($post_type_object) ) { 2437 $check_cap = "read_{$status}_posts"; 2438 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2439 } else 2440 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2441 2442 if ( ! empty($q['perm'] ) && 'readable' == $q['perm'] && ! current_user_can( $read_private_cap ) ) 2443 $p_status_owner[] = "$wpdb->posts.post_status = '$status'"; 2444 else 2445 $p_status[] = "$wpdb->posts.post_status = '$status'"; 2446 } else 2434 2447 $r_status[] = "$wpdb->posts.post_status = '$status'"; 2435 2448 } 2436 2449 } 2437 2450 } 2438 2451 2439 2452 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 2440 $r_status = array_merge($r_status, $p_status );2453 $r_status = array_merge($r_status, $p_status, $p_status_owner); 2441 2454 unset($p_status); 2455 unset($p_status_owner); 2442 2456 } 2443 2457 2444 2458 if ( !empty($e_status) ) { … … 2450 2464 else 2451 2465 $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; 2452 2466 } 2453 if ( !empty($p_status) ) { 2467 2468 if ( ! empty( $p_status ) ) { 2454 2469 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) ) 2455 2470 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 2456 2471 else 2457 2472 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2458 2473 } 2474 if ( ! empty( $p_status ) ) { 2475 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 2476 } 2459 2477 if ( $post_status_join ) { 2460 2478 $join .= " LEFT JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; 2461 2479 foreach ( $statuswheres as $index => $statuswhere ) 2462 2480 $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; 2463 2481 } 2464 2482 foreach ( $statuswheres as $statuswhere ) 2465 $where .= " AND $statuswhere"; 2483 $where .= " AND $statuswhere"; 2484 2466 2485 } elseif ( !$this->is_singular ) { 2467 2486 $where .= " AND ($wpdb->posts.post_status = 'publish'"; 2468 2487 2469 2488 // Add public states. 2470 $public_states = get_post_stati( array('public' => true) ); 2489 $_args = array_merge( array( 'public' => true ), $type_arg ); 2490 $public_states = apply_filters_ref_array( 'posts_public_stati', array( get_post_stati( $_args ), &$this ) ); 2471 2491 foreach ( (array) $public_states as $state ) { 2472 2492 if ( 'publish' == $state ) // Publish is hard-coded above. 2473 2493 continue; … … 2476 2496 2477 2497 if ( $this->is_admin ) { 2478 2498 // Add protected states that should show in the admin all list. 2479 $admin_all_states = get_post_stati( array('protected' => true, 'show_in_admin_all_list' => true) ); 2499 $_args = array_merge( array( 'protected' => true, 'show_in_admin_all_list' => true ), $type_arg ); 2500 $admin_all_states = get_post_stati( $_args ); 2480 2501 foreach ( (array) $admin_all_states as $state ) 2481 2502 $where .= " OR $wpdb->posts.post_status = '$state'"; 2482 2503 } 2483 2504 2484 2505 if ( is_user_logged_in() ) { 2485 2506 // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. 2486 $private_states = get_post_stati( array('private' => true) ); 2487 foreach ( (array) $private_states as $state ) 2507 $_args = array_merge( array( 'private' => true ), $type_arg ); 2508 $private_states = apply_filters_ref_array( 'posts_private_stati', array( get_post_stati( $_args ), &$this ) ); 2509 foreach ( (array) $private_states as $state ) { 2510 if ( ! empty($post_type_object) ) { 2511 $check_cap = "read_{$state}_posts"; 2512 $read_private_cap = ( ! empty( $post_type_object->cap->$check_cap ) ) ? $post_type_object->cap->$check_cap : $post_type_object->cap->read_private_posts; 2513 } else 2514 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 2515 2488 2516 $where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'"; 2517 } 2489 2518 } 2490 2519 2491 2520 $where .= ')'; … … 2526 2555 $cwhere = "WHERE comment_approved = '1' $where"; 2527 2556 $cgroupby = "$wpdb->comments.comment_id"; 2528 2557 } else { // Other non singular e.g. front 2558 $public_stati = apply_filters( 'comment_feed_stati', get_post_stati( array( 'public' => true ) ) ); 2559 $public_csv = implode( "', '", $public_stati ); 2560 2529 2561 $cjoin = "JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 2530 $cwhere = "WHERE post_status = 'publish'AND comment_approved = '1'";2562 $cwhere = "WHERE post_status IN ( '$public_csv' ) AND comment_approved = '1'"; 2531 2563 $cgroupby = ''; 2532 2564 } 2533 2565 … … 2738 2770 $stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')"; 2739 2771 } 2740 2772 2773 $public_stati = apply_filters_ref_array( 'posts_sticky_stati', array( get_post_stati( array( 'public' => true ) ), &$this ) ); 2741 2774 $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" ); 2742 2775 foreach ( $stickies as $sticky_post ) { 2743 2776 // Ignore sticky posts the current user cannot read or are not published. 2744 if ( 'publish' != $sticky_post->post_status)2777 if ( ! in_array( $sticky_post->post_status, $public_stati ) ) 2745 2778 continue; 2779 2746 2780 array_splice($this->posts, $sticky_offset, 0, array($sticky_post)); 2747 2781 $sticky_offset++; 2748 2782 } -
wp-includes/general-template.php
915 915 } 916 916 917 917 //filters 918 $ where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r);919 $ join = apply_filters( 'getarchives_join', '', $r);918 $public_stati = apply_filters( 'getarchives_stati', get_post_stati( array( 'public' => true ) ) ); 919 $public_csv = implode( "', '", $public_stati ); 920 920 921 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status IN ('" . $public_csv . "')", $r ); 922 $join = apply_filters('getarchives_join', "", $r); 923 921 924 $output = ''; 922 925 923 926 if ( 'monthly' == $type ) { -
wp-includes/script-loader.php
332 332 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 ); 333 333 334 334 $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), false, 1 ); 335 $ scripts->localize( 'post', 'postL10n',array(335 $arr = array( 336 336 'ok' => __('OK'), 337 337 'cancel' => __('Cancel'), 338 338 'publishOn' => __('Publish on:'), … … 352 352 'privatelyPublished' => __('Privately Published'), 353 353 'published' => __('Published'), 354 354 'comma' => _x( ',', 'tag delimiter' ), 355 ) ); 355 ); 356 357 $custom = array(); 358 foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ) { 359 if ( 'publish' == $_status ) 360 continue; 356 361 362 $custom[ $_status ] = $_status_obj->labels->visibility; 363 364 if ( $_status_obj->public ) 365 $custom[ $_status . 'Sticky' ] = sprintf( __('%s, Sticky'), $_status_obj->label ); 366 } 367 368 $arr = array_merge( $custom, $arr ); // note: 'publish' has existing value of 'Publish', cannot be used to reference status name 369 370 $scripts->localize( 'post', 'postL10n', $arr ); 371 357 372 $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), false, 1 ); 373 $scripts->add_data( 'link', 'group', 1 ); 358 374 359 375 $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery') ); 360 376 $scripts->add_data( 'comment', 'group', 1 ); -
wp-content
-
wp-content/plugins
Property changes on: wp-content ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +.
-
wp-admin/includes/post.php
Property changes on: wp-content/plugins ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +.
71 71 // What to do based on which button they pressed 72 72 if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] ) 73 73 $post_data['post_status'] = 'draft'; 74 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) 74 if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] ) // TODO: is this set anywhere? 75 75 $post_data['post_status'] = 'private'; 76 76 if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) ) 77 77 $post_data['post_status'] = 'publish'; … … 88 88 89 89 // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published. 90 90 // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. 91 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) 92 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) 93 $ post_data['post_status'] = 'pending';91 if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) ) { 92 if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) ) { 93 $moderation_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 94 94 95 $_status_obj = get_post_status_object( $moderation_status ); 96 $cap_name = "set_{$moderation_status}_posts"; 97 98 if ( empty($_status_obj) || ! $_status_obj->moderation || ( ! empty($ptype->cap->$cap_name) && ! current_user_can($ptype->cap->$cap_name) ) ) 99 $moderation_status = 'pending'; 100 101 $post_data['post_status'] = $moderation_status; 102 } 103 } 104 95 105 if ( ! isset($post_data['post_status']) ) 96 106 $post_data['post_status'] = $previous_status; 97 107 … … 182 192 case 'password' : 183 193 unset( $post_data['sticky'] ); 184 194 break; 185 case 'private' : 186 $post_data['post_status'] = 'private'; 187 $post_data['post_password'] = ''; 188 unset( $post_data['sticky'] ); 189 break; 195 default: 196 $status_obj = get_post_status_object( $post_data['visibility'] ); 197 198 if ( ! empty( $status_obj->private ) || ! empty( $status_obj->public ) ) { 199 $post_data['post_status'] = $status_obj->name; 200 $post_data['post_password'] = ''; 201 } 202 203 if ( ! empty( $status_obj->private ) ) { 204 unset( $post_data['sticky'] ); 205 } 190 206 } 191 207 } 192 208 … … 568 584 case 'password' : 569 585 unset( $_POST['sticky'] ); 570 586 break; 571 case 'private' : 572 $_POST['post_status'] = 'private'; 573 $_POST['post_password'] = ''; 574 unset( $_POST['sticky'] ); 575 break; 587 default: 588 $status_obj = get_post_status_object( $_POST['visibility'] ); 589 if ( ! empty( $status_obj->private ) ) { 590 $_POST['post_status'] = $status_obj->name; 591 $_POST['post_password'] = ''; 592 unset( $_POST['sticky'] ); 593 } 576 594 } 577 595 } 578 596 … … 862 880 863 881 if ( isset($q['orderby']) ) 864 882 $orderby = $q['orderby']; 865 elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )883 elseif ( isset($q['post_status']) && ( in_array($q['post_status'], array('pending', 'draft')) || ! empty( $GLOBALS['wp_post_statuses'][$q['post_status']]->moderation ) ) ) 866 884 $orderby = 'modified'; 867 885 868 886 if ( isset($q['order']) ) … … 1024 1042 $original_date = $post->post_date; 1025 1043 $original_name = $post->post_name; 1026 1044 1045 $post_status_obj = get_post_status_object( $post->post_status ); 1046 1027 1047 // Hack: get_permalink would return ugly permalink for 1028 1048 // drafts, so we will fake, that our post is published 1029 if ( in_array($post->post_status, array('draft', 'pending')) ) {1049 if ( in_array($post->post_status, array('draft', 'pending')) || ! empty($post_status_obj->moderation) ) { 1030 1050 $post->post_status = 'publish'; 1031 1051 $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); 1032 1052 } … … 1084 1104 1085 1105 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 1086 1106 1087 if ( 'publish' == $post->post_status ) { 1107 $public_stati = get_post_stati( array( 'public' => true ) ); 1108 if ( in_array( $post->post_status, $public_stati ) ) { 1088 1109 $ptype = get_post_type_object($post->post_type); 1089 1110 $view_post = $ptype->labels->view_item; 1090 1111 $title = __('Click to edit this part of the permalink'); -
wp-admin/includes/template.php
254 254 <div class="post_author">' . $post->post_author . '</div> 255 255 <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> 256 256 <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> 257 <div class="_status">' . esc_html( $post->post_status ) . '</div> 257 <div class="_status">' . esc_html( $post->post_status ) . '</div>'; 258 259 if ( 'future' == $post->post_status ) { 260 if ( ! $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 261 $scheduled_status = 'publish'; 262 echo ' 263 <div class="scheduled_status">' . esc_html( $scheduled_status ). '</div>'; 264 } 265 266 echo ' 258 267 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 259 268 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 260 269 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> … … 575 584 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 576 585 global $wp_locale, $post, $comment; 577 586 578 if ( $for_post ) 579 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); 580 587 if ( $for_post ) { 588 $post_status_obj = get_post_status_object($post->post_status); 589 $edit = ( ( 'draft' != $post->post_status ) && empty($post_status_obj->moderation) ) || ( $post->post_date_gmt && '0000-00-00 00:00:00' != $post->post_date_gmt ); 590 } 591 581 592 $tab_index_attribute = ''; 582 593 if ( (int) $tab_index > 0 ) 583 594 $tab_index_attribute = " tabindex=\"$tab_index\""; … … 1467 1478 else 1468 1479 $post_status = ''; 1469 1480 1481 $post_status_obj = get_post_status_object($post->post_status); 1482 1470 1483 if ( !empty($post->post_password) ) 1471 1484 $post_states['protected'] = __('Password protected'); 1472 if ( 'private' == $post->post_status && 'private' != $post_status ) 1473 $post_states['private'] = __('Private'); 1474 if ( 'draft' == $post->post_status && 'draft' != $post_status ) 1475 $post_states['draft'] = __('Draft'); 1476 if ( 'pending' == $post->post_status && 'pending' != $post_status ) 1477 /* translators: post state */ 1478 $post_states['pending'] = _x('Pending', 'post state'); 1479 if ( is_sticky($post->ID) ) 1480 $post_states['sticky'] = __('Sticky'); 1485 1486 if ( $post_status_obj && ( 'publish' != $post->post_status ) ) { 1487 if ( $post->post_status != $post_status ) { 1488 $post_states[] = $post_status_obj->label; 1481 1489 1490 if ( 'future' == $post->post_status ) { 1491 if ( $scheduled_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) { 1492 if ( 'publish' != $scheduled_status ) { 1493 if ( $_scheduled_status_obj = get_post_status_object( $scheduled_status ) ) 1494 $post_states[] = $_scheduled_status_obj->label; 1495 } 1496 } 1497 } 1498 } 1499 } 1500 1482 1501 $post_states = apply_filters( 'display_post_states', $post_states ); 1483 1502 1484 1503 if ( ! empty($post_states) ) { -
wp-admin/includes/ajax-actions.php
735 735 wp_die( -1 ); 736 736 737 737 $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); 738 $post_status_obj = get_post_status_object($status); 738 739 739 if ( empty($ status) )740 if ( empty($post_status_obj) ) 740 741 wp_die( 1 ); 741 elseif ( in_array($status, array('draft', 'pending', 'trash') ))742 elseif ( ! $post_status_obj->public && ! $post_status_obj->private ) 742 743 wp_die( __('ERROR: you are replying to a comment on a draft post.') ); 743 744 744 745 $user = wp_get_current_user(); … … 1354 1355 if ( isset($data['post_parent']) ) 1355 1356 $data['parent_id'] = $data['post_parent']; 1356 1357 1358 $post_type_object = get_post_type_object( $post['post_type'] ); 1359 1357 1360 // status 1358 if ( isset($data['keep_private']) && 'private' == $data['keep_private'] ) 1359 $data['post_status'] = 'private'; 1360 else 1361 foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post['post_type'] ), 'object' ) as $_status => $_status_obj ) { 1362 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) // private and custom public stati only here 1363 continue; 1364 1365 if ( isset($data["keep_{$_status}"]) ) { 1366 $set_status_cap = "set_{$_status}_posts"; 1367 $check_cap = ( ! empty( $post_type_object->cap->$set_status_cap ) ) ? $post_type_object->cap->$set_status_cap : $post_type_object->cap->publish_posts; 1368 1369 if ( current_user_can( $check_cap ) ) { 1370 $data['post_status'] = $_status; 1371 $keeping_private = true; 1372 break; 1373 } 1374 } 1375 } 1376 1377 if ( empty($keeping_private) ) // private or custom public status selected and granted 1361 1378 $data['post_status'] = $data['_status']; 1362 1379 1363 1380 if ( empty($data['comment_status']) ) … … 1445 1462 if ( count($search_terms) > 1 && $search_terms[0] != $s ) 1446 1463 $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; 1447 1464 1448 $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); 1465 $public_stati = apply_filters( 'find_posts_stati', get_post_stati( array( 'public' => true ) ) ); 1466 $public_csv = implode( "', '", $public_stati ); 1467 1468 $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', $public_csv) AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); 1449 1469 1450 1470 if ( ! $posts ) { 1451 1471 $posttype = get_post_type_object($what); 1452 1472 wp_die( $posttype->labels->not_found ); 1453 1473 } 1474 1475 $stat = array(); 1454 1476 1455 1477 $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>'; 1456 1478 foreach ( $posts as $post ) { 1457 1479 1458 switch ( $post->post_status ) { 1459 case 'publish' : 1460 case 'private' : 1461 $stat = __('Published'); 1462 break; 1463 case 'future' : 1464 $stat = __('Scheduled'); 1465 break; 1466 case 'pending' : 1467 $stat = __('Pending Review'); 1468 break; 1469 case 'draft' : 1470 $stat = __('Draft'); 1471 break; 1480 if ( ! isset( $stat[$post->post_status] ) ) { 1481 $_status_obj = get_post_status_object( $post->post_status ); 1482 1483 if ( ! $_status_obj ) 1484 $_status_obj = get_post_status_object( 'draft' ); 1485 elseif ( ( $_status_obj->public || $_status_obj->private ) && ( 'publish' != $post->post_status ) ) 1486 $_status_obj = get_post_status_object( 'publish' ); 1487 1488 $stat[$post->post_status] = $_status_obj->labels->caption; 1472 1489 } 1473 1490 1474 1491 if ( '0000-00-00 00:00:00' == $post->post_date ) { … … 1479 1496 } 1480 1497 1481 1498 $html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>'; 1482 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";1499 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat[$post->post_status] ).'</td></tr>'."\n\n"; 1483 1500 } 1484 1501 $html .= '</tbody></table>'; 1485 1502 -
wp-admin/includes/meta-boxes.php
11 11 */ 12 12 function post_submit_meta_box($post) { 13 13 global $action; 14 15 $post_type = $post->post_type; 16 $post_type_obj = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_obj->cap->publish_posts); 18 $post_status = $post->post_status; 19 20 if ( ! $post_status_obj = get_post_status_object($post_status) ) 21 $post_status_obj = get_post_status_object( 'draft' ); 22 23 $moderation_stati = get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $post_type ), 'object' ); 14 24 15 $post_type = $post->post_type; 16 $post_type_object = get_post_type_object($post_type); 17 $can_publish = current_user_can($post_type_object->cap->publish_posts); 25 foreach( array_keys($moderation_stati) as $_status ) { 26 $set_cap = "set_{$_status}_posts"; 27 if ( ( $_status != $post_status ) && ( ! empty( $post_type_obj->cap->$set_cap ) && ! current_user_can( $post_type_obj->cap->$set_cap ) ) ) 28 unset( $moderation_stati[$_status] ); 29 } 18 30 ?> 19 31 <div class="submitbox" id="submitpost"> 20 32 … … 27 39 28 40 <div id="minor-publishing-actions"> 29 41 <div id="save-action"> 30 <?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?> 31 <input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" /> 32 <?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?> 33 <input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" /> 42 <?php 43 //if ( 'publish' != $post_status && 'future' != $post_status && 'pending' != $post_status ) { 44 if ( ! $post_status_obj->public && ! $post_status_obj->private && ! $post_status_obj->moderation && ( 'future' != $post_status ) ) { 45 // TODO: confirm we don't need a hidden save button when current status is private 46 $draft_status_obj = get_post_status_object( 'draft' ); 47 ?> 48 <input type="submit" name="save" id="save-post" value="<?php echo $draft_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 49 <?php 50 } elseif ( $post_status_obj->moderation && $can_publish ) { 51 ?> 52 <input type="submit" name="save" id="save-post" value="<?php echo $post_status_obj->labels->save_as ?>" tabindex="4" class="button button-highlighted" /> 53 34 54 <?php } ?> 35 55 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" /> 36 56 </div> 37 57 38 58 <div id="preview-action"> 39 59 <?php 40 if ( 'publish' == $post->post_status) {60 if ( $post_status_obj->public ) { 41 61 $preview_link = esc_url( get_permalink( $post->ID ) ); 42 62 $preview_button = __( 'Preview Changes' ); 43 63 } else { … … 59 79 60 80 <div class="misc-pub-section"><label for="post_status"><?php _e('Status:') ?></label> 61 81 <span id="post-status-display"> 62 <?php 63 switch ( $post->post_status ) { 64 case 'private': 65 _e('Privately Published'); 66 break; 67 case 'publish': 68 _e('Published'); 69 break; 70 case 'future': 71 _e('Scheduled'); 72 break; 73 case 'pending': 74 _e('Pending Review'); 75 break; 76 case 'draft': 77 case 'auto-draft': 78 _e('Draft'); 79 break; 80 } 81 ?> 82 <?php echo $post_status_obj->labels->caption; ?> 82 83 </span> 83 <?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>84 <a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> 84 <?php 85 $select_moderation = ( count($moderation_stati) > 1 || ( $post_status != key($moderation_stati) ) ); // multiple moderation stati are selectable or a single non-current moderation stati is selectable 85 86 87 if ( $post_status_obj->public || $post_status_obj->private || $can_publish || $select_moderation ) { ?> 88 <a href="#post_status" <?php if ( $post_status_obj->private || ( $post_status_obj->public && 'publish' != $post_status ) ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a> 89 86 90 <div id="post-status-select" class="hide-if-js"> 87 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post ->post_status ) ? 'draft' : $post->post_status); ?>" />91 <input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post_status ) ? 'draft' : $post_status); ?>" /> 88 92 <select name='post_status' id='post_status' tabindex='4'> 89 <?php if ( 'publish' == $post->post_status ) : ?> 90 <option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option> 91 <?php elseif ( 'private' == $post->post_status ) : ?> 92 <option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option> 93 <?php elseif ( 'future' == $post->post_status ) : ?> 94 <option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option> 93 94 <?php if ( $post_status_obj->public || $post_status_obj->private || ( 'future' == $post_status ) ) : ?> 95 <option<?php selected( $post_status, $post_status ); ?> value='publish'><?php echo $post_status_obj->labels->caption ?></option> 95 96 <?php endif; ?> 96 <option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option> 97 <?php if ( 'auto-draft' == $post->post_status ) : ?> 98 <option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option> 99 <?php else : ?> 100 <option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option> 101 <?php endif; ?> 97 98 <?php 99 foreach( $moderation_stati as $_status => $_status_obj ) : ?> 100 <option<?php selected( $post_status, $_status ); ?> value='<?php echo $_status ?>'><?php echo $_status_obj->labels->caption ?></option> 101 <?php endforeach ?> 102 103 <?php 104 $draft_status_obj = get_post_status_object( 'draft' ); 105 $compare_status = ( 'auto-draft' == $post_status ) ? 'auto-draft' : 'draft'; 106 ?> 107 <option<?php selected( $post_status, $compare_status ); ?> value='draft'><?php echo $draft_status_obj->label ?></option> 108 102 109 </select> 103 110 <a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a> 104 111 <a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a> … … 110 117 <div class="misc-pub-section" id="visibility"> 111 118 <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php 112 119 113 if ( 'private' == $post->post_status ) { 120 if ( 'future' == $post_status ) { // indicate eventual visibility of scheduled post 121 if ( ! $vis_status = get_post_meta( $post->ID, '_scheduled_status', true ) ) 122 $vis_status = 'publish'; 123 124 $vis_status_obj = get_post_status_object( $vis_status ); 125 } else { 126 $vis_status = $post_status; 127 $vis_status_obj = $post_status_obj; 128 } 129 130 if ( 'publish' == $vis_status ) { 114 131 $post->post_password = ''; 115 $visibility = 'private'; 116 $visibility_trans = __('Private'); 132 $visibility = 'public'; 133 134 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 135 $visibility_trans = __('Public, Sticky'); 136 } else { 137 $visibility_trans = __('Public'); 138 } 139 } elseif ( $vis_status_obj->public ) { 140 $post->post_password = ''; 141 $visibility = $vis_status; 142 143 if ( post_type_supports( $post->post_type, 'sticky' ) && is_sticky( $post->ID ) ) { 144 $visibility_trans = sprintf( __('%s, Sticky'), $vis_status_obj->label ); 145 } else { 146 $visibility_trans = $vis_status_obj->labels->visibility; 147 } 148 } elseif ( $vis_status_obj->private ) { 149 $post->post_password = ''; 150 $visibility_trans = $vis_status_obj->labels->visibility; 117 151 } elseif ( !empty( $post->post_password ) ) { 118 152 $visibility = 'password'; 119 153 $visibility_trans = __('Password protected'); … … 135 169 <input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> /> 136 170 <?php endif; ?> 137 171 <input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" /> 172 138 173 <input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br /> 174 175 <?php 176 foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 177 if ( 'publish' == $_status ) 178 continue; 179 180 $post_cap = "set_{$_status}_posts"; 181 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 182 ?> 183 <input type="radio" name="visibility" id="visibility-radio-<?php echo $_status ?>" value="<?php echo $_status ?>" <?php checked( $visibility, $_status ); ?> /> <label for="visibility-radio-<?php echo $_status ?>" class="selectit"><?php echo $_status_obj->labels->visibility ?></label><br /> 184 <?php 185 } // end if this user can set status 186 endforeach ?> 187 139 188 <?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?> 140 189 <span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span> 141 190 <?php endif; ?> 191 142 192 <input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br /> 143 193 <span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span> 144 <input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />145 194 195 <?php 196 foreach( get_post_stati( array( 'private' => true, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 197 $post_cap = "set_{$_status}_posts"; 198 if ( empty( $post_type_obj->cap->$post_cap ) || current_user_can( $post_type_obj->cap->$post_cap ) ) { 199 ?> 200 <input type="radio" name="visibility" id="visibility-radio-<?php echo $_status ?>" value="<?php echo $_status ?>" <?php checked( $visibility, $_status ); ?> /> <label for="visibility-radio-<?php echo $_status ?>" class="selectit"><?php echo $_status_obj->label ?></label><br /> 201 <?php 202 } // end if this user can set status 203 endforeach ?> 146 204 <p> 147 205 <a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a> 148 206 <a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a> … … 155 213 <?php 156 214 // translators: Publish box date format, see http://php.net/date 157 215 $datef = __( 'M j, Y @ G:i' ); 216 217 $published_stati = get_post_stati( array( 'public' => true, 'private' => true ), 'names', 'or' ); 218 158 219 if ( 0 != $post->ID ) { 159 if ( 'future' == $post ->post_status ) { // scheduled for publishing at a future date220 if ( 'future' == $post_status ) { // scheduled for publishing at a future date 160 221 $stamp = __('Scheduled for: <b>%1$s</b>'); 161 } else if ( 'publish' == $post->post_status || 'private' == $post->post_status) { // already published222 } else if ( in_array( $post_status, $published_stati ) ) { // already published 162 223 $stamp = __('Published on: <b>%1$s</b>'); 163 224 } else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified 164 225 $stamp = __('Publish <b>immediately</b>'); … … 204 265 <div id="publishing-action"> 205 266 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" /> 206 267 <?php 207 if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID) {268 if ( ( ! $post_status_obj->public && ! $post_status_obj->private && ( 'future' != $post_status ) ) ) { 208 269 if ( $can_publish ) : 209 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> 210 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" /> 211 <?php submit_button( __( 'Schedule' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 212 <?php else : ?> 213 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" /> 214 <?php submit_button( __( 'Publish' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 270 271 if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : 272 $future_status_obj = get_post_status_object( 'future' ); 273 ?> 274 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $future_status_obj->labels->publish ?>" /> 275 <?php submit_button( $future_status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 276 <?php else : 277 $publish_status_obj = get_post_status_object( 'publish' ); 278 ?> 279 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $publish_status_obj->labels->publish ?>" /> 280 <?php submit_button( $publish_status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 215 281 <?php endif; 216 282 else : ?> 217 <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" /> 218 <?php submit_button( __( 'Submit for Review' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 283 <?php 284 $moderation_button_status = apply_filters( 'post_moderation_status', 'pending', $post->ID ); 285 286 $status_obj = get_post_status_object( $moderation_button_status ); 287 $cap_name = "set_{$moderation_button_status}_posts"; 288 289 if ( ! $status_obj || ( ! empty($post_type_obj->cap->$cap_name) && ! current_user_can($post_type_obj->cap->$cap_name) ) ) 290 $status_obj = get_post_status_object( 'pending' ); 291 ?> 292 <input name="original_publish" type="hidden" id="original_publish" value="<?php echo $status_obj->labels->publish ?>" /> 293 <?php submit_button( $status_obj->labels->publish, 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?> 219 294 <?php 220 295 endif; 221 296 } else { ?> -
wp-admin/includes/nav-menu.php
1039 1039 */ 1040 1040 function _wp_nav_menu_meta_box_object( $object = null ) { 1041 1041 if ( isset( $object->name ) ) { 1042 $public_stati = apply_filters( 'nav_menu_metabox_stati', get_post_stati( array( 'public' => true, 'object_type' => $object->name ) ), $object ); 1043 $public_csv = implode( ',', $public_stati ); 1042 1044 1043 1045 if ( 'page' == $object->name ) { 1044 1046 $object->_default_query = array( 1045 1047 'orderby' => 'menu_order title', 1046 'post_status' => 'publish',1048 'post_status' => $public_csv, 1047 1049 ); 1048 1050 1049 // posts should show only publi sheditems1051 // posts should show only public items 1050 1052 } elseif ( 'post' == $object->name ) { 1051 1053 $object->_default_query = array( 1052 'post_status' => 'publish',1054 'post_status' => $public_csv, 1053 1055 ); 1054 1056 1055 1057 // cats should be in reverse chronological order … … 1059 1061 'order' => 'DESC', 1060 1062 ); 1061 1063 1062 // custom post types should show only publi sheditems1064 // custom post types should show only public items 1063 1065 } else { 1064 1066 $object->_default_query = array( 1065 'post_status' => 'publish',1067 'post_status' => $public_csv, 1066 1068 ); 1067 1069 } 1068 1070 } -
wp-admin/js/post.dev.js
380 380 } 381 381 382 382 function updateText() { 383 var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'),384 optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(),383 var attemptedDate, originalDate, currentDate, publishOn, 384 postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus), aa = $('#aa').val(), 385 385 mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); 386 386 387 387 attemptedDate = new Date( aa, mm - 1, jj, hh, mn ); … … 405 405 publishOn = postL10n.publishOnPast; 406 406 $('#publish').val( postL10n.update ); 407 407 } 408 408 409 if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack 409 410 $('#timestamp').html(stamp); 410 411 } else { … … 419 420 } 420 421 421 422 if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { 423 422 424 $('#publish').val( postL10n.update ); 423 425 if ( optPublish.length == 0 ) { 424 426 postStatus.append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); 425 427 } else { 426 428 optPublish.html( postL10n.privatelyPublished ); 427 429 } 430 428 431 $('option[value="publish"]', postStatus).prop('selected', true); 432 429 433 $('.edit-post-status', '#misc-publishing-actions').hide(); 430 434 } else { 431 435 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { … … 439 443 if ( postStatus.is(':hidden') ) 440 444 $('.edit-post-status', '#misc-publishing-actions').show(); 441 445 } 442 $('#post-status-display').html($('option:selected', postStatus).text()); 443 if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) { 444 $('#save-post').hide(); 445 } else { 446 $('#save-post').show(); 447 if ( $('option:selected', postStatus).val() == 'pending' ) { 448 $('#save-post').show().val( postL10n.savePending ); 449 } else { 450 $('#save-post').show().val( postL10n.saveDraft ); 451 } 452 } 446 453 447 return true; 454 448 } 455 449 … … 461 455 } 462 456 return false; 463 457 }); 464 458 465 459 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 466 460 $('#post-visibility-select').slideUp('fast'); 467 461 $('#visibility-radio-' + $('#hidden-post-visibility').val()).prop('checked', true); … … 469 463 $('#sticky').prop('checked', $('#hidden-post-sticky').prop('checked')); 470 464 $('#post-visibility-display').html(visibility); 471 465 $('.edit-visibility', '#visibility').show(); 472 updateText();473 466 return false; 474 467 }); 475 468 476 469 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 477 470 var pvSelect = $('#post-visibility-select'); 478 471 479 472 pvSelect.slideUp('fast'); 480 473 $('.edit-visibility', '#visibility').show(); 481 updateText();482 474 475 483 476 if ( $('input:radio:checked', pvSelect).val() != 'public' ) { 484 477 $('#sticky').prop('checked', false); 485 478 } // WEAPON LOCKED … … 489 482 } else { 490 483 sticky = ''; 491 484 } 492 485 493 486 $('#post-visibility-display').html( postL10n[$('input:radio:checked', pvSelect).val() + sticky] ); 494 487 return false; 495 488 }); 496 489 497 490 $('input:radio', '#post-visibility-select').change(function() { 498 491 updateVisibility(); 499 492 }); -
wp-admin/js/inline-edit-post.dev.js
78 78 t.revert(); 79 79 $('select[name^="action"]').val('-1'); 80 80 }); 81 82 $('.keep-private, .keep-private input').click(function() { 83 if ( $(this).attr('checked') ) { 84 $('.keep-private input').filter("[name!='" + $(this).attr('name') + "']").removeAttr('checked'); 85 } 86 }); 81 87 }, 82 88 83 89 toggle : function(el){ … … 129 135 if ( typeof(id) == 'object' ) 130 136 id = t.getId(id); 131 137 132 fields = ['post_title', 'post_name', 'post_author', '_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order']; 138 fields = ['post_title', 'post_name', 'post_author', '_status', 'scheduled_status', 'jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password', 'post_format', 'menu_order']; 139 133 140 if ( t.type == 'page' ) 134 141 fields.push('post_parent', 'page_template'); 135 142 … … 198 205 199 206 // handle the post status 200 207 status = $('._status', rowData).text(); 201 if ( 'future' != status ) 208 209 if ( 'future' == status ) { 210 status = $('.scheduled_status', rowData).text(); 211 } else { 202 212 $('select[name="_status"] option[value="future"]', editRow).remove(); 213 } 203 214 204 if ( 'private' == status) {205 $('input[name="keep_ private"]', editRow).prop("checked", true);206 $('input.inline-edit-password-input').val('').prop('disabled', true);215 if ( $('[name=keep_' + status + ']').length > 0) { 216 $('input[name="keep_' + status + '"]', editRow).prop("checked", "checked"); 217 $('input.inline-edit-password-input').val('').prop('disabled', 'disabled'); 207 218 } 208 219 209 220 // remove the current page and children from the parent dropdown -
wp-admin/post.php
51 51 $message = 9; 52 52 break; 53 53 default: 54 $message = 6; 54 $status_obj = get_post_status_object( $status ); 55 if ( ! empty($status_obj->moderation) ) 56 $message = 11; 57 else 58 $message = 6; 55 59 } 56 60 } else { 57 61 $message = 'draft' == $status ? 10 : 1; -
wp-admin/edit-form-advanced.php
45 45 // translators: Publish box date format, see http://php.net/date 46 46 date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 47 47 10 => sprintf( __('Post draft updated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 48 11 => sprintf( __('Post moderated. <a target="_blank" href="%s">Preview post</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 48 49 ); 49 50 $messages['page'] = array( 50 51 0 => '', // Unused. Messages start at index 1. … … 58 59 8 => sprintf( __('Page submitted. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 59 60 9 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 60 61 10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 62 11 => sprintf( __('Page moderated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 61 63 ); 62 64 63 65 $messages = apply_filters( 'post_updated_messages', $messages ); … … 140 142 if ( post_type_supports($post_type, 'comments') ) 141 143 add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core'); 142 144 143 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') ) 145 if ( ! $post_status_object = get_post_status_object( $post->post_status ) ) 146 $post_status_object = get_post_status_object( 'draft' ); 147 148 if ( ( $post_status_object->public || $post_status_object->private ) && post_type_supports($post_type, 'comments') ) 144 149 add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core'); 145 150 146 if ( ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )151 if ( ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) 147 152 add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core'); 148 153 149 154 if ( post_type_supports($post_type, 'author') ) { … … 292 297 if ( !empty($shortlink) ) 293 298 $sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>'; 294 299 295 if ( $post_type_object->public && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>300 if ( $post_type_object->public && ! ( $post_status_object->moderation && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?> 296 301 <div id="edit-slug-box"> 297 302 <?php 298 303 if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status ) … … 385 390 try{document.post.title.focus();}catch(e){} 386 391 </script> 387 392 <?php endif; ?> 393 394 395 <?php 396 add_action( 'admin_print_footer_scripts', create_function('', "_edit_form_advanced_scripts('$post_type');") ); 397 398 function _edit_form_advanced_scripts( $post_type ) { 399 ?> 400 401 <script type="text/javascript"> 402 //<![CDATA[ 403 jQuery(document).ready( function($) { 404 function updateStatusCaptions() { 405 postStatus = $('#post_status'); 406 407 $('#post-status-display').html($('option:selected', postStatus).text()); 408 409 switch( $('option:selected', postStatus).val() ) { 410 411 <?php foreach( get_post_stati( array( 'public' => true, 'private' => true ), 'object', 'or' ) as $_status => $_status_obj ): ?> 412 case '<?php echo $_status ?>': 413 $('#save-post').hide(); 414 break; 415 <?php endforeach; ?> 416 417 <?php foreach( get_post_stati( array( 'moderation' => true, 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ): ?> 418 case '<?php echo $_status ?>': 419 $('#save-post').show().val( '<?php echo $_status_obj->labels->save_as ?>' ); 420 break; 421 <?php endforeach; ?> 422 423 default : 424 <?php $draft_status_obj = get_post_status_object( 'draft' ); ?> 425 $('#save-post').show().val( '<?php echo $draft_status_obj->labels->save_as ?>' ); 426 } 427 } 428 429 $('input:radio', '#post-visibility-select').change(function() { 430 switch ( $('input:radio:checked', '#post-visibility-select').val() ) { 431 case 'public': 432 $('#sticky-span').show(); 433 break; 434 435 <?php foreach( get_post_stati( array( 'public' => true, 'object_type' => $post_type ) ) as $_status ) : ?> 436 case '<?php echo $_status ?>': 437 $('#sticky-span').show(); 438 break; 439 <?php endforeach; ?> 440 441 default : 442 $('#sticky').attr('checked', false); 443 $('#sticky-span').hide(); 444 } 445 }); 446 447 function updateVisibilityCaptions() { 448 var postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus); 449 450 switch( $('input:radio:checked', '#post-visibility-select').val() ) { 451 452 <?php foreach( get_post_stati( array( 'internal' => false, 'object_type' => $post_type ), 'object' ) as $_status => $_status_obj ) : 453 if ( ( 'publish' == $_status ) || ( ! $_status_obj->private && ! $_status_obj->public ) ) 454 continue; 455 ?> 456 case '<?php echo $_status ?>': 457 $('#publish').val( postL10n.update ); 458 459 if ( optPublish.length == 0 ) { 460 postStatus.append('<option value="publish">' + '<?php echo $_status_obj->labels->caption ?>' + '</option>'); 461 } else { 462 optPublish.html( '<?php echo $_status_obj->labels->caption ?>' ); 463 } 464 465 $('option[value=publish]', postStatus).attr('selected', true); 466 $('.edit-post-status', '#misc-publishing-actions').hide(); 467 468 break; 469 <?php endforeach; ?> 470 471 default: 472 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { 473 if ( optPublish.length ) { 474 optPublish.remove(); 475 postStatus.val($('#hidden_post_status').val()); 476 } 477 } else { 478 optPublish.html( postL10n.published ); 479 } 480 if ( postStatus.is(':hidden') ) 481 $('.edit-post-status', '#misc-publishing-actions').show(); 482 } 483 484 return true; 485 } 486 487 $('.save-post-status', '#post-status-select').click(function() { 488 updateStatusCaptions(); 489 return false; 490 }); 491 492 $('.cancel-post-visibility', '#post-visibility-select').click(function () { 493 updateVisibilityCaptions(); 494 return false; 495 }); 496 497 $('.save-post-visibility', '#post-visibility-select').click(function () { // crazyhorse - multiple ok cancels 498 updateVisibilityCaptions(); 499 updateStatusCaptions(); 500 return false; 501 }); 502 }); 503 //]]> 504 </script> 505 506 <?php 507 } // end function edit_form_advanced_scripts 508 ?> 509 No newline at end of file