Making WordPress.org

Ticket #2627: closed-plugins-template.patch

File closed-plugins-template.patch, 6.1 KB (added by joostdevalk, 7 years ago)

Fixes the plugin template for closed and disabled plugins

  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
    index d7ada14e..d5520828 100644
    $content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_ 
    1717$status  = get_post_status();
    1818
    1919?><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    20         <?php echo Template::get_plugin_banner( get_post(), 'html' ); ?>
     20    <?php
     21    // Don't show the plugin banner for closed plugins
     22    if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) {
     23            echo Template::get_plugin_banner( get_post(), 'html' );
     24    }
     25    ?>
    2126
    2227        <header class="plugin-header">
    2328                <?php if ( time() - get_post_modified_time() > 2 * YEAR_IN_SECONDS ) : ?>
    2429                        <div class="plugin-notice notice notice-warning notice-alt">
    2530                                <p><?php _e( 'This plugin <strong>hasn&#146;t been updated in over 2 years</strong>. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' ); ?></p>
    26                         </div><!-- .plugin-notice -->
     31                        </div>
    2732                <?php endif; ?>
    2833                <?php if ( 'publish' !== $status ) :
    2934                                $notice_type = 'notice-error';
    $status = get_post_status(); 
    6570                                        $message .= sprintf( __( 'This plugin was closed on %s.', 'wporg-plugins' ), mysql2date( get_option( 'date_format' ), $closed_date ) );
    6671                                }
    6772            }
     73
     74                if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) {
     75                                    // the notice for closed and disabled is shown below the Description header, because we don't output the readme there
    6876                        ?>
     77            <!-- .plugin-notice -->
    6978                        <div class="plugin-notice notice <?php echo esc_attr( $notice_type ); ?> notice-alt">
    7079                                <p><?php echo $message; ?></p>
    71                         </div><!-- .plugin-notice -->
    72 
    73                         <?php if ( in_array( $status, array( 'closed', 'disabled' ) ) && get_current_user_id() == get_post()->post_author ) : ?>
    74                                 <div class="plugin-notice notice notice-info notice-alt">
    75                                         <p><?php
    76                                                 printf(
    77                                                         /* translators: 1: plugins@wordpress.org */
    78                                                         __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),
    79                                                         'plugins@wordpress.org'
    80                                                 );
    81                                         ?></p>
    82                                 </div><!-- .plugin-notice -->
    83                         <?php endif; ?>
     80                        </div>
     81            <!-- .plugin-notice -->
     82        <?php } ?>
    8483                <?php endif; ?>
    8584
    8685                <div class="entry-thumbnail">
    87                         <?php echo Template::get_plugin_icon( get_post(), 'html' ); ?>
     86            <?php
     87            // Don't show the icon for closed plugins
     88            if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) {
     89                            echo Template::get_plugin_icon( get_post(), 'html' );
     90            }
     91            ?>
    8892                </div>
    8993
    9094                <div class="plugin-actions">
    $status = get_post_status(); 
    168172                                        continue;
    169173                                }
    170174
     175                                if ( 'description' === $section_slug && in_array( $status, array( 'closed', 'disabled' ) ) ) {
     176                                // Don't show the description for closed plugins
     177                                        $section_content = '<div class="plugin-notice notice notice-error notice-alt"><p>' . $message . '</p></div>';
     178                            if ( get_current_user_id() == get_post()->post_author ) {
     179                                    $section_content .= '<div class="plugin-notice notice notice-info notice-alt"><p>' .
     180                                                        sprintf(
     181                                                        /* translators: 1: plugins@wordpress.org */
     182                                                                __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),
     183                                                                'plugins@wordpress.org'
     184                                                        ) . '</p></div><!-- .plugin-notice -->';
     185                            }
     186                                } else {
     187                                        $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) );
     188                                }
     189
    171190                                $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) );
    172191                                if ( empty( $section_content ) ) {
    173192                                        continue;
  • wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php

    diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php
    index b3e28f44..3943927e 100644
    use WordPressdotorg\Plugin_Directory\Template; 
    1313?>
    1414
    1515<div id="admin" class="section">
     16    <?php
     17    $status  = get_post_status();
     18    if ( in_array( $status, array( 'closed', 'disabled' ) ) ) {
     19            echo '<div class="plugin-notice notice notice-error notice-alt"><p>' . __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ); . '</p></div>';
     20            if ( get_current_user_id() == get_post()->post_author ) {
     21                    echo '<div class="plugin-notice notice notice-info notice-alt"><p>' .
     22                                        sprintf(
     23                                        /* translators: 1: plugins@wordpress.org */
     24                                                __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),
     25                                                'plugins@wordpress.org'
     26                                        ) . '</p></div><!-- .plugin-notice -->';
     27            }
     28    }
     29
     30    ?>
    1631        <h2><?php _e( 'Plugin Stats', 'wporg-plugins' ); ?></h2>
    1732
    1833        <h4><?php _e( 'Active versions', 'wporg-plugins' ); ?></h4>