Making WordPress.org

Changeset 5404


Ignore:
Timestamp:
04/21/2017 11:46:46 AM (8 years ago)
Author:
Otto42
Message:

Plugin Directory: Add function for linking to the support forum for a plugin. See #2767. props @SergeyBiryukov

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r5241 r5404  
    401401
    402402    /**
     403     * Returns the URL to the plugin support forum.
     404     *
     405     * @static
     406     *
     407     * @param int|\WP_Post|null $post  Optional. Post ID or post object. Defaults to global $post.
     408     * @return string
     409     */
     410    public static function get_support_url( $post = null ) {
     411        $post = get_post( $post );
     412
     413        /*
     414        * bbPress and BuddyPress get special treatment here.
     415        * In the future we could open this up to all plugins that define a custom support URL.
     416        */
     417        if ( 'buddypress' === $post->post_name ) {
     418            $url = 'https://buddypress.org/support/';
     419        } elseif ( 'bbpress' === $post->post_name ) {
     420            $url = 'https://bbpress.org/forums/';
     421        } else {
     422            $url = 'https://wordpress.org/support/plugin/' . $post->post_name;
     423        }
     424
     425        return $url;
     426    }
     427
     428    /**
    403429     * A helper method to create dashicon stars.
    404430     *
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-support.php

    r4223 r5404  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Widgets;
     3use WordPressdotorg\Plugin_Directory\Template;
    34
    45/**
     
    3233        $resolved    = get_post_meta( $post->ID, 'support_threads_resolved', true ) ?: 0;
    3334        $resolutions = (bool) $threads;
    34         $support_url = 'https://wordpress.org/support/plugin/' . $post->post_name;
     35        $support_url = Template::get_support_url();
    3536
    36         /*
    37          * bbPress and BuddyPress get special treatment here.
    38          * In the future we could open this up to all plugins that define a custom support URL.
    39          */
    40         if ( 'buddypress' === $post->post_name ) {
     37        if ( false === strpos( $support_url, 'https://wordpress.org' ) ) {
    4138            $resolutions = false;
    42             $support_url = 'https://buddypress.org/support/';
    43         } else if ( 'bbpress' === $post->post_name ) {
    44             $resolutions = false;
    45             $support_url = 'https://bbpress.org/forums/';
    46         }
     39        }
    4740
    4841        echo $args['before_widget'];
     
    5851                <span class="counter-count">
    5952                    <?php
    60                     /* Translators: 1: AMount of resolved threads; 2: Amount of total threads; */
     53                    /* Translators: 1: Amount of resolved threads; 2: Amount of total threads; */
    6154                    printf( __( '%1$s out of %2$s', 'wporg-plugins' ), $resolved, $threads );
    6255                    ?>
Note: See TracChangeset for help on using the changeset viewer.