← All changes
|
backend/src/Data/Transformers/PostTransformer.php
+17
-2
0.7.0.4
→
1.4.7
View file →
| @@ -48,8 +48,23 @@ | ||
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param \WP_Post $post |
| 51 | 51 | * |
| 52 | + * @return string | |
| 53 | + */ | |
| 54 | + public function get_edit_post_link( \WP_Post $post ) { | |
| 55 | + | |
| 56 | + if ( strstr( $post->post_type, 'wp_template' ) ) { | |
| 57 | + $id = get_stylesheet() . '//' . $post->post_name; | |
| 58 | + return admin_url( "/site-editor.php?postType={$post->post_type}&postId={$id}" ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + return get_edit_post_link( $post->ID, '' ); | |
| 62 | + } | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * @param \WP_Post $post | |
| 66 | + * | |
| 52 | 67 | * @return array |
| 53 | 68 | */ |
| 54 | 69 | public function transform( \WP_Post $post ) { |
| 55 | 70 | $author = get_the_author_meta( 'display_name', $post->post_author ); |
| @@ -75,9 +90,9 @@ | ||
| 75 | 90 | 'post_author' => $post->post_author, |
| 76 | 91 | 'commentsAllowed' => 'open' === $post->comment_status ? true : false, |
| 77 | 92 | 'excerpt' => $post->post_excerpt, |
| 78 | 93 | 'date' => $date, |
| 79 | - 'editUrl' => get_edit_post_link( $post->ID, '' ), | |
| 94 | + 'editUrl' => $this->get_edit_post_link( $post ), | |
| 80 | 95 | 'previewUrl' => PreviewHelper::get_post_preview_url( $post ), |
| 81 | 96 | 'id' => $post->ID, |
| 82 | 97 | 'labels' => [], |
| 83 | 98 | 'order' => $post->menu_order, |
| @@ -89,9 +104,9 @@ | ||
| 89 | 104 | 'template' => empty( $template ) ? 'default' : $template, |
| 90 | 105 | 'terms' => [], |
| 91 | 106 | 'thumbnail' => get_the_post_thumbnail_url( $post, 'thumbnail' ), |
| 92 | 107 | 'thumbnailData' => $thumb_data, |
| 93 | - 'title' => empty( $post->post_title ) ? __( '(no title)', 'fl-assistant' ) : $post->post_title, | |
| 108 | + 'title' => empty( $post->post_title ) ? __( '(no title)', 'assistant' ) : $post->post_title, | |
| 94 | 109 | 'trashedStatus' => get_post_meta( $post->ID, '_wp_trash_meta_status', true ), |
| 95 | 110 | 'type' => $post->post_type, |
| 96 | 111 | 'url' => get_permalink( $post ), |
| 97 | 112 | 'visibility' => 'public', |