$alt, 'loading' => 'lazy', 'style' => 'max-width:100%;height:auto;'])
: '' . esc_html($alt) . '';
return '
' . $inner . '
';
}
public function shortcode(): string
{
$this->printed = true;
return self::html('shortcode');
}
public function footer(): void
{
if ($this->printed) {
return; // Already placed on this page by the shortcode or the checkout.
}
echo self::html('footer'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts in html().
}
public function checkoutClassic(): void
{
$this->printed = true;
echo self::html('checkout'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts in html().
}
/** @param string $content */
public function checkoutBlock($content)
{
$notice = self::html('checkout');
if ('' === $notice) {
return $content;
}
$this->printed = true;
return $notice . $content;
}
public function adminNotice(): void
{
if (!current_user_can(Plugin::CAP_MANAGE) || !self::isMissing()) {
return;
}
// Only on the plugin's own screens (Guideline 11): never on the
// dashboard or the plugins list. It goes away once the file is added.
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
$id = null !== $screen ? (string) $screen->id : '';
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- reading which settings section is shown.
$section = isset($_GET['section']) ? sanitize_key(wp_unslash($_GET['section'])) : '';
$ownSettings = str_contains($id, 'wc-settings') && Settings::SECTION === $section;
if (!str_contains($id, 'abcreate-warranty-desk') && !$ownSettings) {
return;
}
printf(
'',
esc_html__('Warranty Desk: the EU harmonised notice on the legal guarantee is mandatory since 27 September 2026 and your shop does not show it yet.', 'abcreate-warranty-desk'),
esc_url(admin_url('admin.php?page=wc-settings&tab=products§ion=' . Settings::SECTION)),
esc_html__('Add the official file', 'abcreate-warranty-desk'),
);
}
}