Changeset 3892 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
- Timestamp:
- 08/31/2016 04:58:29 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
r3846 r3892 7 7 const COMPAT = 'theme'; 8 8 9 var $slug = '';10 var $theme = '';9 var $slug = false; 10 var $theme = null; 11 11 12 12 function compat() { 13 13 return self::COMPAT; 14 } 15 16 function compat_title() { 17 return __( 'Theme Support', 'wporg-forums' ); 14 18 } 15 19 … … 35 39 36 40 public function __construct() { 37 if ( defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) && get_current_blog_id() == WPORG_SUPPORT_FORUMS_BLOGID ) { 38 // We have to add the custom view before bbPress runs its own action 39 // on parse_query at priority 2. 40 add_action( 'parse_query', array( $this, 'parse_query' ), 1 ); 41 42 // Add parent class hooks. 43 add_action( 'plugins_loaded', array( $this, 'init' ) ); 44 } 41 $this->init(); 45 42 } 46 43 … … 54 51 } 55 52 56 $theme = $this->get_ theme_data( $slug );53 $theme = $this->get_object( $slug ); 57 54 if ( ! $theme ) { 58 55 return; 59 56 } else { 60 $this->slug = $slug; 61 $this->theme = $theme; 57 $this->slug = $slug; 58 $this->theme = $theme; 59 $this->authors = $this->get_authors( $slug ); 60 $this->contributors = $this->get_contributors( $slug ); 62 61 } 63 64 // Add theme support view.65 bbp_register_view(66 self::COMPAT,67 __( 'Theme Support', 'wporg-forums' ),68 array(69 'post_parent' => Plugin::THEMES_FORUM_ID,70 'tax_query' => array( array(71 'taxonomy' => $this->taxonomy(),72 'field' => 'slug',73 'terms' => $slug,74 ) ),75 'orderby' => '',76 'show_stickies' => false,77 )78 );79 80 // Add theme review view.81 bbp_register_view(82 'reviews',83 __( 'Reviews', 'wporg-forums' ),84 array(85 'post_parent' => Plugin::REVIEWS_FORUM_ID,86 'tax_query' => array( array(87 'taxonomy' => $this->taxonomy(),88 'field' => 'slug',89 'terms' => $slug,90 ) ),91 'orderby' => '',92 'show_stickies' => false,93 )94 );95 62 } 96 63 97 public function get_theme_data( $slug = '' ) { 98 global $wpdb; 64 public function do_view_sidebar() { 65 ?> 66 <div> 67 <h3><?php _e( 'Browse Themes', 'wporg-forums' ); ?></h3> 99 68 100 if ( ! empty( $this->theme ) ) { 101 return $this->theme; 102 } 69 <ul class="theme-submenu"> 70 <li class="view"><a href="//wordpress.org/themes/"><?php _e( 'Featured', 'wporg-forums' ); ?></a></li> 71 <li class="view"><a href="//wordpress.org/themes/browse/popular/"><?php _e( 'Most Popular', 'wporg-forums' ); ?></a></li> 72 <li class="view"><a href="//wordpress.org/themes/browse/new/"><?php _e( 'Latest', 'wporg-forums' ); ?></a></li> 73 <li class="view"><a href="/themes/getting-started/"><?php _e( 'Theme Authors', 'wporg-forums' ); ?></a></li> 74 <li class="view"><a href="/themes/commercial/"><?php _e( 'Commercial', 'wporg-forums' ); ?></a></li> 75 </ul> 76 </div> 103 77 104 $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'repopackage' LIMIT 1", WPORG_THEME_DIRECTORY_BLOGID, $slug ); 105 $row = $wpdb->get_row( $sql ); 106 if ( ! $row ) { 107 return false; 108 } else { 109 $theme = $row; 110 $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_postmeta WHERE post_id = %d AND meta_key NOT LIKE %s", WPORG_THEME_DIRECTORY_BLOGID, $row->ID, '_trac_ticket_%' ); 111 $results = $wpdb->get_results( $sql ); 112 if( $results ) { 113 foreach ( $results as $row ) { 114 if ( ! isset( $theme->{$row->meta_key} ) ) { 115 $theme->{$row->meta_key} = maybe_unserialize( $row->meta_value ); 116 } 117 } 118 } 119 } 120 return $theme; 78 <div> 79 <h3><?php _e( 'Search Themes', 'wporg-forums' ); ?></h3> 80 81 <form id="side-search" method="get" action="//wordpress.org/themes/search.php"> 82 <div> 83 <input type="text" class="text" name="q" value="" /> 84 <input type="submit" class="button" value="<?php _e( 'Search', 'wporg-forums' ); ?>" /> 85 </div> 86 </form> 87 </div> 88 <?php 89 } 90 91 public function do_topic_sidebar() { 92 $theme = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->theme->post_title ) ); 93 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">Support Threads</a>', esc_attr( $this->slug() ) ); 94 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">Reviews</a>', esc_attr( $this->slug() ) ); 95 ?> 96 <div> 97 <h3>About this Theme</h3> 98 <ul> 99 <li><?php echo $theme; ?></li> 100 <li><?php echo $support; ?></li> 101 <li><?php echo $reviews; ?></li> 102 </ul> 103 </div> 104 <?php 105 } 106 107 108 /** 109 * Return a custom view header string so that get_breadcrumbs will display it. 110 */ 111 public function get_view_header() { 112 $slug = esc_attr( $this->slug ); 113 $description = esc_html__( 'Description', 'wporg-forums' ); 114 $support = esc_html__( 'Support', 'wporg-forums' ); 115 $reviews = esc_html__( 'Reviews', 'wporg-forums' ); 116 117 $header = <<<EOT 118 <ul id="sections"> 119 <li class="section-description"> 120 <a href="//wordpress.org/themes/{$slug}/">{$description}</a> 121 </li> 122 <li class="section-support"> 123 <a href="//wordpress.org/support/theme/{$slug}/">{$support}</a> 124 <li> 125 <li class="section-reviews"> 126 <a href="//wordpress.org/support/theme/{$slug}/reviews/">{$reviews}</a> 127 </li> 128 </ul> 129 EOT; 130 return $header; 121 131 } 122 132 }
Note: See TracChangeset
for help on using the changeset viewer.