Plugin Directory

Changeset 3207917


Ignore:
Timestamp:
12/14/2024 10:41:50 AM (14 months ago)
Author:
traveledmap
Message:

Technical refactoring of the blocks

Location:
traveledmap-trip-itinerary-embedded-map/trunk
Files:
49 added
9 edited

Legend:

Unmodified
Added
Removed
  • traveledmap-trip-itinerary-embedded-map/trunk/.gitignore

    r2636205 r3207917  
    1 src/blocks/node_modules
     1src/trip-block/node_modules
     2src/trip-step-block/node_modules
    23
    34## Uncomment line below if you prefer to
  • traveledmap-trip-itinerary-embedded-map/trunk/README.md

    r2636216 r3207917  
    11## Develop
    2 The main thing is to change the variables in the `src/contants/env.php` file
    3 Then `cd src/blocks` and `yarn start`
     2The main thing is to change the variables in the `src/contants/env.php` file :
     3 - ENV_URL
     4 - API_URL
     5Then
     6 - `cd src/trip-block` and `npm i && npm start`
     7 - `cd src/trip-step-block` and `npm i && npm start`
    48
    59## Deploy
    6  - `cd src/blocks && yarn build`
     10 - `cd src/trip-block && yarn build`
     11 - `cd src/trip-step-block && yarn build`
    712 - `git add .`
    813 - `git push`
  • traveledmap-trip-itinerary-embedded-map/trunk/plugin.php

    r2636216 r3207917  
    66 * Author: TraveledMap
    77 * Author URI: https://www.traveledmap.com
    8  * Version: 1.1.2
     8 * Version: 1.2.0
    99 * License: GPL2+
    1010 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt
  • traveledmap-trip-itinerary-embedded-map/trunk/readme.txt

    r2636216 r3207917  
    44Donate link: https://donorbox.org/help-traveledmap-to-stay-free
    55Requires at least: 3.0.1
    6 Tested up to: 5.8.2
     6Tested up to: 6.6.2
    77Requires PHP: 5.6
    8 Stable tag: 1.1.2
     8Stable tag: 1.2.0
    99License: GPLv2
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    210210button to recover the content.
    211211
     212= 1.2.0 =
     213Conformed to WordPress best practices for developing blocks. Made it compatible with newer WordPress versions.
     214
  • traveledmap-trip-itinerary-embedded-map/trunk/src/init.php

    r2636205 r3207917  
    1616function traveledmap_trip_block_assets()
    1717{
    18     // Embedded trip block ---------------------------------------
     18    // Metabox style ---------------------------------------
    1919    wp_register_style(
    20         'traveledmap-trip-style-css', // Handle.
    21         plugins_url('src/blocks/dist/blocks.style.build.css', dirname(__FILE__)),
     20        'traveledmap-metabox-style-css',
     21        plugins_url('src/metabox/style.css', dirname(__FILE__)),
    2222        array('wp-editor'),
    2323        null
    2424    );
    2525
    26     // Register block editor script for backend.
    27     wp_register_script(
    28         'traveledmap-trip-block-js', // Handle.
    29         plugins_url('/src/blocks/dist/blocks.build.js', dirname(__FILE__)), // Block.build.js: We register the block here. Built with Webpack.
    30         array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor'), // Dependencies, defined above.
    31         null, // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime — Gets file modification time.
    32         true // Enqueue the script in the footer.
    33     );
    34 
    35     // Register block editor styles for backend.
    36     wp_register_style(
    37         'traveledmap-trip-block-editor-css', // Handle.
    38         plugins_url('src/blocks/dist/blocks.editor.build.css', dirname(__FILE__)), // Block editor CSS.
    39         array('wp-edit-blocks'), // Dependency to include the CSS after it.
    40         null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
    41     );
    42 
    43     // Other libs -----------------------------------------------
    44     wp_register_script(
    45         'traveledmap_map-sticky-js',
    46         plugins_url('/dist/sticky.min.js', dirname(__FILE__)),
    47         array(),
    48         null,
    49         true
    50     );
     26    wp_enqueue_style('traveledmap-metabox-style-css');
    5127
    5228    // TODO: Introduced in 5.8.0: add_filter('block_categories_all', 'add_new_traveledmap_category', 10, 2);
     
    5430    add_filter('block_categories', 'add_new_traveledmap_category', 10, 2);
    5531
    56     register_block_type(
    57         'traveledmap/embedded-trip-block', array(
    58             // Enqueue blocks.style.build.css on both frontend & backend.
    59             'style' => 'traveledmap-trip-style-css',
    60             // Enqueue blocks.build.js in the editor only.
    61             'editor_script' => 'traveledmap-trip-block-js',
    62             // Enqueue blocks.editor.build.css in the editor only.
    63             'editor_style' => 'traveledmap-trip-block-editor-css',
    64             // Server side rendering
    65             'render_callback' => 'traveledmap_render_callback',
    66             'attributes' => array(
    67                 'tripId' => array('type' => 'string'),
    68                 'traveledmap_user_id' => array('type' => 'string'),
    69                 'traveledmap_trip_base_url' => array('type' => 'string'),
    70                 'baseUrl' => array('type' => 'string'),
    71                 'traveledmap_trip_steps' => array('type' => 'string'),
    72                 'traveledmap_disable_widget' => array('type' => 'boolean', 'default' => false),
    73                 'traveledmap_show_markers_customization' => array('type' => 'boolean', 'default' => false),
    74                 'showPopup' => array('type' => 'boolean', 'default' => false),
    75                 'showPictures' => array('type' => 'boolean', 'default' => true),
    76                 'showPicturesAtStart' => array('type' => 'boolean', 'default' => false),
    77                 'isSticky' => array('type' => 'boolean', 'default' => true),
    78                 'showOnPhones' => array('type' => 'boolean', 'default' => true),
    79                 'showOnTablets' => array('type' => 'boolean', 'default' => true),
    80                 'showOnLargeScreens' => array('type' => 'boolean', 'default' => true),
    81                 'mapHeight' => array('type' => 'string', 'default' => '50%'),
    82                 'standardMapHeight' => array('type' => 'string', 'default' => '30%'),
    83                 'extendedMapHeight' => array('type' => 'string', 'default' => '60%'),
    84                 'marginTop' => array('type' => 'number', 'default' => 0),
    85             )
    86         )
    87     );
     32
     33    register_block_type( __DIR__ . '/trip-block/build' );
     34    register_block_type( __DIR__ . '/trip-step-block/build' );
    8835}
    8936
  • traveledmap-trip-itinerary-embedded-map/trunk/src/metabox/metabox.php

    r2636205 r3207917  
    3535                <input id="traveledmap-trip-id" type="text" name="traveledmap-trip-id" value="' . esc_html($tripId) . '" maxlength="40" />
    3636            </div>
    37             <p class="mt-5">
    38                 <a href="https://www.traveledmap.com/share?tab=0&share=TRIP&tool=WORDPRESS_GUTENBERG" target="_blank">How to find your data?</a>
    39             </p>
     37            <div>
     38                <p class="mt-5">
     39                    <a href="https://www.traveledmap.com/share?tab=website&share=TRIP&tool=WORDPRESS_GUTENBERG" target="_blank">How to find your data?</a>
     40                </p>
     41            </div>
    4042        </div>
    4143
     
    109111
    110112            const traveledMapMetaboxHandleSteps = (steps, tripId, userId) => {
     113                const stateEl = document.getElementById("traveledmap-metabox-state");
     114
    111115                if (!steps) {
    112116                    traveledMapMetaboxStopLoading();
     
    119123                }), {});
    120124
    121                 const stateEl = document.getElementById("traveledmap-metabox-state");
    122125                stateEl.classList.remove("success");
    123126                stateEl.classList.remove("warning");
  • traveledmap-trip-itinerary-embedded-map/trunk/src/shared/constants/env.php

    r2636211 r3207917  
    33define("ENV_URL", "https://www.traveledmap.com");
    44define("API_URL", "https://us-central1-traveledmap.cloudfunctions.net");
    5 define("SDK_VERSION", "1.0.1");
     5define("SDK_VERSION", "1.0.2");
  • traveledmap-trip-itinerary-embedded-map/trunk/src/shared/front-renderer.php

    r2636216 r3207917  
    4949              const handleTraveledMapTripBlockLoad = function () {
    5050                new TraveledMapTrip("' . $elementId . '", {
     51                  baseUrl: "' . ENV_URL . '",
    5152                  userId: "' . $userId . '",
    5253                  tripId: "' . $tripId . '",
  • traveledmap-trip-itinerary-embedded-map/trunk/src/widget/widget.php

    r2636216 r3207917  
    104104                  const handleTraveledMapWidgetLoad = function () {
    105105                    new TraveledMapTrip("' . $elementId . '", {
     106                      baseUrl: "' . ENV_URL . '",
    106107                      userId: "' . $userId . '",
    107108                      tripId: "' . $tripId . '",
     
    155156    public function form($instance)
    156157    {
    157         $thisWidgetRandomId = rand(0, 10000000);
    158158        $title = !empty($instance['title']) ? esc_attr($instance['title']) : '';
    159159        $titleId = esc_attr($this->get_field_id('title'));
     
    201201        $extendedShowPicturesValue = esc_attr(self::instanceVarToChecked($instance, 'extended_show_pictures'));
    202202
    203         $extendedWrapperClass = $extendableValue === "checked" ? '' : 'is-hidden';
     203        $extendedWrapperClass = $extendableValue == "checked" ? '' : 'is-hidden';
    204204
    205205        echo '
     
    219219                <input type="checkbox" name="' . $showOnLargeScreensName. '" ' . $showOnLargeScreensValue . '>
    220220                <label for="' . $showOnLargeScreensName . '">Show on larger screens</label> <br />
    221                 <small>
     221                <small class="tm-widget-note"><i>
    222222                    You can decides on which type of device the widget will show up.
    223                 </small>
     223                </i></small>
    224224            </p>
    225225            <p>
    226226                <label>Map height (in pixels or percentage)</label>
    227227                <input type="text" name="' . $mapHeightName . '" value="' . $mapHeightValue . '" class="widefat" maxlength="10">
    228                 <small>
     228                <small class="tm-widget-note"><i>
    229229                    You can specify height in pixels of percentage. i.e: 500px or 60%<br />
    230230                    Percentage are relative to screen\'s height.
    231                 </small>
     231                </i></small>
    232232            </p>
    233233            <p>
    234234                <input type="checkbox" name="' . $isStickyName . '" ' . $isStickyValue . '>
    235235                <label>Widget is sticky</label> <br />
    236                 <small>
     236                <small class="tm-widget-note"><i>
    237237                    Sticky means that the widget will stay fixed on the screen while user scroll,
    238                     to allow him to see the map whereever his current scroll is on the blog post.
    239                 </small>
     238                    to allow him to see the map wherever his current scroll is on the blog post.
     239                </i></small>
    240240            </p>
    241241            <hr />
     
    254254            <p>
    255255                <h3>Map extended</h3>
    256                 <input type="checkbox" name="' . $extendableName . '" ' . $extendableValue . ' onclick="window.toggleExtendOptions[\'' . $thisWidgetRandomId . '\']()">
     256                <input type="checkbox" name="' . $extendableName . '" ' . $extendableValue . ' onclick="window.toggleExtendOptions(this)">
    257257                <label>Can be expanded (to a large map, using options bellow - you may need to save and refresh to make them appear)</label> <br />
    258258            </p>
     
    260260
    261261        echo '
    262             <div id="tm-extend-options-wrapper-' . $thisWidgetRandomId . '" class="tm-extend-options-wrapper ' . $extendedWrapperClass . '">
     262            <div class="tm-extend-options-wrapper ' . $extendedWrapperClass . '">
    263263                <p>
    264264                    <strong>Extend options</strong><br />
     
    301301                </p>
    302302
    303                 <p>
     303                <p class="tm-widget-note">
    304304                    <strong>Help</strong>
    305305                    Margins: Space between the extended map and the screen\'s border, set in pixels (px)
     
    311311        echo '
    312312            <style>
     313                .tm-widget-note {
     314                    color: #353535;
     315                    line-height: 1em;
     316                    font-size: 12px;
     317                }
    313318                .mt-20 {
    314319                    margin-top: 20px;
     
    330335            <script>
    331336                (function() {
    332                     const randomId = "' . $thisWidgetRandomId . '";
    333                     const extendOptionsWrapperEl = document.getElementById(`tm-extend-options-wrapper-${randomId}`);
    334                     if(!window.toggleExtendOptions) {
    335                         window.toggleExtendOptions = {};
    336                     }
    337                     window.toggleExtendOptions[randomId] = function() {
    338                       if(extendOptionsWrapperEl.classList.contains("is-hidden")) {
    339                         extendOptionsWrapperEl.classList.remove("is-hidden");
     337                    window.toggleExtendOptions = function(el) {
     338                      const siblingWrapper = el.parentNode.querySelector(".tm-extend-options-wrapper")
     339                      if(siblingWrapper.classList.contains("is-hidden")) {
     340                        siblingWrapper.classList.remove("is-hidden");
    340341                      } else {
    341                         extendOptionsWrapperEl.classList.add("is-hidden");
     342                        siblingWrapper.classList.add("is-hidden");
    342343                      }
    343344                    };
Note: See TracChangeset for help on using the changeset viewer.