This repository has been archived on 2026-09-17. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
nixos-config/hosts/blunix/localServices/wordpress-hdm-assets/hdm-header-footer.php
pijukka 8ca3a95a84 HdM-Klon: echtes Elementor-Kit, Fonts und Scroll-Animationen statt Defaults
wordpress.nix zieht die echten Elementor-CSS-Dateien (Kit, Widget-Styles)
von hausdermaterialisierung.org per fetchurl statt der Plugin-Defaults;
hdm-header-footer.php dequeued die Defaults zugunsten dieser CSS und
entfernt wpautop für migrierten Elementor-Content. Neue
hdm-scroll-animations.js/hdm-visual.css bilden Elementors Motion-Effects
(pulse/jello/bounceInDown/swing/tada) als IntersectionObserver-Fallback
nach, da Elementor Pro nicht lizenziert ist. Auf blunix aktiviert und
live geprüft (Kit-13-Zuordnung, Medien-404-Sweep, Animationen Desktop/
Mobil bestätigt); zwei absolut positionierte Deko-Elemente bleiben ohne
Elementors Offset-JS unsichtbar, offener Folgepunkt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyB72YNyCNXwVxCTgfnXCp
2026-09-02 11:51:57 +02:00

226 lines
8.5 KiB
PHP

<?php
/**
* Visual compatibility layer for the hausdermaterialisierung.org clone.
*
* Header and footer are public rendered markup from the source site. The
* source editor account cannot read HFE templates, so keeping this markup is
* the only complete read-only representation currently available.
*/
add_filter( 'body_class', function ( array $classes ): array {
if ( is_singular() ) {
$post = get_queried_object();
if ( $post instanceof WP_Post && str_contains( $post->post_content, 'data-elementor-' ) ) {
$classes[] = 'elementor-page';
$classes[] = 'elementor-page-' . $post->ID;
}
}
$classes[] = 'ehf-header';
$classes[] = 'ehf-footer';
return array_values( array_unique( $classes ) );
} );
add_action( 'wp', function () {
if ( ! is_singular() ) {
return;
}
$post = get_queried_object();
if ( $post instanceof WP_Post && str_contains( $post->post_content, 'data-elementor-' ) ) {
// The migrated content is already rendered Elementor HTML. Running
// wpautop() over it injects <br> and </p> tags into widget markup.
remove_filter( 'the_content', 'wpautop' );
}
} );
add_action( 'wp_enqueue_scripts', function () {
$uploads = wp_upload_dir();
$assets_url = trailingslashit( $uploads['baseurl'] ) . 'hdm-assets/';
wp_dequeue_style( 'elementor-frontend' );
wp_deregister_style( 'elementor-frontend' );
wp_enqueue_style(
'elementor-frontend',
$assets_url . 'custom-frontend.min.css',
[],
'1786740732'
);
foreach ( [ 'widget-image', 'widget-heading', 'widget-image-box', 'widget-video' ] as $style ) {
wp_dequeue_style( $style );
wp_deregister_style( $style );
}
wp_enqueue_style(
'widget-image',
$assets_url . 'widget-image.min.css',
[ 'elementor-frontend' ],
'4.2.2'
);
wp_enqueue_style(
'widget-heading',
$assets_url . 'widget-heading.min.css',
[ 'elementor-frontend' ],
'4.2.2'
);
wp_enqueue_style(
'widget-image-box',
$assets_url . 'custom-widget-image-box.min.css',
[ 'elementor-frontend' ],
'1786740732'
);
wp_enqueue_style(
'widget-video',
$assets_url . 'widget-video.min.css',
[ 'elementor-frontend' ],
'4.2.2'
);
wp_enqueue_style(
'hdm-visual-clone',
$assets_url . 'hdm-visual.css',
[ 'widget-image', 'widget-heading', 'widget-image-box', 'widget-video' ],
'2026-09-02'
);
wp_enqueue_script(
'hdm-scroll-animations',
$assets_url . 'hdm-scroll-animations.js',
[],
'2026-09-02',
true
);
}, 100 );
add_action( 'wp_print_styles', function () {
wp_dequeue_style( 'elementor-gf-roboto' );
wp_dequeue_style( 'elementor-gf-robotoslab' );
}, 1000 );
add_action( 'elementor/init', function () {
$migration_version = '2026-09-02-v2';
if ( get_option( 'hdm_visual_migration_version' ) === $migration_version ) {
return;
}
$system_colors = [
[ '_id' => 'primary', 'title' => 'Primary', 'color' => '#FFFF4B' ],
[ '_id' => 'secondary', 'title' => 'Secondary', 'color' => '#0D6DBD' ],
[ '_id' => 'text', 'title' => 'Text', 'color' => '#000000' ],
[ '_id' => 'accent', 'title' => 'Accent', 'color' => '#FECC3D' ],
];
$custom_colors = [
[ '_id' => '0cbb7ac', 'title' => 'color-1', 'color' => '#8A2841' ],
[ '_id' => '6f96257', 'title' => 'color-2', 'color' => '#FFFFC1' ],
[ '_id' => '9294ffe', 'title' => 'color-3', 'color' => '#CC9F6D' ],
[ '_id' => '176f3dd', 'title' => 'color-4', 'color' => '#FC0E99' ],
[ '_id' => 'd6a7dca', 'title' => 'color-5', 'color' => '#C7A19C' ],
[ '_id' => '6dd1975', 'title' => 'color-6', 'color' => '#F5A497' ],
[ '_id' => '766df99', 'title' => 'color-7', 'color' => '#ED7125' ],
[ '_id' => 'f37e0d0', 'title' => 'color-8', 'color' => '#9F6426' ],
[ '_id' => '9938036', 'title' => 'color-9', 'color' => '#94C135' ],
[ '_id' => 'd3c3697', 'title' => 'color-10', 'color' => '#39AA34' ],
[ '_id' => '54a3003', 'title' => 'color-11', 'color' => '#0F6822' ],
[ '_id' => '19956d3', 'title' => 'color-12', 'color' => '#6C784A' ],
[ '_id' => '8a0f098', 'title' => 'color-13', 'color' => '#1CA3AE' ],
[ '_id' => 'c655dea', 'title' => 'color-14', 'color' => '#6B8791' ],
[ '_id' => 'e88f354', 'title' => 'color-15', 'color' => '#5BC5F1' ],
[ '_id' => '4e5740c', 'title' => 'color-16', 'color' => '#0D6DBD' ],
[ '_id' => '35f50b2', 'title' => 'color-17', 'color' => '#7B6DAF' ],
[ '_id' => '6624883', 'title' => 'color-18', 'color' => '#C492C3' ],
[ '_id' => 'cfa9933', 'title' => 'color-19', 'color' => '#DE7DA9' ],
[ '_id' => '5d20c7e', 'title' => 'color-20', 'color' => '#FFFFFF' ],
];
$system_typography = [];
foreach ( [ 'primary' => '600', 'secondary' => '400', 'text' => '400', 'accent' => '500' ] as $id => $weight ) {
$system_typography[] = [
'_id' => $id,
'title' => ucfirst( $id ),
'typography_typography' => 'custom',
'typography_font_family' => 'HelveticaNeueLTPro-Roman',
'typography_font_weight' => $weight,
];
}
$kit = Elementor\Plugin::$instance->kits_manager->get_active_kit();
if ( $kit ) {
$administrator_ids = get_users( [
'role' => 'administrator',
'number' => 1,
'fields' => 'ID',
] );
if ( ! $administrator_ids ) {
return;
}
// Elementor's document API requires an editor context even for this
// fixed, parameterless migration. Restore the anonymous visitor before
// WordPress continues rendering the request.
$visitor_id = get_current_user_id();
wp_set_current_user( (int) $administrator_ids[0] );
try {
$kit->update_settings( [
'system_colors' => $system_colors,
'custom_colors' => $custom_colors,
'system_typography' => $system_typography,
'container_width' => [ 'unit' => 'px', 'size' => 1200, 'sizes' => [] ],
'space_between_widgets' => [
'unit' => 'px',
'size' => 0,
'row' => '0',
'column' => '0',
'isLinked' => true,
],
'link_normal_color' => '#000000',
'link_hover_color' => '#FFFFFF',
] );
Elementor\Core\Files\CSS\Post::create( $kit->get_main_id() )->update();
} finally {
wp_set_current_user( $visitor_id );
}
}
$posts = get_posts( [
'post_type' => [ 'page', 'post' ],
'post_status' => 'publish',
'posts_per_page' => -1,
'fields' => 'ids',
] );
foreach ( $posts as $post_id ) {
$content = get_post_field( 'post_content', $post_id );
if (
str_contains( $content, 'data-elementor-' ) &&
'builder' !== get_post_meta( $post_id, '_elementor_edit_mode', true )
) {
update_post_meta( $post_id, '_elementor_edit_mode', 'builder' );
}
}
// Restore the source animation marker removed by the first one-off fix.
$front_page_id = (int) get_option( 'page_on_front' );
$front_page = get_post( $front_page_id );
if ( $front_page ) {
$visible = 'elementor-hidden-tablet elementor-hidden-mobile animated-fast elementor-widget';
$source = 'elementor-hidden-tablet elementor-hidden-mobile animated-fast elementor-invisible elementor-widget';
if ( substr_count( $front_page->post_content, $visible ) === 1 ) {
global $wpdb;
$content = str_replace( $visible, $source, $front_page->post_content, $replaced );
if ( 1 === $replaced ) {
$wpdb->update( $wpdb->posts, [ 'post_content' => $content ], [ 'ID' => $front_page_id ] );
clean_post_cache( $front_page_id );
}
}
}
update_option( 'hdm_visual_migration_version', $migration_version, false );
}, 20 );
add_action( 'wp_body_open', function () {
$path = '/var/lib/wordpress/hdm/header-inject.html';
if ( is_readable( $path ) ) {
echo file_get_contents( $path );
}
} );
add_action( 'wp_footer', function () {
$path = '/var/lib/wordpress/hdm/footer-inject.html';
if ( is_readable( $path ) ) {
echo file_get_contents( $path );
}
}, 5 );