Skip to content

Commit

Permalink
reverts the rename of postsToShow as it may cause breaking changes (#…
Browse files Browse the repository at this point in the history
…15453)

* reverts the rename of postsToShow as it may cause breaking changes

* array field allign

* rafactor spacing in PHP
  • Loading branch information
draganescu authored May 6, 2019
1 parent 1d81635 commit d8f1875
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LatestPostsEdit extends Component {
render() {
const { attributes, setAttributes, latestPosts } = this.props;
const { categoriesList } = this.state;
const { displayPostContentRadio, displayPostContent, displayPostDate, postLayout, columns, order, orderBy, categories, postCount, excerptLength } = attributes;
const { displayPostContentRadio, displayPostContent, displayPostDate, postLayout, columns, order, orderBy, categories, postsToShow, excerptLength } = attributes;

const inspectorControls = (
<InspectorControls>
Expand Down Expand Up @@ -113,13 +113,13 @@ class LatestPostsEdit extends Component {
<PanelBody title={ __( 'Sorting and Filtering' ) }>
<QueryControls
{ ...{ order, orderBy } }
numberOfItems={ postCount }
numberOfItems={ postsToShow }
categoriesList={ categoriesList }
selectedCategoryId={ categories }
onOrderChange={ ( value ) => setAttributes( { order: value } ) }
onOrderByChange={ ( value ) => setAttributes( { orderBy: value } ) }
onCategoryChange={ ( value ) => setAttributes( { categories: '' !== value ? value : undefined } ) }
onNumberOfItemsChange={ ( value ) => setAttributes( { postCount: value } ) }
onNumberOfItemsChange={ ( value ) => setAttributes( { postsToShow: value } ) }
/>
{ postLayout === 'grid' &&
<RangeControl
Expand Down Expand Up @@ -154,8 +154,8 @@ class LatestPostsEdit extends Component {
}

// Removing posts from display should be instant.
const displayPosts = latestPosts.length > postCount ?
latestPosts.slice( 0, postCount ) :
const displayPosts = latestPosts.length > postsToShow ?
latestPosts.slice( 0, postsToShow ) :
latestPosts;

const layoutControls = [
Expand Down Expand Up @@ -244,13 +244,13 @@ class LatestPostsEdit extends Component {
}

export default withSelect( ( select, props ) => {
const { postCount, order, orderBy, categories } = props.attributes;
const { postsToShow, order, orderBy, categories } = props.attributes;
const { getEntityRecords } = select( 'core' );
const latestPostsQuery = pickBy( {
categories,
order,
orderby: orderBy,
per_page: postCount,
per_page: postsToShow,
}, ( value ) => ! isUndefined( value ) );
return {
latestPosts: getEntityRecords( 'postType', 'post', latestPostsQuery ),
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
function render_block_core_latest_posts( $attributes ) {
$args = array(
'posts_per_page' => $attributes['postCount'],
'posts_per_page' => $attributes['postsToShow'],
'post_status' => 'publish',
'order' => $attributes['order'],
'orderby' => $attributes['orderBy'],
Expand Down Expand Up @@ -135,7 +135,7 @@ function register_block_core_latest_posts() {
'categories' => array(
'type' => 'string',
),
'postCount' => array(
'postsToShow' => array(
'type' => 'number',
'default' => 5,
),
Expand Down

0 comments on commit d8f1875

Please sign in to comment.