Changeset 3892 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-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-plugin-directory-compat.php
r3846 r3892 7 7 const COMPAT = 'plugin'; 8 8 9 var $slug = '';10 var $plugin = '';9 var $slug = false; 10 var $plugin = null; 11 11 12 12 function compat() { 13 13 return self::COMPAT; 14 } 15 16 function compat_title() { 17 return __( 'Plugin 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 $plugin = $this->get_ plugin_data( $slug );53 $plugin = $this->get_object( $slug ); 57 54 if ( ! $plugin ) { 58 55 return; 59 56 } else { 60 $this->slug = $slug; 61 $this->plugin = $plugin; 57 $this->slug = $slug; 58 $this->plugin = $plugin; 59 $this->authors = $this->get_authors( $slug ); 60 $this->contributors = $this->get_contributors( $slug ); 62 61 } 63 64 // Add plugin support view.65 bbp_register_view(66 self::COMPAT,67 __( 'Plugin Support', 'wporg-forums' ),68 array(69 'post_parent' => Plugin::PLUGINS_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 plugin 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_plugin_data( $slug = '' ) { 98 global $wpdb; 64 public function do_view_sidebar() { 65 ?> 66 <div> 67 <h3><?php _e( 'Browse Plugins', 'wporg-forums' ); ?></h3> 99 68 100 if ( ! empty( $this->plugin ) ) { 101 return $this->plugin; 102 } 69 <ul class="plugin-submenu"> 70 <li class="view"><a href='//wordpress.org/plugins/'><?php _e( 'Featured', 'wporg' ); ?></a></li> 71 <li class="view"><a href='//wordpress.org/plugins/browse/popular/'><?php _e( 'Most Popular', 'wporg' ); ?></a></li> 72 <li class="view"><a href='//wordpress.org/plugins/browse/favorites/'><?php _e( 'Favorites', 'wporg' ); ?></a></li> 73 <li class="view"><a href='//wordpress.org/plugins/browse/beta/'><?php _e( 'Beta Testing', 'wporg' ); ?></a></li> 74 <li class="view"><a href='/plugins/about/'><?php _e( 'Developers', 'wporg' ); ?></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 = 'plugin' LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $slug ); 105 $row = $wpdb->get_row( $sql ); 106 if ( ! $row ) { 107 return false; 108 } else { 109 $plugin = $row; 110 $sql = $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_postmeta WHERE post_id = %d AND meta_key NOT LIKE %s", WPORG_PLUGIN_DIRECTORY_BLOGID, $row->ID, '_trac_ticket_%' ); 111 $results = $wpdb->get_results( $sql ); 112 if( $results ) { 113 foreach ( $results as $row ) { 114 if ( ! isset( $plugin->{$row->meta_key} ) ) { 115 $plugin->{$row->meta_key} = maybe_unserialize( $row->meta_value ); 116 } 117 } 118 } 119 } 120 return $plugin; 78 <div> 79 <h3><?php _e( 'Search Plugins', 'wporg-forums' ); ?></h3> 80 81 <form id="side-search" method="get" action="//wordpress.org/plugins/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 include_once WPORGPATH . 'extend/plugins-plugins/_plugin-icons.php'; 93 $plugin = sprintf( '<a href="//wordpress.org/plugins/%s/">%s</a>', esc_attr( $this->slug() ), esc_html( $this->plugin->post_title ) ); 94 $faq = sprintf( '<a href="//wordpress.org/plugins/%s/faq/">Frequently Asked Questions</a>', esc_attr( $this->slug() ) ); 95 $support = sprintf( '<a href="//wordpress.org/support/plugin/%s/">Support Threads</a>', esc_attr( $this->slug() ) ); 96 $reviews = sprintf( '<a href="//wordpress.org/support/plugin/%s/reviews/">Reviews</a>', esc_attr( $this->slug() ) ); 97 ?> 98 <div> 99 <h3>About this Plugin</h3> 100 <ul> 101 <li><?php echo wporg_get_plugin_icon( $this->slug, 128 ); ?></li> 102 <li style="clear:both;"><?php echo $plugin; ?></li> 103 <?php if ( ! empty( $this->plugin->post_content ) && false !== strpos( $this->plugin->post_content, '<!--section=faq-->' ) ) : ?> 104 <li><?php echo $faq; ?></li> 105 <?php endif; ?> 106 <li><?php echo $support; ?></li> 107 <li><?php echo $reviews; ?></li> 108 </ul> 109 </div> 110 <?php 111 } 112 113 /** 114 * Return a custom view header string so that get_breadcrumbs will display it. 115 */ 116 public function get_view_header() { 117 $slug = esc_attr( $this->slug ); 118 $description = esc_html__( 'Description', 'wporg-forums' ); 119 $support = esc_html__( 'Support', 'wporg-forums' ); 120 $reviews = esc_html__( 'Reviews', 'wporg-forums' ); 121 122 $header = <<<EOT 123 <ul id="sections"> 124 <li class="section-description"> 125 <a href="//wordpress.org/plugins/{$slug}/">{$description}</a> 126 </li> 127 <li class="section-support"> 128 <a href="//wordpress.org/support/plugin/{$slug}/">{$support}</a> 129 <li> 130 <li class="section-reviews"> 131 <a href="//wordpress.org/support/plugin/{$slug}/reviews/">{$reviews}</a> 132 </li> 133 </ul> 134 EOT; 135 return $header; 121 136 } 122 137 }
Note: See TracChangeset
for help on using the changeset viewer.