-
Notifications
You must be signed in to change notification settings - Fork 43
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
Change default behavior of Homepage Posts and Carousel blocks to include posts in subcategories #1482
Merged
Merged
Change default behavior of Homepage Posts and Carousel blocks to include posts in subcategories #1482
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1d5d7a6
Change default behavior on homepage posts block and carousel block to…
5ad33a5
Removed an extraneous line from testing
DennisNDean b860c17
Update src/blocks/carousel/edit.js
DennisNDean 51b7fca
Spacing fixed
DennisNDean 96955d9
Merge branch 'master' of https://github.com/DennisNDean/newspack-blocks
DennisNDean 939a51c
Update includes/class-newspack-blocks.php
DennisNDean 93f5567
Fixed spacing
DennisNDean 0a4cdd4
Merge branch 'master' of https://github.com/DennisNDean/newspack-blocks
DennisNDean bbe9c4e
Update includes/class-newspack-blocks.php
DennisNDean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -628,16 +628,17 @@ function ( $acc, $block ) use ( $block_name ) { | |
if ( current_user_can( 'edit_others_posts' ) && isset( $attributes['includedPostStatuses'] ) ) { | ||
$included_post_statuses = $attributes['includedPostStatuses']; | ||
} | ||
$authors = isset( $attributes['authors'] ) ? $attributes['authors'] : array(); | ||
$categories = isset( $attributes['categories'] ) ? $attributes['categories'] : array(); | ||
$tags = isset( $attributes['tags'] ) ? $attributes['tags'] : array(); | ||
$custom_taxonomies = isset( $attributes['customTaxonomies'] ) ? $attributes['customTaxonomies'] : array(); | ||
$tag_exclusions = isset( $attributes['tagExclusions'] ) ? $attributes['tagExclusions'] : array(); | ||
$category_exclusions = isset( $attributes['categoryExclusions'] ) ? $attributes['categoryExclusions'] : array(); | ||
$specific_posts = isset( $attributes['specificPosts'] ) ? $attributes['specificPosts'] : array(); | ||
$posts_to_show = intval( $attributes['postsToShow'] ); | ||
$specific_mode = isset( $attributes['specificMode'] ) ? intval( $attributes['specificMode'] ) : false; | ||
$args = array( | ||
$authors = isset( $attributes['authors'] ) ? $attributes['authors'] : array(); | ||
$categories = isset( $attributes['categories'] ) ? $attributes['categories'] : array(); | ||
$include_subcategories = isset( $attributes['includeSubcategories'] ) ? intval($attributes['includeSubcategories']) : false; | ||
$tags = isset( $attributes['tags'] ) ? $attributes['tags'] : array(); | ||
$custom_taxonomies = isset( $attributes['customTaxonomies'] ) ? $attributes['customTaxonomies'] : array(); | ||
$tag_exclusions = isset( $attributes['tagExclusions'] ) ? $attributes['tagExclusions'] : array(); | ||
$category_exclusions = isset( $attributes['categoryExclusions'] ) ? $attributes['categoryExclusions'] : array(); | ||
$specific_posts = isset( $attributes['specificPosts'] ) ? $attributes['specificPosts'] : array(); | ||
$posts_to_show = intval( $attributes['postsToShow'] ); | ||
$specific_mode = isset( $attributes['specificMode'] ) ? intval( $attributes['specificMode'] ) : false; | ||
$args = array( | ||
'post_type' => $post_type, | ||
'post_status' => $included_post_statuses, | ||
'suppress_filters' => false, | ||
|
@@ -666,6 +667,14 @@ function ( $acc, $block ) use ( $block_name ) { | |
); | ||
} | ||
if ( $categories && count( $categories ) ) { | ||
if ($include_subcategories === 1){ | ||
foreach ($categories as $parent) { | ||
$children[] = get_categories(array('child_of'=> $parent)); | ||
DennisNDean marked this conversation as resolved.
Show resolved
Hide resolved
|
||
foreach ($children[0] as $child) { | ||
$categories[] = $child->term_id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a tab here |
||
} | ||
} | ||
} | ||
$args['category__in'] = $categories; | ||
} | ||
if ( $tags && count( $tags ) ) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint: there should be a space before and after the arguments for intval():
intval( $attributes['includeSubcategories'] );
This is also the case for other instances in this file, see the spacing and indentation in the conditional statement, foreach loop, etc between lines 670 and 677.
You can find more information on WP coding standards here: https://github.com/WordPress/WordPress-Coding-Standards