Making WordPress.org


Ignore:
Timestamp:
07/24/2024 09:18:02 PM (17 months ago)
Author:
coffee2code
Message:

Support Forums: Add links to RSS feeds for plugin/theme support topics and reviews to page head.

Props SergeyBiryukov, coffee2code.
Fixes #1999.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r13825 r13918  
    3535            // Intercept feed requests prior to bbp_request_feed_trap at 10, before Performance::bbp_request_disable_missing_view_feeds at 9
    3636            add_filter( 'bbp_request', array( $this, 'request' ), 5 );
     37
     38            // Add feed links to head.
     39            add_action( 'wp_head', array( $this, 'meta_link_to_feeds' ) );
    3740
    3841            // Add plugin or theme name to view feed titles.
     
    362365    }
    363366
     367    /**
     368     * Outputs `link` tags in the page head for the support and reviews feeds.
     369     */
     370    public function meta_link_to_feeds() {
     371        if ( ! $this->slug() ) {
     372            return;
     373        }
     374
     375        echo "\n";
     376
     377        $title_support_feed = 'theme' === $this->compat()
     378            ? __( 'Theme Support Feed', 'wporg-forums' )
     379            : __( 'Plugin Support Feed', 'wporg-forums' );
     380        printf(
     381            '<link rel="alternate" type="application/rss+xml" title="%s" href="%s" />' . "\n",
     382            esc_attr( $title_support_feed ),
     383            esc_url( home_url( sprintf( '/%s/%s/feed/', $this->compat(), $this->slug() ) ) )
     384        );
     385
     386        $title_reviews_feed = 'theme' === $this->compat()
     387            ? __( 'Theme Reviews Feed', 'wporg-forums' )
     388            : __( 'Plugin Reviews Feed', 'wporg-forums' );
     389        printf(
     390            '<link rel="alternate" type="application/rss+xml" title="%s" href="%s" />' . "\n",
     391            esc_attr( $title_reviews_feed ),
     392            esc_url( home_url( sprintf( '/%s/%s/reviews/feed/', $this->compat(), $this->slug() ) ) )
     393        );
     394    }
     395
    364396    public function check_topic_for_compat() {
    365397        if ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && false == $this->loaded ) {
Note: See TracChangeset for help on using the changeset viewer.