Skip to content
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

reverts the rename of postsToShow as it may cause breaking changes #15453

Merged
merged 3 commits into from May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/block-library/src/latest-posts/edit.js
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
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