wpForo Forum - Version 2.1.1

Version Description

Download this release

Release Info

Developer Tomdever
Plugin Icon 128x128 wpForo Forum
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0 to 2.1.1

assets/js/ajax.js CHANGED
@@ -703,6 +703,7 @@ $wpf(document).ready(function ($) {
703
  f.on('click', '.wpf-edit-post-cancel', function(){
704
  f.fadeOut('fast');
705
  children.fadeIn('slow');
 
706
  $( 'html, body' ).animate({scrollTop: (wrap.offset().top - 80)}, 415);
707
  });
708
  if( init ){
@@ -710,7 +711,7 @@ $wpf(document).ready(function ($) {
710
  wpforo_trigger_custom_event(document, 'wpforo_topic_portable_form', f);
711
  }
712
  f.fadeIn('slow');
713
- $( 'html, body' ).animate({scrollTop: (wrap.offset().top - 80)}, 415);
714
  $this.removeClass('wpf-processing');
715
  }
716
 
@@ -1149,7 +1150,7 @@ $wpf(document).ready(function ($) {
1149
  }).done(function (response) {
1150
  if( response.success ){
1151
  wpforo_editor.set_content(response.data.body);
1152
- $('html, body').animate({ scrollTop: form.offset().top }, 500);
1153
  }
1154
  }).always(function(){
1155
  wpforo_load_hide();
@@ -1266,7 +1267,7 @@ $wpf(document).ready(function ($) {
1266
  }
1267
 
1268
  function wpforo_content_changed(){
1269
- var form = $('form[data-textareaid="'+ wpforo_editor.active_textareaid +'"]');
1270
  if( wpforo_editor.get_stats().has_content ){
1271
  wpforo_activate_revision_action_buttons(form);
1272
  $('.wpforo_post_preview', form).removeClass('wpf-disabled');
@@ -1277,7 +1278,7 @@ $wpf(document).ready(function ($) {
1277
  }
1278
 
1279
  function wpforo_content_ctrl_s(){
1280
- $('form[data-textareaid="'+ wpforo_editor.active_textareaid +'"] .wpforo_save_revision').trigger("click");
1281
  }
1282
 
1283
  wpforo_wrap.on('change input propertychange', 'form[data-textareaid] textarea', function (e) {
703
  f.on('click', '.wpf-edit-post-cancel', function(){
704
  f.fadeOut('fast');
705
  children.fadeIn('slow');
706
+ wpforo_editor.set_active( wpforo_editor.get_main() );
707
  $( 'html, body' ).animate({scrollTop: (wrap.offset().top - 80)}, 415);
708
  });
709
  if( init ){
711
  wpforo_trigger_custom_event(document, 'wpforo_topic_portable_form', f);
712
  }
713
  f.fadeIn('slow');
714
+ // $( 'html, body' ).animate({scrollTop: (wrap.offset().top - 80)}, 415);
715
  $this.removeClass('wpf-processing');
716
  }
717
 
1150
  }).done(function (response) {
1151
  if( response.success ){
1152
  wpforo_editor.set_content(response.data.body);
1153
+ //$('html, body').animate({ scrollTop: form.offset().top }, 500);
1154
  }
1155
  }).always(function(){
1156
  wpforo_load_hide();
1267
  }
1268
 
1269
  function wpforo_content_changed(){
1270
+ var form = $('form[data-textareaid="'+ wpforo_editor.get_active_textareaid() +'"]');
1271
  if( wpforo_editor.get_stats().has_content ){
1272
  wpforo_activate_revision_action_buttons(form);
1273
  $('.wpforo_post_preview', form).removeClass('wpf-disabled');
1278
  }
1279
 
1280
  function wpforo_content_ctrl_s(){
1281
+ $('form[data-textareaid="'+ wpforo_editor.get_active_textareaid() +'"] .wpforo_save_revision').trigger("click");
1282
  }
1283
 
1284
  wpforo_wrap.on('change input propertychange', 'form[data-textareaid] textarea', function (e) {
assets/js/frontend.js CHANGED
@@ -154,6 +154,9 @@ var wpforo_editor = {
154
  }
155
  return '';
156
  },
 
 
 
157
  set_active: function(textareaid){
158
  if( this.is_exists(textareaid) ){
159
  this.active_textareaid = textareaid;
@@ -203,7 +206,7 @@ var wpforo_editor = {
203
  tinymce_focus: function(textareaid, caret_to_end){
204
  textareaid = this.fix_textareaid(textareaid);
205
  if( this.is_tinymce(textareaid) ){
206
- $wpf('html, body').animate({ scrollTop: ( $wpf('form[data-textareaid="' + textareaid + '"]').offset().top - 200 ) }, 500);
207
  var focus_mce = tinymce.get(textareaid);
208
  focus_mce.focus();
209
  if(caret_to_end){
@@ -215,7 +218,7 @@ var wpforo_editor = {
215
  textarea_focus: function(textareaid, caret_to_end){
216
  textareaid = this.fix_textareaid(textareaid);
217
  if( this.is_textarea(textareaid) ){
218
- $wpf('html, body').animate({ scrollTop: ($wpf('form[data-textareaid="' + textareaid + '"]').offset().top - 200) }, 500);
219
  var textarea = $wpf( 'textarea#' + textareaid );
220
  var textarea_val = textarea.val();
221
  textarea.trigger("focus");
154
  }
155
  return '';
156
  },
157
+ get_active_textareaid: function(){
158
+ return this.fix_textareaid();
159
+ },
160
  set_active: function(textareaid){
161
  if( this.is_exists(textareaid) ){
162
  this.active_textareaid = textareaid;
206
  tinymce_focus: function(textareaid, caret_to_end){
207
  textareaid = this.fix_textareaid(textareaid);
208
  if( this.is_tinymce(textareaid) ){
209
+ $wpf('html, body').animate({ scrollTop: ( $wpf('form[data-textareaid="' + textareaid + '"]').offset().top - 300 ) }, 500);
210
  var focus_mce = tinymce.get(textareaid);
211
  focus_mce.focus();
212
  if(caret_to_end){
218
  textarea_focus: function(textareaid, caret_to_end){
219
  textareaid = this.fix_textareaid(textareaid);
220
  if( this.is_textarea(textareaid) ){
221
+ $wpf('html, body').animate({ scrollTop: ($wpf('form[data-textareaid="' + textareaid + '"]').offset().top - 300) }, 500);
222
  var textarea = $wpf( 'textarea#' + textareaid );
223
  var textarea_val = textarea.val();
224
  textarea.trigger("focus");
assets/js/widgets.js CHANGED
@@ -50,7 +50,7 @@ jQuery(document).ready(function ($) {
50
  }
51
  });
52
 
53
- function do_wpforo_ajax_widget( elem ){
54
  var j = elem.data( 'json' );
55
  if( j ){
56
  if( typeof j !== 'object' ) j = JSON.parse( j );
@@ -70,19 +70,30 @@ jQuery(document).ready(function ($) {
70
  if( j['topic_args'] !== undefined ) j['topic_args'] = JSON.stringify( j['topic_args'] );
71
  if( j['post_args'] !== undefined ) j['post_args'] = JSON.stringify( j['post_args'] );
72
 
73
- $.ajax({
74
- type: 'POST',
75
- url: ajax_url,
76
- data: j,
77
- }).done(function( r ){
78
- if( r.success ) elem.html( r.data['html'] );
79
-
 
 
 
 
 
 
 
 
 
 
 
80
  if( !isNaN( interval ) && interval > 0 ){
81
  setTimeout( function(){
82
  do_wpforo_ajax_widget( elem );
83
  }, interval * 1000 );
84
  }
85
- });
86
  }
87
  }
88
  }
@@ -91,7 +102,7 @@ jQuery(document).ready(function ($) {
91
  var wdgts = $( '.wpforo-widget-wrap .wpforo-ajax-widget[data-json]' );
92
  if( wdgts.length ){
93
  wdgts.each(function( k, v ){
94
- do_wpforo_ajax_widget( $(v) );
95
  });
96
  }
97
  }
50
  }
51
  });
52
 
53
+ function do_wpforo_ajax_widget( elem, is_on_load ){
54
  var j = elem.data( 'json' );
55
  if( j ){
56
  if( typeof j !== 'object' ) j = JSON.parse( j );
70
  if( j['topic_args'] !== undefined ) j['topic_args'] = JSON.stringify( j['topic_args'] );
71
  if( j['post_args'] !== undefined ) j['post_args'] = JSON.stringify( j['post_args'] );
72
 
73
+ var do_ajax = true;
74
+ if( is_on_load && elem.hasClass( 'wpforo-ajax-widget-onload-false' ) ) do_ajax = false;
75
+
76
+ if( do_ajax ){
77
+ $.ajax({
78
+ type: 'POST',
79
+ url: ajax_url,
80
+ data: j,
81
+ }).done(function( r ){
82
+ if( r.success ) elem.html( r.data['html'] );
83
+
84
+ if( !isNaN( interval ) && interval > 0 ){
85
+ setTimeout( function(){
86
+ do_wpforo_ajax_widget( elem );
87
+ }, interval * 1000 );
88
+ }
89
+ });
90
+ }else{
91
  if( !isNaN( interval ) && interval > 0 ){
92
  setTimeout( function(){
93
  do_wpforo_ajax_widget( elem );
94
  }, interval * 1000 );
95
  }
96
+ }
97
  }
98
  }
99
  }
102
  var wdgts = $( '.wpforo-widget-wrap .wpforo-ajax-widget[data-json]' );
103
  if( wdgts.length ){
104
  wdgts.each(function( k, v ){
105
+ do_wpforo_ajax_widget( $(v), true );
106
  });
107
  }
108
  }
classes/Cache.php CHANGED
@@ -228,9 +228,9 @@ class Cache {
228
  $root = ( isset( $item['root'] ) && $item['root'] ) ? $item['root'] : 0;
229
  $tagid = ( isset( $item['tagid'] ) && $item['tagid'] ) ? $item['tagid'] : 0;
230
 
231
- WPF()->forum->reset();
232
- WPF()->topic->reset();
233
- WPF()->post->reset();
234
 
235
  if( $template === 'forum' || $template === 'forum-soft' ) {
236
  $id = isset( $id ) ? $id : $forumid;
228
  $root = ( isset( $item['root'] ) && $item['root'] ) ? $item['root'] : 0;
229
  $tagid = ( isset( $item['tagid'] ) && $item['tagid'] ) ? $item['tagid'] : 0;
230
 
231
+ if( isset( WPF()->forum ) && method_exists(WPF()->forum, 'reset') ) WPF()->forum->reset();
232
+ if( isset( WPF()->topic ) && method_exists(WPF()->topic, 'reset') ) WPF()->topic->reset();
233
+ if( isset( WPF()->post ) && method_exists(WPF()->post, 'reset') ) WPF()->post->reset();
234
 
235
  if( $template === 'forum' || $template === 'forum-soft' ) {
236
  $id = isset( $id ) ? $id : $forumid;
classes/Template.php CHANGED
@@ -2911,7 +2911,7 @@ class Template {
2911
  public function change_cover_button( $user ) {
2912
  if( WPF()->usergroup->can( 'upc' ) && WPF()->perm->user_can_edit_account( $user ) ){
2913
  return sprintf(
2914
- '<div class="wpf-edit-cover" wpf-tooltip="%1$s" wpf-tooltip-position="top" wpf-tooltip-size="small">
2915
  <i class="fas fa-images" data-action="editcover"></i>
2916
  <ul class="wpf-edit-cover-options">
2917
  <li class="wpf-upload-cover"><i class="fas fa-upload"></i> %2$s</li>
@@ -2920,7 +2920,7 @@ class Template {
2920
  </div>',
2921
  wpforo_phrase('Change Cover Image', false),
2922
  wpforo_phrase('Upload New Cover', false),
2923
- wpforo_phrase( 'Set the Default', false )
2924
  );
2925
  }
2926
 
2911
  public function change_cover_button( $user ) {
2912
  if( WPF()->usergroup->can( 'upc' ) && WPF()->perm->user_can_edit_account( $user ) ){
2913
  return sprintf(
2914
+ '<div class="wpf-edit-cover" title="%1$s">
2915
  <i class="fas fa-images" data-action="editcover"></i>
2916
  <ul class="wpf-edit-cover-options">
2917
  <li class="wpf-upload-cover"><i class="fas fa-upload"></i> %2$s</li>
2920
  </div>',
2921
  wpforo_phrase('Change Cover Image', false),
2922
  wpforo_phrase('Upload New Cover', false),
2923
+ wpforo_phrase( 'Reset to Default', false )
2924
  );
2925
  }
2926
 
includes/installation.php CHANGED
@@ -342,7 +342,7 @@ function wpforo_alter_tables() {
342
 
343
  ################################################################
344
  // profiles table fields fixing ////////////////////////////////
345
- if( wpforo_db_check( [ 'table' => WPF()->tables->profiles, 'col' => 'secondary_groups', 'check' => 'col_exists' ] ) ){
346
  $sql = "SELECT `userid`, `facebook`, `twitter`, `skype`, `fields`
347
  FROM `". WPF()->tables->profiles ."`
348
  WHERE (`facebook` IS NOT NULL AND `facebook` <> '')
342
 
343
  ################################################################
344
  // profiles table fields fixing ////////////////////////////////
345
+ if( wpforo_db_check( [ 'table' => WPF()->tables->profiles, 'col' => 'facebook', 'check' => 'col_exists' ] ) ){
346
  $sql = "SELECT `userid`, `facebook`, `twitter`, `skype`, `fields`
347
  FROM `". WPF()->tables->profiles ."`
348
  WHERE (`facebook` IS NOT NULL AND `facebook` <> '')
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: gVectors Team
3
  Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
  Requires at least: 5.1
5
  Tested up to: 6.1
6
- Stable tag: 2.1.0
7
  Requires PHP: 5.6 and higher
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -163,10 +163,16 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
163
 
164
  == Changelog ==
165
 
166
- = wpForo Forum 2.1.0 | 08.11.2022 =
167
 
168
  [wpForo Forum v2.1.0 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-2-1-0-is-released/)
169
 
 
 
 
 
 
 
170
  * Added: Notification via email when the user become approved
171
  * Added: User approval email template "subject" and "message body"
172
  * Added: AJAX powered forum widgets
3
  Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
  Requires at least: 5.1
5
  Tested up to: 6.1
6
+ Stable tag: 2.1.1
7
  Requires PHP: 5.6 and higher
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
163
 
164
  == Changelog ==
165
 
166
+ = wpForo Forum 2.1.0 - 2.1.1 | 10.11.2022 =
167
 
168
  [wpForo Forum v2.1.0 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-2-1-0-is-released/)
169
 
170
+ * Version 2.1.1
171
+ * Changed: Correct location of reply editor after clicking the edit reply button
172
+ * Changed: Keep the regular loading type of widgets. AJAX is only used for multi-board forums when current board doesn't match to the board widget.
173
+ * Fixed Bug: Preparation | Fatal error caused at line 231 of file Cache.php: Call to a member function reset()
174
+ * --------
175
+ * Version 2.1.0
176
  * Added: Notification via email when the user become approved
177
  * Added: User approval email template "subject" and "message body"
178
  * Added: AJAX powered forum widgets
widgets/Forums.php CHANGED
@@ -25,10 +25,8 @@ class Forums extends WP_Widget {
25
  ];
26
  }
27
 
28
- public function load_ajax_widget() {
29
- $_POST = wp_unslash( $_POST );
30
- $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
31
- ob_start();
32
 
33
  if ( wpfval( $instance, 'dropdown' ) ) {
34
  $forum_urls = [];
@@ -55,7 +53,13 @@ class Forums extends WP_Widget {
55
  WPF()->forum->tree( 'front_list', true, WPF()->current_object['forumid'], false );
56
  }
57
 
58
- wp_send_json_success( [ 'html' => ob_get_clean() ] );
 
 
 
 
 
 
59
  }
60
 
61
  public function widget( $args, $instance ) {
@@ -66,11 +70,18 @@ class Forums extends WP_Widget {
66
  'action' => 'wpforo_load_ajax_widget_Forums',
67
  'instance' => $instance,
68
  ];
69
- if( WPF()->board->get_current( 'boardid' ) !== $instance['boardid'] ) $data['referer'] = home_url();
 
 
 
 
 
 
 
70
  $json = json_encode( $data );
71
  echo $args['before_widget'] . '<div id="wpf-widget-forums" class="wpforo-widget-wrap">';
72
  if ( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
73
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
74
  }
75
 
76
  public function form( $instance ) {
25
  ];
26
  }
27
 
28
+ public function get_widget( $instance ) {
29
+ ob_start();
 
 
30
 
31
  if ( wpfval( $instance, 'dropdown' ) ) {
32
  $forum_urls = [];
53
  WPF()->forum->tree( 'front_list', true, WPF()->current_object['forumid'], false );
54
  }
55
 
56
+ return ob_get_clean();
57
+ }
58
+
59
+ public function load_ajax_widget() {
60
+ $_POST = wp_unslash( $_POST );
61
+ $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
62
+ wp_send_json_success( [ 'html' => $this->get_widget( $instance ) ] );
63
  }
64
 
65
  public function widget( $args, $instance ) {
70
  'action' => 'wpforo_load_ajax_widget_Forums',
71
  'instance' => $instance,
72
  ];
73
+ if( WPF()->board->get_current( 'boardid' ) === $instance['boardid'] ){
74
+ $html = $this->get_widget( $data['instance'] );
75
+ $onload = false;
76
+ }else{
77
+ $html = '<div style="text-align: center; font-size: 20px;"><i class="fas fa-spinner fa-spin"></i></div>';
78
+ $onload = true;
79
+ $data['referer'] = home_url();
80
+ }
81
  $json = json_encode( $data );
82
  echo $args['before_widget'] . '<div id="wpf-widget-forums" class="wpforo-widget-wrap">';
83
  if ( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
84
+ 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'];
85
  }
86
 
87
  public function form( $instance ) {
widgets/OnlineMembers.php CHANGED
@@ -27,36 +27,40 @@ class OnlineMembers extends WP_Widget {
27
  ];
28
  }
29
 
30
- public function load_ajax_widget() {
31
- $_POST = wp_unslash( $_POST );
32
- $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
33
  $online_members = WPF()->member->get_online_members( $instance['count'], $instance['groupids'] );
34
  ob_start();
35
  if( ! empty( $online_members ) ) {
36
  echo '<ul>
37
  <li>
38
  <div class="wpforo-list-item">';
39
- foreach( $online_members as $member ) {
40
- if( $instance['display_avatar'] ): ?>
41
- <a href="<?php echo esc_url( WPF()->member->get_profile_url( $member['userid'] ) ) ?>"
42
- class="onlineavatar">
43
- <?php echo WPF()->member->get_avatar( $member['userid'], 'style="width:95%;" class="avatar" title="' . esc_attr( $member['display_name'] ) . '"' ); ?>
44
- </a>
45
- <?php else: ?>
46
- <a href="<?php echo esc_url( WPF()->member->get_profile_url( $member['userid'] ) ) ?>"
47
- class="onlineuser"><?php echo esc_html( $member['display_name'] ) ?></a>
48
- <?php endif; ?>
49
- <?php
50
- }
51
- echo '<div class="wpf-clear"></div>
52
- </div>
53
- </li>
54
- </ul>
55
- </div>';
56
  } else {
57
  echo '<p class="wpf-widget-note">&nbsp;' . wpforo_phrase( 'No online members at the moment', false ) . '</p>';
58
  }
59
- wp_send_json_success( ['html' => ob_get_clean()] );
 
 
 
 
 
 
 
60
  }
61
 
62
  public function widget( $args, $instance ) {
@@ -67,11 +71,12 @@ class OnlineMembers extends WP_Widget {
67
  'instance' => $instance,
68
  ];
69
  if( WPF()->board->get_current( 'boardid' ) !== 0 ) $data['referer'] = home_url();
 
70
  $json = json_encode( $data );
71
  wp_enqueue_script( 'wpforo-widgets-js' );
72
  echo $args['before_widget'] . '<div id="wpf-widget-online-users" class="wpforo-widget-wrap">';
73
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
74
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
75
  }
76
 
77
  public function form( $instance ) {
27
  ];
28
  }
29
 
30
+ public function get_widget( $instance ) {
 
 
31
  $online_members = WPF()->member->get_online_members( $instance['count'], $instance['groupids'] );
32
  ob_start();
33
  if( ! empty( $online_members ) ) {
34
  echo '<ul>
35
  <li>
36
  <div class="wpforo-list-item">';
37
+ foreach( $online_members as $member ) {
38
+ if( $instance['display_avatar'] ): ?>
39
+ <a href="<?php echo esc_url( WPF()->member->get_profile_url( $member['userid'] ) ) ?>"
40
+ class="onlineavatar">
41
+ <?php echo WPF()->member->get_avatar( $member['userid'], 'style="width:95%;" class="avatar" title="' . esc_attr( $member['display_name'] ) . '"' ); ?>
42
+ </a>
43
+ <?php else: ?>
44
+ <a href="<?php echo esc_url( WPF()->member->get_profile_url( $member['userid'] ) ) ?>"
45
+ class="onlineuser"><?php echo esc_html( $member['display_name'] ) ?></a>
46
+ <?php endif; ?>
47
+ <?php
48
+ }
49
+ echo '<div class="wpf-clear"></div>
50
+ </div>
51
+ </li>
52
+ </ul>';
 
53
  } else {
54
  echo '<p class="wpf-widget-note">&nbsp;' . wpforo_phrase( 'No online members at the moment', false ) . '</p>';
55
  }
56
+
57
+ return ob_get_clean();
58
+ }
59
+
60
+ public function load_ajax_widget() {
61
+ $_POST = wp_unslash( $_POST );
62
+ $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
63
+ wp_send_json_success( ['html' => $this->get_widget( $instance )] );
64
  }
65
 
66
  public function widget( $args, $instance ) {
71
  'instance' => $instance,
72
  ];
73
  if( WPF()->board->get_current( 'boardid' ) !== 0 ) $data['referer'] = home_url();
74
+ $html = $this->get_widget( $data['instance'] );
75
  $json = json_encode( $data );
76
  wp_enqueue_script( 'wpforo-widgets-js' );
77
  echo $args['before_widget'] . '<div id="wpf-widget-online-users" class="wpforo-widget-wrap">';
78
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
79
+ echo '<div class="wpforo-widget-content wpforo-ajax-widget wpforo-ajax-widget-onload-false" data-json="' . esc_attr( $json ) . '">' . $html . '</div></div>' . $args['after_widget'];
80
  }
81
 
82
  public function form( $instance ) {
widgets/RecentPosts.php CHANGED
@@ -47,16 +47,13 @@ class RecentPosts extends WP_Widget {
47
  ];
48
  }
49
 
50
- public function load_ajax_widget() {
51
- $_POST = wp_unslash( $_POST );
52
  $is_user_logged_in = (bool) WPF()->current_userid;
53
- $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
54
- $post_args = json_decode( (string) wpfval( $_POST, 'post_args' ), true );
55
  $post_args['private'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
56
  $post_args['status'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
57
  $print_avatar = $instance['display_avatar'] && wpforo_setting( 'profiles', 'avatars' ) && WPF()->usergroup->can( 'va' );
58
 
59
- ob_start();
60
  if( $post_args['limit_per_topic'] ) {
61
  if( $instance['display_only_unread'] && $is_user_logged_in ) {
62
  $grouped_postids = WPF()->post->get_unread_posts( $post_args, $post_args['row_count'] );
@@ -158,7 +155,14 @@ class RecentPosts extends WP_Widget {
158
  }
159
  }
160
 
161
- wp_send_json_success( [ 'html' => sprintf( '<ul>%1$s</ul>', ob_get_clean() ) ] );
 
 
 
 
 
 
 
162
  }
163
 
164
  public function widget( $args, $instance ) {
@@ -188,11 +192,19 @@ class RecentPosts extends WP_Widget {
188
  'check_private' => true,
189
  ]
190
  ];
191
- if( WPF()->board->get_current( 'boardid' ) !== $instance['boardid'] ) $data['referer'] = home_url();
 
 
 
 
 
 
 
 
192
  $json = json_encode( $data );
193
  echo $args['before_widget'] . '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">';
194
  if( ! empty( $instance['title'] ) ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
195
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
196
  }
197
 
198
  public function form( $instance ) {
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'] );
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 ) {
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 ) {
widgets/RecentTopics.php CHANGED
@@ -45,34 +45,31 @@ class RecentTopics extends WP_Widget {
45
  ];
46
  }
47
 
48
- public function load_ajax_widget() {
49
- $_POST = wp_unslash( $_POST );
50
  $is_user_logged_in = (bool) WPF()->current_userid;
51
- $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
52
- $topic_args = json_decode( (string) wpfval( $_POST, 'topic_args' ), true );
53
  $topic_args['private'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;;
54
  $topic_args['status'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
55
 
56
- $row_count = (int) wpfval( $topic_args, 'row_count' );
57
  $topics = [];
58
  $topic_args['offset'] = 0;
59
- while( $row_count && count( $topics ) < $row_count ){
60
- if( ! ( $_topics = WPF()->topic->get_topics( $topic_args ) ) ) break;
61
 
62
- $topics = array_merge( $topics, $_topics );
63
- $topic_args['offset'] += $row_count;
64
- }
65
- array_splice( $topics, $row_count );
66
 
67
- $print_avatar = $instance['display_avatar'] && wpforo_setting( 'profiles', 'avatars' ) && WPF()->usergroup->can( 'va' );
68
 
69
- $lis = '';
70
  foreach( $topics as $topic ) {
71
  $topic_url = wpforo_topic( $topic['topicid'], 'url' );
72
  $member = wpforo_member( $topic );
73
 
74
- $lis .= sprintf(
75
- '<li>
76
  <div class="wpforo-list-item">
77
  %1$s
78
  <div class="wpforo-list-item-right" %2$s>
@@ -84,21 +81,28 @@ class RecentTopics extends WP_Widget {
84
  <div class="wpf-clear"></div>
85
  </div>
86
  </li>',
87
- ( $print_avatar ? sprintf( '<div class="wpforo-list-item-left">%1$s</div>', WPF()->member->avatar( $member ) ) : '' ),
88
- ( !$print_avatar ? 'style="width: 100%"' : '' ),
89
- ( wpfval( $instance, 'goto_unread' ) ?
90
- wpforo_topic_title( $topic, $topic_url, '{p}{au}{t}{/a}', false ) .
91
- ( $topic['topicid'] != wpfval( WPF()->current_object, 'topicid' ) ? wpforo_unread_button( $topic['topicid'], $topic_url, false ) : '' )
92
- :
93
- wpforo_topic_title( $topic, $topic_url, '{p}{a}{t}{/a}', false )
94
- ),
95
- wpforo_phrase( 'by', false ),
96
- wpforo_member_link( $member, '', 30, '', false ),
97
- esc_html( wpforo_date( $topic['created'], 'ago', false ) )
98
- );
99
  }
100
 
101
- wp_send_json_success( [ 'html' => sprintf( '<ul>%1$s</ul>', $lis ) ] );
 
 
 
 
 
 
 
102
  }
103
 
104
  public function widget( $args, $instance ) {
@@ -116,11 +120,18 @@ class RecentTopics extends WP_Widget {
116
  'row_count' => ( ( $count = intval( $instance['count'] ) ) ? $count : $this->default_instance['count'] ),
117
  ],
118
  ];
119
- if( WPF()->board->get_current( 'boardid' ) !== $instance['boardid'] ) $data['referer'] = home_url();
 
 
 
 
 
 
 
120
  $json = json_encode( $data );
121
  echo $args['before_widget'] . '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">';
122
  if( ! empty( $instance['title'] ) ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
123
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
124
  }
125
 
126
  public function form( $instance ) {
45
  ];
46
  }
47
 
48
+ public function get_widget( $instance, $topic_args ) {
 
49
  $is_user_logged_in = (bool) WPF()->current_userid;
 
 
50
  $topic_args['private'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;;
51
  $topic_args['status'] = ( ! $is_user_logged_in || ! WPF()->usergroup->can( 'aum' ) ) ? 0 : null;
52
 
53
+ $row_count = (int) wpfval( $topic_args, 'row_count' );
54
  $topics = [];
55
  $topic_args['offset'] = 0;
56
+ while( $row_count && count( $topics ) < $row_count ){
57
+ if( ! ( $_topics = WPF()->topic->get_topics( $topic_args ) ) ) break;
58
 
59
+ $topics = array_merge( $topics, $_topics );
60
+ $topic_args['offset'] += $row_count;
61
+ }
62
+ array_splice( $topics, $row_count );
63
 
64
+ $print_avatar = $instance['display_avatar'] && wpforo_setting( 'profiles', 'avatars' ) && WPF()->usergroup->can( 'va' );
65
 
66
+ $lis = '';
67
  foreach( $topics as $topic ) {
68
  $topic_url = wpforo_topic( $topic['topicid'], 'url' );
69
  $member = wpforo_member( $topic );
70
 
71
+ $lis .= sprintf(
72
+ '<li>
73
  <div class="wpforo-list-item">
74
  %1$s
75
  <div class="wpforo-list-item-right" %2$s>
81
  <div class="wpf-clear"></div>
82
  </div>
83
  </li>',
84
+ ( $print_avatar ? sprintf( '<div class="wpforo-list-item-left">%1$s</div>', WPF()->member->avatar( $member ) ) : '' ),
85
+ ( !$print_avatar ? 'style="width: 100%"' : '' ),
86
+ ( wpfval( $instance, 'goto_unread' ) ?
87
+ wpforo_topic_title( $topic, $topic_url, '{p}{au}{t}{/a}', false ) .
88
+ ( $topic['topicid'] != wpfval( WPF()->current_object, 'topicid' ) ? wpforo_unread_button( $topic['topicid'], $topic_url, false ) : '' )
89
+ :
90
+ wpforo_topic_title( $topic, $topic_url, '{p}{a}{t}{/a}', false )
91
+ ),
92
+ wpforo_phrase( 'by', false ),
93
+ wpforo_member_link( $member, '', 30, '', false ),
94
+ esc_html( wpforo_date( $topic['created'], 'ago', false ) )
95
+ );
96
  }
97
 
98
+ return sprintf( '<ul>%1$s</ul>', $lis );
99
+ }
100
+
101
+ public function load_ajax_widget() {
102
+ $_POST = wp_unslash( $_POST );
103
+ $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
104
+ $topic_args = json_decode( (string) wpfval( $_POST, 'topic_args' ), true );
105
+ wp_send_json_success( [ 'html' => $this->get_widget( $instance, $topic_args ) ] );
106
  }
107
 
108
  public function widget( $args, $instance ) {
120
  'row_count' => ( ( $count = intval( $instance['count'] ) ) ? $count : $this->default_instance['count'] ),
121
  ],
122
  ];
123
+ if( WPF()->board->get_current( 'boardid' ) === $instance['boardid'] ) {
124
+ $html = $this->get_widget( $data['instance'], $data['topic_args'] );
125
+ $onload = false;
126
+ }else{
127
+ $html = '<div style="text-align: center; font-size: 20px;"><i class="fas fa-spinner fa-spin"></i></div>';
128
+ $onload = true;
129
+ $data['referer'] = home_url();
130
+ }
131
  $json = json_encode( $data );
132
  echo $args['before_widget'] . '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">';
133
  if( ! empty( $instance['title'] ) ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
134
+ 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'];
135
  }
136
 
137
  public function form( $instance ) {
widgets/Search.php CHANGED
@@ -24,10 +24,10 @@ class Search extends WP_Widget {
24
  ];
25
  }
26
 
27
- public function load_ajax_widget() {
28
  ob_start(); ?>
29
 
30
- <form action="<?php echo wpforo_home_url() ?>" method="GET" id="wpforo-search-form">
31
  <?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
32
  <label class="wpf-search-widget-label">
33
  <input type="text" placeholder="<?php wpforo_phrase( 'Search...' ) ?>" name="wpfs" class="wpfw-100" value="<?php echo isset( $_GET['wpfs'] ) ? esc_attr( sanitize_text_field( $_GET['wpfs'] ) ) : '' ?>">
@@ -35,10 +35,15 @@ class Search extends WP_Widget {
35
  </label>
36
  </form>
37
 
38
- <?php
39
- wp_send_json_success( [ 'html' => ob_get_clean() ] );
 
40
  }
41
 
 
 
 
 
42
  public function widget( $args, $instance ) {
43
  wp_enqueue_script( 'wpforo-widgets-js' );
44
  $instance = wpforo_parse_args( $instance, $this->default_instance );
@@ -46,12 +51,20 @@ class Search extends WP_Widget {
46
  'boardid' => $instance['boardid'],
47
  'action' => 'wpforo_load_ajax_widget_Search',
48
  ];
49
- if( WPF()->board->get_current( 'boardid' ) !== $instance['boardid'] ) $data['referer'] = home_url();
 
 
 
 
 
 
 
 
50
  $json = json_encode( $data );
51
 
52
  echo $args['before_widget'] . '<div id="wpf-widget-search" class="wpforo-widget-wrap">';
53
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
54
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
55
  }
56
 
57
  public function form( $instance ) {
24
  ];
25
  }
26
 
27
+ public function get_widget() {
28
  ob_start(); ?>
29
 
30
+ <form action="<?php echo wpforo_home_url() ?>" method="GET" id="wpforo-search-form">
31
  <?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
32
  <label class="wpf-search-widget-label">
33
  <input type="text" placeholder="<?php wpforo_phrase( 'Search...' ) ?>" name="wpfs" class="wpfw-100" value="<?php echo isset( $_GET['wpfs'] ) ? esc_attr( sanitize_text_field( $_GET['wpfs'] ) ) : '' ?>">
35
  </label>
36
  </form>
37
 
38
+ <?php
39
+
40
+ return ob_get_clean();
41
  }
42
 
43
+ public function load_ajax_widget() {
44
+ wp_send_json_success( [ 'html' => $this->get_widget() ] );
45
+ }
46
+
47
  public function widget( $args, $instance ) {
48
  wp_enqueue_script( 'wpforo-widgets-js' );
49
  $instance = wpforo_parse_args( $instance, $this->default_instance );
51
  'boardid' => $instance['boardid'],
52
  'action' => 'wpforo_load_ajax_widget_Search',
53
  ];
54
+
55
+ if( WPF()->board->get_current( 'boardid' ) === $instance['boardid'] ){
56
+ $html = $this->get_widget();
57
+ $onload = false;
58
+ }else{
59
+ $html = '<div style="text-align: center; font-size: 20px;"><i class="fas fa-spinner fa-spin"></i></div>';
60
+ $onload = true;
61
+ $data['referer'] = home_url();
62
+ }
63
  $json = json_encode( $data );
64
 
65
  echo $args['before_widget'] . '<div id="wpf-widget-search" class="wpforo-widget-wrap">';
66
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
67
+ 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'];
68
  }
69
 
70
  public function form( $instance ) {
widgets/Tags.php CHANGED
@@ -26,9 +26,7 @@ class Tags extends WP_Widget {
26
  ];
27
  }
28
 
29
- public function load_ajax_widget() {
30
- $_POST = wp_unslash( $_POST );
31
- $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
32
  $tag_args = [ 'row_count' => (int) wpfval( $instance, 'count' ) ];
33
  $tags = WPF()->topic->get_tags( $tag_args, $items_count );
34
  ob_start();
@@ -47,9 +45,15 @@ class Tags extends WP_Widget {
47
  echo '<p style="text-align:center">' . wpforo_phrase( 'No tags found', false ) . '</p>';
48
  }
49
 
50
- wp_send_json_success( [ 'html' => ob_get_clean() ] );
51
  }
52
 
 
 
 
 
 
 
53
  public function widget( $args, $instance ) {
54
  wp_enqueue_script( 'wpforo-widgets-js' );
55
  $instance = wpforo_parse_args( $instance, $this->default_instance );
@@ -58,12 +62,19 @@ class Tags extends WP_Widget {
58
  'action' => 'wpforo_load_ajax_widget_Tags',
59
  'instance' => $instance,
60
  ];
61
- if( WPF()->board->get_current( 'boardid' ) !== $instance['boardid'] ) $data['referer'] = home_url();
 
 
 
 
 
 
 
62
  $json = json_encode( $data );
63
 
64
  echo $args['before_widget'] . '<div id="wpf-widget-tags" class="wpforo-widget-wrap">';
65
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
66
- echo '<div class="wpforo-widget-content wpforo-ajax-widget" data-json="' . esc_attr( $json ) . '"></div></div>' . $args['after_widget'];
67
  }
68
 
69
  public function form( $instance ) {
26
  ];
27
  }
28
 
29
+ public function get_widget( $instance ) {
 
 
30
  $tag_args = [ 'row_count' => (int) wpfval( $instance, 'count' ) ];
31
  $tags = WPF()->topic->get_tags( $tag_args, $items_count );
32
  ob_start();
45
  echo '<p style="text-align:center">' . wpforo_phrase( 'No tags found', false ) . '</p>';
46
  }
47
 
48
+ return ob_get_clean();
49
  }
50
 
51
+ public function load_ajax_widget() {
52
+ $_POST = wp_unslash( $_POST );
53
+ $instance = json_decode( (string) wpfval( $_POST, 'instance' ), true );
54
+ wp_send_json_success( [ 'html' => $this->get_widget( $instance ) ] );
55
+ }
56
+
57
  public function widget( $args, $instance ) {
58
  wp_enqueue_script( 'wpforo-widgets-js' );
59
  $instance = wpforo_parse_args( $instance, $this->default_instance );
62
  'action' => 'wpforo_load_ajax_widget_Tags',
63
  'instance' => $instance,
64
  ];
65
+ if( WPF()->board->get_current( 'boardid' ) === $instance['boardid'] ){
66
+ $html = $this->get_widget( $data['instance'] );
67
+ $onload = false;
68
+ }else{
69
+ $html = '<div style="text-align: center; font-size: 20px;"><i class="fas fa-spinner fa-spin"></i></div>';
70
+ $onload = true;
71
+ $data['referer'] = home_url();
72
+ }
73
  $json = json_encode( $data );
74
 
75
  echo $args['before_widget'] . '<div id="wpf-widget-tags" class="wpforo-widget-wrap">';
76
  if( $instance['title'] ) echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
77
+ 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'];
78
  }
79
 
80
  public function form( $instance ) {
wpforo.php CHANGED
@@ -5,14 +5,14 @@
5
  * Description: WordPress Forum plugin. wpForo is a full-fledged forum solution for your community. Comes with multiple modern forum layouts.
6
  * Author: gVectors Team
7
  * Author URI: https://gvectors.com/
8
- * Version: 2.1.0
9
  * Text Domain: wpforo
10
  * Domain Path: /languages
11
  */
12
 
13
  namespace wpforo;
14
 
15
- define( 'WPFORO_VERSION', '2.1.0' );
16
 
17
  //Exit if accessed directly
18
  if( ! defined( 'ABSPATH' ) ) exit;
5
  * Description: WordPress Forum plugin. wpForo is a full-fledged forum solution for your community. Comes with multiple modern forum layouts.
6
  * Author: gVectors Team
7
  * Author URI: https://gvectors.com/
8
+ * Version: 2.1.1
9
  * Text Domain: wpforo
10
  * Domain Path: /languages
11
  */
12
 
13
  namespace wpforo;
14
 
15
+ define( 'WPFORO_VERSION', '2.1.1' );
16
 
17
  //Exit if accessed directly
18
  if( ! defined( 'ABSPATH' ) ) exit;