WordPress-Plugin

Import4u Tools für WordPress

Kopiere den PHP-Code unten, lege ihn als Plugin ab – dann kannst du jedes Import4u-Tool per Shortcode in deine Blog-Artikel einbinden. Kein Download nötig.

Shortcode Beispiel:
[import4u tool="zollrechner-de" lang="de" height="720"]

Installation (4 Schritte)

  1. 1Erstelle einen Ordner `zollpilot-tools-for-import4u` in `/wp-content/plugins/`
  2. 2Erstelle darin eine Datei `zollpilot-tools-for-import4u.php` und füge den kopierten Code ein
  3. 3Aktiviere das Plugin im WordPress-Admin unter 'Plugins'
  4. 4Nutze den Shortcode in jedem Beitrag: `[import4u tool="zollrechner-de" lang="de"]`
import4u-tools.php
<?php
/**
 * Plugin Name: ZollPilot Tools for Import4u
 * Plugin URI: https://import-4u.com/kostenlose-tools
 * Description: Embeds the free Import4u compliance, customs and logistics tools (Zollrechner, CE-Check, REACH-Check and more) into any WordPress page or post via shortcode.
 * Version: 1.1.0
 * Author: davidfrisch
 * Author URI: https://import-4u.com
 * License: GPLv2 or later
 * Text Domain: zollpilot-tools-for-import4u
 *
 * Usage:
 *   [import4u tool="zollrechner-de" lang="de" height="720"]
 *   [import4u tool="ce-kennzeichnung-check" lang="en"]
 */

if ( ! defined( 'ABSPATH' ) ) { exit; }

define( 'ZOLLPILOT_TOOLS_VERSION', '1.1.0' );
define( 'ZOLLPILOT_TOOLS_BASE', 'https://import-4u.com' );

function zollpilot_tools_shortcode( $atts ) {
    $atts = shortcode_atts( array(
        'tool'   => '',
        'lang'   => 'en',
        'height' => '720',
        'title'  => '',
    ), $atts, 'import4u' );

    $slug = sanitize_title( $atts['tool'] );
    if ( '' === $slug ) {
        return '<p class="import4u-error">[import4u] Attribut "tool" fehlt. Slugs: https://import-4u.com/kostenlose-tools</p>';
    }

    $allowed_langs = array( 'de', 'en', 'zh' );
    $lang = in_array( $atts['lang'], $allowed_langs, true ) ? $atts['lang'] : 'en';
    $height = max( 400, absint( $atts['height'] ? $atts['height'] : 720 ) );
    $title_text = sanitize_text_field( $atts['title'] );
    $iframe_title = '' !== $title_text ? $title_text : 'Import4u Tool';

    $embed_url = ZOLLPILOT_TOOLS_BASE . '/embed/tool/' . $slug . '?lang=' . $lang;
    $tool_url  = ZOLLPILOT_TOOLS_BASE . '/kostenloses-tool/' . $slug . '?lang=' . $lang;

    static $registered = false;
    if ( ! $registered ) {
        add_action( 'wp_footer', 'zollpilot_tools_enqueue_loader' );
        $registered = true;
    }

    ob_start();
    ?>
    <span class="import4u-tool-embed" data-slug="<?php echo esc_attr( $slug ); ?>">
        <span class="import4u-tool-embed__frame" style="position:relative;display:block;width:100%;max-width:760px;margin:0 auto;border-radius:14px;overflow:hidden;box-shadow:0 4px 20px rgba(0,0,0,.08);">
            <iframe src="<?php echo esc_url( $embed_url ); ?>"
                    width="100%"
                    height="<?php echo esc_attr( $height ); ?>"
                    style="width:100%;height:<?php echo esc_attr( $height ); ?>px;border:0;display:block;"
                    loading="lazy"
                    referrerpolicy="no-referrer-when-downgrade"
                    title="<?php echo esc_attr( $iframe_title ); ?>"></iframe>
        </span>
        <?php if ( '' !== $title_text ) : ?>
        <p class="import4u-tool-embed__source" style="text-align:center;font-size:13px;margin:10px 0 0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;color:#374151;">
            <a href="<?php echo esc_url( $tool_url ); ?>" target="_blank" rel="noopener noreferrer" style="font-weight:600;color:#111;text-decoration:none;"><?php echo esc_html( $title_text ); ?></a>
        </p>
        <?php endif; ?>
    </span>
    <?php
    return ob_get_clean();
}
add_shortcode( 'import4u', 'zollpilot_tools_shortcode' );

function zollpilot_tools_enqueue_loader() {
    wp_enqueue_script(
        'import4u-tools-embed',
        ZOLLPILOT_TOOLS_BASE . '/embed.js',
        array(),
        ZOLLPILOT_TOOLS_VERSION,
        true
    );
}

Shortcode-Attribute

toolPflichtTool-Slug (Pflicht) – siehe Embed Hub
langde / en / zh (Standard: en)
heightHöhe in px (Standard: 720, min: 400)
titleOptional: blendet einen Quellen-Link mit diesem Linktext unter dem Tool ein

Das Plugin setzt keinen Credit-Link. Ein Quellen-Link erscheint nur, wenn du im Shortcode das Attribut title angibst.