Repository navigation
Expand file tree
/
Copy pathwsform-ml.php
More file actions
142 lines (118 loc) · 4.25 KB
/
Copy pathwsform-ml.php
File metadata and controls
142 lines (118 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* Plugin Name: WSForm Multilingual
* Plugin URI: https://github.com/defcon1702/wsform-ml
* Description: Automatic translation management for WSForm with Polylang integration. Scans forms automatically and manages translations centrally. ⚠️ IMPORTANT: Entirely AI-generated - use only on staging environments!
* Version: 1.7.1
* Author: Sebastian Berger
* Author URI: https://github.com/defcon1702
* Text Domain: wsform-ml
* Domain Path: /languages
* Requires at least: 5.8
* Requires PHP: 7.4
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* ⚠️ AI-GENERATED CODE WARNING:
* This plugin was entirely developed using AI (Cascade/Claude).
* - Test thoroughly on staging environments before production use
* - Code review by a developer is strongly recommended
* - Always create backups before installation
* - Use at your own risk
*/
if (!defined('ABSPATH')) {
exit;
}
define('WSFORM_ML_VERSION', '1.7.1');
define('WSFORM_ML_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WSFORM_ML_PLUGIN_URL', plugin_dir_url(__FILE__));
define('WSFORM_ML_PLUGIN_BASENAME', plugin_basename(__FILE__));
final class WSForm_ML {
private static $instance = null;
public static function instance() {
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
$this->load_dependencies();
$this->init_hooks();
}
private function load_dependencies() {
// Core Classes
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-logger.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-database.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-field-scanner.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-translation-manager.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-renderer.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-polylang-integration.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-language-field-manager.php';
require_once WSFORM_ML_PLUGIN_DIR . 'admin/class-rest-api.php';
// Feature Management & Native API
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-feature-manager.php';
require_once WSFORM_ML_PLUGIN_DIR . 'includes/class-native-adapter.php';
if (is_admin()) {
require_once WSFORM_ML_PLUGIN_DIR . 'admin/class-admin-menu.php';
require_once WSFORM_ML_PLUGIN_DIR . 'admin/class-settings-page.php';
}
}
private function init_hooks() {
register_activation_hook(__FILE__, [$this, 'activate']);
register_deactivation_hook(__FILE__, [$this, 'deactivate']);
add_action('plugins_loaded', [$this, 'init']);
add_action('init', [$this, 'load_textdomain']);
}
public function activate() {
WSForm_ML_Database::create_tables();
flush_rewrite_rules();
}
public function deactivate() {
flush_rewrite_rules();
}
public function init() {
if (!$this->check_dependencies()) {
add_action('admin_notices', [$this, 'dependency_notice']);
return;
}
// Initialisiere Feature Manager
$feature_manager = WSForm_ML_Feature_Manager::instance();
// Initialisiere Legacy Renderer wenn aktiviert
if ($feature_manager->is_enabled(WSForm_ML_Feature_Manager::FEATURE_LEGACY_RENDERER)) {
WSForm_ML_Renderer::instance();
}
// Initialisiere Native Adapter (prüft selbst ob aktiviert)
WSForm_ML_Native_Adapter::instance();
// Initialisiere Language Field Manager (für Sprachfeld-Integration)
WSForm_ML_Language_Field_Manager::instance();
// REST API immer initialisieren
WSForm_ML_REST_API::instance();
if (is_admin()) {
WSForm_ML_Admin_Menu::instance();
WSForm_ML_Settings_Page::instance();
}
}
private function check_dependencies() {
if (!class_exists('WS_Form')) {
return false;
}
return true;
}
public function dependency_notice() {
?>
<div class="notice notice-error">
<p>
<strong><?php _e('WSForm Multilingual', 'wsform-ml'); ?>:</strong>
<?php _e('Dieses Plugin benötigt WS Form. Bitte installieren und aktivieren Sie WS Form.', 'wsform-ml'); ?>
</p>
</div>
<?php
}
public function load_textdomain() {
load_plugin_textdomain('wsform-ml', false, dirname(WSFORM_ML_PLUGIN_BASENAME) . '/languages');
}
}
function wsform_ml() {
return WSForm_ML::instance();
}
wsform_ml();