'; } // ── Widget ──────────────────────────────────────────────────────────────────── class AdWol_Banner_Widget extends WP_Widget { public function __construct() { parent::__construct( 'adwol_banner_widget', __( 'AdWol Banner', 'adwol-werbung' ), [ 'description' => __( 'Responsives AdWol-Werbebanner (automatische Größenanpassung).', 'adwol-werbung' ) ] ); } public function widget( $args, $instance ): void { $tag = adwol_embed_tag( 'r' ); if ( ! $tag ) return; echo wp_kses( $args['before_widget'] ?? '', [ 'div' => [ 'class' => true, 'id' => true ] ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $tag; echo wp_kses( $args['after_widget'] ?? '', [ 'div' => [] ] ); } } add_action( 'widgets_init', function() { register_widget( 'AdWol_Banner_Widget' ); } ); // ── In-post ad injection ────────────────────────────────────────────────────── function adwol_inject_inpost( string $content ): string { if ( ! is_single() || strlen( $content ) < 500 ) return $content; $tag = adwol_embed_tag( 'r' ); if ( ! $tag ) return $content; $before = substr( $content, 0, 500 ); $after = substr( $content, 500 ); $parts = explode( '
', $after, 2 ); if ( count( $parts ) < 2 ) return $content; return $before . $parts[0] . '' . $tag . $parts[1]; } if ( get_option( 'adwol_inpost_enabled', '1' ) === '1' ) { add_filter( 'the_content', 'adwol_inject_inpost' ); } // ── Related posts with ad ───────────────────────────────────────────────────── function adwol_related_posts( string $content ): string { if ( ! is_single() ) return $content; global $post, $adwol_related_cache; if ( isset( $adwol_related_cache ) ) { return $content . $adwol_related_cache; } $pid = $post->ID; $title = get_the_title(); $tags = wp_get_post_tags( $pid ); $tag_names = ''; $query_args = [ 'post__not_in' => [ $pid ], 'post_type' => 'post', 'posts_per_page' => 3, 'ignore_sticky_posts'=> 1, ]; if ( $tags ) { $tag_ids = wp_list_pluck( $tags, 'term_id' ); $tag_names = implode( ',', wp_list_pluck( $tags, 'name' ) ); $query_args['tag__in'] = $tag_ids; } else { $cats = get_the_category( $pid ); if ( $cats ) $query_args['cat'] = $cats[0]->cat_ID; } $rel_query = new WP_Query( $query_args ); if ( ! $rel_query->have_posts() ) { wp_reset_postdata(); return $content; } $html = '
'
. '| '
. ' | '
. ''
. '' . $post_title . ''
. ' ' . $excerpt . ' ' . ' | '
. '
AdWol WerbungAdWol v= ADWOL_VERSION ?> · FAQ · Kontakt · Wir schließen Gewährleistung und Haftung aus. Nutzung auf eigene Gefahr.