'mm_bot_sanitize_settings', ] ); } ); function mm_bot_sanitize_settings( $input ) { $clean = []; $text_fields = [ 'server_ip', 'server_ver', 'server_specs', 'bot_name', 'welcome' ]; $url_fields = [ 'url_wiki', 'url_rules', 'url_tickets', 'url_faq', 'url_team', 'url_shop', 'url_gallery', 'url_player_history', 'url_forum', 'link_discord', 'litebans_dashboard_url', ]; foreach ( $text_fields as $f ) { $clean[ $f ] = isset( $input[ $f ] ) ? sanitize_text_field( $input[ $f ] ) : ''; } foreach ( $url_fields as $f ) { $clean[ $f ] = isset( $input[ $f ] ) ? esc_url_raw( $input[ $f ] ) : ''; } $clean['qa'] = []; if ( ! empty( $input['qa'] ) && is_array( $input['qa'] ) ) { foreach ( $input['qa'] as $item ) { if ( empty( $item['keys'] ) ) continue; $clean['qa'][] = [ 'keys' => sanitize_text_field( $item['keys'] ), 'val' => wp_kses_post( $item['val'] ), ]; } } return $clean; } // ========================================================================= // 2. ADMIN-SEITE // ========================================================================= // BUG-FIX: Funktion außerhalb von mm_render_bot_admin() definieren. // Innerhalb einer Funktion definierte benannte Funktionen erzeugen einen // Fatal Error "Cannot redeclare", wenn die äußere Funktion jemals ein // zweites Mal ausgeführt wird (z.B. durch AJAX, REST, bestimmte Plugins). if ( ! function_exists( 'mm_find_page_by_shortcode' ) ) : function mm_find_page_by_shortcode( $shortcodes ) { global $wpdb; $conditions = []; foreach ( (array) $shortcodes as $sc ) { $conditions[] = $wpdb->prepare( 'post_content LIKE %s', '%[' . $wpdb->esc_like( $sc ) . '%' ); } if ( empty( $conditions ) ) return ''; $where = implode( ' OR ', $conditions ); $page = $wpdb->get_row( "SELECT ID FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type IN ('page','post') AND ({$where}) LIMIT 1" ); return $page ? get_permalink( $page->ID ) : ''; } endif; function mm_render_bot_admin() { $data = get_option( 'mm_bot_data', [] ); ?>