Update from Git Manager GUI

This commit is contained in:
2026-03-18 21:56:45 +01:00
parent ea210d5a75
commit ee592829c0
12 changed files with 1954 additions and 0 deletions

116
includes/class-wmw-core.php Normal file
View File

@@ -0,0 +1,116 @@
<?php
/**
* WMW_Core Bootstrap singleton.
* Wires up all sub-systems and handles asset enqueueing.
*/
defined( 'ABSPATH' ) || exit;
final class WMW_Core {
private static ?WMW_Core $instance = null;
private function __construct() {
new WMW_CPT();
new WMW_Admin();
new WMW_Frontend();
new WMW_Search();
new WMW_Shortcodes();
add_action( 'wp_enqueue_scripts', [ $this, 'frontend_assets' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_assets' ] );
add_filter( 'plugin_action_links_' . WMW_BASENAME, [ $this, 'action_links' ] );
add_action( 'init', [ $this, 'load_textdomain' ] );
}
public static function get_instance(): WMW_Core {
if ( self::$instance === null ) {
self::$instance = new self();
}
return self::$instance;
}
/* ── Textdomain ─────────────────────────────────────────────── */
public function load_textdomain(): void {
load_plugin_textdomain( 'wp-multi-wiki', false, dirname( WMW_BASENAME ) . '/languages' );
}
/* ── Frontend Assets ────────────────────────────────────────── */
public function frontend_assets(): void {
if ( ! $this->is_wiki_context() ) return;
// Dashicons on frontend
wp_enqueue_style( 'dashicons' );
wp_enqueue_style(
'wmw-frontend',
WMW_URL . 'assets/css/frontend.css',
[ 'dashicons' ],
WMW_VERSION
);
wp_enqueue_script(
'wmw-frontend',
WMW_URL . 'assets/js/frontend.js',
[ 'jquery' ],
WMW_VERSION,
true
);
wp_localize_script( 'wmw-frontend', 'WMW', [
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wmw_search' ),
'l10n' => [
'no_results' => __( 'Keine Ergebnisse gefunden.', 'wp-multi-wiki' ),
'searching' => __( 'Suche …', 'wp-multi-wiki' ),
'navigation' => __( 'Navigation', 'wp-multi-wiki' ),
],
] );
}
/* ── Admin Assets ───────────────────────────────────────────── */
public function admin_assets( string $hook ): void {
$screen = get_current_screen();
if ( ! $screen ) return;
$is_wmw = str_contains( $hook, 'wp-multi-wiki' )
|| str_contains( $hook, 'wmw-settings' )
|| in_array( $screen->post_type, [ 'wmw_wiki', 'wmw_article' ], true )
|| in_array( $screen->taxonomy ?? '', [ 'wmw_category', 'wmw_tag' ], true );
if ( ! $is_wmw ) return;
wp_enqueue_style(
'wmw-admin',
WMW_URL . 'assets/css/admin.css',
[],
WMW_VERSION
);
wp_enqueue_script(
'wmw-admin',
WMW_URL . 'assets/js/admin.js',
[ 'jquery' ],
WMW_VERSION,
true
);
}
/* ── Helpers ────────────────────────────────────────────────── */
private function is_wiki_context(): bool {
return is_singular( [ 'wmw_wiki', 'wmw_article' ] )
|| is_post_type_archive( 'wmw_wiki' )
|| is_tax( [ 'wmw_category', 'wmw_tag' ] );
}
public function action_links( array $links ): array {
array_unshift(
$links,
'<a href="' . admin_url( 'admin.php?page=wp-multi-wiki' ) . '">' . __( 'Dashboard', 'wp-multi-wiki' ) . '</a>'
);
return $links;
}
}