*/ private const LOCALIZE_ALLOWED_FIELDS = [ 'ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_name', 'post_modified', 'post_modified_gmt', 'post_parent', 'guid', 'menu_order', 'post_type', 'post_mime_type', 'comment_count', ]; /** * Build the post slice for reactPress.post without leaking passwords or locked content. * * @param \WP_Post $post Current page when the React app is enqueued. * @return array */ public static function for_localize_script(\WP_Post $post): array { $data = []; foreach (self::LOCALIZE_ALLOWED_FIELDS as $field) { $data[$field] = \get_post_field($field, $post, 'raw'); } $password_required = \post_password_required($post); $data['isPasswordProtected'] = $password_required; if ($password_required) { $data['post_content'] = ''; $data['post_excerpt'] = ''; } return $data; } }