/** * Produktbox-Kurzcode (Businessator, 2026-11-02). * Shortcode [us_produktbox id="2901" variante="box|inline" label="Passend zum Thema · E-Book"]Nutzensatz[/us_produktbox] * Titel, Preis, Bild und Link kommen live aus dem WooCommerce-Produkt -> Preis/Link nur an EINER Stelle pflegen. * Stichpunkte pro Produkt zentral in $us_pbox_punkte. */ if ( function_exists( 'add_shortcode' ) && ! shortcode_exists( 'us_produktbox' ) ) : add_shortcode( 'us_produktbox', function ( $atts, $content = '' ) { if ( ! function_exists( 'wc_get_product' ) ) { return ''; } $a = shortcode_atts( array( 'id' => 0, 'variante' => 'box', 'label' => 'Passend zum Thema · E-Book', 'button' => '' ), $atts, 'us_produktbox' ); $p = wc_get_product( (int) $a['id'] ); if ( ! $p || 'publish' !== $p->get_status() ) { return ''; } $us_pbox_punkte = array( 2901 => array( 'Zwei fertige Unterrichtsentwürfe mit Verlaufsplan', 'Vorlagen für Arbeitsblätter und Klassenregeln', 'In der Praxis erprobt, für die Sekundarstufe' ), 2659 => array( 'Über 50 Seiten wissenschaftliche Ausarbeitung', 'Vollständiges Literatur- und Abbildungsverzeichnis', 'Genaue Quellenangaben – ideal zum Zitieren' ), 16351 => array( 'Als PDF zum Ausdrucken', 'Als Word-Datei zum Anpassen', 'Sofort einsetzbar' ), 10683 => array( 'Als PDF zum Ausdrucken', 'Als Word-Datei zum Anpassen', 'Sofort einsetzbar' ), ); $id = $p->get_id(); $link = get_permalink( $id ); // Produktseite (interner Link, gut für SEO). Alternative: $p->get_product_url() = Digistore direkt $preis = html_entity_decode( wp_strip_all_tags( wc_price( wc_get_price_to_display( $p ) ) ), ENT_QUOTES, 'UTF-8' ); $preis = preg_replace( '/,00(?=[\s\x{00A0}]*€)/u', '', $preis ); // 17,00 € -> 17 € $ist_ebook = in_array( $id, array( 2901, 2659 ), true ); $button = $a['button'] ? $a['button'] : ( $ist_ebook ? 'Zum E-Book' : 'Zur Kopiervorlage' ); $img_id = $p->get_image_id(); $img = $img_id ? wp_get_attachment_image( $img_id, 'inline' === $a['variante'] ? 'thumbnail' : 'medium', false, array( 'class' => 'us-pbox__img', 'alt' => '', 'loading' => 'lazy' ) ) : ''; $text = wp_kses_post( trim( $content ) ); if ( 'inline' === $a['variante'] ) { return ''; } $li = ''; foreach ( isset( $us_pbox_punkte[ $id ] ) ? $us_pbox_punkte[ $id ] : array() as $pt ) { $li .= '