PluginProbe
wpForo Forum / 2.1.2
wpForo Forum v2.1.2
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / widgets / RecentPosts.php

RecentPosts.php in wpForo Forum 2.1.2, at widgets/RecentPosts.php

387 lines 23.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace wpforo\widgets;
4
5 use WP_Widget;
6
7 class RecentPosts extends WP_Widget {
8 private $default_instance = [];
9 private $orderby_fields = [];
10 private $order_fields = [];
11
12 function __construct() {
13 parent::__construct( 'wpforo_recent_posts', 'wpForo Recent Posts', [ 'description' => 'Your forum\'s recent posts.' ] );
14 $this->init_local_vars();
15 add_action( 'wp_ajax_wpforo_load_ajax_widget_RecentPosts', [ $this, 'load_ajax_widget' ] );
16 add_action( 'wp_ajax_nopriv_wpforo_load_ajax_widget_RecentPosts', [ $this, 'load_ajax_widget' ] );
17 if( is_admin() ) {
18 add_action( 'wp_ajax_wpforo_get_forum_tree', [ $this, 'get_forum_tree' ] );
19 }
20 }
21
22 private function init_local_vars() {
23 $this->default_instance = [
24 'boardid' => 0,
25 'title' => 'Recent Posts',
26 'forumids' => [],
27 'orderby' => 'created',
28 'order' => 'DESC',
29 'count' => 9,
30 'limit_per_topic' => 0,
31 'display_avatar' => true,
32 'forumids_filter' => false,
33 'current_forumid_filter' => false,
34 'exclude_firstposts' => false,
35 'display_only_unread' => false,
36 'display_new_indicator' => false,
37 'refresh_interval' => 0,
38 'excerpt_length' => 55,
39 ];
40 $this->orderby_fields = [
41 'created' => __( 'Created Date', 'wpforo' ),
42 'modified' => __( 'Modified Date', 'wpforo' ),
43 ];
44 $this->order_fields = [
45 'DESC' => __( 'DESC', 'wpforo' ),
46 'ASC' => __( 'ASC', 'wpforo' ),
47 ];
48 }
49
50 public function get_widget( $instance, $post_args ) {
51 $is_user_logged_in = (bool) WPF()->current_userid;
52 $post_args['private'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
53 $post_args['status'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
54 $print_avatar = $instance['display_avatar'] && wpforo_setting( 'profiles', 'avatars' ) && WPF()->usergroup->can( 'va' );
55
56 ob_start();
57 if( $post_args['limit_per_topic'] ) {
58 if( $instance['display_only_unread'] && $is_user_logged_in ) {
59 $grouped_postids = WPF()->post->get_unread_posts( $post_args, $post_args['row_count'] );
60 } else {
61 $grouped_postids = WPF()->post->get_posts( $post_args );
62 }
63 if( ! empty( $grouped_postids ) ) {
64 $grouped_postids = implode( ',', $grouped_postids );
65 $postids = array_filter( array_map( 'wpforo_bigintval', explode( ',', $grouped_postids ) ) );
66 rsort( $postids );
67 foreach( $postids as $postid ) {
68 $class = '';
69 $post = wpforo_post( $postid );
70 if( ! wpfval($post, 'forumid') ) continue;
71 if( ! WPF()->post->view_access( $post ) ) continue;
72 $current = $post['topicid'] == wpfval( WPF()->current_object, 'topicid' );
73 if( ! $current ) {
74 $class = 'class="' . ( $instance['display_only_unread'] ? 'wpf-unread-post' : wpforo_unread( $post['topicid'], 'post', false, $post['postid'] ) ) . '"';
75 }
76 $member = wpforo_member( $post );
77 ?>
78 <li <?php echo $class; ?>>
79 <div class="wpforo-list-item ">
80 <?php if( $print_avatar ): ?>
81 <div class="wpforo-list-item-left">
82 <?php echo WPF()->member->avatar( $member ); ?>
83 </div>
84 <?php endif; ?>
85 <div class="wpforo-list-item-right" <?php if( ! $print_avatar ): ?> style="width: 100%"<?php endif; ?>>
86 <p class="posttitle">
87 <a href="<?php echo esc_url( $post['url'] ) ?>"><?php
88 if( $t = esc_html( trim( $post['title'] ) ) ) {
89 echo $t;
90 } else {
91 echo wpforo_phrase( 'RE', false, 'default' ) . ': ' . esc_html( trim( wpforo_topic( $post['topicid'], 'title' ) ) );
92 } ?>
93 </a>
94 <?php if( ! $current && $instance['display_new_indicator'] ) wpforo_unread_button( $post['topicid'], '', true, $post['postid'] ) ?>
95 </p>
96 <p class="posttext"><?php echo esc_html( wpforo_text( $post['body'], $instance['excerpt_length'], false ) ); ?></p>
97 <p class="postuser"><?php wpforo_phrase( 'by' ) ?> <?php wpforo_member_link( $member ) ?>
98 , <?php esc_html( wpforo_date( $post['created'] ) ) ?></p>
99 </div>
100 <div class="wpf-clear"></div>
101 </div>
102 </li>
103 <?php
104 }
105 } else {
106 $error_message = ( $instance['display_only_unread'] ) ? 'No new posts found' : 'No posts found';
107 echo '<li class="wpf-no-post-found">' . wpforo_phrase( $error_message, false ) . '</li>';
108 }
109 } else {
110 if( $instance['display_only_unread'] && $is_user_logged_in ) {
111 $recent_posts = WPF()->post->get_unread_posts( $post_args, $post_args['row_count'] );
112 } else {
113 $recent_posts = WPF()->post->get_posts( $post_args );
114 }
115 if( ! empty( $recent_posts ) ) {
116 foreach( $recent_posts as $post ) {
117 $class = '';
118 $post_url = wpforo_post( $post['postid'], 'url' );
119 $member = wpforo_member( $post );
120 $current = $post['topicid'] == wpfval( WPF()->current_object, 'topicid' );
121 if( ! $current ) {
122 $class = 'class="' . ( $instance['display_only_unread'] ? 'wpf-unread-post' : wpforo_unread( $post['topicid'], 'post', false, $post['postid'] ) ) . '"';
123 }
124 ?>
125 <li <?php echo $class; ?>>
126 <div class="wpforo-list-item">
127 <?php if( $print_avatar ): ?>
128 <div class="wpforo-list-item-left">
129 <?php echo WPF()->member->avatar( $member ); ?>
130 </div>
131 <?php endif; ?>
132 <div class="wpforo-list-item-right" <?php if( ! $print_avatar ): ?> style="width:100%"<?php endif; ?>>
133 <p class="posttitle">
134 <a href="<?php echo esc_url( $post_url ) ?>"><?php
135 if( $t = esc_html( trim( $post['title'] ) ) ) {
136 echo $t;
137 } else {
138 echo wpforo_phrase( 'RE', false, 'default' ) . ': ' . esc_html( trim( wpforo_topic( $post['topicid'], 'title' ) ) );
139 } ?>
140 </a>
141 <?php if( ! $current && $instance['display_new_indicator'] ) wpforo_unread_button( $post['topicid'], '', true, $post['postid'] ) ?>
142 </p>
143 <p class="posttext"><?php echo esc_html( wpforo_text( $post['body'], $instance['excerpt_length'] ) ); ?></p>
144 <p class="postuser"><?php wpforo_phrase( 'by' ) ?> <?php wpforo_member_link( $member ) ?>
145 , <?php esc_html( wpforo_date( $post['created'] ) ) ?></p>
146 </div>
147 <div class="wpf-clear"></div>
148 </div>
149 </li>
150 <?php
151 }
152 } else {
153 $error_message = ( $instance['display_only_unread'] ) ? 'No new posts found' : 'No posts found';
154 echo '<li class="wpf-no-post-found">' . wpforo_phrase( $error_message, false ) . '</li>';
155 }
156 }
157
158 return sprintf( '<ul>%1$s</ul>', ob_get_clean() );
159 }
160
161 public function load_ajax_widget() {
162 $_POST = wp_unslash( $_POST );
163 $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
164 $post_args = json_decode( (string) wpfval( $_POST, 'post_args' ), true );
165 wp_send_json_success( [ 'html' => $this->get_widget( $instance, $post_args ) ] );
166 }
167
168 public function widget( $args, $instance ) {
169 wp_enqueue_script( 'wpforo-widgets-js' );
170 $is_user_logged_in = (bool) WPF()->current_userid;
171 $instance = wpforo_parse_args( $instance, $this->default_instance );
172 if( $instance['display_only_unread'] ) {
173 $display_widget = $is_user_logged_in;
174 $display_widget = apply_filters( 'wpforo_widget_display_recent_posts', $display_widget );
175 } else {
176 $display_widget = true;
177 }
178 if( ! $display_widget ) return;
179
180 if( $instance['current_forumid_filter'] && $instance['boardid'] === WPF()->board->get_current( 'boardid' ) && $current_forumid = wpfval( WPF()->current_object, 'forumid' ) ) $instance['forumids'] = (array) $current_forumid;
181 $data = [
182 'boardid' => $instance['boardid'],
183 'action' => 'wpforo_load_ajax_widget_RecentPosts',
184 'instance' => $instance,
185 'post_args' => [
186 'forumids' => ( $instance['forumids'] ?: $this->default_instance['forumids'] ),
187 'orderby' => ( key_exists( $instance['orderby'], $this->orderby_fields ) ? $instance['orderby'] : $this->default_instance['orderby'] ),
188 'order' => ( key_exists( $instance['order'], $this->order_fields ) ? $instance['order'] : $this->default_instance['order'] ),
189 'row_count' => ( intval( $instance['count'] ) ?: $this->default_instance['count'] ),
190 'limit_per_topic' => ( intval( $instance['limit_per_topic'] ) ?: $this->default_instance['limit_per_topic'] ),
191 'is_first_post' => $instance['exclude_firstposts'] ? false : null,
192 'check_private' => true,
193 ]
194 ];
195 if( WPF()->board->get_current( 'boardid' ) === $instance['boardid'] ){
196 $html = $this->get_widget( $data['instance'], $data['post_args'] );
197 $onload = false;
198 }else{
199 $html = '<div style="text-align: center; font-size: 20px;"><i class="fas fa-spinner fa-spin"></i></div>';
200 $onload = true;
201 $data['referer'] = home_url();
202 }
203
204 $json = json_encode( $data );
205 echo $args['before_widget'] . '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">';
206 if( ! empty( $instance['title'] ) ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
207 echo '<div class="wpforo-widget-content wpforo-ajax-widget ' . ( ! $onload ? 'wpforo-ajax-widget-onload-false' : '' ) . '" data-json="' . esc_attr( $json ) . '">' . $html . '</div></div>' . $args['after_widget'];
208 }
209
210 public function form( $instance ) {
211 $instance = wpforo_parse_args( $instance, $this->default_instance );
212 $title = (string) $instance['title'];
213 $boardid = (int) $instance['boardid'];
214 $selected = array_unique( array_filter( array_map( 'intval', (array) $instance['forumids'] ) ) );
215 $orderby = (string) $instance['orderby'];
216 $order = (string) $instance['order'];
217 $count = (int) $instance['count'];
218 $limit_per_topic = (int) $instance['limit_per_topic'];
219 $display_avatar = (bool) $instance['display_avatar'];
220 $forumids_filter = (bool) $instance['forumids_filter'];
221 $current_forumid_filter = (bool) $instance['current_forumid_filter'];
222 $exclude_firstposts = (bool) $instance['exclude_firstposts'];
223 $display_only_unread = (bool) $instance['display_only_unread'];
224 $display_new_indicator = (bool) $instance['display_new_indicator'];
225 $refresh_interval = (int) $instance['refresh_interval'];
226 $excerpt_length = (int) $instance['excerpt_length'];
227 WPF()->change_board( $boardid );
228 ?>
229 <style>
230 .wpf-wdg-wrapper .wpf_wdg_forumids_wrap {
231 display: none !important;
232 }
233
234 .wpf-wdg-wrapper input.wpf_wdg_forumids_filter_1:checked ~ .wpf_wdg_forumids_wrap {
235 display: block !important;
236 }
237 .wpf_wdg_limit_per_topic {
238 width: 53px;
239 }
240 </style>
241 <div class="wpf-wdg-wrapper">
242 <p>
243 <label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php _e( 'Title', 'wpforo' ); ?>:</label>
244 <input id="<?php echo $this->get_field_id( 'title' ) ?>" class="widefat"
245 name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
246 value="<?php echo esc_attr( $title ); ?>">
247 </p>
248 <p>
249 <label for="<?php echo $this->get_field_id( 'boardid' ) ?>"></label>
250 <select id="<?php echo $this->get_field_id( 'boardid' ) ?>" class="wpf_wdg_boardid" name="<?php echo esc_attr( $this->get_field_name( 'boardid' ) ); ?>">
251 <?php echo WPF()->board->dropdown( $boardid ) ?>
252 </select>
253 </p>
254 <div>
255 <span><?php _e( 'Filter by forums', 'wpforo' ); ?> :</span>
256
257 <label for="<?php echo $this->get_field_id( 'forumids_filter' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
258 <input id="<?php echo $this->get_field_id( 'forumids_filter' ) ?>_1" value="1" class="wpf_wdg_forumids_filter_1" name="<?php echo esc_attr( $this->get_field_name( 'forumids_filter' ) ); ?>" <?php checked( $forumids_filter ); ?> type="radio">
259
260 <label for="<?php echo $this->get_field_id( 'forumids_filter' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
261 <input id="<?php echo $this->get_field_id( 'forumids_filter' ) ?>_0" value="0" class="wpf_wdg_forumids_filter_0" name="<?php echo esc_attr( $this->get_field_name( 'forumids_filter' ) ); ?>" <?php checked( $forumids_filter, false ); ?> type="radio">
262
263 <div class="wpf_wdg_forumids_wrap">
264 <label for="<?php echo $this->get_field_id( 'forumids' ) ?>"></label>
265 <select id="<?php echo $this->get_field_id( 'forumids' ) ?>" class="wpf_wdg_forumids" name="<?php echo esc_attr( $this->get_field_name( 'forumids' ) ); ?>[]" multiple>
266 <?php WPF()->forum->tree( 'select_box', false, $selected ) ?>
267 </select>
268 </div>
269 </div>
270 <p>
271 <span><?php _e( 'Autofilter by current forum', 'wpforo' ); ?> : </span>
272
273 <label for="<?php echo $this->get_field_id( 'current_forumid_filter' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
274 <input id="<?php echo $this->get_field_id( 'current_forumid_filter' ) ?>_1" name="<?php echo esc_attr( $this->get_field_name( 'current_forumid_filter' ) ); ?>" value="1" <?php checked( $current_forumid_filter ); ?> type="radio">
275
276 <label for="<?php echo $this->get_field_id( 'current_forumid_filter' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
277 <input id="<?php echo $this->get_field_id( 'current_forumid_filter' ) ?>_0" name="<?php echo esc_attr( $this->get_field_name( 'current_forumid_filter' ) ); ?>" value="0" <?php checked( $current_forumid_filter, false ); ?> type="radio">
278 </p>
279 <p>
280 <label for="<?php echo $this->get_field_id( 'orderby' ) ?>"><?php _e( 'Order by', 'wpforo' ); ?>
281 :</label>
282 <select class="wpf_wdg_orderby" name="<?php echo esc_attr( $this->get_field_name( 'orderby' ) ); ?>"
283 id="<?php echo $this->get_field_id( 'orderby' ) ?>" <?php echo( $limit_per_topic ? 'disabled' : '' ) ?>>
284 <?php foreach( $this->orderby_fields as $orderby_key => $orderby_field ) : ?>
285 <option value="<?php echo $orderby_key; ?>"<?php echo( $orderby_key == $orderby ? ' selected' : '' ); ?>><?php echo $orderby_field; ?></option>
286 <?php endforeach; ?>
287 </select>
288 <label>
289 <select class="wpf_wdg_order"
290 name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" <?php echo( $limit_per_topic ? 'disabled' : '' ) ?>>
291 <?php foreach( $this->order_fields as $order_key => $order_field ) : ?>
292 <option value="<?php echo $order_key; ?>"<?php echo( $order_key == $order ? ' selected' : '' ); ?>><?php echo $order_field; ?></option>
293 <?php endforeach; ?>
294 </select>
295 </label>
296 </p>
297 <p>
298 <label for="<?php echo $this->get_field_id( 'limit_per_topic' ) ?>"><?php _e( 'Limit Per Topic', 'wpforo' ); ?></label>&nbsp;
299 <input id="<?php echo $this->get_field_id( 'limit_per_topic' ) ?>" class="wpf_wdg_limit_per_topic"
300 type="number" min="0"
301 name="<?php echo esc_attr( $this->get_field_name( 'limit_per_topic' ) ); ?>"
302 value="<?php echo esc_attr( $limit_per_topic ); ?>">
303 <span style="color: #aaa;"><?php _e( 'set 0 to remove this limit', 'wpforo' ) ?></span>
304 </p>
305 <p>
306 <label for="<?php echo $this->get_field_id( 'count' ) ?>"><?php _e( 'Number of Items', 'wpforo' ); ?></label>&nbsp;
307 <input id="<?php echo $this->get_field_id( 'count' ) ?>" type="number" min="1" style="width: 53px;"
308 name="<?php echo esc_attr( $this->get_field_name( 'count' ) ); ?>"
309 value="<?php echo esc_attr( $count ); ?>">
310 </p>
311 <p>
312 <label for="<?php echo $this->get_field_id( 'excerpt_length' ) ?>"><?php _e( 'Excerpt Length', 'wpforo' ); ?></label>&nbsp;
313 <input id="<?php echo $this->get_field_id( 'excerpt_length' ) ?>" type="number" min="0" style="display: inline-block; width: 53px;" name="<?php echo esc_attr( $this->get_field_name( 'excerpt_length' ) ); ?>" value="<?php echo esc_attr( $excerpt_length ); ?>">
314 <span style="color: #ccc"><?php _e( 'Set 0 to disable autorefresh', 'wpforo' ) ?></span>
315 </p>
316 <p>
317 <span><?php _e( 'Display with avatars', 'wpforo' ); ?> : </span>
318
319 <label for="<?php echo $this->get_field_id( 'display_avatar' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
320 <input id="<?php echo $this->get_field_id( 'display_avatar' ) ?>_1" value="1" <?php checked( $display_avatar ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_avatar' ) ); ?>">
321
322 <label for="<?php echo $this->get_field_id( 'display_avatar' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
323 <input id="<?php echo $this->get_field_id( 'display_avatar' ) ?>_0" value="0" <?php checked( $display_avatar, false ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_avatar' ) ); ?>">
324 </p>
325 <p>
326 <span><?php _e( 'Exclude First Posts', 'wpforo' ); ?></span>
327 <label for="<?php echo $this->get_field_id( 'exclude_firstposts' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
328 <input id="<?php echo $this->get_field_id( 'exclude_firstposts' ) ?>_1" value="1" <?php checked( $exclude_firstposts ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'exclude_firstposts' ) ); ?>">
329
330 <label for="<?php echo $this->get_field_id( 'exclude_firstposts' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
331 <input id="<?php echo $this->get_field_id( 'exclude_firstposts' ) ?>_0" value="0" <?php checked( $exclude_firstposts, false ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'exclude_firstposts' ) ); ?>">
332 </p>
333 <p>
334 <span><?php _e( 'Display Only Unread Posts', 'wpforo' ); ?></span>
335 <label for="<?php echo $this->get_field_id( 'display_only_unread' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
336 <input id="<?php echo $this->get_field_id( 'display_only_unread' ) ?>_1" value="1" <?php checked( $display_only_unread ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_only_unread' ) ); ?>">
337
338 <label for="<?php echo $this->get_field_id( 'display_only_unread' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
339 <input id="<?php echo $this->get_field_id( 'display_only_unread' ) ?>_0" value="0" <?php checked( $display_only_unread, false ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_only_unread' ) ); ?>">
340 </p>
341 <p>
342 <span><?php _e( 'Display [new] indicator', 'wpforo' ); ?> : </span>
343
344 <label for="<?php echo $this->get_field_id( 'display_new_indicator' ) ?>_1"><?php _e( 'Yes', 'wpforo' ); ?></label>
345 <input id="<?php echo $this->get_field_id( 'display_new_indicator' ) ?>_1" value="1" <?php checked( $display_new_indicator ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_new_indicator' ) ); ?>">
346
347 <label for="<?php echo $this->get_field_id( 'display_new_indicator' ) ?>_0"><?php _e( 'No', 'wpforo' ); ?></label>
348 <input id="<?php echo $this->get_field_id( 'display_new_indicator' ) ?>_0" value="0" <?php checked( $display_new_indicator, false ); ?> type="radio" name="<?php echo esc_attr( $this->get_field_name( 'display_new_indicator' ) ); ?>">
349 </p>
350 <p>
351 <label for="<?php echo $this->get_field_id( 'refresh_interval' ) ?>"><?php _e( 'Auto Refresh Interval Seconds', 'wpforo' ); ?></label>&nbsp;
352 <input id="<?php echo $this->get_field_id( 'refresh_interval' ) ?>" type="number" min="0" style="display: inline-block; width: 53px;" name="<?php echo esc_attr( $this->get_field_name( 'refresh_interval' ) ); ?>" value="<?php echo esc_attr( $refresh_interval ); ?>">
353 <span style="color: #ccc"><?php _e( 'Set 0 to disable autorefresh', 'wpforo' ) ?></span>
354 </p>
355 </div>
356 <?php
357 }
358
359 public function update( $new_instance, $old_instance ) {
360 $new_instance = wpforo_parse_args( $new_instance, $this->default_instance );
361 $instance = [];
362 $instance['title'] = strip_tags( (string) $new_instance['title'] );
363 $instance['boardid'] = (int) $new_instance['boardid'];
364 $instance['forumids_filter'] = (bool) (int) $new_instance['forumids_filter'];
365 $instance['forumids'] = array_unique( array_filter( array_map( 'intval', (array) $new_instance['forumids'] ) ) );
366 $instance['orderby'] = ( ! empty( $new_instance['orderby'] ) && key_exists( $new_instance['orderby'], $this->orderby_fields ) ) ? $new_instance['orderby'] : $this->default_instance['orderby'];
367 $instance['order'] = ( ! empty( $new_instance['order'] ) && key_exists( $new_instance['order'], $this->order_fields ) ) ? $new_instance['order'] : $this->default_instance['order'];
368 $instance['count'] = (int) $new_instance['count'];
369 $instance['display_avatar'] = (bool) (int) $new_instance['display_avatar'];
370 $instance['current_forumid_filter'] = (bool) (int) $new_instance['current_forumid_filter'];
371 $instance['limit_per_topic'] = (int) $new_instance['limit_per_topic'];
372 $instance['exclude_firstposts'] = (bool) (int) $new_instance['exclude_firstposts'];
373 $instance['display_only_unread'] = (bool) (int) $new_instance['display_only_unread'];
374 $instance['display_new_indicator'] = (bool) (int) $new_instance['display_new_indicator'];
375 $instance['refresh_interval'] = (int) $new_instance['refresh_interval'];
376 $instance['excerpt_length'] = (int) $new_instance['excerpt_length'];
377
378 return $instance;
379 }
380
381 public function get_forum_tree() {
382 ob_start();
383 WPF()->forum->tree( 'select_box', false, [] );
384 wp_send_json_success( [ 'html' => ob_get_clean() ] );
385 }
386 }
387