Making WordPress.org

Ticket #7437: 7437.diff

File 7437.diff, 2.8 KB (added by dufresnesteven, 16 months ago)

Adds the theme screenshot to the theme forums.

  • class-theme-directory-compat.php

    class Theme_Directory_Compat extends Dir 
    114114
    115115                return true;
    116116        }
    117117
    118118        public function do_view_sidebar() {
    119119
    120120                $this->do_topic_sidebar();
    121121
    122122        }
    123123
    124124        public function do_topic_sidebar() {
    125125                if ( ! $this->theme ) {
    126126                        return;
    127127                }
    128128
     129                $icon       = '';
    129130                $theme      = sprintf( '<a href="//wordpress.org/themes/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) );
    130131                $support    = sprintf( '<a href="%s">%s</a>', home_url( '/theme/' . esc_attr( $this->slug() ) . '/' ), __( 'Support Threads', 'wporg-forums' ) );
    131132                $active     = sprintf( '<a href="%s">%s</a>', home_url( '/theme/' . esc_attr( $this->slug() ) . '/active/' ), __( 'Active Topics', 'wporg-forums' ) );
    132133                $unresolved = sprintf( '<a href="%s">%s</a>', home_url( '/theme/' . esc_attr( $this->slug() ) . '/unresolved/' ), __( 'Unresolved Topics', 'wporg-forums' ) );
    133134                $reviews    = sprintf( '<a href="%s">%s</a>', home_url( '/theme/' . esc_attr( $this->slug() ) . '/reviews/' ), __( 'Reviews', 'wporg-forums' ) );
    134135                $create     = '';
    135136
    136137                $create_label = '';
    137138                if ( isset( $this->ratings ) && $this->ratings->is_rating_view() && bbp_current_user_can_access_create_topic_form() ) {
    138139                        $create_label = $this->ratings->review_exists() ?
    139140                                __( 'Edit Review', 'wporg-forums' ) :
    140141                                __( 'Add Review', 'wporg-forums' );
    141142                } elseif ( bbp_is_single_forum() && bbp_current_user_can_access_create_topic_form() ) {
    142143                        $create_label = __( 'Create Topic', 'wporg-forums' );
    143144                }
    144145                if ( $create_label ) {
    145146                        $create = sprintf( '<a href="#new-post">%s</a>', $create_label );
    146147                }
     148
     149                if ( file_exists( WPORGPATH . 'wp-content/plugins/theme-directory/class-wporg-themes-repo-package.php' ) ) {
     150                        include_once WPORGPATH . 'wp-content/plugins/theme-directory/class-wporg-themes-repo-package.php';
     151               
     152                        if ( class_exists( 'WPORG_Themes_Repo_Package' ) ) {
     153                                switch_to_blog( WPORG_THEME_DIRECTORY_BLOGID );
     154                                $repo_package = new \WPORG_Themes_Repo_Package( $this->theme->ID );
     155                                $icon = $repo_package->screenshot_url();
     156                                restore_current_blog();
     157                        }
     158                }
     159
    147160                ?>
    148161                <div>
    149162                        <ul>
     163                                <?php if ( ! empty( $icon ) ) : ?>
     164                                        <li class="theme-meta-icon"><img src="<?php echo esc_url( $icon ); ?>"></li>
     165                                <?php endif; ?>
    150166                                <li><?php echo $theme; ?></li>
    151167                                <li><?php echo $support; ?></li>
    152168                                <li><?php echo $active; ?></li>
    153169                                <li><?php echo $unresolved; ?></li>
    154170                                <li><?php echo $reviews; ?></li>
    155171                                <?php if ( $create ) : ?>
    156172                                <li class="create-topic"><?php echo $create; ?></li>
    157173                                <?php endif; ?>
    158174                        </ul>
    159175                </div>
    160176                <?php
    161177        }
    162178
    163179        public function do_view_header() {
    164180        }