ESTRUCTURA PROFESIONAL RECOMENDADA





wp-content/plugins/industrie-imkerei-system/

├── industrie-imkerei-system.php

├── assets/
│ ├── style.css
│ └── app.js

├── includes/
│ ├── class-database.php
│ ├── class-shortcodes.php
│ ├── class-ajax.php
│ ├── class-admin.php
│ ├── class-frontend.php
│ ├── class-qr.php
│ ├── class-kpi.php
│ └── class-routes.php

└── templates/
├── dashboard.php
└── volk-detail.php

QUÉ VA EN CADA ARCHIVO

ArchivoFunción
class-database.phptablas MySQL
class-shortcodes.phpshortcodes
class-ajax.phpAJAX
class-admin.phpdashboard WP
class-frontend.phpfrontend
class-qr.phpQR system
class-kpi.phpKPIs
class-routes.phprutas y logística

TU SIGUIENTE PASO

Ahora mismo necesitas SOLO 3:





includes/
├── class-database.php
├── class-ajax.php
└── class-shortcodes.php

1. class-database.php

Crear:





wp-content/plugins/industrie-imkerei-system/includes/class-database.php

Pegar:





<?php

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

class ImkereiDatabase {

public static function install_tables() {

global $wpdb;

require_once ABSPATH .
'wp-admin/includes/upgrade.php';

$charset_collate =
$wpdb->get_charset_collate();

$table =
$wpdb->prefix . 'bienenvoelker';

$sql = "CREATE TABLE $table (

id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
volk_id VARCHAR(50) NOT NULL,
standort VARCHAR(100),
status VARCHAR(50),
honig_kg FLOAT DEFAULT 0,
varroa FLOAT DEFAULT 0,
letzte_kontrolle DATETIME,
PRIMARY KEY (id)

) $charset_collate;";

dbDelta($sql);
}
}

2. class-ajax.php

Crear:





includes/class-ajax.php

Pegar:





<?php

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

class ImkereiAjax {

public function __construct() {

add_action(
'wp_ajax_update_volk_status',
array($this, 'update_volk_status')
);

add_action(
'wp_ajax_nopriv_update_volk_status',
array($this, 'update_volk_status')
);
}

public function update_volk_status() {

global $wpdb;

$table =
$wpdb->prefix . 'bienenvoelker';

$volk_id =
sanitize_text_field(
$_POST['volk_id']
);

$status =
sanitize_text_field(
$_POST['status']
);

$wpdb->update(

$table,

array(
'status' => $status,
'letzte_kontrolle' =>
current_time('mysql')
),

array(
'volk_id' => $volk_id
)
);

wp_send_json_success(
array(
'new_status' => $status
)
);
}
}

3. class-shortcodes.php

Crear:





includes/class-shortcodes.php

Pegar:





<?php

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

class ImkereiShortcodes {

public function __construct() {

add_shortcode(
'imkerei_dashboard',
array($this, 'dashboard')
);
}

public function dashboard() {

global $wpdb;

$table =
$wpdb->prefix . 'bienenvoelker';

$results =
$wpdb->get_results(
"SELECT * FROM $table"
);

ob_start();

echo '<div class="imkerei-grid">';

foreach ($results as $row) {

echo '<div class="imkerei-card">';

echo '<h2>'
. esc_html($row->volk_id)
. '</h2>';

echo '<p>'
. esc_html($row->status)
. '</p>';

echo '</div>';
}

echo '</div>';

return ob_get_clean();
}
}

4. ACTUALIZAR PLUGIN PRINCIPAL

Ahora industrie-imkerei-system.php
queda MUCHO más limpio.

REEMPLAZAR TODO por:





<?php
/*
Plugin Name: Industrie Imkerei System
*/

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

/*
LOAD FILES
*/

require_once plugin_dir_path(__FILE__) .
'includes/class-database.php';

require_once plugin_dir_path(__FILE__) .
'includes/class-ajax.php';

require_once plugin_dir_path(__FILE__) .
'includes/class-shortcodes.php';

/*
MAIN CLASS
*/

class IndustrieImkereiSystem {

public function __construct() {

add_action(
'wp_enqueue_scripts',
array($this, 'load_assets')
);

new ImkereiAjax();

new ImkereiShortcodes();
}

public function load_assets() {

wp_enqueue_style(
'imkerei-style',
plugin_dir_url(__FILE__) .
'assets/style.css'
);

wp_enqueue_script(
'imkerei-app',
plugin_dir_url(__FILE__) .
'assets/app.js',
array(),
'1.0',
true
);

wp_localize_script(
'imkerei-app',
'imkerei_ajax',
array(
'ajax_url' =>
admin_url('admin-ajax.php')
)
);
}
}

/*
ACTIVATION
*/

register_activation_hook(
__FILE__,
array(
'ImkereiDatabase',
'install_tables'
)
);

/*
START
*/

new IndustrieImkereiSystem();

RESULTADO

Ahora tienes arquitectura profesional:

✅ modular
✅ escalable
✅ limpia
✅ compatible PHP 8.3
✅ mantenible
✅ industrial ERP ready


SIGUIENTE NIVEL

Después podrás añadir fácilmente:

  • QR generator
  • GPS routes
  • XLSX import
  • PWA offline
  • worker accounts
  • AI recommendations
  • KPI engine
  • queen tracking
  • honey production AI ranking

sin destruir el plugin principal.

Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert