Changeset 2054291
- Timestamp:
- 03/20/2019 10:13:52 PM (7 years ago)
- Location:
- embed-gutenberg-block-google-maps/trunk
- Files:
-
- 2 added
- 2 deleted
- 2 edited
-
assets/css/style.836e5da587e9ec9692c0.css (added)
-
assets/css/style.aef3c8c366ce19f8c0b4.css (deleted)
-
assets/js/index.836e5da587e9ec9692c0.js (added)
-
assets/js/index.aef3c8c366ce19f8c0b4.js (deleted)
-
embed-gutenberg-block-google-maps.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
embed-gutenberg-block-google-maps/trunk/embed-gutenberg-block-google-maps.php
r2020814 r2054291 5 5 * Author: Pantheon, Andrew Taylor 6 6 * Author URI: https://pantheon.io/ 7 * Version: 1.5. 18 * License: GPL29 * License URI: http ://www.gnu.org/licenses/gpl-2.0.txt7 * Version: 1.5.2 8 * License: MIT 9 * License URI: https://opensource.org/licenses/MIT 10 10 * Text Domain: pantheon-google-map-block 11 11 * Requires PHP: 5.6 … … 43 43 { 44 44 // Make paths variables so we don't write em twice ;) 45 $hash = ' aef3c8c366ce19f8c0b4';45 $hash = '836e5da587e9ec9692c0'; 46 46 $blockPath = "assets/js/index.$hash.js"; 47 47 $stylePath = "assets/css/style.$hash.css"; … … 63 63 wp_json_encode( 64 64 array( 65 'APIKeyConstantDefined' => defined( 'GOOGLE_MAPS_API_KEY' ), 65 66 'APIKey' => getGoogleMapAPIKey(), 66 67 'userCanManageOptions' => current_user_can( 'manage_options' ), … … 126 127 // Set the API url based to embed or static maps based on the interactive setting 127 128 $apiURL = ( $interactive ) ? "https://www.google.com/maps/embed/v1/place?key=${APIkey}&q=${location}&zoom=${zoom}&maptype=${mapType}" : "https://maps.googleapis.com/maps/api/staticmap?center=${location}&zoom=${zoom}&size=${maxWidth}x${maxHeight}&maptype=${mapType}&key=${APIkey}"; 128 129 // Check status code of apiURL 130 $ch = curl_init($apiURL); 131 curl_setopt($ch, CURLOPT_HEADER, true); 132 curl_setopt($ch, CURLOPT_NOBODY, true); 133 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 134 curl_setopt($ch, CURLOPT_TIMEOUT,10); 135 $output = curl_exec($ch); 136 $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 137 curl_close($ch); 138 139 // Don't output anything if the response from Google Maps isn't a 200 129 130 // Look for a cached response code for the map URL. 131 $httpcode = get_transient( 'pantheon_google_map_block_url_response_code' ); 132 133 // Ensure the status code from cache is an integer. 134 if( false !== $httpcode ) { 135 $httpcode = intval( $httpcode ); 136 } 137 138 // If the response code is not found in the cache 139 // Or the current response code is not a 200 140 if( false === $httpcode || $httpcode !== 200 ) { 141 // Get a new response code for the map URL 142 $response = wp_remote_head( $apiURL ); 143 $httpcode = wp_remote_retrieve_response_code( $response ); 144 // Set a transient to cache the response code. 145 set_transient( 'pantheon_google_map_block_url_response_code', $httpcode, DAY_IN_SECONDS ); 146 } 147 148 // Don't output anything if the response from Google Maps isn't a 200. 140 149 if( $httpcode !== 200 ){ 141 150 return; … … 147 156 // Create the output 148 157 $output = "<div class='$classNames'><div class='map'>"; 158 149 159 // If the map is interactive show the iframe 150 160 if( $interactive ){ … … 166 176 */ 167 177 function registerMapBlock() { 168 if( \function_exists('register_block_type') ){178 if( function_exists('register_block_type') ){ 169 179 blockScripts(); 170 \register_block_type( 'pantheon/google-map', array(180 register_block_type( 'pantheon/google-map', array( 171 181 'editor_script' => 'pantheon-google-map-block-js', 172 182 'style' => 'pantheon-google-map-block-css', -
embed-gutenberg-block-google-maps/trunk/readme.txt
r2020814 r2054291 5 5 Plugin URI: https://github.com/pantheon-systems/google-map-gutenberg-block 6 6 Requires at least: 5.0 7 Tested up to: 5. 0.37 Tested up to: 5.1.1 8 8 Requires PHP: 5.6 9 Stable tag: 1.5. 110 License: GPLv2 or later11 License URI: http ://www.gnu.org/licenses/gpl-2.0.html9 Stable tag: 1.5.2 10 License: MIT 11 License URI: https://opensource.org/licenses/MIT 12 12 13 13 This plugin provides a Google Maps embed block for the Gutenberg editor. … … 68 68 == Changelog == 69 69 70 = 1.5.2 = 71 Use the [WordPress HTTP API](https://developer.wordpress.org/plugins/http-api/) instead of `curl` to check the response code of the map URL. Additionally, cache the map URL response code in a transient to avoid making a request on each page load. 72 73 Hide the API key input section in the map block settings when the Google Map API key is defined with the `GOOGLE_MAPS_API_KEY` constant. Additionally, add the `api-key-input-container` class to the `div` surrounding the API key input field in the map block settings for easier styling. 74 70 75 = 1.5.1 = 71 76 Aspect ratio bug fixes to address [this WordPress.org issue](https://circleci.com/docs/api/#trigger-a-new-job).
Note: See TracChangeset
for help on using the changeset viewer.