← All changes
|
modules/site-navigation/data/endpoints/add-new-post.php
+3
-6
4.3.0-beta2
→
3.26.2
View file →
| @@ -40,15 +40,13 @@ | ||
| 40 | 40 | public function create_items( $request ) { |
| 41 | 41 | $post_type = $request->get_param( 'post_type' ); |
| 42 | 42 | |
| 43 | 43 | if ( ! $this->validate_post_type( $post_type ) ) { |
| 44 | - $sanitized_post_type = esc_html( str_replace( '%', '%%', $post_type ) ); | |
| 45 | - return new \WP_Error( 400, sprintf( 'Post type %s does not exist.', $sanitized_post_type ), [ 'status' => 400 ] ); | |
| 44 | + return new \WP_Error( 400, sprintf( 'Post type %s does not exist.', $post_type ), [ 'status' => 400 ] ); | |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | if ( ! User::is_current_user_can_edit_post_type( $post_type ) ) { |
| 49 | - $sanitized_post_type = esc_html( str_replace( '%', '%%', $post_type ) ); | |
| 50 | - return new \WP_Error( 401, sprintf( 'User dont have capability to create page of type - %s.', $sanitized_post_type ), [ 'status' => 401 ] ); | |
| 48 | + return new \WP_Error( 401, sprintf( 'User dont have capability to create page of type - %s.', $post_type ), [ 'status' => 401 ] ); | |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | // Temporary solution for the fact that documents creation not using the actual registered post types. |
| 54 | 52 | $post_type = $this->map_post_type( $post_type ); |
| @@ -55,10 +53,9 @@ | ||
| 55 | 53 | |
| 56 | 54 | $document = Plugin::$instance->documents->create( $post_type ); |
| 57 | 55 | |
| 58 | 56 | if ( is_wp_error( $document ) ) { |
| 59 | - $sanitized_post_type = esc_html( str_replace( '%', '%%', $post_type ) ); | |
| 60 | - return new \WP_Error( 500, sprintf( 'Error while creating %s.', $sanitized_post_type ) ); | |
| 57 | + return new \WP_Error( 500, sprintf( 'Error while creating %s.', $post_type ) ); | |
| 61 | 58 | } |
| 62 | 59 | |
| 63 | 60 | return [ |
| 64 | 61 | 'id' => $document->get_main_id(), |