$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'] );
}
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'] );
$q['post_parent'] = 0;
}
+ // Filter query clauses to include filenames.
+ if ( isset( $q['s'] ) ) {
+ add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );
+ }
+
return $q;
}
* @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 );
*
* @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).
$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 );
}
}
*
* @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 );