Upload via Git Manager GUI - functions.php
This commit is contained in:
@@ -87,8 +87,10 @@ function minecraft_modern_scripts() {
|
||||
true
|
||||
);
|
||||
|
||||
// FAQ Skript
|
||||
if ( post_type_exists( 'faq' ) ) {
|
||||
// BUG-FIX: post_type_exists('faq') prüft nur ob der CPT registriert ist, nicht ob wir
|
||||
// auf einer FAQ-Seite sind – das Script wurde damit seitenübergreifend geladen.
|
||||
// Jetzt: nur auf FAQ-Archiv-, Einzel- und Seiten mit FAQ-Template laden.
|
||||
if ( post_type_exists( 'faq' ) && ( is_post_type_archive( 'faq' ) || is_singular( 'faq' ) || is_page( 'FAQ' ) || is_page( 'faq' ) ) ) {
|
||||
wp_enqueue_script(
|
||||
'faq-accordion-script',
|
||||
get_template_directory_uri() . '/js/faq-accordion.js',
|
||||
@@ -308,7 +310,17 @@ add_action( 'init', 'create_faq_post_type' );
|
||||
|
||||
function set_static_front_page_automatically() {
|
||||
if ( 'page' !== get_option( 'show_on_front' ) ) {
|
||||
$home_page = get_page_by_title( 'Home' );
|
||||
// BUG-FIX: get_page_by_title() ist seit WP 6.2 deprecated. Ersetzt durch WP_Query.
|
||||
$home_query = new WP_Query( array(
|
||||
'post_type' => 'page',
|
||||
'title' => 'Home',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1,
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
) );
|
||||
$home_page = $home_query->have_posts() ? $home_query->posts[0] : null;
|
||||
if ( ! $home_page ) {
|
||||
$home_page_id = wp_insert_post( array(
|
||||
'post_title' => 'Home',
|
||||
@@ -343,15 +355,27 @@ add_filter( 'body_class', 'add_home_body_class' );
|
||||
// =============================================================================
|
||||
|
||||
function create_faq_page_automatically() {
|
||||
if ( get_theme_mod( 'faq_enabled', true ) && get_page_by_title( 'FAQ' ) == null ) {
|
||||
wp_insert_post( array(
|
||||
'post_title' => 'FAQ',
|
||||
'post_content' => 'Diese Seite zeigt alle FAQs an. Der Inhalt wird automatisch generiert.',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'page',
|
||||
'post_author' => 1,
|
||||
) );
|
||||
}
|
||||
if ( ! get_theme_mod( 'faq_enabled', true ) ) return;
|
||||
|
||||
// BUG-FIX: get_page_by_title() ist seit WP 6.2 deprecated. Ersetzt durch WP_Query.
|
||||
$faq_query = new WP_Query( array(
|
||||
'post_type' => 'page',
|
||||
'title' => 'FAQ',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1,
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
) );
|
||||
if ( $faq_query->have_posts() ) return;
|
||||
|
||||
wp_insert_post( array(
|
||||
'post_title' => 'FAQ',
|
||||
'post_content' => 'Diese Seite zeigt alle FAQs an. Der Inhalt wird automatisch generiert.',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'page',
|
||||
'post_author' => 1,
|
||||
) );
|
||||
}
|
||||
add_action( 'customize_save_after', 'create_faq_page_automatically' );
|
||||
|
||||
@@ -1154,6 +1178,9 @@ add_action( 'wp_body_open', 'mm_render_announcement_bar' );
|
||||
|
||||
|
||||
function mm_announcement_enqueue_assets() {
|
||||
// BUG-FIX: CSS/JS nicht laden wenn die Ankündigungs-Bar deaktiviert ist.
|
||||
if ( ! get_option( 'mm_announcement_enabled' ) ) return;
|
||||
|
||||
wp_enqueue_style( 'mm-announcement-style', get_template_directory_uri() . '/css/announcement.css', array(), '1.2' );
|
||||
wp_enqueue_script( 'mm-announcement-script', get_template_directory_uri() . '/js/announcement.js', array(), '1.4', true );
|
||||
|
||||
@@ -2492,7 +2519,8 @@ function mm_video_save_meta( $post_id ) {
|
||||
update_post_meta( $post_id, '_mm_video_category', sanitize_text_field( $_POST['mm_video_category'] ) );
|
||||
}
|
||||
}
|
||||
add_action( 'save_post', 'mm_video_save_meta' );
|
||||
// BUG-FIX: 'save_post' feuert bei JEDEM Post-Type. Spezifischer Hook benutzen.
|
||||
add_action( 'save_post_mm_video', 'mm_video_save_meta' );
|
||||
|
||||
function mm_livestream_save_meta( $post_id ) {
|
||||
if ( ! isset( $_POST['mm_livestream_nonce'] ) || ! wp_verify_nonce( $_POST['mm_livestream_nonce'], 'mm_livestream_save' ) ) return;
|
||||
|
||||
Reference in New Issue
Block a user