Plugin Development / Elementor

  • Hallo zusammen.

    Erstmal vielen Dank an die Admins für dieses Forum.;)

    Leider stehe ich gerade etwas auf dem Schlauch und brauche eure Hilfe.
    Das [size=14][COLOR=#000000]Plugin Development[/COLOR][/SIZE] ist Neuland für mich. Daher bitte ich um "Gnade":confused:

    Ausgangslage:
    Wordpress 6.1.1
    PHP 8.1.14
    Elementor Pro

    Grundidee:
    Zeiterfassung für Mitarbeiter über die Webseite.
    Eine Tabelle in $wbdb wird bereit erstellt beim abrufen des script.
    Die Abfrage funktioniert auch schon automatisch. Und wird auch dargestellt.

    Leider stellt mit WP dies nicht nur im <body> dar sondern auch im Header.

    Hat jemand einen Ahnung was da falsch ist?

    <?php
    declare(strict_types=1);

    /*
    Plugin Name: dmt_timestamp
    Description: Make timestamps from your Workers
    Version: 1.0.0
    Author: TomStarSky
    Author URI: https://di-mitia.ch
    Text Domain: dmt_timestamp
    Domain Path:
    */

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

    function dmt_timestamp_show_shortcode(): void
    {
    global $wpdb;

    $table_name = $wpdb->prefix . 'employees';
    $employees = $wpdb->get_results( "SELECT * FROM $table_name" );

    echo '<table>';
    echo '<tr>';
    echo '<th>Name</th>';
    echo '<th>Role</th>';
    echo '<th>Salary</th>';
    echo '<th>month</th>';
    echo '<th>regular_hours</th>';
    echo '<th>overtime_hours</th>';
    echo '<th>vacation_hours</th>';
    echo '</tr>';

    foreach ( $employees as $employee ) {
    echo '<tr>';
    echo '<td>' . $employee->name . '</td>';
    echo '<td>' . $employee->role . '</td>';
    echo '<td>' . $employee->salary . '</td>';
    echo '<td>' . $employee->month . '</td>';
    echo '<td>' . $employee->regular_hours . '</td>';
    echo '<td>' . $employee->overtime_hours . '</td>';
    echo '<td>' . $employee->vacation_hours . '</td>';
    echo '</tr>';
    }
    echo '</table>';
    }

    add_shortcode('dmt_timestamp_show', 'dmt_timestamp_show_shortcode');
    ?>


    Danke um eure Hilfe!! :rolleyes:

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!