BP_Core_Network_Posts_Widget::widget( array $args, array $instance )
Display the Members widget.
Description
See also
- WP_Widget::widget(): for description of parameters.
Parameters
- $args
-
(Required) Widget arguments.
- $instance
-
(Required) Widget settings, as saved by the user.
Source
File: bp-core/classes/class-bp-core-network-posts-widget.php
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | public function widget( $args , $instance ) { // Get widget settings. $settings = $this ->parse_settings( $instance ); /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title' , $settings [ 'title' ], $instance , $this ->id_base ); $number = (! empty ( $instance [ 'number' ] ) ) ? absint( $instance [ 'number' ] ) : 5; $show_date = isset( $instance [ 'show_date' ] ) ? $instance [ 'show_date' ] : false; $show_image = isset( $instance [ 'show_image' ] ) ? $instance [ 'show_image' ] : true; if ( ! function_exists( 'get_sites' ) ){ return ; } $blogs = get_sites( array ( 'fields' => 'ids' , 'orderby' => 'last_updated' , 'order' => 'DESC' , )); $args [ 'before_widget' ]; if ( $title ) { echo $args [ 'before_title' ] . $title . $args [ 'after_title' ]; } if ( $blogs ) { ?> <ul id= "network-list" class = "item-list" aria-live= "polite" aria-relevant= "all" aria-atomic= "true" > <?php foreach ( $blogs as $blog_key ) { switch_to_blog( $blog_key ); /** * Filters the arguments for the Recent Posts widget. * * @since 3.4.0 * * @see WP_Query::get_posts() * * @param array $args An array of arguments used to retrieve the recent posts. */ $r = new WP_Query( apply_filters( 'widget_network_posts_args' , array ( 'posts_per_page' => $number , 'no_found_rows' => true, 'post_status' => 'publish' , 'ignore_sticky_posts' => true ) ) ); if ( $r ->have_posts() ) { ?> <?php while ( $r ->have_posts() ) : $r ->the_post(); ?> <li class = "vcard" > <div class = "item-avatar" > <a href= "<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>" > <?php echo get_avatar( get_the_author_meta( 'ID' ), 80 ); ?> </a> </div> <div class = "item" > <div class = "item-title" > <a class = "post-author" href= "<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>" ><?php the_author(); ?></a> <span class = "netowrk-post-type" >created a post:</span> </div> <div class = "item-data" > <span class = "netowrk-post-content" > <a href= "<?php the_permalink(); ?>" class = "bb-title" ><?php echo wp_trim_words( the_title( '' , '' , false ), 6, '…' ); ?></a> </span> <?php if ( $show_image && has_post_thumbnail() ) { ?> <div class = "data-photo" ><a href= "<?php the_permalink(); ?>" title= "<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'buddyboss' ), the_title_attribute( 'echo=0' ) ) ); ?>" class = "entry-media entry-img" > <?php the_post_thumbnail(); ?> </a> </div> <?php } ?> <?php if ( $show_date ) : ?> <br/><span class = "netowrk-post-activity" ><?php echo get_the_date(); ?></span> <?php endif ; ?> </div> </div> </li> <?php endwhile ; ?> <?php // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } // Back the current blog restore_current_blog(); } ?> </ul><?php } echo $args [ 'after_widget' ]; } |
Changelog
Version | Description |
---|---|
1.0.3 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.