Changeset 12324
- Timestamp:
- 01/11/2019 02:37:16 AM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/classes/class-bp-blogs-recent-posts-widget.php
r12323 r12324 62 62 echo $args['before_title'] . $title . $args['after_title']; 63 63 64 if ( empty( $instance['max_posts'] ) || empty( $instance['max_posts'] ) ) { 64 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 65 if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) { 65 66 $instance['max_posts'] = 10; 66 67 } … … 129 130 */ 130 131 public function update( $new_instance, $old_instance ) { 131 $instance = $old_instance; 132 $instance = $old_instance; 133 134 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 135 132 136 $instance['title'] = strip_tags( $new_instance['title'] ); 133 $instance['max_posts'] = strip_tags( $new_instance['max_posts'] );137 $instance['max_posts'] = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] ); 134 138 $instance['link_title'] = ! empty( $new_instance['link_title'] ); 135 139 … … 151 155 ) ); 152 156 157 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 158 153 159 $title = strip_tags( $instance['title'] ); 154 $max_posts = strip_tags( $instance['max_posts'] );160 $max_posts = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] ); 155 161 $link_title = (bool) $instance['link_title']; 156 162 … … 159 165 <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> 160 166 <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> 161 <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>167 <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="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p> 162 168 <?php 163 169 } -
trunk/src/bp-core/bp-core-functions.php
r12303 r12324 3929 3929 return (bool) apply_filters( 'bp_is_large_install', $is_large ); 3930 3930 } 3931 3932 /** 3933 * Returns the upper limit on the "max" item count, for widgets that support it. 3934 * 3935 * @since 5.0.0 3936 * 3937 * @param string $widget_class Optional. Class name of the calling widget. 3938 * @return int 3939 */ 3940 function bp_get_widget_max_count_limit( $widget_class = '' ) { 3941 /** 3942 * Filters the upper limit on the "max" item count, for widgets that support it. 3943 * 3944 * @since 5.0.0 3945 * 3946 * @param int $count Defaults to 50. 3947 * @param string $widget_class Class name of the calling widget. 3948 */ 3949 return apply_filters( 'bp_get_widget_max_count_limit', 50, $widget_class ); 3950 } -
trunk/src/bp-groups/classes/class-bp-groups-widget.php
r12323 r12324 103 103 echo $before_title . $title . $after_title; 104 104 105 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 105 106 $max_groups = ! empty( $instance['max_groups'] ) ? (int) $instance['max_groups'] : 5; 107 108 if ( $max_groups > $max_limit ) { 109 $max_groups = $max_limit; 110 } 106 111 107 112 $group_args = array( … … 184 189 $instance = $old_instance; 185 190 191 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 192 186 193 $instance['title'] = strip_tags( $new_instance['title'] ); 187 $instance['max_groups'] = strip_tags( $new_instance['max_groups'] );194 $instance['max_groups'] = $new_instance['max_groups'] > $max_limit ? $max_limit : intval( $new_instance['max_groups'] ); 188 195 $instance['group_default'] = strip_tags( $new_instance['group_default'] ); 189 196 $instance['link_title'] = ! empty( $new_instance['link_title'] ); … … 209 216 $instance = bp_parse_args( (array) $instance, $defaults, 'groups_widget_form' ); 210 217 218 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 219 211 220 $title = strip_tags( $instance['title'] ); 212 $max_groups = strip_tags( $instance['max_groups'] );221 $max_groups = $instance['max_groups'] > $max_limit ? $max_limit : intval( $instance['max_groups'] ); 213 222 $group_default = strip_tags( $instance['group_default'] ); 214 223 $link_title = (bool) $instance['link_title']; … … 219 228 <p><label for="<?php echo $this->get_field_id('link_title') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title') ?>" id="<?php echo $this->get_field_id('link_title') ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Groups directory', 'buddypress' ) ?></label></p> 220 229 221 <p><label for="<?php echo $this->get_field_id( 'max_groups' ); ?>"><?php _e( 'Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p>230 <p><label for="<?php echo $this->get_field_id( 'max_groups' ); ?>"><?php _e( 'Max groups to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p> 222 231 223 232 <p> -
trunk/src/bp-members/classes/class-bp-core-members-widget.php
r12323 r12324 91 91 echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; 92 92 93 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 94 $max_members = $settings['max_members'] > $max_limit ? $max_limit : (int) $settings['max_members']; 95 93 96 // Setup args for querying members. 94 97 $members_args = array( 95 98 'user_id' => 0, 96 99 'type' => $settings['member_default'], 97 'per_page' => $ settings['max_members'],98 'max' => $ settings['max_members'],100 'per_page' => $max_members, 101 'max' => $max_members, 99 102 'populate_extras' => true, 100 103 'search_terms' => false, … … 178 181 $instance = $old_instance; 179 182 183 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 184 180 185 $instance['title'] = strip_tags( $new_instance['title'] ); 181 $instance['max_members'] = strip_tags( $new_instance['max_members'] );186 $instance['max_members'] = $new_instance['max_members'] > $max_limit ? $max_limit : intval( $new_instance['max_members'] ); 182 187 $instance['member_default'] = strip_tags( $new_instance['member_default'] ); 183 188 $instance['link_title'] = ! empty( $new_instance['link_title'] ); … … 195 200 */ 196 201 public function form( $instance ) { 202 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 197 203 198 204 // Get widget settings. 199 205 $settings = $this->parse_settings( $instance ); 200 206 $title = strip_tags( $settings['title'] ); 201 $max_members = strip_tags( $settings['max_members'] );207 $max_members = $settings['max_members'] > $max_limit ? $max_limit : intval( $settings['max_members'] ); 202 208 $member_default = strip_tags( $settings['member_default'] ); 203 209 $link_title = (bool) $settings['link_title']; ?> … … 220 226 <label for="<?php echo $this->get_field_id( 'max_members' ); ?>"> 221 227 <?php esc_html_e( 'Max members to show:', 'buddypress' ); ?> 222 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type=" text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" />228 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /> 223 229 </label> 224 230 </p> -
trunk/src/bp-members/classes/class-bp-core-recently-active-widget.php
r11564 r12324 64 64 echo $args['before_title'] . $title . $args['after_title']; 65 65 66 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 67 $max_members = $settings['max_members'] > $max_limit ? $max_limit : (int) $settings['max_members']; 68 66 69 // Setup args for querying members. 67 70 $members_args = array( 68 71 'user_id' => 0, 69 72 'type' => 'active', 70 'per_page' => $ settings['max_members'],71 'max' => $ settings['max_members'],73 'per_page' => $max_members, 74 'max' => $max_members, 72 75 'populate_extras' => true, 73 76 'search_terms' => false, … … 117 120 */ 118 121 public function update( $new_instance, $old_instance ) { 119 $instance = $old_instance; 122 $instance = $old_instance; 123 124 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 125 120 126 $instance['title'] = strip_tags( $new_instance['title'] ); 121 $instance['max_members'] = strip_tags( $new_instance['max_members'] );127 $instance['max_members'] = $new_instance['max_members'] > $max_limit ? $max_limit : intval( $new_instance['max_members'] ); 122 128 123 129 return $instance; … … 133 139 */ 134 140 public function form( $instance ) { 141 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 135 142 136 143 // Get widget settings. 137 144 $settings = $this->parse_settings( $instance ); 138 145 $title = strip_tags( $settings['title'] ); 139 $max_members = strip_tags( $settings['max_members'] ); ?> 146 $max_members = $settings['max_members'] > $max_limit ? $max_limit : intval( $settings['max_members'] ); 147 ?> 140 148 141 149 <p> … … 149 157 <label for="<?php echo $this->get_field_id( 'max_members' ); ?>"> 150 158 <?php esc_html_e( 'Max members to show:', 'buddypress' ); ?> 151 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type=" text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" />159 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /> 152 160 </label> 153 161 </p> -
trunk/src/bp-members/classes/class-bp-core-whos-online-widget.php
r11564 r12324 63 63 echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; 64 64 65 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 66 $max_members = $settings['max_members'] > $max_limit ? $max_limit : (int) $settings['max_members']; 67 65 68 // Setup args for querying members. 66 69 $members_args = array( 67 70 'user_id' => 0, 68 71 'type' => 'online', 69 'per_page' => $ settings['max_members'],70 'max' => $ settings['max_members'],72 'per_page' => $max_members, 73 'max' => $max_members, 71 74 'populate_extras' => true, 72 75 'search_terms' => false, … … 116 119 */ 117 120 public function update( $new_instance, $old_instance ) { 118 $instance = $old_instance; 121 $instance = $old_instance; 122 123 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 124 119 125 $instance['title'] = strip_tags( $new_instance['title'] ); 120 $instance['max_members'] = strip_tags( $new_instance['max_members'] );126 $instance['max_members'] = $new_instance['max_members'] > $max_limit ? $max_limit : intval( $new_instance['max_members'] ); 121 127 122 128 return $instance; … … 132 138 */ 133 139 public function form( $instance ) { 140 $max_limit = bp_get_widget_max_count_limit( __CLASS__ ); 134 141 135 142 // Get widget settings. 136 143 $settings = $this->parse_settings( $instance ); 137 144 $title = strip_tags( $settings['title'] ); 138 $max_members = strip_tags( $settings['max_members'] ); ?> 145 $max_members = $settings['max_members'] > $max_limit ? $max_limit : intval( $settings['max_members'] ); 146 ?> 139 147 140 148 <p> … … 148 156 <label for="<?php echo $this->get_field_id( 'max_members' ); ?>"> 149 157 <?php esc_html_e( 'Max members to show:', 'buddypress' ); ?> 150 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type=" text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" />158 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /> 151 159 </label> 152 160 </p>
Note: See TracChangeset
for help on using the changeset viewer.