New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block data to REST API #2649

Closed
wants to merge 54 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+2 −2
Diff settings

Always

Just for now

Viewing a subset of changes. View all

fix rendered data setup

  • Loading branch information...
adamsilverstein committed Sep 4, 2017
commit cfd2f5e1b8921a9f12c592a8f547b7802721b5f5
View
@@ -126,8 +126,8 @@ function get_block_data_for_api_from_post_content( $content ) {
$item_data['attributes'] = $block['attrs'];

This comment has been minimized.

@rmccue

rmccue Sep 5, 2017

Contributor

This should be $attributes not $block['attrs']. Also, properties should always be set if they're exposed in a given context to avoid index errors.

This comment has been minimized.

@adamsilverstein
}
$item_data['content'] = $block['rawContent'];

This comment has been minimized.

@rmccue

rmccue Sep 5, 2017

Contributor

$block['rawContent'] -> $raw_content

Also, should this only be exposed for $context === 'edit'?

This comment has been minimized.

@adamsilverstein

adamsilverstein Sep 7, 2017

Contributor

This is perhaps misnamed when it is returned from the parser - its not really the raw content and doesn't include the html markers for example. This really represents the rendered html and is returned as content for a block (matching naming from #2503). As far as I can see, rendered is only used for a couple of block types where their content is dynamic, for example a recent post list.

This comment has been minimized.

@adamsilverstein

adamsilverstein Sep 7, 2017

Contributor

Can you review the data thats output, it seems public? we could show blocks only in edit context, but that would make my idea of using them for a front end data source less useful.

if ( null !== $raw_content ) {
$item_data['rendered'] = $raw_content ;
if ( null !== $block['renderedContent'] ) {
$item_data['rendered'] = $block['renderedContent'] ;
}
$data[] = $item_data;
ProTip! Use n and p to navigate between commits in a pull request.