Changeset 2636205
- Timestamp:
- 11/27/2021 06:37:54 AM (4 years ago)
- Location:
- traveledmap-trip-itinerary-embedded-map
- Files:
-
- 31 added
- 6 edited
-
. (modified) (1 prop)
-
trunk/.gitignore (modified) (1 diff)
-
trunk/README.md (added)
-
trunk/assets/no-preview.jpg (added)
-
trunk/plugin.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/blocks (added)
-
trunk/src/blocks/.editorconfig (added)
-
trunk/src/blocks/.eslintignore (added)
-
trunk/src/blocks/.eslintrc.json (added)
-
trunk/src/blocks/dist (added)
-
trunk/src/blocks/dist/blocks.build.js (added)
-
trunk/src/blocks/dist/blocks.editor.build.css (added)
-
trunk/src/blocks/dist/blocks.style.build.css (added)
-
trunk/src/blocks/package.json (added)
-
trunk/src/blocks/src (added)
-
trunk/src/blocks/src/blocks.js (added)
-
trunk/src/blocks/src/common.scss (added)
-
trunk/src/blocks/src/editor.scss (added)
-
trunk/src/blocks/src/style.scss (added)
-
trunk/src/blocks/src/trip (added)
-
trunk/src/blocks/src/trip-step (added)
-
trunk/src/blocks/src/trip-step/step-block.js (added)
-
trunk/src/blocks/src/trip/trip-block.js (added)
-
trunk/src/blocks/yarn.lock (added)
-
trunk/src/init.php (modified) (8 diffs)
-
trunk/src/metabox/metabox.php (modified) (4 diffs)
-
trunk/src/shared (added)
-
trunk/src/shared/constants (added)
-
trunk/src/shared/constants/env.php (added)
-
trunk/src/shared/front-renderer.php (added)
-
trunk/src/shared/utils (added)
-
trunk/src/shared/utils/utils.js (added)
-
trunk/src/shared/utils/utils.php (added)
-
trunk/src/widget (added)
-
trunk/src/widget/shortcode.php (added)
-
trunk/src/widget/widget.php (added)
Legend:
- Unmodified
- Added
- Removed
-
traveledmap-trip-itinerary-embedded-map
-
Property
svn:ignore
set to
trunk/.git
-
Property
svn:ignore
set to
-
traveledmap-trip-itinerary-embedded-map/trunk/.gitignore
r2156545 r2636205 1 node_modules1 src/blocks/node_modules 2 2 3 3 ## Uncomment line below if you prefer to -
traveledmap-trip-itinerary-embedded-map/trunk/plugin.php
r2543856 r2636205 6 6 * Author: TraveledMap 7 7 * Author URI: https://www.traveledmap.com 8 * Version: 1. 0.118 * Version: 1.1.0 9 9 * License: GPL2+ 10 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.txt -
traveledmap-trip-itinerary-embedded-map/trunk/readme.txt
r2543856 r2636205 4 4 Donate link: https://donorbox.org/help-traveledmap-to-stay-free 5 5 Requires at least: 3.0.1 6 Tested up to: 5. 6.06 Tested up to: 5.8.2 7 7 Requires PHP: 5.6 8 Stable tag: 1. 0.118 Stable tag: 1.1.0 9 9 License: GPLv2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 187 187 * Update to latest WordPress version 188 188 189 = 1.0.10 = 190 * Update to latest WordPress version 191 192 = 1.0.11 = 193 * Update to latest WordPress version 194 195 = 1.1.0 = 196 * Technical rework of the library to be compatible with the TripEmbedderJS SDK. 197 * Improvements to handle more use cases and options 198 * Made compatible with the latest WordPress version 199 189 200 == Upgrade Notice == 190 No upgrade to do for the moment 201 = 1.1.0 = 202 When upgrading to 1.1.0, you will need to recover content from the trip-steps' blocks because the content 203 changed. To do this, you just have to visit the editor page of the post where the trip is displayed, and click on the 204 button to recover the content. 205 -
traveledmap-trip-itinerary-embedded-map/trunk/src/init.php
r2337263 r2636205 1 1 <?php 2 /**3 * Blocks Initializer4 *5 * Enqueue CSS/JS of all the blocks.6 *7 * @since 1.0.08 * @package CGB9 */10 2 11 3 // Exit if accessed directly. … … 14 6 } 15 7 16 require_once('metabox/metabox.php'); 17 require_once('iframe/render.php'); 18 require_once('iframe/iframe-widget.php'); 19 require_once('iframe/shortcode.php'); 20 require_once('categories/traveledmap.php'); 8 require_once('metabox/metabox.php'); // the metabox is the right column on the backoffice 9 require_once('shared/utils/utils.php'); // utils 10 require_once('shared/front-renderer.php'); // utils that helps rendering the map in an iframe 11 require_once('shared/constants/env.php'); // constants for the environment 12 require_once('widget/widget.php'); // All the functions that allows the widget to work (save data and so on) 13 require_once('widget/shortcode.php'); // The shortcode to display the map without block 14 require_once('categories/traveledmap.php'); // The category that contains all the blocks 21 15 22 16 function traveledmap_trip_block_assets() … … 25 19 wp_register_style( 26 20 'traveledmap-trip-style-css', // Handle. 27 plugins_url(' dist/blocks.style.build.css', dirname(__FILE__)),21 plugins_url('src/blocks/dist/blocks.style.build.css', dirname(__FILE__)), 28 22 array('wp-editor'), 29 23 null … … 33 27 wp_register_script( 34 28 'traveledmap-trip-block-js', // Handle. 35 plugins_url('/ dist/blocks.build.js', dirname(__FILE__)), // Block.build.js: We register the block here. Built with Webpack.29 plugins_url('/src/blocks/dist/blocks.build.js', dirname(__FILE__)), // Block.build.js: We register the block here. Built with Webpack. 36 30 array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor'), // Dependencies, defined above. 37 31 null, // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime — Gets file modification time. … … 42 36 wp_register_style( 43 37 'traveledmap-trip-block-editor-css', // Handle. 44 plugins_url(' dist/blocks.editor.build.css', dirname(__FILE__)), // Block editor CSS.38 plugins_url('src/blocks/dist/blocks.editor.build.css', dirname(__FILE__)), // Block editor CSS. 45 39 array('wp-edit-blocks'), // Dependency to include the CSS after it. 46 40 null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time. … … 56 50 ); 57 51 52 // TODO: Introduced in 5.8.0: add_filter('block_categories_all', 'add_new_traveledmap_category', 10, 2); 53 // but wait to introduce it for older versions 58 54 add_filter('block_categories', 'add_new_traveledmap_category', 10, 2); 59 55 … … 69 65 'render_callback' => 'traveledmap_render_callback', 70 66 'attributes' => array( 71 ' mapUrl' => array('type' => 'string'),67 'tripId' => array('type' => 'string'), 72 68 'traveledmap_user_id' => array('type' => 'string'), 73 'traveledmap_trip_id' => array('type' => 'string'),74 69 'traveledmap_trip_base_url' => array('type' => 'string'), 70 'baseUrl' => array('type' => 'string'), 75 71 'traveledmap_trip_steps' => array('type' => 'string'), 76 72 'traveledmap_disable_widget' => array('type' => 'boolean', 'default' => false), … … 90 86 ) 91 87 ); 92 93 // Custom scripts94 wp_enqueue_script('traveledmap_map-sticky-js');95 88 } 96 89 -
traveledmap-trip-itinerary-embedded-map/trunk/src/metabox/metabox.php
r2337263 r2636205 22 22 23 23 $html = ' 24 24 25 <div class="components-panel__row"> 25 26 <div> … … 67 68 68 69 <div class="components-panel__row"> 69 <button id="traveledmap-check-trip-button" onclick=" handleData()" class="components-button is-button is-primary is-large">70 <button id="traveledmap-check-trip-button" onclick="traveledMapMetaboxGetSteps()" class="components-button is-button is-primary is-large"> 70 71 <span class="not-loading">Validate</span> 71 72 <span class="loading">Loading ...</span> … … 77 78 const loadedTripId = "' . esc_js($tripId) . '"; 78 79 79 const handleData = () => { 80 const buttonEl = document.getElementById("traveledmap-check-trip-button"); 81 buttonEl.classList.add("is-loading"); 82 const userId = document.getElementById("traveledmap-user-id").value; 83 const tripId = document.getElementById("traveledmap-trip-id").value; 84 const link = `https://www.traveledmap.com/trip/${userId}/${tripId}?isWPMetaboxTest=true`; 85 const iframeEl = document.getElementById("traveledmap-steps-wrapper").appendChild(document.createElement("iframe")); 86 iframeEl.setAttribute("src", link); 87 iframeEl.classList.add("traveledmap-validation-iframe"); 88 buttonEl.disabled = true; 89 buttonEl.classList.add("is-disabled"); 90 91 window.addEventListener("message", (event) => { 92 if(!event || !event.data || !event.data.type) { 93 buttonEl.classList.remove("is-loading"); 94 return; 80 const traveledMapMetaboxStopLoading = () => { 81 const buttonEl = document.getElementById("traveledmap-check-trip-button"); 82 buttonEl.classList.remove("is-loading"); 83 buttonEl.disabled = false; 84 buttonEl.classList.remove("is-disabled"); 85 } 86 87 traveledMapMetaboxGetSteps = () => { 88 const buttonEl = document.getElementById("traveledmap-check-trip-button"); 89 buttonEl.classList.add("is-loading"); 90 buttonEl.disabled = true; 91 buttonEl.classList.add("is-disabled"); 92 93 const userId = document.getElementById("traveledmap-user-id").value; 94 const tripId = document.getElementById("traveledmap-trip-id").value; 95 96 const endpoint = `' . API_URL . '/httpTripGetSteps`; 97 fetch(endpoint, { 98 method: "POST", 99 body: JSON.stringify({ data: { userNickname: userId, tripNickname: tripId }}), 100 headers: { "Content-Type": "application/json" }, 101 }) 102 .then((res) => res.json()) 103 .then((stepsRes) => traveledMapMetaboxHandleSteps(stepsRes.result, tripId, userId )) 104 .catch(err => { 105 console.error("Couldnt fetch steps", err); 106 traveledMapMetaboxStopLoading() 107 }) 108 } 109 110 const traveledMapMetaboxHandleSteps = (steps, tripId, userId) => { 111 if (!steps) { 112 traveledMapMetaboxStopLoading(); 113 stateEl.classList.add("error"); 114 console.error("No steps loaded", steps); 95 115 } 96 97 buttonEl.disabled = false; 98 buttonEl.classList.remove("is-disabled"); 116 const stepsHashWithName = steps.reduce((acc, step) => ({ 117 ...acc, 118 [step.hash]: step.name, 119 }), {}); 120 99 121 const stateEl = document.getElementById("traveledmap-metabox-state"); 100 switch (event.data.type) { 101 case "sendTripStepsHash": 102 const tripSteps = event.data.detail.steps; 103 stateEl.classList.remove("success"); 104 stateEl.classList.remove("warning"); 105 stateEl.classList.remove("error"); 106 if(loadedTripId === tripId && loadedUserId === userId) { 107 stateEl.classList.add("success"); 108 } else { 109 stateEl.classList.add("warning"); 110 } 111 document.getElementById("traveledmap-trip-steps").value = JSON.stringify(tripSteps).replace(/\'/g, ""); 112 break; 113 case "tripDoesNotExist": 114 stateEl.classList.remove("success"); 115 stateEl.classList.remove("warning"); 116 stateEl.classList.add("error"); 117 break; 118 } 119 buttonEl.classList.remove("is-loading"); 120 }); 121 }; 122 stateEl.classList.remove("success"); 123 stateEl.classList.remove("warning"); 124 stateEl.classList.remove("error"); 125 if(loadedTripId === tripId && loadedUserId === userId) { 126 stateEl.classList.add("success"); 127 } else { 128 stateEl.classList.add("warning"); 129 } 130 console.log({ stepsHashWithName }) 131 document.getElementById("traveledmap-trip-steps").value = JSON.stringify(stepsHashWithName).replace(/\'/g, ""); 132 traveledMapMetaboxStopLoading(); 133 } 122 134 </script> 123 135 '; … … 133 145 function traveledmap_save_meta_box($post_id) 134 146 { 135 $baseUrl = "https://www.traveledmap.com/trip";147 $baseUrl = ENV_URL . "/trip"; 136 148 if (isset($_POST['traveledmap-user-id'])) { 137 149 $userInput = $_POST['traveledmap-user-id'];
Note: See TracChangeset
for help on using the changeset viewer.