Changeset 9469 for trunk/src/bp-blogs/bp-blogs-widgets.php
- Timestamp:
- 02/10/2015 12:59:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-widgets.php
r9468 r9469 17 17 global $wpdb; 18 18 19 if ( bp_is_active( 'activity' ) && (int) $wpdb->blogid == bp_get_root_blog_id() )19 if ( bp_is_active( 'activity' ) && bp_is_root_blog( $wpdb->blogid ) ) { 20 20 add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Blogs_Recent_Posts_Widget");' ) ); 21 } 21 22 } 22 23 add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' ); … … 30 31 * Constructor method. 31 32 */ 32 function __construct() {33 public function __construct() { 33 34 $widget_ops = array( 34 35 'description' => __( 'A list of recently published posts from across your network.', 'buddypress' ), … … 46 47 * @param array $instance Widget settings, as saved by the user. 47 48 */ 48 function widget( $args, $instance ) {49 public function widget( $args, $instance ) { 49 50 50 $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : __( 'Recent Networkwide Posts', 'buddypress' ); 51 $title = ! empty( $instance['title'] ) 52 ? esc_html( $instance['title'] ) 53 : __( 'Recent Networkwide Posts', 'buddypress' ); 51 54 52 55 if ( ! empty( $instance['link_title'] ) ) { … … 66 69 echo $args['before_title'] . $title . $args['after_title']; 67 70 68 if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] ) 69 $instance['max_posts'] = 10; ?> 71 if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) { 72 $instance['max_posts'] = 10; 73 } 70 74 71 <?php // Override some of the contextually set parameters for bp_has_activities() ?> 72 <?php if ( bp_has_activities( array( 'action' => 'new_blog_post', 'max' => $instance['max_posts'], 'per_page' => $instance['max_posts'], 'user_id' => 0, 'scope' => false, 'object' => false, 'primary_id' => false ) ) ) : ?> 75 // Override some of the contextually set parameters for bp_has_activities() 76 $args = array( 77 'action' => 'new_blog_post', 78 'max' => $instance['max_posts'], 79 'per_page' => $instance['max_posts'], 80 'user_id' => 0, 81 'scope' => false, 82 'object' => false, 83 'primary_id' => false 84 ); ?> 85 86 <?php if ( bp_has_activities( $args ) ) : ?> 73 87 74 88 <ul id="blog-post-list" class="activity-list item-list"> … … 78 92 <li> 79 93 <div class="activity-content" style="margin: 0"> 80 81 <div class="activity-header"> 82 <?php bp_activity_action() ?> 83 </div> 94 <div class="activity-header"><?php bp_activity_action(); ?></div> 84 95 85 96 <?php if ( bp_get_activity_content_body() ) : ?> 86 <div class="activity-inner"> 87 <?php bp_activity_content_body() ?>88 </div> 97 98 <div class="activity-inner"><?php bp_activity_content_body(); ?></div> 99 89 100 <?php endif; ?> 90 101 … … 97 108 98 109 <?php else : ?> 110 99 111 <div id="message" class="info"> 100 <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ) ?></p>112 <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ); ?></p> 101 113 </div> 114 102 115 <?php endif; ?> 103 116 … … 113 126 * @return array $instance The parsed options to be saved. 114 127 */ 115 function update( $new_instance, $old_instance ) {116 $instance = $old_instance;117 $instance['title'] = strip_tags( $new_instance['title'] );118 $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );128 public function update( $new_instance, $old_instance ) { 129 $instance = $old_instance; 130 $instance['title'] = strip_tags( $new_instance['title'] ); 131 $instance['max_posts'] = strip_tags( $new_instance['max_posts'] ); 119 132 $instance['link_title'] = (bool) $new_instance['link_title']; 120 133 … … 127 140 * @param $instance Settings for this widget. 128 141 */ 129 function form( $instance ) {142 public function form( $instance ) { 130 143 $instance = wp_parse_args( (array) $instance, array( 131 144 'title' => __( 'Recent Networkwide Posts', 'buddypress' ), … … 134 147 ) ); 135 148 136 $title = strip_tags( $instance['title'] );137 $max_posts = strip_tags( $instance['max_posts'] );149 $title = strip_tags( $instance['title'] ); 150 $max_posts = strip_tags( $instance['max_posts'] ); 138 151 $link_title = (bool) $instance['link_title']; 139 152 140 153 ?> 141 154 142 <p><label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ) ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" type="text" value="<?php echo esc_attr( $title )?>" style="width: 100%;" /></label></p>143 <p><label for="<?php echo $this->get_field_id( 'link_title' ) ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ) ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' )?></label></p>144 <p><label for="<?php echo $this->get_field_id( 'max_posts' ) ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>155 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%;" /></label></p> 156 <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p> 157 <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p> 145 158 <?php 146 159 }
Note: See TracChangeset
for help on using the changeset viewer.