Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

[Gutenberg] Search block for Homepage #18

Merged
merged 9 commits into from
Apr 12, 2018
Merged

Conversation

miina
Copy link
Contributor

@miina miina commented Apr 3, 2018

This PR is based on #13 .
Fixes #26.

The PR aims to do the following:

  • Make section heading editable;
  • Make search button text editable;
  • Make search link dynamic based on the input text;
  • Use WP default search;
  • Search from "adventure" post type

Missing dependencies

  • Search results page;
  • "Adventure" post type;

Blocked by #7.

@miina miina changed the title [WIP] [Gutenberg] Search block for Homepage [Gutenberg] Search block for Homepage Apr 3, 2018
@miina miina changed the title [Gutenberg] Search block for Homepage [WIP] [Gutenberg] Search block for Homepage Apr 3, 2018
@miina miina changed the title [WIP] [Gutenberg] Search block for Homepage [Gutenberg] Search block for Homepage Apr 4, 2018
functions.php Outdated
function travel_filter_search_pre_get_posts( $query ) {

if ( $query->is_search ) {
$query->set( 'post_type', array( 'post', 'adventure' ) );
Copy link
Contributor Author

@miina miina Apr 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this should search from adventure post type only. Thought that perhaps for now it can search from blog posts as well and changed later if needed. Thoughts?

@miina miina changed the title [Gutenberg] Search block for Homepage [WIP] [Gutenberg] Search block for Homepage Apr 5, 2018
@miina miina changed the title [WIP] [Gutenberg] Search block for Homepage [Gutenberg] Search block for Homepage Apr 10, 2018
@kienstra kienstra self-assigned this Apr 12, 2018
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good, A Few Points

Hi @miina,
As you mentioned, this is dependent on Issue #7 (PR #33). And maybe you didn't intend for this to be reviewed yet. I just made these points because the parent issue (#26) is "Ready For Review."

This PR now shows a diff of 38 files, but this diff of the PR's branch feature/search_block to develop shows only 4 files. Maybe it didn't recompute the diff after merging #13. But I only reviewed that smaller diff.

*
* @param object $query Original query.
*/
public function travel_filter_search_pre_get_posts( $query ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this method name might need to be filter_search_pre_get_posts to match the add_filter() call above:

add_filter( 'pre_get_posts', array( $this, 'filter_search_pre_get_posts' ), 10, 1 );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this!

.travel-search .travel-link {
color: #8b58e3
}
.travel-input-group {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add an empty line above this selector? And similarly for the 2 selectors above this?

Otherwise, it'd be fine to remove the empty line above .travel-search-input.blocks-rich-text.

/**
* Modify the default search query to include 'adventure' post type.
*
* @param object $query Original query.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please remove the extra space between $query and Original query. It's hard to see, but there are 2 spaces.

add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_scripts' ) );
add_filter( 'the_content', array( $this, 'filter_the_content_amp_atts' ), 10, 1 );
add_filter( 'wp_kses_allowed_html', array( $this, 'filter_wp_kses_allowed_html' ), 10, 2 );
add_filter( 'pre_get_posts', array( $this, 'filter_search_pre_get_posts' ), 10, 1 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be add_action( 'pre_get_posts', instead of add_filter.

Also, the 3rd argument of 1 doesn't hurt, but this would probably be cleaner without it.

@kienstra kienstra removed their assignment Apr 12, 2018
@miina
Copy link
Contributor Author

miina commented Apr 12, 2018

@kienstra Thank you for reviewing.

Made the changes + also added a placeholder for search.php which displays the found posts and adventures so it would be easier to test functionally as well.

In most cases, retain both edits.
Also, change add_filter( 'pre_get_posts' )
to add_action( 'pre_get_posts' ).
@kienstra
Copy link
Contributor

kienstra commented Apr 12, 2018

Approved

Hi @miina,
Thanks for your recent updates, and for creating this "Search" block.

Thanks for adding the search.php template. As you mentioned, it's a placeholder. So I didn't review it much.

@kienstra kienstra merged commit 987d012 into develop Apr 12, 2018
@kienstra kienstra deleted the feature/search_block branch April 12, 2018 23:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants