]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/post.php
WordPress 4.7.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / post.php
index 790b736cdf2c0c09b5021c24410c827c354e88f8..eca583a2ecb0b2c59c993c7aa7de315fb64b0393 100644 (file)
@@ -160,7 +160,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
                $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
                $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] );
                if ( !$valid_date ) {
-                       return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
+                       return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
                }
                $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
        }
@@ -288,6 +288,8 @@ function edit_post( $post_data = null ) {
                                continue;
                        if ( $meta->post_id != $post_ID )
                                continue;
+                       if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) )
+                               continue;
                        if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
                                continue;
                        update_meta( $key, $value['key'], $value['value'] );
@@ -1144,6 +1146,11 @@ function wp_edit_attachments_query_vars( $q = false ) {
                $q['post_parent'] = 0;
        }
 
+       // Filter query clauses to include filenames.
+       if ( isset( $q['s'] ) ) {
+               add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+       }
+
        return $q;
 }
 
@@ -1207,9 +1214,9 @@ function postbox_classes( $id, $page ) {
  * @since 2.5.0
  *
  * @param int    $id    Post ID or post object.
- * @param string $title Optional. Title. Default null.
- * @param string $name  Optional. Name. Default null.
- * @return array Array with two entries of type string.
+ * @param string $title Optional. Title to override the post's current title when generating the post name. Default null.
+ * @param string $name  Optional. Name to override the post name. Default null.
+ * @return array Array containing the sample permalink with placeholder for the post name, and the post name.
  */
 function get_sample_permalink($id, $title = null, $name = null) {
        $post = get_post( $id );
@@ -1270,7 +1277,7 @@ function get_sample_permalink($id, $title = null, $name = null) {
         *
         * @since 4.4.0
         *
-        * @param string  $permalink Sample permalink.
+        * @param array   $permalink Array containing the sample permalink with placeholder for the post name, and the post name.
         * @param int     $post_id   Post ID.
         * @param string  $title     Post title.
         * @param string  $name      Post name (slug).
@@ -1300,14 +1307,14 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
        $preview_target = '';
 
        if ( current_user_can( 'read_post', $post->ID ) ) {
-               if ( 'draft' === $post->post_status ) {
+               if ( 'draft' === $post->post_status || empty( $post->post_name ) ) {
                        $view_link = get_preview_post_link( $post );
                        $preview_target = " target='wp-preview-{$post->ID}'";
                } else {
                        if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
                                $view_link = get_permalink( $post );
                        } else {
-                               // Allow non-published (private, future) to be viewed at a pretty permalink.
+                               // Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set
                                $view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink );
                        }
                }
@@ -1367,14 +1374,12 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
  *
  * @since 2.9.0
  *
- * @global array $_wp_additional_image_sizes
- *
  * @param int $thumbnail_id ID of the attachment used for thumbnail
  * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
  * @return string html
  */
 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
-       global $_wp_additional_image_sizes;
+       $_wp_additional_image_sizes = wp_get_additional_image_sizes();
 
        $post               = get_post( $post );
        $post_type_object   = get_post_type_object( $post->post_type );