} else { ?> <?php echo $glocal_home_settings['updates']['updates_heading']; ?> <?php } ?> </h2> <?php if (function_exists('network_latest_posts')) { $parameters = array('title_only' => 'false', 'ignore_blog' => '1', 'auto_excerpt' => 'true', 'display_type' => 'ulist', 'full_meta' => 'true', 'sort_by_date' => 'true', 'use_pub_date' => 'true', 'wrapper_list_css' => 'highlights-list', 'wrapper_block_css' => 'module row highlights', 'instance' => 'highlights-module'); // If a category was selected, limit to that category if (isset($updatecategory)) { $parameters['category'] = $updatecategory; } // If number of updates is specified, limit to that number of updates if ($updatenumber) { $parameters['number_posts'] = $updatenumber; } // Execute $hightlights_updates = network_latest_posts($parameters); } else { get_template_part('partials/error', 'plugin'); } ?> </article>
public function widget($args, $instance) { // Process blog_id if (!empty($instance['blog_id'])) { // Check it's an array if (is_array($instance['blog_id'])) { // If it's null if (in_array('null', $instance['blog_id'])) { // Set it to a real NULL $instance['blog_id'] = NULL; // If it's not 'null' then convert to value1,..,valueN } else { // Scape the string (trying to minimize injection risks $instance['blog_id'] = implode(',', array_map('mysql_real_escape_string', $instance['blog_id'])); } // If it isn't an array } else { // Check if it's null if ($instance['blog_id'] == 'null') { // Set it to a real NULL $instance['blog_id'] = NULL; } } } // Process ignore_blog if (!empty($instance['ignore_blog'])) { // Check it's an array if (is_array($instance['ignore_blog'])) { // If it's null if (in_array('null', $instance['ignore_blog'])) { // Set it to a real NULL $instance['ignore_blog'] = NULL; // If it's not 'null' then convert to value1,..,valueN } else { // Scape the string (trying to minimize injection risks $instance['ignore_blog'] = implode(',', array_map('mysql_real_escape_string', $instance['ignore_blog'])); } // If it isn't an array } else { // Check if it's null if ($instance['ignore_blog'] == 'null') { // Set it to a real NULL $instance['ignore_blog'] = NULL; } } } // Duplicate the instances $options = $instance; if (empty($options['thumbnail_wh'])) { // Set the thumbnail_wh variable putting together width and height $options['thumbnail_wh'] = (int) $options['thumbnail_w'] . 'x' . (int) $options['thumbnail_h']; } // If we couldn't find anything, set some default values if (is_array($options)) { // Parse & merge parameters with the defaults $options = wp_parse_args($options, $this->defaults); } // Set the instance identifier, so each instance of the widget is treated individually $options['instance'] = $this->number; // If there are passed arguments, transform them into variables if (!empty($args)) { extract($args); } // Display the widget // Start the output buffer to control the display position ob_start(); // Get the posts network_latest_posts($options); // Open the aside tag (widget placeholder) $output_string = "<aside class='widget nlposts-widget'>"; // Grab the content $output_string .= ob_get_contents(); // Close the aside tag $output_string .= "</aside>"; // Clean the output buffer ob_end_clean(); // Put the content where we want echo $output_string; }
function network_latest_posts_shortcode($atts) { if (!empty($atts)) { // Legacy mode due to variable renaming // So existent shorcodes don't break ;) foreach ($atts as $key => $value) { switch ($key) { case 'number': $atts['number_posts'] = $value; break; case 'days': $atts['time_frame'] = $value; break; case 'titleonly': $atts['title_only'] = $value; break; case 'begin_wrap': $atts['before_wrap'] = $value; break; case 'end_wrap': $atts['after_wrap'] = $value; break; case 'blogid': $atts['blog_id'] = $value; break; case 'cpt': $atts['custom_post_type'] = $value; break; case 'cat': $atts['category'] = $value; break; default: $atts[$key] = $value; break; } } extract($atts); } // Start the output buffer to control the display position ob_start(); // Get the posts network_latest_posts($atts); // Output the content $shortcode = ob_get_contents(); // Clean the output buffer ob_end_clean(); // Put the content where we want return $shortcode; }
<?php get_sidebar('site_networks'); ?> <main class="main-network" role="main"> <h4 class="subtitle">News in this network</h4> <?php $blog_ids = get_post_meta($post->ID, 'glocal_network_sites'); $blog_list = implode(",", $blog_ids); if (function_exists('network_latest_posts')) { $parameters = array('title' => '', 'title_only' => 'false', 'auto_excerpt' => 'true', 'full_meta' => 'true', 'display_type' => 'ulist', 'thumbnail' => 'true', 'thumbnail_wh' => 'medium', 'thumbnail_class' => 'post-img', 'wrapper_block_css' => 'network-posts', 'instance' => 'network-posts', 'blog_id' => $blog_list, 'number_posts' => '25'); // Execute $posts = network_latest_posts($parameters); } ?> </main> </div> </div> <?php get_footer();