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

Fix phpcs issue via phpcbf #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions inc/classes/class-search-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public function get_search_results( $search_query, $page = 1, $posts_per_page =
if ( ! empty( $result->items ) ) {
foreach ( $result->items as $item ) {

$item_detail['title'] = $item->title;
$item_detail['link'] = $item->link;
$item_detail['title'] = $item->title;
$item_detail['link'] = $item->link;
$item_detail['snippet'] = $item->snippet;

$item_details[] = $item_detail;
Expand Down
30 changes: 15 additions & 15 deletions inc/classes/class-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ public function get_posts( $items ) {
*/
public function get_post( $item ) {

$post_id = - wp_rand( 1, 99999 ); // Negative ID, to avoid clash with a valid post.
$post = new \stdClass();
$post->ID = $post_id;
$post->post_author = 1;
$post->post_date = current_time( 'mysql' );
$post->post_date_gmt = current_time( 'mysql', 1 );
$post->post_title = $item['title'];
$post->post_content = $item['snippet'];
$post->post_status = 'publish';
$post->comment_status = 'closed';
$post->ping_status = 'closed';
$post->post_name = $this->get_post_name( $item['link'] ); // Get post slug from URL.
$post_id = - wp_rand( 1, 99999 ); // Negative ID, to avoid clash with a valid post.
$post = new \stdClass();
$post->ID = $post_id;
$post->post_author = 1;
$post->post_date = current_time( 'mysql' );
$post->post_date_gmt = current_time( 'mysql', 1 );
$post->post_title = $item['title'];
$post->post_content = $item['snippet'];
$post->post_status = 'publish';
$post->comment_status = 'closed';
$post->ping_status = 'closed';
$post->post_name = $this->get_post_name( $item['link'] ); // Get post slug from URL.
$post->search_permalink = $item['link']; // Get post permalink from URL. This will replace the WP default permalink.
$post->post_type = 'page';
$post->filter = 'raw'; // Important!
$post->post_type = 'page';
$post->filter = 'raw'; // Important!

// Convert to WP_Post object.
$wp_post = new \WP_Post( $post );
Expand Down Expand Up @@ -173,7 +173,7 @@ public function get_post_name( $url ) {
public function update_permalink( $permalink, $post ) {
$post = get_post( $post );

if ( ! empty( $post->search_permalink ) ) {
if ( ! empty( $post->search_permalink ) ) {
return $post->search_permalink;
}

Expand Down