Upload file wp-multi-wiki.php via GUI
This commit is contained in:
118
wp-multi-wiki.php
Normal file
118
wp-multi-wiki.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: WP Multi Wiki
|
||||||
|
* Plugin URI: https://github.com/M-Viper/wp-multi-wiki
|
||||||
|
* Description: Erstelle und verwalte mehrere Wikis – ideal für Plugin-Dokumentation. Mit Kategorien, Suche, TOC und mehr.
|
||||||
|
* Version: 1.0.0
|
||||||
|
* Author: M_Viper
|
||||||
|
* License: GPL v2 or later
|
||||||
|
* Text Domain: wp-multi-wiki
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||||
|
|
||||||
|
define( 'WMW_VERSION', '1.0.0' );
|
||||||
|
define( 'WMW_PLUGIN_FILE', __FILE__ );
|
||||||
|
define( 'WMW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
|
define( 'WMW_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
define( 'WMW_PLUGIN_BASE', plugin_basename( __FILE__ ) );
|
||||||
|
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-activator.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-post-types.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-admin.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-frontend.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-shortcodes.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-toc.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-search.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-ajax.php';
|
||||||
|
require_once WMW_PLUGIN_DIR . 'includes/class-wmw-gitea-importer.php';
|
||||||
|
|
||||||
|
register_activation_hook( __FILE__, array( 'WMW_Activator', 'activate' ) );
|
||||||
|
register_deactivation_hook( __FILE__, array( 'WMW_Activator', 'deactivate' ) );
|
||||||
|
|
||||||
|
function wmw_init() {
|
||||||
|
$post_types = new WMW_Post_Types();
|
||||||
|
$post_types->register();
|
||||||
|
|
||||||
|
if ( is_admin() ) {
|
||||||
|
$admin = new WMW_Admin();
|
||||||
|
$admin->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
$frontend = new WMW_Frontend();
|
||||||
|
$frontend->init();
|
||||||
|
|
||||||
|
$shortcodes = new WMW_Shortcodes();
|
||||||
|
$shortcodes->register();
|
||||||
|
|
||||||
|
$search = new WMW_Search();
|
||||||
|
$search->init();
|
||||||
|
|
||||||
|
$ajax = new WMW_Ajax();
|
||||||
|
$ajax->init();
|
||||||
|
}
|
||||||
|
add_action( 'plugins_loaded', 'wmw_init' );
|
||||||
|
|
||||||
|
function wmw_flush_on_activation() {
|
||||||
|
if ( get_option( 'wmw_flush_rewrite' ) ) {
|
||||||
|
flush_rewrite_rules();
|
||||||
|
delete_option( 'wmw_flush_rewrite' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action( 'init', 'wmw_flush_on_activation', 20 );
|
||||||
|
|
||||||
|
function wmw_action_links( $links ) {
|
||||||
|
$links[] = '<a href="' . admin_url( 'admin.php?page=wp-multi-wiki' ) . '">Wikis</a>';
|
||||||
|
$links[] = '<a href="' . admin_url( 'admin.php?page=wmw-settings' ) . '">Einstellungen</a>';
|
||||||
|
return $links;
|
||||||
|
}
|
||||||
|
add_filter( 'plugin_action_links_' . WMW_PLUGIN_BASE, 'wmw_action_links' );
|
||||||
|
|
||||||
|
// ── Global Helpers ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
function wmw_get_wikis( $args = array() ) {
|
||||||
|
$defaults = array(
|
||||||
|
'post_type' => 'wmw_wiki',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'title',
|
||||||
|
'order' => 'ASC',
|
||||||
|
);
|
||||||
|
return get_posts( wp_parse_args( $args, $defaults ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmw_get_articles( $wiki_id, $args = array() ) {
|
||||||
|
$defaults = array(
|
||||||
|
'post_type' => 'wmw_article',
|
||||||
|
'post_status' => 'publish',
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'title',
|
||||||
|
'order' => 'ASC',
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => '_wmw_wiki_id',
|
||||||
|
'value' => absint( $wiki_id ),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return get_posts( wp_parse_args( $args, $defaults ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmw_get_article_wiki_id( $article_id ) {
|
||||||
|
return (int) get_post_meta( $article_id, '_wmw_wiki_id', true );
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmw_get_article_wiki( $article_id ) {
|
||||||
|
$wiki_id = wmw_get_article_wiki_id( $article_id );
|
||||||
|
return $wiki_id ? get_post( $wiki_id ) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmw_get_wiki_icon( $wiki_id ) {
|
||||||
|
$icon = get_post_meta( $wiki_id, '_wmw_icon', true );
|
||||||
|
return $icon ? esc_html( $icon ) : '📖';
|
||||||
|
}
|
||||||
|
|
||||||
|
function wmw_get_wiki_color( $wiki_id ) {
|
||||||
|
$color = get_post_meta( $wiki_id, '_wmw_color', true );
|
||||||
|
return $color ? sanitize_hex_color( $color ) : '#2271b1';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user