ID, self::USER_META_JOB_TITLE, true ); $expertise = get_user_meta( $user->ID, self::USER_META_EXPERTISE, true ); $website = get_user_meta( $user->ID, self::USER_META_WEBSITE, true ); $same_as = get_user_meta( $user->ID, self::USER_META_SAME_AS, true ); ?>

'Person', 'name' => $user->display_name, 'url' => $author_url ); if ( ! empty( $job_title ) ) { $person['jobTitle'] = $job_title; } if ( ! empty( $expertise ) ) { $person['description'] = $expertise; } if ( ! empty( $same_as_urls ) ) { $person['sameAs'] = $same_as_urls; } return $person; } private function get_author_expert_data( $author_id ) { $person = $this->build_person_schema( $author_id ); return empty( $person ) ? array() : $person; } /* ===== Frontend-Ausgabe ===== */ public function output_person_schema_in_head() { if ( ! is_singular() ) { return; } global $post; if ( empty( $post ) || ! is_object( $post ) ) { return; } $o = $this->get_opts(); if ( ! in_array( $post->post_type, $o['enabled_post_types'], true ) ) { return; } if ( get_post_meta( $post->ID, self::META_NO_EMBED, true ) ) { return; } $person = $this->build_person_schema( $post->post_author ); if ( empty( $person ) ) { return; } $graph = array( '@context' => 'https://schema.org', '@graph' => array( $person, array( '@type' => 'Article', 'url' => get_permalink( $post ), 'headline' => wp_strip_all_tags( get_the_title( $post ) ), 'datePublished' => get_post_time( 'c', true, $post ), 'dateModified' => get_post_modified_time( 'c', true, $post ), 'author' => array( '@type' => 'Person', 'name' => $person['name'], 'url' => $person['url'] ), 'reviewedBy' => array( '@type' => 'Person', 'name' => $person['name'], 'url' => $person['url'], 'jobTitle' => $person['jobTitle'] ?? '' ), 'publisher' => array( '@type' => 'Organization', 'name' => get_bloginfo( 'name' ), 'url' => home_url() ), ), ), ); $flags = 0; if ( defined( 'JSON_UNESCAPED_UNICODE' ) ) { $flags |= JSON_UNESCAPED_UNICODE; } if ( defined( 'JSON_UNESCAPED_SLASHES' ) ) { $flags |= JSON_UNESCAPED_SLASHES; } if ( defined( 'JSON_PRETTY_PRINT' ) ) { $flags |= JSON_PRETTY_PRINT; } $json = function_exists( 'wp_json_encode' ) ? wp_json_encode( $graph, $flags ) : json_encode( $graph, $flags ); echo "\n\n"; echo '' . "\n"; } public function output_aije_meta_description() { if ( ! is_singular() ) { return; } global $post; if ( empty( $post ) ) { return; } $seo = $this->get_active_seo_plugin(); if ( $seo !== 'own' ) { return; } $seo_title = get_post_meta( $post->ID, '_aije_seo_title', true ); if ( ! empty( $seo_title ) ) { add_filter( 'pre_get_document_title', function() use ( $seo_title ) { return esc_html( $seo_title ); } ); } $meta = get_post_meta( $post->ID, '_aije_metadesc', true ); if ( ! empty( $meta ) ) { echo '' . "\n"; } $robots = get_post_meta( $post->ID, '_aije_robots', true ); if ( ! empty( $robots ) && $robots !== 'index,follow' ) { echo '' . "\n"; } $canonical = get_post_meta( $post->ID, '_aije_canonical', true ); if ( ! empty( $canonical ) ) { echo '' . "\n"; } } public function output_tracking_head() { $opts = $this->get_opts(); $gtm_id = trim( $opts['gtm_id'] ?? '' ); $ga4_id = trim( $opts['ga4_id'] ?? '' ); $gsc_verify = trim( $opts['gsc_verify'] ?? '' ); if ( $gsc_verify ) { $code = str_replace( 'google-site-verification=', '', $gsc_verify ); echo '' . "\n"; } if ( $gtm_id ) { echo "\n\n\n"; } if ( $ga4_id && ! $gtm_id ) { echo '' . "\n"; echo '' . "\n"; } $meta_pixel = trim( $opts['meta_pixel'] ?? '' ); if ( $meta_pixel ) { echo "\n"; echo '' . "\n"; echo '' . "\n"; echo "\n"; } } /* ===== Auto-Embed (JSON-Blob) ===== */ public function auto_embed() { if ( ! function_exists( 'is_singular' ) || ! is_singular() ) { return; } global $post; if ( empty( $post ) || ! is_object( $post ) ) { return; } $o = $this->get_opts(); if ( ! in_array( $post->post_type, $o['enabled_post_types'], true ) ) { return; } if ( get_post_meta( $post->ID, self::META_NO_EMBED, true ) ) { return; } $data = $this->extract_payload( $post ); $flags = 0; if ( defined( 'JSON_UNESCAPED_UNICODE' ) ) { $flags |= JSON_UNESCAPED_UNICODE; } if ( defined( 'JSON_UNESCAPED_SLASHES' ) ) { $flags |= JSON_UNESCAPED_SLASHES; } if ( empty( $o['minify'] ) && defined( 'JSON_PRETTY_PRINT' ) ) { $flags |= JSON_PRETTY_PRINT; } $json = function_exists( 'wp_json_encode' ) ? wp_json_encode( $data, $flags ) : json_encode( $data ); echo "\n\n"; echo '' . "\n"; if ( ! empty( $o['enable_schema'] ) ) { echo '' . "\n"; } echo "\n"; } private function extract_payload( $post ) { $o = $this->get_opts(); $u = get_userdata( $post->post_author ); $acf = array(); $content = apply_filters( 'the_content', $post->post_content ); $text = wp_strip_all_tags( $content ); $lines = preg_split( "/\r\n|\n|\r/", $text ); $paragraphs = array(); foreach ( $lines as $line ) { $line = trim( preg_replace( '/\s+/u', ' ', $line ) ); if ( $line !== '' ) { $paragraphs[] = $line; } } $links = array(); if ( preg_match_all( '/]+href=[\'\"]?([^\'\" >]+)[\'\"]?[^>]*>(.*?)<\/a>/i', $content, $m, PREG_SET_ORDER ) ) { foreach ( $m as $a ) { $href = trim( $a[1] ); $txt = trim( wp_strip_all_tags( $a[2] ) ); if ( $href !== '' ) { $links[] = array( 'text' => $txt, 'href' => $href ); } } } if ( ! empty( $o['acf_include'] ) && function_exists( 'get_fields' ) ) { $acf_fields = get_fields( $post->ID ); if ( is_array( $acf_fields ) && ! empty( $acf_fields ) ) { $acf = $acf_fields; } } $data = array( 'title' => get_the_title( $post ), 'author' => $u ? $u->display_name : null, 'date' => get_post_time( 'Y-m-d', true, $post ), 'paragraphs' => $paragraphs, 'links' => $links, 'meta' => array( 'post_id' => (int) $post->ID, 'site' => get_bloginfo( 'name' ), 'url' => get_permalink( $post ), 'lang' => get_bloginfo( 'language' ) ), ); $expert = $this->get_author_expert_data( $post->post_author ); if ( ! empty( $expert ) ) { $data['author_expert'] = $expert; } if ( ! empty( $acf ) ) { $data['acf'] = $acf; } return $data; } private function schema_article( $post ) { $obj = array( '@context' => 'https://schema.org', '@type' => 'Article', 'url' => get_permalink( $post ), 'headline' => wp_strip_all_tags( get_the_title( $post ) ), 'publisher' => array( '@type' => 'Organization', 'name' => get_bloginfo( 'name' ) ), ); $u = get_userdata( $post->post_author ); if ( $u && $u->display_name ) { $obj['author'] = array( '@type' => 'Person', 'name' => $u->display_name ); } $flags = 0; if ( defined( 'JSON_UNESCAPED_UNICODE' ) ) { $flags |= JSON_UNESCAPED_UNICODE; } if ( defined( 'JSON_UNESCAPED_SLASHES' ) ) { $flags |= JSON_UNESCAPED_SLASHES; } return function_exists( 'wp_json_encode' ) ? wp_json_encode( $obj, $flags ) : json_encode( $obj ); } /* ===== llms.txt ===== */ public function register_llms_rewrite() { add_rewrite_rule( '^llms\.txt$', 'index.php?aije_llms=1', 'top' ); add_rewrite_tag( '%aije_llms%', '([0-9]+)' ); } public function serve_llms_txt() { if ( ! get_query_var( 'aije_llms' ) ) { return; } if ( ! get_option( 'aije_llms_enabled', 1 ) ) { return; } nocache_headers(); header( 'Content-Type: text/plain; charset=utf-8' ); echo $this->generate_llms_content(); exit; } public function append_llms_to_robots( $output, $public ) { if ( get_option( 'aije_llms_block_bots', 0 ) ) { foreach ( array( 'GPTBot', 'CCBot', 'anthropic-ai', 'Claude-Web', 'Bytespider', 'FacebookBot', 'Applebot-Extended' ) as $bot ) { $output .= "\nUser-agent: " . $bot . "\nDisallow: /\n"; } } if ( get_option( 'aije_llms_enabled', 1 ) ) { $output .= "\n# LLMs\nLLMs: " . home_url( '/llms.txt' ) . "\n"; } return $output; } public function generate_llms_content() { $o = $this->get_opts(); $custom = get_option( 'aije_llms_custom', '' ); $lines = array(); $lines[] = '# ' . get_bloginfo( 'name' ); $desc = get_bloginfo( 'description' ); if ( $desc ) { $lines[] = '> ' . $desc; } $lines[] = ''; $lines[] = '## Website'; $lines[] = '- URL: ' . home_url(); $lines[] = '- Sprache: ' . get_bloginfo( 'language' ); $lines[] = ''; $admins = get_users( array( 'role' => 'administrator', 'number' => 1 ) ); if ( $admins ) { $admin = $admins[0]; $job = get_user_meta( $admin->ID, self::USER_META_JOB_TITLE, true ); $bio = get_user_meta( $admin->ID, self::USER_META_EXPERTISE, true ); $same_as = get_user_meta( $admin->ID, self::USER_META_SAME_AS, true ); $lines[] = '## Autor'; $lines[] = '- Name: ' . $admin->display_name; if ( $job ) { $lines[] = '- Expertise: ' . $job; } if ( $bio ) { $lines[] = '- Biografie: ' . wp_trim_words( $bio, 25 ); } if ( $same_as ) { foreach ( preg_split( "/\r\n|\n|\r/", $same_as ) as $link ) { $link = trim( $link ); if ( $link && substr( $link, 0, 1 ) !== '#' ) { $lines[] = '- Profil: ' . $link; } } } $lines[] = ''; } $posts = get_posts( array( 'post_type' => $o['enabled_post_types'], 'posts_per_page' => 10, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC' ) ); if ( $posts ) { $lines[] = '## Aktuelle Inhalte'; foreach ( $posts as $p ) { $lines[] = '- [' . get_the_title( $p ) . '](' . get_permalink( $p ) . ')'; } $lines[] = ''; } $lines[] = '## Nutzungshinweise'; $lines[] = '- Zitate mit Quellenangabe erlaubt'; $lines[] = '- Kommerzielle Nutzung ohne Genehmigung nicht gestattet'; $lines[] = '- Generiert mit WP Rankify (https://wprankify.de)'; if ( $custom ) { $lines[] = ''; $lines[] = $custom; } return implode( "\n", $lines ); } }