Changeset 3284129
- Timestamp:
- 04/29/2025 01:18:20 PM (9 months ago)
- Location:
- search-with-google
- Files:
-
- 20 edited
- 1 copied
-
tags/1.2.3 (copied) (copied from search-with-google/trunk)
-
tags/1.2.3/inc/classes/class-assets.php (modified) (2 diffs)
-
tags/1.2.3/inc/classes/class-notice.php (modified) (3 diffs)
-
tags/1.2.3/inc/classes/class-plugin.php (modified) (1 diff)
-
tags/1.2.3/inc/classes/class-search-engine.php (modified) (5 diffs)
-
tags/1.2.3/inc/classes/class-search.php (modified) (8 diffs)
-
tags/1.2.3/inc/classes/class-settings.php (modified) (4 diffs)
-
tags/1.2.3/inc/helpers/autoloader.php (modified) (3 diffs)
-
tags/1.2.3/inc/traits/trait-singleton.php (modified) (1 diff)
-
tags/1.2.3/readme.txt (modified) (3 diffs)
-
tags/1.2.3/search-with-google.php (modified) (1 diff)
-
trunk/inc/classes/class-assets.php (modified) (2 diffs)
-
trunk/inc/classes/class-notice.php (modified) (3 diffs)
-
trunk/inc/classes/class-plugin.php (modified) (1 diff)
-
trunk/inc/classes/class-search-engine.php (modified) (5 diffs)
-
trunk/inc/classes/class-search.php (modified) (8 diffs)
-
trunk/inc/classes/class-settings.php (modified) (4 diffs)
-
trunk/inc/helpers/autoloader.php (modified) (3 diffs)
-
trunk/inc/traits/trait-singleton.php (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/search-with-google.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
search-with-google/tags/1.2.3/inc/classes/class-assets.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 34 33 35 34 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); 36 37 35 } 38 36 -
search-with-google/tags/1.2.3/inc/classes/class-notice.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 37 36 */ 38 37 add_action( 'admin_notices', array( $this, 'display_notice' ) ); 39 40 38 } 41 39 … … 74 72 </div> 75 73 <?php 76 77 74 } 78 75 } -
search-with-google/tags/1.2.3/inc/classes/class-plugin.php
r3013212 r3284129 27 27 Search::get_instance(); 28 28 Notice::get_instance(); 29 30 29 } 31 32 30 } -
search-with-google/tags/1.2.3/inc/classes/class-search-engine.php
r3013212 r3284129 37 37 38 38 $this->init(); 39 40 39 } 41 40 … … 49 48 $this->api_key = get_option( 'gcs_api_key' ); 50 49 $this->cse_id = get_option( 'gcs_cse_id' ); 51 52 50 } 53 51 … … 106 104 } elseif ( 200 !== $response_code ) { 107 105 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); 108 } else {106 } elseif ( ! is_wp_error( $response ) ) { 109 107 110 if ( ! is_wp_error( $response ) ) {111 108 112 109 $response_body = wp_remote_retrieve_body( $response ); 113 110 $result = json_decode( $response_body ); 114 111 115 if ( ! is_wp_error( $result ) ) {112 if ( ! is_wp_error( $result ) ) { 116 113 117 if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase114 if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 118 115 119 $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase116 $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 120 117 121 // If no results found and pagination request then try another request.122 if ( 0 === $total_results && $page > 1 ) {123 return $this->get_search_results( $search_query, $page - 1, $posts_per_page );124 }118 // If no results found and pagination request then try another request. 119 if ( 0 === $total_results && $page > 1 ) { 120 return $this->get_search_results( $search_query, $page - 1, $posts_per_page ); 121 } 125 122 126 if ( ! empty( $result->items ) ) {127 foreach ( $result->items as $item ) {123 if ( ! empty( $result->items ) ) { 124 foreach ( $result->items as $item ) { 128 125 129 $item_detail['title'] = $item->title;130 $item_detail['link'] = $item->link;131 $item_detail['snippet'] = $item->snippet;126 $item_detail['title'] = $item->title; 127 $item_detail['link'] = $item->link; 128 $item_detail['snippet'] = $item->snippet; 132 129 133 $item_details[] = $item_detail; 134 } 130 $item_details[] = $item_detail; 135 131 } 136 132 } 137 } else {138 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) );139 133 } 134 } else { 135 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); 140 136 } 141 137 } … … 158 154 159 155 return ( $page * $posts_per_page ) - ( $posts_per_page - 1 ); 160 161 156 } 162 157 … … 176 171 177 172 return $api_url; 178 179 173 } 180 174 } -
search-with-google/tags/1.2.3/inc/classes/class-search.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 38 37 add_filter( 'posts_pre_query', array( $this, 'filter_search_query' ), 10, 2 ); 39 38 add_filter( 'page_link', array( $this, 'update_permalink' ), 10, 2 ); 40 41 39 } 42 40 … … 86 84 87 85 return $posts; 88 89 86 } 90 87 … … 101 98 102 99 return 'gcs_results_' . sanitize_title( $search_query ) . '_' . $page . '_' . $posts_per_page; 103 104 100 } 105 101 … … 122 118 123 119 return $posts; 124 125 120 } 126 121 … … 152 147 // Convert to WP_Post object. 153 148 return new \WP_Post( $post ); 154 155 149 } 156 150 … … 167 161 168 162 return ltrim( $url_parse['path'], '/' ); 169 170 163 } 171 164 … … 187 180 188 181 return $permalink; 189 190 182 } 191 183 } -
search-with-google/tags/1.2.3/inc/classes/class-settings.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 /** … … 33 32 34 33 add_action( 'admin_init', array( $this, 'register_settings' ) ); 35 36 34 } 37 35 … … 85 83 'cse_settings_section' 86 84 ); 87 88 85 } 89 86 … … 147 144 </div> 148 145 <?php 149 150 146 } 151 147 } -
search-with-google/tags/1.2.3/inc/helpers/autoloader.php
r2402707 r3284129 11 11 * Auto loader function. 12 12 * 13 * @param string $ resource Source namespace.13 * @param string $loader_resource Source namespace. 14 14 * 15 15 * @return void 16 16 */ 17 function autoloader( $ resource = '' ) {17 function autoloader( $loader_resource = '' ) { 18 18 19 $resource_path = false;20 $namespace_root = 'RT\Search_With_Google\\';21 $ resource = trim( $resource, '\\' );19 $resource_path = false; 20 $namespace_root = 'RT\Search_With_Google\\'; 21 $loader_resource = trim( $loader_resource, '\\' ); 22 22 23 if ( empty( $ resource ) || strpos( $resource, '\\' ) === false || strpos( $resource, $namespace_root ) !== 0 ) {23 if ( empty( $loader_resource ) || strpos( $loader_resource, '\\' ) === false || strpos( $loader_resource, $namespace_root ) !== 0 ) { 24 24 // Not our namespace, bail out. 25 25 return; … … 27 27 28 28 // Remove our root namespace. 29 $ resource = str_replace( $namespace_root, '', $resource );29 $loader_resource = str_replace( $namespace_root, '', $loader_resource ); 30 30 31 31 $path = explode( 32 32 '\\', 33 str_replace( '_', '-', strtolower( $ resource ) )33 str_replace( '_', '-', strtolower( $loader_resource ) ) 34 34 ); 35 35 … … 81 81 require_once( $resource_path ); // phpcs:ignore 82 82 } 83 84 83 } 85 84 -
search-with-google/tags/1.2.3/inc/traits/trait-singleton.php
r3013212 r3284129 84 84 85 85 return $instance[ $called_class ]; 86 87 86 } 88 89 87 } // End trait -
search-with-google/tags/1.2.3/readme.txt
r3231781 r3284129 4 4 Tags: google, search, cse, custom search engine, programmable search, programmable search engine, google cse, google custom search engine, google programmable search, google programmable search engine, google search 5 5 Requires at least: 4.8 6 Tested up to: 6. 7.17 Stable tag: 1.2. 26 Tested up to: 6.8 7 Stable tag: 1.2.3 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 70 70 == Changelog == 71 71 72 = 1.2.3 = 73 * Compatible with WordPress 6.8 74 72 75 = 1.2.2 = 73 76 * Compatible with WordPress 6.7.1 … … 87 90 == Upgrade Notice == 88 91 92 = 1.2.3 = 93 * Compatible with WordPress 6.8 94 89 95 = 1.2.2 = 90 96 * Compatible with WordPress 6.7.1 91 97 * Updates element selectors for automated testing 92 93 = 1.1 =94 * Compatible with WordPress 6.4.295 * Updated PHP code to be compatible with PHP 8.296 * Fixed WordPress coding standards issues97 * Used VIP compatible code for WordPress VIP compatibility98 * Added support for the Custom JSON API99 * Added Deprecation notice for the Custom site-restricted JSON API -
search-with-google/tags/1.2.3/search-with-google.php
r3231781 r3284129 3 3 * Plugin Name: Search with Google 4 4 * Description: Replace WordPress default search with Google Custom Search results. 5 * Version: 1.2. 25 * Version: 1.2.3 6 6 * Author: rtCamp 7 7 * Author URI: https://rtCamp.com -
search-with-google/trunk/inc/classes/class-assets.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 34 33 35 34 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); 36 37 35 } 38 36 -
search-with-google/trunk/inc/classes/class-notice.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 37 36 */ 38 37 add_action( 'admin_notices', array( $this, 'display_notice' ) ); 39 40 38 } 41 39 … … 74 72 </div> 75 73 <?php 76 77 74 } 78 75 } -
search-with-google/trunk/inc/classes/class-plugin.php
r3013212 r3284129 27 27 Search::get_instance(); 28 28 Notice::get_instance(); 29 30 29 } 31 32 30 } -
search-with-google/trunk/inc/classes/class-search-engine.php
r3013212 r3284129 37 37 38 38 $this->init(); 39 40 39 } 41 40 … … 49 48 $this->api_key = get_option( 'gcs_api_key' ); 50 49 $this->cse_id = get_option( 'gcs_cse_id' ); 51 52 50 } 53 51 … … 106 104 } elseif ( 200 !== $response_code ) { 107 105 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); 108 } else {106 } elseif ( ! is_wp_error( $response ) ) { 109 107 110 if ( ! is_wp_error( $response ) ) {111 108 112 109 $response_body = wp_remote_retrieve_body( $response ); 113 110 $result = json_decode( $response_body ); 114 111 115 if ( ! is_wp_error( $result ) ) {112 if ( ! is_wp_error( $result ) ) { 116 113 117 if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase114 if ( isset( $result->searchInformation->totalResults ) && isset( $result->items ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 118 115 119 $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase116 $total_results = (int) $result->searchInformation->totalResults; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 120 117 121 // If no results found and pagination request then try another request.122 if ( 0 === $total_results && $page > 1 ) {123 return $this->get_search_results( $search_query, $page - 1, $posts_per_page );124 }118 // If no results found and pagination request then try another request. 119 if ( 0 === $total_results && $page > 1 ) { 120 return $this->get_search_results( $search_query, $page - 1, $posts_per_page ); 121 } 125 122 126 if ( ! empty( $result->items ) ) {127 foreach ( $result->items as $item ) {123 if ( ! empty( $result->items ) ) { 124 foreach ( $result->items as $item ) { 128 125 129 $item_detail['title'] = $item->title;130 $item_detail['link'] = $item->link;131 $item_detail['snippet'] = $item->snippet;126 $item_detail['title'] = $item->title; 127 $item_detail['link'] = $item->link; 128 $item_detail['snippet'] = $item->snippet; 132 129 133 $item_details[] = $item_detail; 134 } 130 $item_details[] = $item_detail; 135 131 } 136 132 } 137 } else {138 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) );139 133 } 134 } else { 135 return new \WP_Error( $response_code, __( 'Unknown error occurred', 'search-with-google' ) ); 140 136 } 141 137 } … … 158 154 159 155 return ( $page * $posts_per_page ) - ( $posts_per_page - 1 ); 160 161 156 } 162 157 … … 176 171 177 172 return $api_url; 178 179 173 } 180 174 } -
search-with-google/trunk/inc/classes/class-search.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 … … 38 37 add_filter( 'posts_pre_query', array( $this, 'filter_search_query' ), 10, 2 ); 39 38 add_filter( 'page_link', array( $this, 'update_permalink' ), 10, 2 ); 40 41 39 } 42 40 … … 86 84 87 85 return $posts; 88 89 86 } 90 87 … … 101 98 102 99 return 'gcs_results_' . sanitize_title( $search_query ) . '_' . $page . '_' . $posts_per_page; 103 104 100 } 105 101 … … 122 118 123 119 return $posts; 124 125 120 } 126 121 … … 152 147 // Convert to WP_Post object. 153 148 return new \WP_Post( $post ); 154 155 149 } 156 150 … … 167 161 168 162 return ltrim( $url_parse['path'], '/' ); 169 170 163 } 171 164 … … 187 180 188 181 return $permalink; 189 190 182 } 191 183 } -
search-with-google/trunk/inc/classes/class-settings.php
r3013212 r3284129 23 23 24 24 $this->setup_hooks(); 25 26 25 } 27 26 /** … … 33 32 34 33 add_action( 'admin_init', array( $this, 'register_settings' ) ); 35 36 34 } 37 35 … … 85 83 'cse_settings_section' 86 84 ); 87 88 85 } 89 86 … … 147 144 </div> 148 145 <?php 149 150 146 } 151 147 } -
search-with-google/trunk/inc/helpers/autoloader.php
r2402707 r3284129 11 11 * Auto loader function. 12 12 * 13 * @param string $ resource Source namespace.13 * @param string $loader_resource Source namespace. 14 14 * 15 15 * @return void 16 16 */ 17 function autoloader( $ resource = '' ) {17 function autoloader( $loader_resource = '' ) { 18 18 19 $resource_path = false;20 $namespace_root = 'RT\Search_With_Google\\';21 $ resource = trim( $resource, '\\' );19 $resource_path = false; 20 $namespace_root = 'RT\Search_With_Google\\'; 21 $loader_resource = trim( $loader_resource, '\\' ); 22 22 23 if ( empty( $ resource ) || strpos( $resource, '\\' ) === false || strpos( $resource, $namespace_root ) !== 0 ) {23 if ( empty( $loader_resource ) || strpos( $loader_resource, '\\' ) === false || strpos( $loader_resource, $namespace_root ) !== 0 ) { 24 24 // Not our namespace, bail out. 25 25 return; … … 27 27 28 28 // Remove our root namespace. 29 $ resource = str_replace( $namespace_root, '', $resource );29 $loader_resource = str_replace( $namespace_root, '', $loader_resource ); 30 30 31 31 $path = explode( 32 32 '\\', 33 str_replace( '_', '-', strtolower( $ resource ) )33 str_replace( '_', '-', strtolower( $loader_resource ) ) 34 34 ); 35 35 … … 81 81 require_once( $resource_path ); // phpcs:ignore 82 82 } 83 84 83 } 85 84 -
search-with-google/trunk/inc/traits/trait-singleton.php
r3013212 r3284129 84 84 85 85 return $instance[ $called_class ]; 86 87 86 } 88 89 87 } // End trait -
search-with-google/trunk/readme.txt
r3231781 r3284129 4 4 Tags: google, search, cse, custom search engine, programmable search, programmable search engine, google cse, google custom search engine, google programmable search, google programmable search engine, google search 5 5 Requires at least: 4.8 6 Tested up to: 6. 7.17 Stable tag: 1.2. 26 Tested up to: 6.8 7 Stable tag: 1.2.3 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 70 70 == Changelog == 71 71 72 = 1.2.3 = 73 * Compatible with WordPress 6.8 74 72 75 = 1.2.2 = 73 76 * Compatible with WordPress 6.7.1 … … 87 90 == Upgrade Notice == 88 91 92 = 1.2.3 = 93 * Compatible with WordPress 6.8 94 89 95 = 1.2.2 = 90 96 * Compatible with WordPress 6.7.1 91 97 * Updates element selectors for automated testing 92 93 = 1.1 =94 * Compatible with WordPress 6.4.295 * Updated PHP code to be compatible with PHP 8.296 * Fixed WordPress coding standards issues97 * Used VIP compatible code for WordPress VIP compatibility98 * Added support for the Custom JSON API99 * Added Deprecation notice for the Custom site-restricted JSON API -
search-with-google/trunk/search-with-google.php
r3231781 r3284129 3 3 * Plugin Name: Search with Google 4 4 * Description: Replace WordPress default search with Google Custom Search results. 5 * Version: 1.2. 25 * Version: 1.2.3 6 6 * Author: rtCamp 7 7 * Author URI: https://rtCamp.com
Note: See TracChangeset
for help on using the changeset viewer.