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[] = 'Wikis'; $links[] = 'Einstellungen'; 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'; }