FEATURE Handling open in new tab

This commit is contained in:
Antoine M 2026-03-20 17:09:20 +01:00
parent a62f00f31e
commit 5ccff70aff
2 changed files with 3 additions and 6 deletions

View File

@ -14,13 +14,12 @@ import { Tip } from "@wordpress/components";
import { ReactComponent as ArrowIcon } from "./img/carhop-fleche-lien-externe-full.svg";
export default function Edit({ attributes, setAttributes }) {
const { color } = attributes;
const { color, link } = attributes;
const colors = useSetting("color.palette.theme");
function handleColorChange(value) {
setAttributes({ color: value });
}
console.log(color);
return (
<>

View File

@ -3,9 +3,7 @@ $align = isset($attributes['align']) ? $attributes['align'] : '';
$link = isset($attributes['link']) ? $attributes['link'] : [];
$text = isset($attributes['text']) ? $attributes['text'] : '';
$color = isset($attributes['color']) ? $attributes['color'] : '';
$target = isset($link) && $link['opensInNewTab'] ? '_blank' : '_self';
$styles = [];
if ($color) {
@ -21,6 +19,6 @@ $wrapper_attributes = get_block_wrapper_attributes([
$link_url = isset($link['url']) ? esc_url($link['url']) : '#';
?>
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?>>
<a href="<?php echo $link_url; ?>" <?php echo $wrapper_attributes; ?> target="<?php echo $target; ?>">
<?php echo esc_html($text); ?>
</a>