forked from daimpad/OpenDataWizard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen-data-wizard.php
More file actions
175 lines (158 loc) · 5.72 KB
/
Copy pathopen-data-wizard.php
File metadata and controls
175 lines (158 loc) · 5.72 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
* Plugin Name: Open Data Wizard
* Plugin URI: https://github.com/daimpad/OpenDataWizard
* Description: DCAT-AP 3.0 konforme Open Data Metadatenverwaltung für WordPress. Bereitstellung als maschinenlesbarer JSON-LD-Endpoint für offene Daten.
* Version: 2.35.3
* Requires at least: 6.4
* Requires PHP: 8.1
* Author: nozilla
* Author URI: https://github.com/daimpad/OpenDataWizard
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: open-data-wizard
* Domain Path: /languages
* GitHub Plugin URI: daimpad/OpenDataWizard
* Primary Branch: main
* GitHub Branch: main
* Release Asset: true
*
* @package OpenDataWizard
*/
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'ODW_VERSION', '2.35.3' );
define( 'ODW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ODW_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ODW_PLUGIN_FILE', __FILE__ );
// Setup-Klasse früh laden: on_activation() wird vor dem vollständigen
// Bootstrap aufgerufen, darf Carbon Fields daher nicht voraussetzen.
require_once ODW_PLUGIN_DIR . 'includes/class-setup.php';
// ---------------------------------------------------------------------------
// Activation / Deactivation
// ---------------------------------------------------------------------------
register_activation_hook( __FILE__, 'odw_activate' );
register_deactivation_hook( __FILE__, 'odw_deactivate' );
/**
* Runs on plugin activation: registers CPT and flushes rewrite rules.
*/
function odw_activate(): void {
odw_register_cpt_static();
flush_rewrite_rules();
ODW_Setup::on_activation();
}
/**
* Runs on plugin deactivation: flushes rewrite rules.
*/
function odw_deactivate(): void {
flush_rewrite_rules();
}
/**
* Minimal CPT registration used during activation (before theme is set up).
*/
function odw_register_cpt_static(): void {
register_post_type(
'odw_dataset',
array(
'public' => false,
'supports' => array( 'title', 'revisions' ),
)
);
}
// ---------------------------------------------------------------------------
// Bootstrap
// ---------------------------------------------------------------------------
/**
* Bootstrap Carbon Fields and all plugin modules.
*/
function odw_bootstrap(): void {
$autoloader = ODW_PLUGIN_DIR . 'vendor/autoload.php';
if ( ! file_exists( $autoloader ) ) {
add_action(
'admin_notices',
function (): void {
// Häufigste Ursache: Das Plugin wurde aus dem Quellcode-Archiv
// installiert (z. B. „Code herunterladen" auf GitHub oder ein
// Update aus einer Version vor 2.34.0). Dieses Archiv enthält
// bewusst keine Abhängigkeiten — nur das Release-ZIP ist
// vollständig. Die Anleitung nennt daher zuerst den Weg, den
// Redakteur:innen ohne Kommandozeile gehen können.
echo '<div class="notice notice-error"><p><strong>';
esc_html_e( 'Open Data Wizard: Installation unvollständig', 'open-data-wizard' );
echo '</strong></p><p>';
esc_html_e(
'Dem Plugin fehlen seine Programmbibliotheken, daher ist es derzeit inaktiv. Das passiert, wenn es aus dem Quellcode-Archiv statt aus dem fertigen Plugin-Paket installiert wurde.',
'open-data-wizard'
);
echo '</p><p><strong>';
esc_html_e( 'So beheben Sie das:', 'open-data-wizard' );
echo '</strong> ';
printf(
/* translators: %s: link to the releases page, already wrapped in an <a> tag. */
esc_html__( 'Laden Sie das fertige Plugin-Paket (ZIP) unter %s herunter und spielen Sie es über „Plugins → Installieren → Plugin hochladen" ein. Ihre Datensätze bleiben dabei erhalten.', 'open-data-wizard' ),
'<a href="https://github.com/daimpad/OpenDataWizard/releases/latest" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Releases', 'open-data-wizard' ) . ' ↗</a>'
);
echo '</p><p class="description">';
esc_html_e(
'Für Entwickler:innen: Alternativ im Plugin-Verzeichnis „composer install" ausführen.',
'open-data-wizard'
);
echo '</p></div>';
}
);
return;
}
require_once $autoloader;
try {
\Carbon_Fields\Carbon_Fields::boot();
} catch ( \Throwable $e ) {
add_action(
'admin_notices',
function () use ( $e ): void {
echo '<div class="notice notice-error"><p>';
printf(
/* translators: %s: Error message */
esc_html__( 'Open Data Wizard: Carbon Fields konnte nicht initialisiert werden — %s', 'open-data-wizard' ),
esc_html( $e->getMessage() )
);
echo '</p></div>';
}
);
return;
}
require_once ODW_PLUGIN_DIR . 'includes/class-settings.php';
require_once ODW_PLUGIN_DIR . 'includes/class-post-types.php';
require_once ODW_PLUGIN_DIR . 'includes/class-fields.php';
require_once ODW_PLUGIN_DIR . 'includes/class-rdf.php';
require_once ODW_PLUGIN_DIR . 'includes/class-rest-api.php';
require_once ODW_PLUGIN_DIR . 'includes/class-validation.php';
require_once ODW_PLUGIN_DIR . 'includes/class-quality.php';
require_once ODW_PLUGIN_DIR . 'includes/class-admin.php';
require_once ODW_PLUGIN_DIR . 'includes/class-batch-import.php';
require_once ODW_PLUGIN_DIR . 'includes/class-shortcode.php';
require_once ODW_PLUGIN_DIR . 'includes/class-cli.php';
ODW_Settings::init();
ODW_Post_Types::init();
ODW_Fields::init();
ODW_Rest_API::init();
ODW_Validation::init();
ODW_Quality::init();
ODW_Admin::init();
ODW_Shortcode::init();
ODW_Setup::init();
ODW_CLI::init();
}
add_action( 'after_setup_theme', 'odw_bootstrap' );
/**
* Load plugin textdomain.
*/
function odw_load_textdomain(): void {
load_plugin_textdomain(
'open-data-wizard',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages'
);
}
add_action( 'init', 'odw_load_textdomain' );