Plugin Directory

Changeset 1995227


Ignore:
Timestamp:
12/14/2018 11:14:27 PM (7 years ago)
Author:
heremobilitydemand
Message:

Added support of gutenberg text editor

Location:
here-mobility/trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • here-mobility/trunk/css/mce-here-button.css

    r1985784 r1995227  
    11i.mce-i-here_panel:before {
    22    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>');
    44}
    55i.mce-i-here_link:before {
    66    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>');
    88}
    99
  • here-mobility/trunk/heremobility.php

    r1986691 r1995227  
    88The 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.
    99The 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.2
     10 * Version: 1.0.3
    1111 * Author: HERE Mobility
    1212 * Author URI: https://mobility.here.com/
    1313 * License: GPLv2 or later
    1414 * Text Domain: heremobility
    15  * License: GPLv2 or later
    1615 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    1716 */
    1817class HereMobility
    1918{
    20     const PLUGIN_VERSION = '1.0.2';
     19    const PLUGIN_VERSION = '1.0.3';
    2120    const SHORTCODE_WIDGET_TAG = 'here_panel';
    2221    const SHORTCODE_LINK_TAG = 'here_link';
    2322    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    );
    2430
    2531    /**
     
    3743        }
    3844
     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
    3950        //add shortcode
    4051        add_shortcode(self::SHORTCODE_WIDGET_TAG, array($this, 'widget_shortcode_handler'));
    4152        add_shortcode(self::SHORTCODE_LINK_TAG, array($this, 'link_shortcode_handler'));
     53
    4254        register_deactivation_hook(__FILE__, array($this, 'here_deactivation'));
    4355        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        }
    44103    }
    45104
     
    78137                'appKey' => '',
    79138                'appSecret' => ''
    80             ), $attrs);
     139            ),
     140            $attrs
     141        );
    81142
    82143        $options = get_option(HereMobility_Settings::HERE_OPTIONS);
     
    169230    function load_widget_scripts($data)
    170231    {
    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);
    173233        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__));
    175235    }
    176236
     
    192252            add_filter('mce_buttons', array($this, 'mce_buttons'));
    193253        }
     254
    194255    }
    195256
     
    232293
    233294        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);
    240296
    241297        wp_enqueue_script('HereMobility_Settings', plugins_url('js/here-settings.js', __FILE__), array('jquery', 'here_autocomplete'), self::PLUGIN_VERSION, TRUE);
    242298    }
     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    }
    243328}
    244329
    245330new HereMobility();
     331
  • here-mobility/trunk/js/here-widget-button.js

    r1985784 r1995227  
    9494                    },
    9595                    {
    96                         type: 'container',
    97                         name: 'rewriteCredentianls',
    98                         label  : 'Rewrite default credentials',
    99                         html: '<input class="mce-rewrite-credentianls" type="checkbox" />'
    100                     },
    101                     {
    10296                        type: 'textbox',
    10397                        name: 'appKey',
     
    119113                    jQuery('.dialog-warnings').text('').hide();
    120114
    121                     if (jQuery('.mce-rewrite-credentianls').prop('checked') === true && (!data.appKey || !data.appSecret)) {
     115                    if ((!data.appKey && data.appSecret) || (data.appKey && !data.appSecret)) {
    122116                        showError('App Key and App Secret are required.');
    123117                        return false;
     
    158152
    159153                        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                         }
    170154
    171155                        if (params.settings === 'default') {
     
    208192                            }
    209193                        });
    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                         });
    223194                    });
    224195                },
  • here-mobility/trunk/js/loader.js

    r1980502 r1995227  
    1313    s.async = 1;
    1414    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);
    1616})(window, document, data.widgetUrl, data.id, 'hmw', data.appKey);
    1717
  • here-mobility/trunk/readme.txt

    r1986691 r1995227  
    44Tags: HERE mobility, taxi
    55Requires PHP: 5.4
    6 Requires at least:  Version 4.0
    7 Tested up to: 4.9.8
    8 Stable tag: 1.0.2
     6Requires at least: 4.0
     7Tested up to: 5.0.8
     8Stable tag: 1.0.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    7474== Changelog ==
    7575
     76= 1.0.3 =
     77* Added support of gutenberg text editor
     78
    7679= 1.0.2 =
    7780* Updated widget settings
Note: See TracChangeset for help on using the changeset viewer.