From 57c2b67984a395aaec58fa1f7cf2b0f8441527f2 Mon Sep 17 00:00:00 2001 From: Nikhil Joshua Date: Tue, 11 Apr 2023 13:18:49 +0530 Subject: [PATCH] Fix phpcs issue via phpcbf --- inc/classes/class-search-engine.php | 4 ++-- inc/classes/class-search.php | 30 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/inc/classes/class-search-engine.php b/inc/classes/class-search-engine.php index 94929e0..4aa8925 100644 --- a/inc/classes/class-search-engine.php +++ b/inc/classes/class-search-engine.php @@ -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; diff --git a/inc/classes/class-search.php b/inc/classes/class-search.php index acf3751..01e4342 100644 --- a/inc/classes/class-search.php +++ b/inc/classes/class-search.php @@ -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 ); @@ -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; }