PluginProbe
Assistant – Every Day Productivity Apps / 1.0.2
Assistant – Every Day Productivity Apps v1.0.2
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
← All changes | backend/src/Data/Transformers/PostTransformer.php +16 -2 0.41.0.2 View file →
@@ -1,14 +1,13 @@
1 1 <?php
2 2
3 -
4 3 namespace FL\Assistant\Data\Transformers;
5 4
6 5 use FL\Assistant\Data\Repository\NotationsRepository;
7 6 use FL\Assistant\Data\Repository\TermsRepository;
8 7 use FL\Assistant\System\Integrations\BeaverBuilder;
8 +use FL\Assistant\Helpers\PreviewHelper;
9 9
10 -
11 10 /**
12 11 * Class PostTransformer
13 12 *
14 13 * Convert a WP_Post object to array suitable for REST output
@@ -59,14 +58,27 @@
59 58
60 59 $thumb_id = get_post_thumbnail_id( $post );
61 60 $thumb_data = wp_prepare_attachment_for_js( $thumb_id );
62 61
62 + $all_users = get_users( [ 'who' => 'authors' ] );
63 + $users = [];
64 +
65 + foreach ( $all_users as $user ) {
66 + $users[ $user->ID ] = $user->display_name;
67 + }
68 +
69 + if ( ! function_exists( 'wp_check_post_lock' ) ) {
70 + require_once ABSPATH . 'wp-admin/includes/post.php';
71 + }
72 +
63 73 $response = [
64 74 'author' => $author,
75 + 'post_author' => $post->post_author,
65 76 'commentsAllowed' => 'open' === $post->comment_status ? true : false,
66 77 'excerpt' => $post->post_excerpt,
67 78 'date' => $date,
68 79 'editUrl' => get_edit_post_link( $post->ID, '' ),
80 + 'previewUrl' => PreviewHelper::get_post_preview_url( $post ),
69 81 'id' => $post->ID,
70 82 'labels' => [],
71 83 'order' => $post->menu_order,
72 84 'parent' => $post->post_parent,
@@ -84,8 +96,10 @@
84 96 'url' => get_permalink( $post ),
85 97 'visibility' => 'public',
86 98 'commentsCount' => get_comments_number( $post->ID ),
87 99 'isSticky' => is_sticky( $post->ID ),
100 + 'authorList' => $users,
101 + 'hasLock' => wp_check_post_lock( $post->ID ),
88 102 ];
89 103
90 104 // Post visibility.
91 105 if ( 'private' === $post->post_status ) {