From 44106e0bb652a65c67f5cb66c4a10f821c824e0a Mon Sep 17 00:00:00 2001 From: Shalin Shah Date: Fri, 15 Dec 2023 11:31:46 +0530 Subject: [PATCH] Fix: Backward Compatibility --- inc/classes/class-notice.php | 2 +- inc/classes/class-plugin.php | 2 +- inc/classes/class-search-engine.php | 10 +++++----- inc/classes/class-search.php | 14 +++++++------- inc/classes/class-settings.php | 10 +++++----- inc/helpers/autoloader.php | 2 +- search-with-google.php | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/inc/classes/class-notice.php b/inc/classes/class-notice.php index 2dd3734..d97e0b7 100644 --- a/inc/classes/class-notice.php +++ b/inc/classes/class-notice.php @@ -61,4 +61,4 @@ public function display_notice() { api_key = get_option( 'gcs_api_key' ); $this->cse_id = get_option( 'gcs_cse_id' ); @@ -67,7 +67,7 @@ protected function init(): void { * * @return array|\WP_Error Posts or false if empty or error. */ - public function get_search_results( string $search_query, int $page = 1, int $posts_per_page = 10 ): \WP_Error|array { + public function get_search_results( $search_query, $page = 1, $posts_per_page = 10 ) { $item_details = array(); $total_results = 0; @@ -161,7 +161,7 @@ public function get_search_results( string $search_query, int $page = 1, int $po * * @return float|int */ - public function get_start_index( int $page, int $posts_per_page ): float|int { + public function get_start_index( $page, $posts_per_page ) { return ( $page * $posts_per_page ) - ( $posts_per_page - 1 ); diff --git a/inc/classes/class-search.php b/inc/classes/class-search.php index eeb7281..5d1fcc9 100644 --- a/inc/classes/class-search.php +++ b/inc/classes/class-search.php @@ -30,7 +30,7 @@ protected function __construct() { * * @return void */ - protected function setup_hooks(): void { + protected function setup_hooks() { /** * Filters. @@ -48,7 +48,7 @@ protected function setup_hooks(): void { * * @return array|null Modified posts. */ - public function filter_search_query( array|null $posts, \WP_Query $query ): array|null { + public function filter_search_query( $posts, $query ) { if ( ! $query->is_search || is_admin() ) { return $posts; @@ -97,7 +97,7 @@ public function filter_search_query( array|null $posts, \WP_Query $query ): arra * * @return string */ - public function get_transient_key( string $search_query, int $page, int $posts_per_page ): string { + public function get_transient_key( $search_query, $page, $posts_per_page ) { return 'gcs_results_' . sanitize_title( $search_query ) . '_' . $page . '_' . $posts_per_page; @@ -110,7 +110,7 @@ public function get_transient_key( string $search_query, int $page, int $posts_p * * @return array */ - public function get_posts( array $items ): array { + public function get_posts( $items ) { $posts = array(); @@ -131,7 +131,7 @@ public function get_posts( array $items ): array { * * @return \WP_Post */ - public function get_post( array $item ): \WP_Post { + public function get_post( $item ) { $post_id = - wp_rand( 1, 99999 ); // Negative ID, to avoid clash with a valid post. $post = new \stdClass(); @@ -161,7 +161,7 @@ public function get_post( array $item ): \WP_Post { * * @return string */ - public function get_post_name( string $url ): string { + public function get_post_name( $url ) { $url_parse = wp_parse_url( $url ); @@ -177,7 +177,7 @@ public function get_post_name( string $url ): string { * * @return string Updated permalink. */ - public function update_permalink( string $permalink, int $post_id ): string { + public function update_permalink( $permalink, $post_id ) { $post = get_post( $post_id ); diff --git a/inc/classes/class-settings.php b/inc/classes/class-settings.php index 3912ded..c741c92 100644 --- a/inc/classes/class-settings.php +++ b/inc/classes/class-settings.php @@ -29,7 +29,7 @@ protected function __construct() { * * @return void */ - protected function setup_hooks(): void { + protected function setup_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); @@ -40,7 +40,7 @@ protected function setup_hooks(): void { * * @return void */ - public function register_settings(): void { + public function register_settings() { $args = array( 'type' => 'string', @@ -82,7 +82,7 @@ public function register_settings(): void { * * @return void */ - public function cse_settings_section_cb(): void { + public function cse_settings_section_cb() { } /** @@ -90,7 +90,7 @@ public function cse_settings_section_cb(): void { * * @return void */ - public function cse_api_key_field_cb(): void { + public function cse_api_key_field_cb() { // Get the value of the setting we've registered with register_setting(). $setting = get_option( 'gcs_api_key' ); // Output the field. @@ -104,7 +104,7 @@ public function cse_api_key_field_cb(): void { * * @return void */ - public function cse_id_field_cb(): void { + public function cse_id_field_cb() { // Get the value of the setting we've registered with register_setting(). $setting = get_option( 'gcs_cse_id' ); // Output the field. diff --git a/inc/helpers/autoloader.php b/inc/helpers/autoloader.php index 1a1809c..6d2f0f4 100644 --- a/inc/helpers/autoloader.php +++ b/inc/helpers/autoloader.php @@ -14,7 +14,7 @@ * * @return void */ -function autoloader( string $resource = '' ): void { +function autoloader( $resource = '' ) { $resource_path = false; $namespace_root = 'RT\Search_With_Google\\'; diff --git a/search-with-google.php b/search-with-google.php index 0c6c2e7..62d08ec 100644 --- a/search-with-google.php +++ b/search-with-google.php @@ -27,7 +27,7 @@ * * @return void */ -function search_with_google_plugin_loader(): void { +function search_with_google_plugin_loader() { \RT\Search_With_Google\Inc\Plugin::get_instance(); }