features = $features; } public function register(): void { // Both filters only ever run inside feed requests. add_filter( 'the_content_feed', array( $this, 'append_backlink' ) ); add_filter( 'the_excerpt_rss', array( $this, 'append_backlink' ) ); } public function append_backlink( string $content ): string { if ( ! $this->features->enabled( 'rss_backlink' ) ) { return $content; } $post = get_post(); if ( ! $post instanceof \WP_Post ) { return $content; } $sentence = sprintf( /* translators: 1: post permalink, 2: post title, 3: home URL, 4: site name */ __( 'The post %2$s first appeared on %4$s.', 'acez-seo' ), esc_url( (string) get_permalink( $post ) ), esc_html( get_the_title( $post ) ), esc_url( home_url( '/' ) ), esc_html( get_bloginfo( 'name' ) ) ); return $content . "\n" . '

' . $sentence . '

'; } }