Browse Source

Accept booking page URL instead of username and password

master
Amir Reza Mehrbakhsh 2 years ago
parent
commit
2db1445b52
10 changed files with 26995 additions and 27250 deletions
  1. +1
    -1
      .gitignore
  2. +14
    -11
      Planist.php
  3. +1
    -0
      assets/planist-block/.gitignore
  4. +1
    -1
      assets/planist-block/build/index.asset.php
  5. +1
    -273
      assets/planist-block/build/index.js
  6. +0
    -1
      assets/planist-block/build/index.js.map
  7. +26861
    -26861
      assets/planist-block/package-lock.json
  8. +22
    -22
      assets/planist-block/package.json
  9. +37
    -5
      assets/planist-block/src/icons.js
  10. +57
    -75
      assets/planist-block/src/index.js

+ 1
- 1
.gitignore View File

@ -1 +1 @@
./idea
.idea

+ 14
- 11
Planist.php View File

@ -42,24 +42,27 @@ class Planist
function shortcode($atts)
{
$atts = shortcode_atts(array(
'username' => '',
'duration' => ''
'url' => ''
), $atts, 'planist');
if (empty($atts['username']))
return '';
return $this->iframe($atts['username'], $atts['duration']);
return $this->iframe($atts['url']);
}
private function iframe($username, $duration)
private function iframe($url)
{
$url = 'https://app.planist.fr/' . $username;
if (!empty($duration))
$url .= '/' . $duration;
$path = parse_url($url)['path'];
if (strpos($path, '/') !== 0) {
$path = '/' . $path;
}
$username = explode('/', $path)[1];
$url = 'https://app.planist.fr' . $path;
$style = 'border: none;min-height: 500px;width: 100%;';
$style = apply_filters('planist_iframe_style', $style, $username, $duration);
$style = apply_filters('planist_iframe_style', $style, $url);
return '<iframe src="' . $url . '" title="' . ucwords($username) . ' Booking Page" width="100%" height="100%" style="' . $style . '"></iframe>';
}


+ 1
- 0
assets/planist-block/.gitignore View File

@ -0,0 +1 @@
node_modules

+ 1
- 1
assets/planist-block/build/index.asset.php View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element'), 'version' => 'fb0652384638c8e38554');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element'), 'version' => '25ce2927510f1dbefeca');

+ 1
- 273
assets/planist-block/build/index.js View File

@ -1,273 +1 @@
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./src/icons.js":
/*!**********************!*\
!*** ./src/icons.js ***!
\**********************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
const icons = {};
icons.planist = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", {
version: "1.1",
id: "prefix__Layer_1",
xmlns: "http://www.w3.org/2000/svg",
x: "0",
y: "0",
viewBox: "0 0 1120.2 281.9",
"enable-background": "new 0 0 1120.2 281.9"
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M226.2 19.3H287V281.8H226.2z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M414.8 88.4a96.7 96.7 0 1 0 96.7 96.7 96.6 96.6 0 0 0-96.7-96.7zm0 132.7a36 36 0 1 1 35.9-35.9 36 36 0 0 1-35.9 35.9z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
class: "prefix__st0",
d: "M456.1 272.6v9.1h55.3v-90.6a96.6 96.6 0 0 1-55.3 81.5z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
class: "prefix__st1",
d: "M456.1 272.6a96.9 96.9 0 0 0 55.3-81.5V185h-55.3v87.6z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M634.9 88.4a92.2 92.2 0 0 0-92.2 92.2v101.2H598v-98.1a37 37 0 0 1 74 0v98.1h55.3V180.7a92.4 92.4 0 0 0-92.4-92.3z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M758.2 88.5H819V281.8H758.2z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("circle", {
cx: "788.6",
cy: "30.4",
r: "30.4",
fill: "#de2029"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M0 137.1H60.8V281.9H0z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M105.9 19.3H0v60.8h105.9a28.5 28.5 0 0 1 0 56.9H0v60.8h105.9a89.2 89.2 0 0 0 0-178.5z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
fill: "#ed2939",
d: "M0 137.1H60.8V197.9H0z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
class: "prefix__st0",
d: "M0 19.3H60.8V80.1H0z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
class: "prefix__st0",
d: "M1041.9 96.1H1102.7V137.5H1041.9z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M1094.6 229.4h-.3c-12.6-1.1-22-12-22-24.6V159l.2-.2h-.2V47h-60.8v173.3a61.5 61.5 0 0 0 108.7 39.5l-25.6-30.4z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
class: "prefix__st1",
d: "M1011.5 96.1H1072.3V137.5H1011.5z"
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
d: "M899.6 209.4c25.4 3.4 30.1 15.7 30.7 21.6a7.8 7.8 0 0 1-4.5 7.8c-18.6 9.2-48.9-15.2-48.9-15.2l-26.8 39s67 39.1 109.2 5.9a54 54 0 0 0 19.5-55c-6.9-27.8-47.9-41.3-47.9-41.3-24.9-6.2-30.1-15.7-30.7-21.6a7.9 7.9 0 0 1 4.4-7.8c18.6-9.2 48.9 15.2 48.9 15.2l26.8-39s-67-39.1-109.2-5.9a53.8 53.8 0 0 0-19.5 55c.1 0 5.9 35.7 48 41.3z"
}));
/* harmony default export */ __webpack_exports__["default"] = (icons);
/***/ }),
/***/ "@wordpress/block-editor":
/*!*************************************!*\
!*** external ["wp","blockEditor"] ***!
\*************************************/
/***/ (function(module) {
module.exports = window["wp"]["blockEditor"];
/***/ }),
/***/ "@wordpress/blocks":
/*!********************************!*\
!*** external ["wp","blocks"] ***!
\********************************/
/***/ (function(module) {
module.exports = window["wp"]["blocks"];
/***/ }),
/***/ "@wordpress/components":
/*!************************************!*\
!*** external ["wp","components"] ***!
\************************************/
/***/ (function(module) {
module.exports = window["wp"]["components"];
/***/ }),
/***/ "@wordpress/element":
/*!*********************************!*\
!*** external ["wp","element"] ***!
\*********************************/
/***/ (function(module) {
module.exports = window["wp"]["element"];
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ !function() {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function() { return module['default']; } :
/******/ function() { return module; };
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ }();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
!function() {
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks");
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _icons__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./icons */ "./src/icons.js");
(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.registerBlockType)('planist-gutenberg/planist-block', {
title: 'Planist',
icon: _icons__WEBPACK_IMPORTED_MODULE_4__["default"].planist,
category: 'widgets',
keyword: ['planist', 'event', 'schedule', 'calender'],
attributes: {
username: {
type: 'string',
default: ''
},
duration: {
type: 'string',
default: '30m'
}
},
example: {
attributes: {
username: 'mohsen',
duration: '45m'
}
},
edit: props => {
const {
className,
attributes: {
username,
duration
},
setAttributes
} = props;
const onChangeUsername = value => {
setAttributes({
username: value
});
};
const onChangeDuration = value => {
setAttributes({
duration: value
});
};
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps)(), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.InspectorControls, {
key: "setting"
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
className: className,
style: {
padding: '10px'
}
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.TextControl, {
label: "Username",
value: username,
onChange: onChangeUsername
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.TextControl, {
label: "Duration",
value: duration,
onChange: onChangeDuration
}))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
className: "planist-block"
}, username ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, _icons__WEBPACK_IMPORTED_MODULE_4__["default"].planist, "/", username, duration ? '/' + duration : '') : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, _icons__WEBPACK_IMPORTED_MODULE_4__["default"].planist, " Set username and duration")));
},
save: props => {
const {
className,
attributes: {
username,
duration
}
} = props;
return `[planist username="${username}" duration="${duration}"]`;
}
});
}();
/******/ })()
;
//# sourceMappingURL=index.js.map
!function(){"use strict";var e=window.wp.element,t=window.wp.blocks,a=window.wp.blockEditor,l=window.wp.components;const n={};n.planist=(0,e.createElement)("svg",{version:"1.1",id:"prefix__Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0",y:"0",viewBox:"0 0 1120.2 281.9","enable-background":"new 0 0 1120.2 281.9"},(0,e.createElement)("path",{d:"M226.2 19.3H287V281.8H226.2z"}),(0,e.createElement)("path",{d:"M414.8 88.4a96.7 96.7 0 1 0 96.7 96.7 96.6 96.6 0 0 0-96.7-96.7zm0 132.7a36 36 0 1 1 35.9-35.9 36 36 0 0 1-35.9 35.9z"}),(0,e.createElement)("path",{class:"prefix__st0",d:"M456.1 272.6v9.1h55.3v-90.6a96.6 96.6 0 0 1-55.3 81.5z"}),(0,e.createElement)("path",{class:"prefix__st1",d:"M456.1 272.6a96.9 96.9 0 0 0 55.3-81.5V185h-55.3v87.6z"}),(0,e.createElement)("path",{d:"M634.9 88.4a92.2 92.2 0 0 0-92.2 92.2v101.2H598v-98.1a37 37 0 0 1 74 0v98.1h55.3V180.7a92.4 92.4 0 0 0-92.4-92.3z"}),(0,e.createElement)("path",{d:"M758.2 88.5H819V281.8H758.2z"}),(0,e.createElement)("circle",{cx:"788.6",cy:"30.4",r:"30.4",fill:"#de2029"}),(0,e.createElement)("path",{d:"M0 137.1H60.8V281.9H0z"}),(0,e.createElement)("path",{d:"M105.9 19.3H0v60.8h105.9a28.5 28.5 0 0 1 0 56.9H0v60.8h105.9a89.2 89.2 0 0 0 0-178.5z"}),(0,e.createElement)("path",{fill:"#ed2939",d:"M0 137.1H60.8V197.9H0z"}),(0,e.createElement)("path",{class:"prefix__st0",d:"M0 19.3H60.8V80.1H0z"}),(0,e.createElement)("path",{class:"prefix__st0",d:"M1041.9 96.1H1102.7V137.5H1041.9z"}),(0,e.createElement)("path",{d:"M1094.6 229.4h-.3c-12.6-1.1-22-12-22-24.6V159l.2-.2h-.2V47h-60.8v173.3a61.5 61.5 0 0 0 108.7 39.5l-25.6-30.4z"}),(0,e.createElement)("path",{class:"prefix__st1",d:"M1011.5 96.1H1072.3V137.5H1011.5z"}),(0,e.createElement)("path",{d:"M899.6 209.4c25.4 3.4 30.1 15.7 30.7 21.6a7.8 7.8 0 0 1-4.5 7.8c-18.6 9.2-48.9-15.2-48.9-15.2l-26.8 39s67 39.1 109.2 5.9a54 54 0 0 0 19.5-55c-6.9-27.8-47.9-41.3-47.9-41.3-24.9-6.2-30.1-15.7-30.7-21.6a7.9 7.9 0 0 1 4.4-7.8c18.6-9.2 48.9 15.2 48.9 15.2l26.8-39s-67-39.1-109.2-5.9a53.8 53.8 0 0 0-19.5 55c.1 0 5.9 35.7 48 41.3z"}));var r=n;(0,t.registerBlockType)("planist-gutenberg/planist-block",{title:"Planist",icon:r.planist,category:"widgets",keyword:["planist","event","schedule","calender"],attributes:{url:{type:"string",default:""}},example:{attributes:{url:"https://app.planist.fr/mohsen/45m"}},edit:t=>{const{className:n,attributes:{url:s},setAttributes:c}=t;return(0,e.createElement)("div",(0,a.useBlockProps)(),(0,e.createElement)(a.InspectorControls,{key:"setting"},(0,e.createElement)("div",{className:n,style:{padding:"10px"}},(0,e.createElement)(l.TextControl,{label:"Booking page URL",value:s,onChange:e=>{c({url:e})}}))),(0,e.createElement)("div",{className:"planist-block"},s?(0,e.createElement)("div",null,r.planist," ",s):(0,e.createElement)("div",null,r.planist," Set booking page URL")))},save:e=>{const{className:t,attributes:{url:a}}=e;return`[planist url="${a}"]`}})}();

+ 0
- 1
assets/planist-block/build/index.js.map
File diff suppressed because it is too large
View File


+ 26861
- 26861
assets/planist-block/package-lock.json
File diff suppressed because it is too large
View File


+ 22
- 22
assets/planist-block/package.json View File

@ -1,24 +1,24 @@
{
"name": "planist-block",
"version": "1.0.0",
"private": true,
"description": "Planist Block",
"author": "Parsa Kafi",
"license": "",
"keywords": [
"question",
"answer"
],
"homepage": "https://planist.fr",
"main": "build/index.js",
"devDependencies": {
"@wordpress/scripts": "^24.6.0"
},
"scripts": {
"build": "wp-scripts build",
"format:js": "wp-scripts format",
"lint:js": "wp-scripts lint-js",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start"
}
"name": "planist-block",
"version": "1.0.0",
"private": true,
"description": "Planist Block",
"author": "Parsa Kafi",
"license": "",
"keywords": [
"question",
"answer"
],
"homepage": "https://planist.fr",
"main": "build/index.js",
"devDependencies": {
"@wordpress/scripts": "^24.6.0"
},
"scripts": {
"build": "wp-scripts build",
"format:js": "wp-scripts format",
"lint:js": "wp-scripts lint-js",
"packages-update": "wp-scripts packages-update",
"start": "wp-scripts start"
}
}

+ 37
- 5
assets/planist-block/src/icons.js View File

@ -1,5 +1,37 @@
const icons = {};
icons.planist = <svg version="1.1" id="prefix__Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 1120.2 281.9" enable-background="new 0 0 1120.2 281.9"><path d="M226.2 19.3H287V281.8H226.2z"/><path d="M414.8 88.4a96.7 96.7 0 1 0 96.7 96.7 96.6 96.6 0 0 0-96.7-96.7zm0 132.7a36 36 0 1 1 35.9-35.9 36 36 0 0 1-35.9 35.9z"/><path class="prefix__st0" d="M456.1 272.6v9.1h55.3v-90.6a96.6 96.6 0 0 1-55.3 81.5z"/><path class="prefix__st1" d="M456.1 272.6a96.9 96.9 0 0 0 55.3-81.5V185h-55.3v87.6z"/><path d="M634.9 88.4a92.2 92.2 0 0 0-92.2 92.2v101.2H598v-98.1a37 37 0 0 1 74 0v98.1h55.3V180.7a92.4 92.4 0 0 0-92.4-92.3z"/><path d="M758.2 88.5H819V281.8H758.2z"/><circle cx="788.6" cy="30.4" r="30.4" fill="#de2029"/><path d="M0 137.1H60.8V281.9H0z"/><path d="M105.9 19.3H0v60.8h105.9a28.5 28.5 0 0 1 0 56.9H0v60.8h105.9a89.2 89.2 0 0 0 0-178.5z"/><path fill="#ed2939" d="M0 137.1H60.8V197.9H0z"/><path class="prefix__st0" d="M0 19.3H60.8V80.1H0z"/><path class="prefix__st0" d="M1041.9 96.1H1102.7V137.5H1041.9z"/><path d="M1094.6 229.4h-.3c-12.6-1.1-22-12-22-24.6V159l.2-.2h-.2V47h-60.8v173.3a61.5 61.5 0 0 0 108.7 39.5l-25.6-30.4z"/><path class="prefix__st1" d="M1011.5 96.1H1072.3V137.5H1011.5z"/><path d="M899.6 209.4c25.4 3.4 30.1 15.7 30.7 21.6a7.8 7.8 0 0 1-4.5 7.8c-18.6 9.2-48.9-15.2-48.9-15.2l-26.8 39s67 39.1 109.2 5.9a54 54 0 0 0 19.5-55c-6.9-27.8-47.9-41.3-47.9-41.3-24.9-6.2-30.1-15.7-30.7-21.6a7.9 7.9 0 0 1 4.4-7.8c18.6-9.2 48.9 15.2 48.9 15.2l26.8-39s-67-39.1-109.2-5.9a53.8 53.8 0 0 0-19.5 55c.1 0 5.9 35.7 48 41.3z"/></svg>
export default icons;
const icons = {};
icons.planist = (
<svg
version="1.1"
id="prefix__Layer_1"
xmlns="http://www.w3.org/2000/svg"
x="0"
y="0"
viewBox="0 0 1120.2 281.9"
enable-background="new 0 0 1120.2 281.9"
>
<path d="M226.2 19.3H287V281.8H226.2z" />
<path d="M414.8 88.4a96.7 96.7 0 1 0 96.7 96.7 96.6 96.6 0 0 0-96.7-96.7zm0 132.7a36 36 0 1 1 35.9-35.9 36 36 0 0 1-35.9 35.9z" />
<path
class="prefix__st0"
d="M456.1 272.6v9.1h55.3v-90.6a96.6 96.6 0 0 1-55.3 81.5z"
/>
<path
class="prefix__st1"
d="M456.1 272.6a96.9 96.9 0 0 0 55.3-81.5V185h-55.3v87.6z"
/>
<path d="M634.9 88.4a92.2 92.2 0 0 0-92.2 92.2v101.2H598v-98.1a37 37 0 0 1 74 0v98.1h55.3V180.7a92.4 92.4 0 0 0-92.4-92.3z" />
<path d="M758.2 88.5H819V281.8H758.2z" />
<circle cx="788.6" cy="30.4" r="30.4" fill="#de2029" />
<path d="M0 137.1H60.8V281.9H0z" />
<path d="M105.9 19.3H0v60.8h105.9a28.5 28.5 0 0 1 0 56.9H0v60.8h105.9a89.2 89.2 0 0 0 0-178.5z" />
<path fill="#ed2939" d="M0 137.1H60.8V197.9H0z" />
<path class="prefix__st0" d="M0 19.3H60.8V80.1H0z" />
<path class="prefix__st0" d="M1041.9 96.1H1102.7V137.5H1041.9z" />
<path d="M1094.6 229.4h-.3c-12.6-1.1-22-12-22-24.6V159l.2-.2h-.2V47h-60.8v173.3a61.5 61.5 0 0 0 108.7 39.5l-25.6-30.4z" />
<path class="prefix__st1" d="M1011.5 96.1H1072.3V137.5H1011.5z" />
<path d="M899.6 209.4c25.4 3.4 30.1 15.7 30.7 21.6a7.8 7.8 0 0 1-4.5 7.8c-18.6 9.2-48.9-15.2-48.9-15.2l-26.8 39s67 39.1 109.2 5.9a54 54 0 0 0 19.5-55c-6.9-27.8-47.9-41.3-47.9-41.3-24.9-6.2-30.1-15.7-30.7-21.6a7.9 7.9 0 0 1 4.4-7.8c18.6-9.2 48.9 15.2 48.9 15.2l26.8-39s-67-39.1-109.2-5.9a53.8 53.8 0 0 0-19.5 55c.1 0 5.9 35.7 48 41.3z" />
</svg>
);
export default icons;

+ 57
- 75
assets/planist-block/src/index.js View File

@ -1,84 +1,66 @@
import { registerBlockType } from '@wordpress/blocks';
import {
InspectorControls,
useBlockProps,
} from '@wordpress/block-editor';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import { TextControl } from '@wordpress/components';
import icons from './icons';
registerBlockType( 'planist-gutenberg/planist-block', {
title: 'Planist',
icon: icons.planist,
category: 'widgets',
keyword: [ 'planist', 'event', 'schedule', 'calender' ],
attributes: {
url: {
type: 'string',
default: '',
},
},
example: {
attributes: {
url: 'https://app.planist.fr/mohsen/45m',
},
},
edit: ( props ) => {
const {
className,
attributes: { url },
setAttributes,
} = props;
registerBlockType('planist-gutenberg/planist-block', {
title: 'Planist',
icon: icons.planist,
category: 'widgets',
keyword: ['planist', 'event', 'schedule', 'calender'],
attributes: {
username: {
type: 'string',
default: ''
},
duration: {
type: 'string',
default: '30m'
}
},
example: {
attributes: {
username: 'mohsen',
duration: '45m',
},
},
edit: (props) => {
const {
className,
attributes: {
username,
duration
},
setAttributes,
} = props;
const onChangeUrl = ( value ) => {
setAttributes( { url: value } );
};
const onChangeUsername = (value) => {
setAttributes({ username: value });
};
return (
<div { ...useBlockProps() }>
<InspectorControls key="setting">
<div className={ className } style={ { padding: '10px' } }>
<TextControl
label="Booking page URL"
value={ url }
onChange={ onChangeUrl }
/>
</div>
</InspectorControls>
const onChangeDuration = (value) => {
setAttributes({ duration: value });
};
<div className="planist-block">
{ url ? (
<div>
{ icons.planist } { url }
</div>
) : (
<div>{ icons.planist } Set booking page URL</div>
) }
</div>
</div>
);
},
save: ( props ) => {
const {
className,
attributes: { url },
} = props;
return (
<div {...useBlockProps()}>
<InspectorControls key="setting">
<div className={className} style={{ padding: '10px' }}>
<TextControl
label="Username"
value={username}
onChange={onChangeUsername}
/>
<TextControl
label="Duration"
value={duration}
onChange={onChangeDuration}
/>
</div>
</InspectorControls>
<div className="planist-block">
{username ? (<div>{icons.planist}/{username}{duration ? '/' + duration : ''}</div>) : (<div>{icons.planist} Set username and duration</div>)}
</div>
</div>
);
},
save: (props) => {
const {
className,
attributes: {
username,
duration
},
} = props;
return `[planist username="${username}" duration="${duration}"]`;
},
});
return `[planist url="${ url }"]`;
},
} );

Loading…
Cancel
Save