Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Looking for sites at the Pro Level
- */
- class proshortcode {
- var $build = 1;
- var $db;
- function __construct() {
- global $wpdb;
- $this->db =& $wpdb;
- if($this->db->blogid == 1) {
- // Only add the feed for the main site
- add_action('init', array(&$this, 'initialise_proshortcode') );
- }
- add_shortcode( 'pro-posts', array( &$this, 'list_pro_posts_shortcode') );
- }
- function proshortcode() {
- $this->__construct();
- }
- function initialise_proshortcode() {
- // In case we need it in future :)
- }
- function list_pro_posts($tmp_number,$tmp_title_characters = 0,$tmp_content_characters = 0,
- $tmp_title_content_divider = '<br />',$tmp_title_before,$tmp_title_after,$tmp_global_before,
- $tmp_global_after,$tmp_before,$tmp_after,$tmp_title_link = 'no',$tmp_show_avatars = 'yes',
- $tmp_avatar_size = 16, $posttype = 'post', $output = true) {
- global $network_query, $network_post, $wpdb;
- /*
- http://www.smashingmagazine.com/2013/01/14/using-wp_query-wordpress/
- $args = array('cat' => 4);
- $category_posts = new WP_Query($args);
- */
- // http://premium.wpmudev.org/forums/topic/restricting-specific-page-templates-within-prosites#post-652329
- $network_query = network_query_posts( array( 'post_type' => $posttype, 'posts_per_page' => $tmp_number ));
- $html = '';
- global $wpdb;
- $blog_id = $wpdb->blogid;
- $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
- $level = $wpdb->get_var( $sql );
- $pro = "SELECT blog_ID FROM {$wpdb->base_prefix}pro_sites WHERE 'level' = 1 ";
- $html .= $tmp_global_before;
- while( network_have_posts( $pro ) ) {
- network_the_post();
- switch_to_blog( $network_post->BLOG_ID );
- //Get network blog post featured image
- $n_post = network_get_post();
- // }
- $featured_image = get_the_post_thumbnail( $n_post->ID, 'large' );
- //Network blog name
- $blogname = get_blog_option( $network_post->BLOG_ID, 'blogname' );
- restore_current_blog();
- $html .= $tmp_before;
- $html .= $tmp_title_before . '<a href="' . network_get_permalink() . '" class="no-crop">';
- $the_title = network_get_the_title();
- $html .= '<div id="npost-meta"><div class="blog-name">' . $blogname . '</div> <hr> <div id="net-post-title">' . substr($the_title,0,$tmp_title_characters) . '</div></div>';
- $html .= $tmp_after;
- }
- if($output) {
- echo $html;
- } else {
- return $html;
- }
- }
- function list_pro_posts_shortcode($atts, $content = null, $code = "") {
- $defaults = array( 'number' => 25,
- 'title_characters' => 25,
- 'content_characters' => 30,
- 'title_content_divider' => '<br />',
- 'title_before' => '<div>',
- 'title_after' => '</div>',
- 'global_before' => '<ul>',
- 'global_after' => '</ul>',
- 'before' => '<li class="crop-square">',
- 'after' => '</a></li>',
- 'title_link' => 'yes',
- 'show_avatars' => 'no',
- 'show_images' => 'yes',
- 'avatar_size' => 16,
- 'posttype' => 'post'
- );
- extract(shortcode_atts($defaults, $atts));
- $html = '';
- $html .= $this->list_pro_posts( $number, $title_characters, $content_characters, $title_content_divider, $title_before, $title_after, $global_before, $global_after, $before, $after, $title_link, $show_avatars, $avatar_size, $posttype, false);
- return $html;
- }
- }
- function list_pro_posts($tmp_number,$tmp_title_characters = 0,$tmp_content_characters = 0,$tmp_title_content_divider = '<br />',$tmp_title_before,$tmp_title_after,$tmp_global_before,$tmp_global_after,$tmp_before,$tmp_after,$tmp_title_link = 'no',$tmp_show_avatars = 'yes', $tmp_avatar_size = 16, $posttype = 'post', $output = true) {
- global $proshortcode;
- $proshortcode->list_pro_posts( $tmp_number, $tmp_title_characters, $tmp_content_characters, $tmp_title_content_divider, $tmp_title_before, $tmp_title_after, $tmp_global_before, $tmp_global_after, $tmp_before, $tmp_after, $tmp_title_link, $tmp_show_avatars, $tmp_avatar_size, $posttype, $output );
- }
- $proshortcode = new proshortcode();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement