Changeset 1995227
- Timestamp:
- 12/14/2018 11:14:27 PM (7 years ago)
- Location:
- here-mobility/trunk
- Files:
-
- 2 added
- 5 edited
-
css/gutenberg-here-block-editor.css (added)
-
css/mce-here-button.css (modified) (1 diff)
-
heremobility.php (modified) (6 diffs)
-
js/gutenberg-here-widget.js (added)
-
js/here-widget-button.js (modified) (4 diffs)
-
js/loader.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
here-mobility/trunk/css/mce-here-button.css
r1985784 r1995227 1 1 i.mce-i-here_panel:before { 2 2 font-family: "dashicons"; 3 content: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" width="26" height="12" viewBox="0 0 26 12"> <g fill="#555D66" fill-rule="nonzero"> <path d="M21.85 6.5a.65.65 0 1 1 1.3 0v4a.65.65 0 1 1-1.3 0v-4z"/> <path d="M24.5 7.85a.65.65 0 1 1 0 1.3h-4a.65.65 0 1 1 0-1.3h4zM5 1.3a3.7 3.7 0 0 0 0 7.4h9a3.7 3.7 0 1 0 0-7.4H5zM5 0h9a5 5 0 0 1 0 10H5A5 5 0 1 1 5 0z"/> <path d="M13.5 4.558a.65.65 0 1 1 0 1.3h-8a.65.65 0 1 1 0-1.3h8z"/> </g> </svg>');3 content: url('data:image/svg+xml; utf8, <svg width="21px" height="15px" viewBox="0 0 21 15" version="1.1" xmlns="http://www.w3.org/2000/svg"> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="Assets" transform="translate(-30.000000, -60.000000)" fill="#555D66"> <g id="add-widget" transform="translate(30.000000, 60.000000)"> <g id="Group-Copy-5"> <path d="M11.7803728,7.04685964 C11.7803728,9.71305039 9.61920155,11.8744393 6.95285814,11.8744393 C4.28689187,11.8744393 2.1257206,9.71305039 2.1257206,7.04685964 C2.1257206,4.38066888 4.28689187,2.2194685 6.95285814,2.2194685 C9.61920155,2.2194685 11.7803728,4.38066888 11.7803728,7.04685964 M6.99962287,0 C3.13380206,0 0,3.13403284 0,6.99990572 L0,14 L6.99962287,14 C10.8656322,14 14,10.8659672 14,6.99990572 C14,3.13403284 10.8656322,0 6.99962287,0" id="Fill-14"></path> <path d="M6.99990212,4 C5.34305569,4 4,5.34325144 4,7.00009788 C4,7.28295977 4.03915044,7.55681707 4.11236175,7.81638446 L5.95889204,7.2943134 C5.93226975,7.20074386 5.91797984,7.10208476 5.91797984,7.00009788 C5.91797984,6.40246648 6.40227073,5.91797984 6.99990212,5.91797984 C7.59753352,5.91797984 8.08182441,6.40246648 8.08182441,7.00009788 C8.08182441,7.59753352 7.59753352,8.08221591 6.99990212,8.08221591 C6.90261329,8.08221591 6.80826074,8.06910052 6.71860624,8.045023 L6.2198297,9.89742586 C6.46863071,9.96417735 6.72995987,10 6.99990212,10 C8.65674856,10 10,8.65694431 10,7.00009788 C10,5.34325144 8.65674856,4 6.99990212,4" id="Fill-15"></path> </g> <g id="Group-Copy-4" transform="translate(14.000000, 8.000000)" fill-rule="nonzero"> <path d="M2.85,1.5 C2.85,1.14101491 3.14101491,0.85 3.5,0.85 C3.85898509,0.85 4.15,1.14101491 4.15,1.5 L4.15,5.5 C4.15,5.85898509 3.85898509,6.15 3.5,6.15 C3.14101491,6.15 2.85,5.85898509 2.85,5.5 L2.85,1.5 Z" id="Line-2"></path> <path d="M5.5,2.85 C5.85898509,2.85 6.15,3.14101491 6.15,3.5 C6.15,3.85898509 5.85898509,4.15 5.5,4.15 L1.5,4.15 C1.14101491,4.15 0.85,3.85898509 0.85,3.5 C0.85,3.14101491 1.14101491,2.85 1.5,2.85 L5.5,2.85 Z" id="Line-2"></path> </g> </g> </g> </g> </svg>'); 4 4 } 5 5 i.mce-i-here_link:before { 6 6 font-family: "dashicons"; 7 content: "\f230";7 content: url('data:image/svg+xml; utf8, <svg width="15px" height="15px" viewBox="0 0 15 15" version="1.1" xmlns="http://www.w3.org/2000/svg"> <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g id="Assets" transform="translate(-132.000000, -60.000000)" fill="#555D66" fill-rule="nonzero"> <g id="web-development-icons-22-copy" transform="translate(133.000000, 61.000000)"> <path d="M6.78320001,6.46714858 C6.52520097,6.21753529 6.51840298,5.80603421 6.76801626,5.54803517 C7.01762954,5.29003614 7.42913063,5.28323814 7.68712966,5.53285142 C8.97095678,6.77495026 8.97095678,8.76332435 7.68712966,10.0054232 L4.87394285,12.7271729 C3.60217022,13.957609 1.58464297,13.957609 0.312870336,12.7271729 C-0.970956779,11.485074 -0.970956779,9.49669995 0.328005436,8.24041843 L2.16839488,6.57018241 C2.4342268,6.32892801 2.84530148,6.34885203 3.08655588,6.61468394 C3.32781027,6.88051586 3.30788626,7.29159054 3.04205434,7.53284494 L1.21679999,9.18889827 C0.461066669,9.92006797 0.461066669,11.061706 1.21679999,11.7928757 C1.9845878,12.5357081 3.20222539,12.5357081 3.97001319,11.7928757 L6.78320001,9.07112603 C7.53893333,8.33995633 7.53893333,7.19831827 6.78320001,6.46714858 Z" id="Shape"></path> <path d="M6.21679999,6.96053032 C6.47479903,7.21014361 6.48159702,7.6216447 6.23198374,7.87964373 C5.98237046,8.13764277 5.57086937,8.14444076 5.31287034,7.89482748 C4.02904322,6.65272865 4.02904322,4.66435455 5.2995977,3.43547247 L8.38576536,0.272827122 C9.657538,-0.957609041 11.6750652,-0.957609041 12.9468379,0.272827122 C14.230665,1.51492595 14.230665,3.50330005 12.9587209,4.73360204 L10.8055873,6.92690936 C10.5541035,7.18308543 10.1425638,7.18688925 9.88638772,6.93540543 C9.63021165,6.68392161 9.62640783,6.27238195 9.87789165,6.01620588 L12.0429082,3.81110173 C12.7986415,3.07993203 12.7986415,1.93829397 12.0429082,1.20712428 C11.2751204,0.464291908 10.0574828,0.464291908 9.30296765,1.19390753 L6.21679999,4.35655287 C5.46106667,5.08772257 5.46106667,6.22936063 6.21679999,6.96053032 Z" id="Shape"></path> </g> </g> </g> </svg>'); 8 8 } 9 9 -
here-mobility/trunk/heremobility.php
r1986691 r1995227 8 8 The Web Widget supports pickup location, destination, and required departure time, in addition, your users can also customize their ride according to any special requirements they have from suitcases to number of passengers. 9 9 The HERE Mobility Web Widget connects to the Mobility Marketplace to find the most relevant rides matching your users' requests and displays them to your users to choose from and book. 10 * Version: 1.0. 210 * Version: 1.0.3 11 11 * Author: HERE Mobility 12 12 * Author URI: https://mobility.here.com/ 13 13 * License: GPLv2 or later 14 14 * Text Domain: heremobility 15 * License: GPLv2 or later16 15 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 17 16 */ 18 17 class HereMobility 19 18 { 20 const PLUGIN_VERSION = '1.0. 2';19 const PLUGIN_VERSION = '1.0.3'; 21 20 const SHORTCODE_WIDGET_TAG = 'here_panel'; 22 21 const SHORTCODE_LINK_TAG = 'here_link'; 23 22 const WIDGET_URL = 'https://marketplace.mobility.here.com/web-widget/widget.js'; 23 24 private $autoCompleteSettings = array( 25 'suggestUrl' => 'https://places.api.here.com/places/v1/autosuggest', 26 'appId' => 'qfXhceMnNGqjczjYpdun', 27 'appCode' => 'k9_zXXajLc5oltB-eC9ceA', 28 'acceptLanguage' => 'en-US;q=0.9' 29 ); 24 30 25 31 /** … … 37 43 } 38 44 45 $this->register_block_type_function(); 46 47 // Register gutenberg block script 48 add_action('enqueue_block_editor_assets', array($this, 'here_mobility_gutenberg_widget_assets')); 49 39 50 //add shortcode 40 51 add_shortcode(self::SHORTCODE_WIDGET_TAG, array($this, 'widget_shortcode_handler')); 41 52 add_shortcode(self::SHORTCODE_LINK_TAG, array($this, 'link_shortcode_handler')); 53 42 54 register_deactivation_hook(__FILE__, array($this, 'here_deactivation')); 43 55 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'add_action_links')); 56 } 57 58 59 function register_block_type_function() 60 { 61 if ( function_exists( 'register_block_type' ) ) { 62 // Hook server side rendering into render callback 63 register_block_type( 64 'here/mobility-widget', [ 65 'render_callback' => array($this, 'widget_shortcode_handler'), 66 'attributes' => array( 67 'id' => array( 68 'type' => 'string', 69 ), 70 'pickup' => array( 71 'type' => 'string', 72 ), 73 'destination' => array( 74 'type' => 'string', 75 ), 76 'appKey' => array( 77 'type' => 'string', 78 ), 79 'appSecret' => array( 80 'type' => 'string' 81 ) 82 ), 83 ] 84 ); 85 86 register_block_type( 87 'here/widget-link', [ 88 'render_callback' => array($this, 'link_shortcode_handler'), 89 'attributes' => array( 90 'id' => array( 91 'type' => 'string', 92 ), 93 'pickup' => array( 94 'type' => 'string', 95 ), 96 'destination' => array( 97 'type' => 'string', 98 ), 99 ), 100 ] 101 ); 102 } 44 103 } 45 104 … … 78 137 'appKey' => '', 79 138 'appSecret' => '' 80 ), $attrs); 139 ), 140 $attrs 141 ); 81 142 82 143 $options = get_option(HereMobility_Settings::HERE_OPTIONS); … … 169 230 function load_widget_scripts($data) 170 231 { 171 wp_enqueue_script('sha256', plugins_url('js/sha256.min.js', __FILE__), array(), self::PLUGIN_VERSION, TRUE); 172 wp_enqueue_script('here_loader', plugins_url('js/loader.js', __FILE__), array('sha256'), self::PLUGIN_VERSION, TRUE); 232 wp_enqueue_script('here_loader', plugins_url('js/loader.js', __FILE__), array('jquery'), self::PLUGIN_VERSION, TRUE); 173 233 wp_localize_script('here_loader', 'data', $data); 174 wp_enqueue_style('wordpress -hmw', plugins_url('css/wordpress-hmw.css', __FILE__));234 wp_enqueue_style('wordpress_hmw', plugins_url('css/wordpress-hmw.css', __FILE__)); 175 235 } 176 236 … … 192 252 add_filter('mce_buttons', array($this, 'mce_buttons')); 193 253 } 254 194 255 } 195 256 … … 232 293 233 294 wp_enqueue_script('here_autocomplete', plugins_url('js/autocomplete.js', __FILE__), array('jquery'), self::PLUGIN_VERSION, TRUE); 234 wp_localize_script('here_autocomplete', 'autocompleteSettings', [ 235 suggestUrl => 'https://places.api.here.com/places/v1/autosuggest', 236 appId => 'qfXhceMnNGqjczjYpdun', 237 appCode => 'k9_zXXajLc5oltB-eC9ceA', 238 acceptLanguage => 'en-US;q=0.9' 239 ]); 295 wp_localize_script('here_autocomplete', 'autocompleteSettings', $this->autoCompleteSettings); 240 296 241 297 wp_enqueue_script('HereMobility_Settings', plugins_url('js/here-settings.js', __FILE__), array('jquery', 'here_autocomplete'), self::PLUGIN_VERSION, TRUE); 242 298 } 299 300 function here_mobility_gutenberg_widget_assets() 301 { 302 // Scripts. 303 wp_enqueue_script( 304 'here-mobility-widget', 305 plugins_url('js/gutenberg-here-widget.js', __FILE__), 306 array('wp-blocks', 'wp-i18n', 'wp-element', 'jquery'), 307 filemtime(plugin_dir_path(__FILE__) . 'gutenberg-here-widget.js') 308 ); 309 310 wp_localize_script('here-mobility-widget', 'hereSettings', array( 311 'widgetImageUrl' => plugins_url("js/img/widget.png", __FILE__), 312 'autocomplete' => array( 313 'suggestUrl' => 'https://places.api.here.com/places/v1/autosuggest', 314 'appId' => 'qfXhceMnNGqjczjYpdun', 315 'appCode' => 'k9_zXXajLc5oltB-eC9ceA', 316 'acceptLanguage' => 'en-US;q=0.9' 317 ) 318 )); 319 320 // Styles. 321 wp_enqueue_style( 322 'here/mobility-widget-editor', 323 plugins_url('css/gutenberg-here-block-editor.css', __FILE__), 324 array('wp-edit-blocks'), 325 filemtime(plugin_dir_path(__FILE__) . 'editor.css') 326 ); 327 } 243 328 } 244 329 245 330 new HereMobility(); 331 -
here-mobility/trunk/js/here-widget-button.js
r1985784 r1995227 94 94 }, 95 95 { 96 type: 'container',97 name: 'rewriteCredentianls',98 label : 'Rewrite default credentials',99 html: '<input class="mce-rewrite-credentianls" type="checkbox" />'100 },101 {102 96 type: 'textbox', 103 97 name: 'appKey', … … 119 113 jQuery('.dialog-warnings').text('').hide(); 120 114 121 if ( jQuery('.mce-rewrite-credentianls').prop('checked') === true && (!data.appKey ||!data.appSecret)) {115 if ((!data.appKey && data.appSecret) || (data.appKey && !data.appSecret)) { 122 116 showError('App Key and App Secret are required.'); 123 117 return false; … … 158 152 159 153 jQuery('<div class="dialog-warnings"></div>').insertAfter( '.mce-window-head').hide(); 160 161 if (params.appKey) {162 jQuery('.mce-rewrite-credentianls').prop('checked', true);163 jQuery('.mce-app-key').prop('disabled', false);164 jQuery('.mce-app-secret').prop('disabled', false);165 } else {166 jQuery('.mce-rewrite-credentianls').prop('checked', false);167 jQuery('.mce-app-key').prop('disabled', true);168 jQuery('.mce-app-secret').prop('disabled', true);169 }170 154 171 155 if (params.settings === 'default') { … … 208 192 } 209 193 }); 210 211 jQuery('.mce-rewrite-credentianls').change(function (event) {212 213 if (jQuery('.mce-rewrite-credentianls').prop('checked') === true) {214 jQuery('.mce-app-key').prop('disabled', false);215 jQuery('.mce-app-secret').prop('disabled', false);216 } else {217 jQuery('.mce-app-key').val('');218 jQuery('.mce-app-secret').val('');219 jQuery('.mce-app-key').prop('disabled', true);220 jQuery('.mce-app-secret').prop('disabled', true);221 }222 });223 194 }); 224 195 }, -
here-mobility/trunk/js/loader.js
r1980502 r1995227 13 13 s.async = 1; 14 14 s.src = d + '?a=' + t + '&b=' + (w[e].t / 864e5 | 0); 15 i.querySelector('#' + g) .appendChild(s);15 i.querySelector('#' + g) && i.querySelector('#' + g).appendChild(s); 16 16 })(window, document, data.widgetUrl, data.id, 'hmw', data.appKey); 17 17 -
here-mobility/trunk/readme.txt
r1986691 r1995227 4 4 Tags: HERE mobility, taxi 5 5 Requires PHP: 5.4 6 Requires at least: Version4.07 Tested up to: 4.9.88 Stable tag: 1.0. 26 Requires at least: 4.0 7 Tested up to: 5.0.8 8 Stable tag: 1.0.3 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 74 74 == Changelog == 75 75 76 = 1.0.3 = 77 * Added support of gutenberg text editor 78 76 79 = 1.0.2 = 77 80 * Updated widget settings
Note: See TracChangeset
for help on using the changeset viewer.