handling block depreacation
This commit is contained in:
parent
5582eef274
commit
5d8b790ac5
|
|
@ -21,9 +21,6 @@
|
|||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"blockCustomTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"pageHeaderTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'c79b0c0a1da145209afe');
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '33d8b36cf2904cb62a91');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,112 @@
|
|||
/******/ "use strict";
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./src/deprecated.js":
|
||||
/*!***************************!*\
|
||||
!*** ./src/deprecated.js ***!
|
||||
\***************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__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_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
|
||||
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__);
|
||||
|
||||
|
||||
|
||||
|
||||
const v1 = {
|
||||
attributes: {
|
||||
hasCustomTitle: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
blockCustomTitle: {
|
||||
type: "string"
|
||||
},
|
||||
pageHeaderTitle: {
|
||||
type: "string"
|
||||
},
|
||||
hasCta: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
cta: {
|
||||
type: "object"
|
||||
},
|
||||
hasCustomImage: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
imageUrl: {
|
||||
type: "string"
|
||||
},
|
||||
imageAlt: {
|
||||
type: "string"
|
||||
},
|
||||
imageId: {
|
||||
type: "number"
|
||||
},
|
||||
imageProportion: {
|
||||
type: "string",
|
||||
default: "original"
|
||||
},
|
||||
anchor: {
|
||||
type: "string"
|
||||
},
|
||||
coverSize: {
|
||||
type: "string",
|
||||
default: "medium"
|
||||
}
|
||||
},
|
||||
save({
|
||||
attributes
|
||||
}) {
|
||||
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps.save({
|
||||
className: `innerblocks`
|
||||
})
|
||||
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.InnerBlocks.Content, null));
|
||||
},
|
||||
migrate(attributes, innerBlocks) {
|
||||
const {
|
||||
blockCustomTitle,
|
||||
pageHeaderTitle,
|
||||
...restAttributes
|
||||
} = attributes;
|
||||
|
||||
// const pageTitle = useSelect((select) => {
|
||||
// const { getEditedPostAttribute } = select("core/editor");
|
||||
// return getEditedPostAttribute("title");
|
||||
// });
|
||||
|
||||
return [restAttributes, [(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.createBlock)("homegrade-content-blocks/section-titling", {
|
||||
content: attributes.sectionTitle,
|
||||
level: 3
|
||||
}, [(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.createBlock)("core/heading", {
|
||||
placeholder: "Titre de section",
|
||||
content: attributes.hasCustomTitle ? blockCustomTitle : "",
|
||||
level: 1,
|
||||
className: "section_titling__title"
|
||||
}), (0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.createBlock)("core/paragraph", {
|
||||
content: attributes.pageHeaderTitle,
|
||||
placeholder: "Tapez votre sous-titre...",
|
||||
className: "section_titling__subtitle"
|
||||
})]), ...innerBlocks]];
|
||||
}
|
||||
};
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ([v1]);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/edit.js":
|
||||
/*!*********************!*\
|
||||
!*** ./src/edit.js ***!
|
||||
|
|
@ -36,10 +142,7 @@ function Edit({
|
|||
setAttributes
|
||||
}) {
|
||||
const {
|
||||
anchor,
|
||||
blockCustomTitle,
|
||||
hasCustomTitle,
|
||||
pageHeaderTitle,
|
||||
hasCta,
|
||||
cta,
|
||||
hasCustomImage,
|
||||
|
|
@ -48,12 +151,6 @@ function Edit({
|
|||
imageUrl,
|
||||
coverSize
|
||||
} = attributes;
|
||||
const pageTitle = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
||||
const {
|
||||
getEditedPostAttribute
|
||||
} = select("core/editor");
|
||||
return getEditedPostAttribute("title");
|
||||
});
|
||||
const pageIllustration = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
||||
const currentPost = select("core/editor").getCurrentPost();
|
||||
if (currentPost && currentPost.acf && currentPost.acf.page_illustration) {
|
||||
|
|
@ -61,16 +158,6 @@ function Edit({
|
|||
return Image;
|
||||
}
|
||||
});
|
||||
function onChangeBlockCustomTitle(blockCustomTitle) {
|
||||
setAttributes({
|
||||
blockCustomTitle
|
||||
});
|
||||
}
|
||||
function onChangeTitle(newTitle) {
|
||||
setAttributes({
|
||||
pageHeaderTitle: newTitle
|
||||
});
|
||||
}
|
||||
function onChangeHasCustomTitle(newHasAutoTitle) {
|
||||
setAttributes({
|
||||
hasCustomTitle: !hasCustomTitle
|
||||
|
|
@ -206,25 +293,10 @@ function Edit({
|
|||
})
|
||||
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
class: "block-content-page-header__content"
|
||||
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "section_titling section_titling--left"
|
||||
}, !hasCustomTitle && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h1", {
|
||||
className: "section_titling__title"
|
||||
}, pageTitle), hasCustomTitle && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.RichText, {
|
||||
className: "section_titling__title",
|
||||
tagName: "h1",
|
||||
placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ajouter ici le Titre du Bloc Header", "homegrade"),
|
||||
value: blockCustomTitle,
|
||||
onChange: onChangeBlockCustomTitle
|
||||
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.RichText, {
|
||||
className: "section_titling__subtitle",
|
||||
tagName: "h2",
|
||||
placeholder: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Ajouter ici le Titre du Bloc Header", "homegrade"),
|
||||
value: pageHeaderTitle,
|
||||
onChange: onChangeTitle
|
||||
// style={{ textAlign: props.attributes.alignment }}
|
||||
})), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.InnerBlocks, {
|
||||
template: [["core/paragraph", {
|
||||
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.InnerBlocks, {
|
||||
template: [["homegrade-content-blocks/section-titling", {
|
||||
lock: true
|
||||
}], ["core/paragraph", {
|
||||
placeholder: "Ajouter ici le texte"
|
||||
}]],
|
||||
allowedBlocks: ["core/paragraph", "core/list", "core/button", "core/buttons", "gravityforms/form", "homegrade-content-blocks/section-titling"]
|
||||
|
|
@ -264,6 +336,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./save */ "./src/save.js");
|
||||
/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./edit */ "./src/edit.js");
|
||||
/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./block.json */ "./src/block.json");
|
||||
/* harmony import */ var _deprecated__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./deprecated */ "./src/deprecated.js");
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -287,7 +361,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||
})))
|
||||
},
|
||||
edit: _edit__WEBPACK_IMPORTED_MODULE_4__["default"],
|
||||
save: _save__WEBPACK_IMPORTED_MODULE_3__["default"]
|
||||
save: _save__WEBPACK_IMPORTED_MODULE_3__["default"],
|
||||
deprecated: _deprecated__WEBPACK_IMPORTED_MODULE_6__["default"]
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -315,11 +390,7 @@ function save({
|
|||
attributes,
|
||||
setAttributes
|
||||
}) {
|
||||
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps.save({
|
||||
className: `innerblocks`
|
||||
})
|
||||
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null));
|
||||
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null));
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -465,7 +536,7 @@ module.exports = window["wp"]["primitives"];
|
|||
\************************/
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false,"anchor":true},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"hasCustomTitle":{"type":"boolean","default":false},"blockCustomTitle":{"type":"string"},"pageHeaderTitle":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"},"hasCustomImage":{"type":"boolean","default":false},"imageUrl":{"type":"string"},"imageAlt":{"type":"string"},"imageId":{"type":"number"},"imageProportion":{"type":"string","default":"original"},"anchor":{"type":"string"},"coverSize":{"type":"string","default":"medium"}}}');
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false,"anchor":true},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"hasCustomTitle":{"type":"boolean","default":false},"pageHeaderTitle":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"},"hasCustomImage":{"type":"boolean","default":false},"imageUrl":{"type":"string"},"imageAlt":{"type":"string"},"imageId":{"type":"number"},"imageProportion":{"type":"string","default":"original"},"anchor":{"type":"string"},"coverSize":{"type":"string","default":"medium"}}}');
|
||||
|
||||
/***/ })
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -13,19 +13,8 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
|
|||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||
?>
|
||||
|
||||
|
||||
<section id="<?php echo $anchor ?? "" ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
|
||||
<div class="block-content-page-header__content">
|
||||
<div className="section_titling">
|
||||
<?php if (!$attributes['hasCustomTitle']) : ?>
|
||||
<h1 class="section_titling__title"><?php echo get_the_title() ?></h1>
|
||||
<?php endif; ?>
|
||||
<?php if ($attributes['hasCustomTitle'] && $customTitle) : ?>
|
||||
<h1 class="section_titling__title"><?php echo $customTitle ?></h1>
|
||||
<?php endif; ?>
|
||||
<p class="section_titling__subtitle"><?php echo $pageHeaderTitle ?> </p>
|
||||
</div>
|
||||
<p><?php echo $pageHeaderDescription ?> </p>
|
||||
<?php echo $content ?>
|
||||
<?php if ($cta && $cta['title'] && $cta['url']) : ?>
|
||||
<a class="block-content-page-header__cta-link" href="<?php echo $cta['url'] ?>"><?php echo $cta['title'] ?></a>
|
||||
|
|
@ -38,5 +27,4 @@ $anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
|||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?>" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
</section>
|
||||
|
|
@ -1,11 +1,4 @@
|
|||
/*!**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** css ./node_modules/.pnpm/css-loader@6.10.0_webpack@5.90.3/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/.pnpm/postcss-loader@6.2.1_postcss@8.4.35_webpack@5.90.3/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/.pnpm/sass-loader@12.6.0_sass@1.71.1_webpack@5.90.3/node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***!
|
||||
\**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
||||
.block-content-page-header p {
|
||||
display: none;
|
||||
}
|
||||
.block-content-page-header .innerblocks p {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=style-index.css.map*/
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"./style-index.css","mappings":";;;AAEC;EACC;AADF;AAGC;EACC;AADF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["// Styled by the theme\r\n.block-content-page-header {\r\n\tp {\r\n\t\tdisplay: none;\r\n\t}\r\n\t.innerblocks p {\r\n\t\tdisplay: block;\r\n\t}\r\n}\r\n"],"names":[],"sourceRoot":""}
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"blockCustomTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
"pageHeaderTitle": {
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
|||
101
blocks/content-page-header/src/deprecated.js
Normal file
101
blocks/content-page-header/src/deprecated.js
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
import { createBlock } from "@wordpress/blocks";
|
||||
import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
|
||||
import { useSelect } from "@wordpress/data";
|
||||
|
||||
const v1 = {
|
||||
attributes: {
|
||||
hasCustomTitle: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
blockCustomTitle: {
|
||||
type: "string",
|
||||
},
|
||||
pageHeaderTitle: {
|
||||
type: "string",
|
||||
},
|
||||
hasCta: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
cta: {
|
||||
type: "object",
|
||||
},
|
||||
hasCustomImage: {
|
||||
type: "boolean",
|
||||
default: false,
|
||||
},
|
||||
imageUrl: {
|
||||
type: "string",
|
||||
},
|
||||
imageAlt: {
|
||||
type: "string",
|
||||
},
|
||||
imageId: {
|
||||
type: "number",
|
||||
},
|
||||
imageProportion: {
|
||||
type: "string",
|
||||
default: "original",
|
||||
},
|
||||
anchor: {
|
||||
type: "string",
|
||||
},
|
||||
coverSize: {
|
||||
type: "string",
|
||||
default: "medium",
|
||||
},
|
||||
},
|
||||
|
||||
save({ attributes }) {
|
||||
return (
|
||||
<div
|
||||
{...useBlockProps.save({
|
||||
className: `innerblocks`,
|
||||
})}
|
||||
>
|
||||
<InnerBlocks.Content />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
migrate(attributes, innerBlocks) {
|
||||
const { blockCustomTitle, pageHeaderTitle, ...restAttributes } = attributes;
|
||||
|
||||
// const pageTitle = useSelect((select) => {
|
||||
// const { getEditedPostAttribute } = select("core/editor");
|
||||
// return getEditedPostAttribute("title");
|
||||
// });
|
||||
|
||||
|
||||
return [
|
||||
restAttributes,
|
||||
[
|
||||
createBlock(
|
||||
"homegrade-content-blocks/section-titling",
|
||||
{
|
||||
content: attributes.sectionTitle,
|
||||
level: 3,
|
||||
},
|
||||
[
|
||||
createBlock("core/heading", {
|
||||
placeholder: "Titre de section",
|
||||
content: attributes.hasCustomTitle ? blockCustomTitle : "",
|
||||
level: 1,
|
||||
className: "section_titling__title",
|
||||
}),
|
||||
createBlock("core/paragraph", {
|
||||
content: attributes.pageHeaderTitle,
|
||||
placeholder: "Tapez votre sous-titre...",
|
||||
className: "section_titling__subtitle",
|
||||
}),
|
||||
],
|
||||
),
|
||||
|
||||
...innerBlocks,
|
||||
],
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default [v1];
|
||||
|
|
@ -21,14 +21,11 @@ import {
|
|||
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
||||
} from "@wordpress/components";
|
||||
|
||||
import { trash } from "@wordpress/icons";
|
||||
import { lock, trash } from "@wordpress/icons";
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const {
|
||||
anchor,
|
||||
blockCustomTitle,
|
||||
hasCustomTitle,
|
||||
pageHeaderTitle,
|
||||
hasCta,
|
||||
cta,
|
||||
hasCustomImage,
|
||||
|
|
@ -38,11 +35,6 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
coverSize,
|
||||
} = attributes;
|
||||
|
||||
const pageTitle = useSelect((select) => {
|
||||
const { getEditedPostAttribute } = select("core/editor");
|
||||
return getEditedPostAttribute("title");
|
||||
});
|
||||
|
||||
const pageIllustration = useSelect((select) => {
|
||||
const currentPost = select("core/editor").getCurrentPost();
|
||||
if (currentPost && currentPost.acf && currentPost.acf.page_illustration) {
|
||||
|
|
@ -51,12 +43,6 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
}
|
||||
});
|
||||
|
||||
function onChangeBlockCustomTitle(blockCustomTitle) {
|
||||
setAttributes({ blockCustomTitle });
|
||||
}
|
||||
function onChangeTitle(newTitle) {
|
||||
setAttributes({ pageHeaderTitle: newTitle });
|
||||
}
|
||||
function onChangeHasCustomTitle(newHasAutoTitle) {
|
||||
setAttributes({ hasCustomTitle: !hasCustomTitle });
|
||||
if (newHasAutoTitle) {
|
||||
|
|
@ -158,7 +144,7 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
!imageUrl
|
||||
? __(
|
||||
"Ajouter votre image manuellement",
|
||||
"homegrade-blocks"
|
||||
"homegrade-blocks",
|
||||
)
|
||||
: __("Remplacer", "homegrade-blocks")
|
||||
}
|
||||
|
|
@ -223,38 +209,9 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
})}
|
||||
>
|
||||
<div class="block-content-page-header__content">
|
||||
<div className="section_titling section_titling--left">
|
||||
{!hasCustomTitle && (
|
||||
<h1 className="section_titling__title">{pageTitle}</h1>
|
||||
)}
|
||||
{hasCustomTitle && (
|
||||
<RichText
|
||||
className="section_titling__title"
|
||||
tagName="h1"
|
||||
placeholder={__(
|
||||
"Ajouter ici le Titre du Bloc Header",
|
||||
"homegrade"
|
||||
)}
|
||||
value={blockCustomTitle}
|
||||
onChange={onChangeBlockCustomTitle}
|
||||
/>
|
||||
)}
|
||||
|
||||
<RichText
|
||||
className="section_titling__subtitle"
|
||||
tagName="h2"
|
||||
placeholder={__(
|
||||
"Ajouter ici le Titre du Bloc Header",
|
||||
"homegrade"
|
||||
)}
|
||||
value={pageHeaderTitle}
|
||||
onChange={onChangeTitle}
|
||||
// style={{ textAlign: props.attributes.alignment }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<InnerBlocks
|
||||
template={[
|
||||
["homegrade-content-blocks/section-titling", { lock: true }],
|
||||
["core/paragraph", { placeholder: "Ajouter ici le texte" }],
|
||||
]}
|
||||
allowedBlocks={[
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import "./style.scss";
|
|||
import save from "./save";
|
||||
import Edit from "./edit";
|
||||
import metadata from "./block.json";
|
||||
import deprecated from "./deprecated";
|
||||
|
||||
registerBlockType(metadata.name, {
|
||||
icon: {
|
||||
|
|
@ -26,4 +27,5 @@ registerBlockType(metadata.name, {
|
|||
},
|
||||
edit: Edit,
|
||||
save,
|
||||
deprecated
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,19 +13,8 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
|
|||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||
?>
|
||||
|
||||
|
||||
<section id="<?php echo $anchor ?? "" ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
|
||||
<div class="block-content-page-header__content">
|
||||
<div className="section_titling">
|
||||
<?php if (!$attributes['hasCustomTitle']) : ?>
|
||||
<h1 class="section_titling__title"><?php echo get_the_title() ?></h1>
|
||||
<?php endif; ?>
|
||||
<?php if ($attributes['hasCustomTitle'] && $customTitle) : ?>
|
||||
<h1 class="section_titling__title"><?php echo $customTitle ?></h1>
|
||||
<?php endif; ?>
|
||||
<p class="section_titling__subtitle"><?php echo $pageHeaderTitle ?> </p>
|
||||
</div>
|
||||
<p><?php echo $pageHeaderDescription ?> </p>
|
||||
<?php echo $content ?>
|
||||
<?php if ($cta && $cta['title'] && $cta['url']) : ?>
|
||||
<a class="block-content-page-header__cta-link" href="<?php echo $cta['url'] ?>"><?php echo $cta['title'] ?></a>
|
||||
|
|
@ -38,5 +27,4 @@ $anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
|||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?>" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
</section>
|
||||
|
|
@ -3,12 +3,8 @@ import { __ } from "@wordpress/i18n";
|
|||
|
||||
export default function save({ attributes, setAttributes }) {
|
||||
return (
|
||||
<div
|
||||
{...useBlockProps.save({
|
||||
className: `innerblocks`,
|
||||
})}
|
||||
>
|
||||
<>
|
||||
<InnerBlocks.Content />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Styled by the theme
|
||||
.block-content-page-header {
|
||||
p {
|
||||
display: none;
|
||||
}
|
||||
.innerblocks p {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
// .block-content-page-header {
|
||||
// p {
|
||||
// display: none;
|
||||
// }
|
||||
// .innerblocks p {
|
||||
// display: block;
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user