← All changes
|
modules/site-navigation/data/endpoints/duplicate-post.php
+4
-5
4.1.0-dev2
→
3.27.4
View file →
| @@ -49,10 +49,9 @@ | ||
| 49 | 49 | |
| 50 | 50 | $post = get_post( $post_id ); |
| 51 | 51 | |
| 52 | 52 | if ( ! User::is_current_user_can_edit_post_type( $post->post_type ) ) { |
| 53 | - $sanitized_post_type = esc_html( str_replace( '%', '%%', $post->post_type ) ); | |
| 54 | - return new \WP_Error( 401, sprintf( 'User dont have capability to create page of type - %s.', $sanitized_post_type ), [ 'status' => 401 ] ); | |
| 53 | + return new \WP_Error( 401, sprintf( 'User dont have capability to create page of type - %s.', $post->post_type ), [ 'status' => 401 ] ); | |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | if ( ! $post ) { |
| 58 | 57 | return new \WP_Error( 500, 'Post not found' ); |
| @@ -63,12 +62,12 @@ | ||
| 63 | 62 | if ( is_wp_error( $new_post_id ) ) { |
| 64 | 63 | return new \WP_Error( 500, 'Error while duplicating post.' ); |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | - // Duplicate all post meta | |
| 66 | + //Duplicate all post meta | |
| 68 | 67 | $this->duplicate_post_meta( $post_id, $new_post_id ); |
| 69 | 68 | |
| 70 | - // Duplicate all taxonomies | |
| 69 | + //Duplicate all taxonomies | |
| 71 | 70 | $this->duplicate_post_taxonomies( $post_id, $new_post_id ); |
| 72 | 71 | |
| 73 | 72 | return [ |
| 74 | 73 | 'post_id' => $new_post_id, |
| @@ -131,9 +130,9 @@ | ||
| 131 | 130 | } |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | /** |
| 135 | - * Duplicate_post_taxonomies | |
| 134 | + * duplicate_post_taxonomies | |
| 136 | 135 | * |
| 137 | 136 | * @param int $post_id |
| 138 | 137 | * @param int $new_post_id |
| 139 | 138 | */ |