diff --git a/inc/classes/class-assets.php b/inc/classes/class-assets.php index ed61cd5..6c68e83 100644 --- a/inc/classes/class-assets.php +++ b/inc/classes/class-assets.php @@ -22,7 +22,6 @@ class Assets { protected function __construct() { $this->setup_hooks(); - } /** @@ -33,7 +32,6 @@ protected function __construct() { protected function setup_hooks() { add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); - } /** diff --git a/inc/classes/class-notice.php b/inc/classes/class-notice.php index 890270c..2ed919a 100644 --- a/inc/classes/class-notice.php +++ b/inc/classes/class-notice.php @@ -22,7 +22,6 @@ class Notice { protected function __construct() { $this->setup_hooks(); - } /** @@ -36,7 +35,6 @@ protected function setup_hooks() { * Actions. */ add_action( 'admin_notices', array( $this, 'display_notice' ) ); - } /** @@ -73,6 +71,5 @@ public function display_notice() {

init(); - } /** @@ -48,7 +47,6 @@ protected function init() { $this->api_key = get_option( 'gcs_api_key' ); $this->cse_id = get_option( 'gcs_cse_id' ); - } /** @@ -105,38 +103,35 @@ public function get_search_results( $search_query, $page = 1, $posts_per_page = return new \WP_Error( $response_code, $response_message ); } elseif ( 200 !== $response_code ) { return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); - } else { - - if ( ! is_wp_error( $response ) ) { + } elseif ( ! is_wp_error( $response ) ) { $response_body = wp_remote_retrieve_body( $response ); $result = json_decode( $response_body ); - if ( ! is_wp_error( $result ) ) { + if ( ! is_wp_error( $result ) ) { - if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase + $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase - // If no results found and pagination request then try another request. - if ( 0 === $total_results && $page > 1 ) { - return $this->get_search_results( $search_query, $page - 1, $posts_per_page ); - } + // If no results found and pagination request then try another request. + if ( 0 === $total_results && $page > 1 ) { + return $this->get_search_results( $search_query, $page - 1, $posts_per_page ); + } - if ( ! empty( $result->items ) ) { - foreach ( $result->items as $item ) { + if ( ! empty( $result->items ) ) { + foreach ( $result->items as $item ) { - $item_detail['title'] = $item->title; - $item_detail['link'] = $item->link; - $item_detail['snippet'] = $item->snippet; + $item_detail['title'] = $item->title; + $item_detail['link'] = $item->link; + $item_detail['snippet'] = $item->snippet; - $item_details[] = $item_detail; - } + $item_details[] = $item_detail; } } - } else { - return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); } + } else { + return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); } } @@ -157,7 +152,6 @@ public function get_search_results( $search_query, $page = 1, $posts_per_page = public function get_start_index( $page, $posts_per_page ) { return ( $page * $posts_per_page ) - ( $posts_per_page - 1 ); - } /** @@ -175,6 +169,5 @@ private function get_api_url() { } return $api_url; - } } diff --git a/inc/classes/class-search.php b/inc/classes/class-search.php index 5d1fcc9..a77a132 100644 --- a/inc/classes/class-search.php +++ b/inc/classes/class-search.php @@ -22,7 +22,6 @@ class Search { protected function __construct() { $this->setup_hooks(); - } /** @@ -37,7 +36,6 @@ protected function setup_hooks() { */ add_filter( 'posts_pre_query', array( $this, 'filter_search_query' ), 10, 2 ); add_filter( 'page_link', array( $this, 'update_permalink' ), 10, 2 ); - } /** @@ -85,7 +83,6 @@ public function filter_search_query( $posts, $query ) { $query->max_num_pages = intval( floor( $query->found_posts / $posts_per_page ) ); return $posts; - } /** @@ -100,7 +97,6 @@ public function filter_search_query( $posts, $query ) { public function get_transient_key( $search_query, $page, $posts_per_page ) { return 'gcs_results_' . sanitize_title( $search_query ) . '_' . $page . '_' . $posts_per_page; - } /** @@ -121,7 +117,6 @@ public function get_posts( $items ) { } return $posts; - } /** @@ -151,7 +146,6 @@ public function get_post( $item ) { // Convert to WP_Post object. return new \WP_Post( $post ); - } /** @@ -166,7 +160,6 @@ public function get_post_name( $url ) { $url_parse = wp_parse_url( $url ); return ltrim( $url_parse['path'], '/' ); - } /** @@ -186,6 +179,5 @@ public function update_permalink( $permalink, $post_id ) { } return $permalink; - } } diff --git a/inc/classes/class-settings.php b/inc/classes/class-settings.php index 4fdf007..8311cff 100644 --- a/inc/classes/class-settings.php +++ b/inc/classes/class-settings.php @@ -22,7 +22,6 @@ class Settings { protected function __construct() { $this->setup_hooks(); - } /** * Action / Filters to be declare here. @@ -32,7 +31,6 @@ protected function __construct() { protected function setup_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); - } /** @@ -84,7 +82,6 @@ public function register_settings() { 'reading', 'cse_settings_section' ); - } /** @@ -146,7 +143,6 @@ public function cse_search_type_field_cb() {