wpForo Forum - Version 1.6.3

Version Description

Download this release

Release Info

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

Code changes from version 1.6.2 to 1.6.3

Files changed (44) hide show
  1. readme.txt +44 -11
  2. wpf-admin/forum.php +2 -2
  3. wpf-admin/options-tabs/members.php +1 -1
  4. wpf-admin/options-tabs/posts.php +46 -0
  5. wpf-admin/xml/english.xml +10 -0
  6. wpf-assets/addons/wpforo-emoticons/header-off.png +0 -0
  7. wpf-assets/addons/wpforo-emoticons/header.png +0 -0
  8. wpf-assets/js/ajax.js +296 -67
  9. wpf-assets/js/frontend.js +66 -33
  10. wpf-includes/class-forms.php +1 -1
  11. wpf-includes/class-forums.php +3 -1
  12. wpf-includes/class-members.php +21 -4
  13. wpf-includes/class-permissions.php +3 -0
  14. wpf-includes/class-phrases.php +1 -1
  15. wpf-includes/class-posts.php +2 -2
  16. wpf-includes/class-revisions.php +458 -0
  17. wpf-includes/class-template.php +39 -12
  18. wpf-includes/class-topics.php +2 -0
  19. wpf-includes/class-usergroups.php +6 -6
  20. wpf-includes/functions-template.php +8 -3
  21. wpf-includes/functions.php +86 -67
  22. wpf-includes/install-sql.php +28 -15
  23. wpf-includes/integration/buddypress.php +10 -1
  24. wpf-includes/integration/ultimate-member.php +2 -1
  25. wpf-includes/wpf-actions.php +33 -27
  26. wpf-includes/wpf-hooks.php +99 -103
  27. wpf-includes/wpf-phrases.php +12 -0
  28. wpf-languages/wpforo-de_DE.mo +0 -0
  29. wpf-languages/wpforo-de_DE.po +6545 -6110
  30. wpf-languages/wpforo.pot +219 -132
  31. wpf-themes/classic/colors.css +17 -5
  32. wpf-themes/classic/footer.php +1 -3
  33. wpf-themes/classic/layouts/3/comment.php +1 -1
  34. wpf-themes/classic/layouts/3/post.php +1 -1
  35. wpf-themes/classic/members.php +1 -1
  36. wpf-themes/classic/profile-activity.php +1 -1
  37. wpf-themes/classic/profile-home.php +1 -1
  38. wpf-themes/classic/profile.php +1 -1
  39. wpf-themes/classic/recent.php +1 -0
  40. wpf-themes/classic/search.php +1 -1
  41. wpf-themes/classic/style-rtl.css +53 -52
  42. wpf-themes/classic/style.css +63 -30
  43. wpf-themes/classic/styles/matrix.css +18 -6
  44. wpforo.php +34 -27
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: gVectors Team
3
Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
Requires at least: 4.1
5
Tested up to: 5.2
6
- Stable tag: 1.6.2
7
- Requires PHP: 5.5 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
@@ -164,6 +164,48 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
164
165
== Changelog ==
166
167
= wpForo Forum 1.6.2 | 11.07.2019 =
168
169
[wpForo Forum v1.6.2 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-2-is-released/)
@@ -209,15 +251,6 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
209
* Optimization: Better performance, lower database queries...
210
211
212
- IMPORTANT NOTES for UPDATE
213
-
214
- - If you're updating from wpForo Forum versions less than 1.6.0, please read the "Important notes and update" section of 1.6.0 version below.
215
- - Forum template files are modified. If you have an old customized copies of forum template files in your WP theme /wpforo/ folder please update them.
216
- - To load your customized colors please refresh forum front-end page twice.
217
- - If you have a Cache Plugin, please delete all caches after wpForo update.
218
- - If you use CDN and found some issue please purge it.
219
-
220
-
221
= wpForo Forum 1.6.1 | 10.03.2019 =
222
223
[wpForo Forum v1.6.1 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-1-is-released/)
3
Tags: forum, forums, forum plugin, WordPress forum plugin, community, discussion
4
Requires at least: 4.1
5
Tested up to: 5.2
6
+ Stable tag: 1.6.3
7
+ Requires PHP: 5.6 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
164
165
== Changelog ==
166
167
+ = wpForo Forum 1.6.3 | 01.09.2019 =
168
+
169
+ [wpForo Forum v1.6.3 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-3-is-released/)
170
+
171
+ * Added: Post preview button
172
+ * Added: Save post draft
173
+ * Added: Auto drafting of post editor content
174
+ * Added: Revisions system based post draft
175
+ * Added: Multiple revisions with options to restore and delete
176
+ * Added: Option to enable / disable post preview and drafting
177
+ * Added: Option to set max number of revisions
178
+ * Added: Option to set auto-drafting interval
179
+ * Added: Current user profile shortcode `[wpforo item="profile"]`
180
+ * Added: Changed last poster avatar link to last reply in Threaed Layout
181
+ * Added: German translation update, many thanks to Birgit Barth
182
+ * Added: Hook `wpforo_replace_buddypress_avatar` to replace BuddyPress avatar
183
+ * New Addon: [wpForo Emoticons](https://gvectors.com/product/wpforo-emoticons/)
184
+ * Fixed Bug: Wrong last post and date info on Simplified Layout forums
185
+ * Fixed Bug: Fix Spoiler Bug when spoiler title contains apostrophes
186
+ * Fixed Bug: Topic and post icons on profile activity page
187
+ * Fixed Bug: Post dates don't reflect WP Date Format if the option is enabled.
188
+ * Fixed Bug: Allow brackets in topic title but still remove shortcodes
189
+ * Fixed Bug: No result when select "Not Replied Topics" in dropdown
190
+ * Fixed Bug: 404 error when forum search field is empty
191
+ * Fixed Bug: 404 error when regular page slug part matches with forum base path
192
+ * Fixed Bug: Forum Members linking to wrong user profile
193
+ * Fixed Bug: Forum tab in profile page in new versions of Ultimate Member plugin
194
+ * Fixed Bug: Report email is only being sent to first forum admin email address
195
+ * Fixed Bug: Some TinyMCE plugins are not loaded in forum editor
196
+ * Fixed Bug: PHP Warning message on saving forum members setting
197
+ * Fixed Bug: Strip shortcodes in forum search result
198
+ * Fixed Bug: Other small bugs.
199
+
200
+ IMPORTANT NOTES for UPDATE
201
+
202
+ - If you're updating from wpForo Forum versions less than 1.6.0, please read the "Important notes and update" section of 1.6.0 version below.
203
+ - Forum template files are modified. If you have an old customized copies of forum template files in your WP theme /wpforo/ folder please update them.
204
+ - To load your customized colors please refresh forum front-end page twice.
205
+ - If you have a Cache Plugin, please delete all caches after wpForo update.
206
+ - If you use CDN and found some issue please purge it.
207
+
208
+
209
= wpForo Forum 1.6.2 | 11.07.2019 =
210
211
[wpForo Forum v1.6.2 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-2-is-released/)
251
* Optimization: Better performance, lower database queries...
252
253
254
= wpForo Forum 1.6.1 | 10.03.2019 =
255
256
[wpForo Forum v1.6.1 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-1-is-released/)
wpf-admin/forum.php CHANGED
@@ -50,10 +50,10 @@
50
<?php if( !isset($_GET['action'])) : ?>
51
<?php if( WPF()->forum->manage() ): ?>
52
53
- <div class="wpf-info-bar" style="line-height: 1em; clear:both; padding: 5px 30px; font-size:15px; display:block; box-shadow:none; margin: 20px 0 10px 0; font-style: italic; background: #FFFFC6; width:90%; position: relative;">
54
<a href="https://wpforo.com/docs/root/categories-and-forums/forum-manager/" title="<?php _e('Read the documentation', 'wpforo') ?>" target="_blank" style="font-size: 16px; position: absolute; right: 15px; top: 15px;"><i class="far fa-question-circle"></i></a>
55
<ul style="list-style-type: disc; line-height:18px;">
56
- <li style="list-style:none; margin-left:-17px; font-style:normal; font-weight:bold;"><i class="fas fa-info-circle" aria-hidden="true"></i>&nbsp; <?php _e('Important Tips', 'wpforo'); ?></li>
57
<li><?php _e('Please drag and drop forum panels to set parent-child hierarchy.', 'wpforo'); ?></li>
58
<li><?php _e('If a category (blue panels) does not have forums (grey panels) it will not be displayed on front-end. Each category should contain at least one forum.', 'wpforo'); ?></li>
59
<li><?php _e('Forums can be displayed with different layouts (Extended, Simplified, Q&A, Threaded), just edit the top (blue panels) category and set the layout you want. Child forums\' layout depends on the top category (blue panels) layout. They cannot have a different layout.', 'wpforo'); ?></li>
50
<?php if( !isset($_GET['action'])) : ?>
51
<?php if( WPF()->forum->manage() ): ?>
52
53
+ <div class="wpf-info-bar" style="line-height: 1em; clear:both; padding: 5px 50px; box-sizing: border-box; font-size:15px; display:block; box-shadow:none; margin: 20px 0 10px 0; font-style: italic; background: #FFFFFF; width:100%; position: relative;">
54
<a href="https://wpforo.com/docs/root/categories-and-forums/forum-manager/" title="<?php _e('Read the documentation', 'wpforo') ?>" target="_blank" style="font-size: 16px; position: absolute; right: 15px; top: 15px;"><i class="far fa-question-circle"></i></a>
55
<ul style="list-style-type: disc; line-height:18px;">
56
+ <li style="list-style:none; margin-left:-17px; font-style:normal; font-weight:bold; padding-bottom: 5px;"><i class="fas fa-info-circle" aria-hidden="true"></i>&nbsp; <?php _e('Important Tips', 'wpforo'); ?></li>
57
<li><?php _e('Please drag and drop forum panels to set parent-child hierarchy.', 'wpforo'); ?></li>
58
<li><?php _e('If a category (blue panels) does not have forums (grey panels) it will not be displayed on front-end. Each category should contain at least one forum.', 'wpforo'); ?></li>
59
<li><?php _e('Forums can be displayed with different layouts (Extended, Simplified, Q&A, Threaded), just edit the top (blue panels) category and set the layout you want. Child forums\' layout depends on the top category (blue panels) layout. They cannot have a different layout.', 'wpforo'); ?></li>
wpf-admin/options-tabs/members.php CHANGED
@@ -27,7 +27,7 @@
27
<th><label><?php _e('Members URL structure', 'wpforo'); ?> <a href="https://wpforo.com/docs/root/wpforo-settings/members-settings/#members-url" title="<?php _e('Read the documentation', 'wpforo') ?>" target="_blank"><i class="far fa-question-circle"></i></a></label></th>
28
<td>
29
<?php $opt_id_attr = ''; $opt_nicename_attr = ''; ?>
30
- <?php if( wpfo(WPF()->member->options['url_structure'], false) == 'id' ){ $opt_id_attr = 'checked="checked"'; }else{ $opt_nicename_attr = 'checked="checked"'; } ?>
31
<input id="id" type="radio" name="wpforo_member_options[url_structure]" value="id" <?php echo $opt_id_attr ?>/><label style="color: gray" for="id"><?php echo wpforo_home_url() ?>profile/<b style="color: #4093bf">USER_ID</b>/</label><br/>
32
<input id="nicename" type="radio" name="wpforo_member_options[url_structure]" value="nicename" <?php echo $opt_nicename_attr ?>/><label style="color: gray" for="nicename"><?php echo wpforo_home_url() ?>profile/<b style="color: #4093bf">USER_NICENAME</b>/</label>
33
</td>
27
<th><label><?php _e('Members URL structure', 'wpforo'); ?> <a href="https://wpforo.com/docs/root/wpforo-settings/members-settings/#members-url" title="<?php _e('Read the documentation', 'wpforo') ?>" target="_blank"><i class="far fa-question-circle"></i></a></label></th>
28
<td>
29
<?php $opt_id_attr = ''; $opt_nicename_attr = ''; ?>
30
+ <?php if( wpfo(WPF()->member->options['url_structure'], false) === 'id' ){ $opt_id_attr = 'checked="checked"'; }else{ $opt_nicename_attr = 'checked="checked"'; } ?>
31
<input id="id" type="radio" name="wpforo_member_options[url_structure]" value="id" <?php echo $opt_id_attr ?>/><label style="color: gray" for="id"><?php echo wpforo_home_url() ?>profile/<b style="color: #4093bf">USER_ID</b>/</label><br/>
32
<input id="nicename" type="radio" name="wpforo_member_options[url_structure]" value="nicename" <?php echo $opt_nicename_attr ?>/><label style="color: gray" for="nicename"><?php echo wpforo_home_url() ?>profile/<b style="color: #4093bf">USER_NICENAME</b>/</label>
33
</td>
wpf-admin/options-tabs/posts.php CHANGED
@@ -203,6 +203,52 @@
203
<textarea name="wpforo_post_options[attach_cant_view_msg]"><?php echo esc_textarea( ( !empty( WPF()->post->options['attach_cant_view_msg'] ) ? WPF()->post->options['attach_cant_view_msg'] : '' ) ) ?></textarea>
204
</td>
205
</tr>
206
<?php do_action('wpforo_settings_post_bottom'); ?>
207
</tbody>
208
</table>
203
<textarea name="wpforo_post_options[attach_cant_view_msg]"><?php echo esc_textarea( ( !empty( WPF()->post->options['attach_cant_view_msg'] ) ? WPF()->post->options['attach_cant_view_msg'] : '' ) ) ?></textarea>
204
</td>
205
</tr>
206
+
207
+ <tr>
208
+ <th><?php _e('Post Preview and Draft Saving', 'wpforo') ?></th>
209
+ <td>
210
+ <table>
211
+ <tr style="background-color: transparent;">
212
+ <td style="border-bottom: 1px dashed #aaaaaa; width: auto;">
213
+ <div class="wpf-switch-field">
214
+ <input id="is_preview_on_1" type="radio" name="wpforo_revision_options[is_preview_on]" value="1" <?php wpfo_check(WPF()->revision->options['is_preview_on'], 1); ?>/><label for="is_preview_on_1"><?php _e('Enable','wpforo'); ?></label> &nbsp;
215
+ <input id="is_preview_on_0" type="radio" name="wpforo_revision_options[is_preview_on]" value="0" <?php wpfo_check(WPF()->revision->options['is_preview_on'], 0); ?>/><label for="is_preview_on_0"><?php _e('Disable','wpforo'); ?></label>
216
+ </div>
217
+ </td>
218
+ <th style="border-bottom: 1px dashed #aaaaaa; padding-left: 0;"><label style="font-weight: normal;"><?php _e('Post Preview', 'wpforo'); ?></label></th>
219
+ </tr>
220
+ <tr style="background-color: transparent;">
221
+ <td style="border-bottom: 1px dashed #aaaaaa; width: auto;">
222
+ <div class="wpf-switch-field">
223
+ <input id="is_draft_on_1" type="radio" name="wpforo_revision_options[is_draft_on]" value="1" <?php wpfo_check(WPF()->revision->options['is_draft_on'], 1); ?>/><label for="is_draft_on_1"><?php _e('Enable','wpforo'); ?></label> &nbsp;
224
+ <input id="is_draft_on_0" type="radio" name="wpforo_revision_options[is_draft_on]" value="0" <?php wpfo_check(WPF()->revision->options['is_draft_on'], 0); ?>/><label for="is_draft_on_0"><?php _e('Disable','wpforo'); ?></label>
225
+ </div>
226
+ </td>
227
+ <th style="border-bottom: 1px dashed #aaaaaa; padding-left: 0;"><label style="font-weight: normal;"><?php _e('Post Draft', 'wpforo'); ?></label></th>
228
+ </tr>
229
+ <tr style="background-color: transparent;">
230
+ <td style="border-bottom: 1px dashed #aaaaaa; width: auto;">
231
+ <select name="wpforo_revision_options[auto_draft_interval]" id="auto_draft_interval">
232
+ <option value="0" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 0, 'selected'); ?>><?php _e('disabled', 'wpforo') ?></option>
233
+ <option value="15000" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 15000, 'selected'); ?>><?php _e('15 seconds', 'wpforo') ?></option>
234
+ <option value="30000" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 30000, 'selected'); ?>><?php _e('30 seconds', 'wpforo') ?></option>
235
+ <option value="60000" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 60000, 'selected'); ?>><?php _e('1 minute', 'wpforo') ?></option>
236
+ <option value="120000" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 120000, 'selected'); ?>><?php _e('2 minutes', 'wpforo') ?></option>
237
+ <option value="300000" <?php wpfo_check(WPF()->revision->options['auto_draft_interval'], 300000, 'selected'); ?>><?php _e('5 minutes', 'wpforo') ?></option>
238
+ </select>
239
+ </td>
240
+ <th style="border-bottom: 1px dashed #aaaaaa; padding-left: 0;"><label for="auto_draft_interval" style="font-weight: normal; white-space: nowrap;"><?php _e('Auto Drafting Interval', 'wpforo'); ?></label></th>
241
+ </tr>
242
+ <tr style="background-color: transparent;">
243
+ <td style="border-bottom: 1px dashed #aaaaaa; width: auto;">
244
+ <input id="max_drafts_per_page" type="number" min="3" name="wpforo_revision_options[max_drafts_per_page]" value="<?php wpfo(WPF()->revision->options['max_drafts_per_page']) ?>" class="wpf-field-small" />
245
+ </td>
246
+ <th style="border-bottom: 1px dashed #aaaaaa; padding-left: 0; white-space: nowrap;"><label for="max_drafts_per_page" style="font-weight: normal;"><?php _e('Max Number of Revisions', 'wpforo'); ?></label></th>
247
+ </tr>
248
+ </table>
249
+ </td>
250
+ </tr>
251
+
252
<?php do_action('wpforo_settings_post_bottom'); ?>
253
</tbody>
254
</table>
wpf-admin/xml/english.xml CHANGED
@@ -671,4 +671,14 @@
671
<phrase name="%s Replies"><![CDATA[%s Replies]]></phrase>
672
<phrase name="%s Reply"><![CDATA[%s Reply]]></phrase>
673
<phrase name="Quote this text"><![CDATA[Quote this text]]>
674
</language>
671
<phrase name="%s Replies"><![CDATA[%s Replies]]></phrase>
672
<phrase name="%s Reply"><![CDATA[%s Reply]]></phrase>
673
<phrase name="Quote this text"><![CDATA[Quote this text]]>
674
+ <phrase name="Preview"><![CDATA[Preview]]>
675
+ <phrase name="Revision"><![CDATA[Revision]]>
676
+ <phrase name="Revisions"><![CDATA[Revisions]]>
677
+ <phrase name="%1$s Revisions"><![CDATA[%1$s Revisions]]>
678
+ <phrase name="Saved"><![CDATA[Saved]]>
679
+ <phrase name="Restore"><![CDATA[Restore]]>
680
+ <phrase name="Save Draft"><![CDATA[Save Draft]]>
681
+ <phrase name="Saving Draft"><![CDATA[Saving Draft]]>
682
+ <phrase name="Loading Topics"><![CDATA[Loading Topics]]>
683
+ <phrase name="Topic Tag:"><![CDATA[Topic Tag:]]>
684
</language>
wpf-assets/addons/wpforo-emoticons/header-off.png ADDED
Binary file
wpf-assets/addons/wpforo-emoticons/header.png ADDED
Binary file
wpf-assets/js/ajax.js CHANGED
@@ -36,8 +36,7 @@ jQuery(document).ready(function ($) {
36
37
// Like
38
wpforo_wrap.on('click', '.wpforo-like', function () {
39
- $("#wpf-msg-box").hide();
40
- $('#wpforo-load').visible();
41
var postid = $(this).data('postid'),
42
that = $(this);
43
$.ajax({
@@ -67,14 +66,13 @@ jQuery(document).ready(function ($) {
67
like_count = parseInt(like_count) + 1;
68
that.children(".wpf-like-count").text(like_count);
69
}
70
- $('#wpforo-load').invisible();
71
wpforo_notice_show(response.notice);
72
});
73
});
74
// unlike
75
wpforo_wrap.on('click', '.wpforo-unlike', function () {
76
- $("#wpf-msg-box").hide();
77
- $('#wpforo-load').visible();
78
var postid = $(this).data('postid'),
79
that = $(this);
80
$.ajax({
@@ -104,7 +102,7 @@ jQuery(document).ready(function ($) {
104
like_count = parseInt(like_count) - 1;
105
that.children(".wpf-like-count").text(like_count);
106
}
107
- $('#wpforo-load').invisible();
108
wpforo_notice_show(response.notice);
109
});
110
});
@@ -112,8 +110,7 @@ jQuery(document).ready(function ($) {
112
113
// Vote
114
wpforo_wrap.on('click', '.wpforo-voteup', function () {
115
- $("#wpf-msg-box").hide();
116
- $('#wpforo-load').visible();
117
var type = $(this).data('type'),
118
postid = $(this).data('postid'),
119
that = $(this);
@@ -137,14 +134,13 @@ jQuery(document).ready(function ($) {
137
count = wpfvote_num.text();
138
wpfvote_num.text(++count).fadeIn();
139
}
140
- $('#wpforo-load').invisible();
141
wpforo_notice_show(response.notice);
142
});
143
});
144
145
wpforo_wrap.on('click', '.wpforo-votedown', function () {
146
- $("#wpf-msg-box").hide();
147
- $('#wpforo-load').visible();
148
var type = $(this).data('type'),
149
postid = $(this).data('postid'),
150
that = $(this);
@@ -168,7 +164,7 @@ jQuery(document).ready(function ($) {
168
count = wpfvote_num.text();
169
wpfvote_num.text(--count).fadeIn();
170
}
171
- $('#wpforo-load').invisible();
172
wpforo_notice_show(response.notice);
173
});
174
});
@@ -176,8 +172,7 @@ jQuery(document).ready(function ($) {
176
177
// Answer
178
wpforo_wrap.on('click', '.wpf-toggle-answer', function () {
179
- $("#wpf-msg-box").hide();
180
- $('#wpforo-load').visible();
181
var postid = $(this).data('postid'),
182
that = $(this);
183
$.ajax({
@@ -200,14 +195,13 @@ jQuery(document).ready(function ($) {
200
window.location.reload();
201
}, 300);
202
}
203
- $('#wpforo-load').invisible();
204
wpforo_notice_show(response.notice);
205
});
206
});
207
208
wpforo_wrap.on('click', '.wpf-toggle-not-answer', function () {
209
- $("#wpf-msg-box").hide();
210
- $('#wpforo-load').visible();
211
var postid = $(this).data('postid'),
212
that = $(this);
213
$.ajax({
@@ -230,7 +224,7 @@ jQuery(document).ready(function ($) {
230
window.location.reload();
231
}, 300);
232
}
233
- $('#wpforo-load').invisible();
234
wpforo_notice_show(response.notice);
235
});
236
});
@@ -238,8 +232,7 @@ jQuery(document).ready(function ($) {
238
239
// Quote
240
wpforo_wrap.on('click', '.wpforo-quote', function () {
241
- $("#wpf-msg-box").hide();
242
- $("#wpforo-load").visible();
243
244
$('#wpf-form-wrapper').show();
245
@@ -281,15 +274,13 @@ jQuery(document).ready(function ($) {
281
wpforo_editor.set_content( response, wpforo_editor.get_main() );
282
283
$('html, body').animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000);
284
- $('#wpforo-load').invisible();
285
});
286
});
287
288
// Report
289
wpforo_wrap.on('click', '.wpforo-report', function(){
290
- var wpforo_load = $('#wpforo-load');
291
- $("#wpf-msg-box").hide();
292
- wpforo_load.visible();
293
var postid = $(this).data('postid');
294
$('#wpf_reportpostid').attr('value', postid);
295
@@ -313,12 +304,11 @@ jQuery(document).ready(function ($) {
313
});
314
315
dialog.dialog( "open" );
316
- wpforo_load.invisible();
317
});
318
319
$("#wpf_reportdialog").on('click', '#wpf_sendreport', function () {
320
- $("#wpf-msg-box").hide();
321
- $('#wpforo-load').visible();
322
var postid = $('#wpf_reportpostid').attr('value');
323
var messagecontent = $('#wpf_reportmessagecontent').attr('value');
324
@@ -337,7 +327,7 @@ jQuery(document).ready(function ($) {
337
console.log(e);
338
}
339
$("#wpf_reportdialog").dialog('close');
340
- $('#wpforo-load').invisible();
341
wpforo_notice_show(response);
342
});
343
});
@@ -345,8 +335,7 @@ jQuery(document).ready(function ($) {
345
346
// Sticky
347
wpforo_wrap.on('click', '.wpforo-sticky', function () {
348
- $("#wpf-msg-box").hide();
349
- $('#wpforo-load').visible();
350
var topicid = $(this).data('topicid'),
351
that = $(this);
352
@@ -371,15 +360,14 @@ jQuery(document).ready(function ($) {
371
that.attr("wpf-tooltip", wpforo_phrase('Unsticky') );
372
}
373
}
374
- $('#wpforo-load').invisible();
375
wpforo_notice_show(response.notice);
376
});
377
});
378
379
380
wpforo_wrap.on('click', '.wpforo-unsticky', function () {
381
- $("#wpf-msg-box").hide();
382
- $('#wpforo-load').visible();
383
var topicid = $(this).data('topicid'),
384
that = $(this);
385
@@ -404,14 +392,14 @@ jQuery(document).ready(function ($) {
404
that.attr("wpf-tooltip", wpforo_phrase('Sticky') );
405
}
406
}
407
- $('#wpforo-load').invisible();
408
wpforo_notice_show(response.notice);
409
});
410
});
411
412
// Approve
413
wpforo_wrap.on('click','.wpforo-approve', function(){
414
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
415
var status_value = 'approve';
416
var postid_value = $(this).attr('id'),
417
that = $(this);
@@ -436,14 +424,14 @@ jQuery(document).ready(function ($) {
436
that.attr("wpf-tooltip", wpforo_phrase('Unapprove') );
437
}
438
}
439
- $('#wpforo-load').invisible();
440
window.location.reload();
441
});
442
});
443
444
// Unapprove
445
wpforo_wrap.on('click','.wpforo-unapprove', function(){
446
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
447
var status_value = 'unapprove';
448
var postid_value = $(this).attr('id'),
449
that = $(this);
@@ -468,7 +456,7 @@ jQuery(document).ready(function ($) {
468
that.attr("wpf-tooltip", wpforo_phrase('Approve') );
469
}
470
}
471
- $('#wpforo-load').invisible();
472
window.location.reload();
473
});
474
});
@@ -476,7 +464,7 @@ jQuery(document).ready(function ($) {
476
477
// Private
478
wpforo_wrap.on('click','.wpforo-private', function(){
479
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
480
var status_value = 'private';
481
var postid_value = $(this).attr('id'),
482
that = $(this);
@@ -499,12 +487,12 @@ jQuery(document).ready(function ($) {
499
that.attr("wpf-tooltip", wpforo_phrase('Public') );
500
}
501
}
502
- $('#wpforo-load').invisible();
503
});
504
});
505
506
wpforo_wrap.on('click','.wpforo-public', function(){
507
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
508
var status_value = 'public';
509
var postid_value = $(this).attr('id'),
510
that = $(this);
@@ -527,13 +515,13 @@ jQuery(document).ready(function ($) {
527
that.attr("wpf-tooltip", wpforo_phrase('Private') );
528
}
529
}
530
- $('#wpforo-load').invisible();
531
});
532
});
533
534
// Solved
535
wpforo_wrap.on('click','.wpforo-solved', function(){
536
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
537
var status_value = 'solved';
538
var postid_value = $(this).attr('id'),
539
that = $(this);
@@ -555,12 +543,12 @@ jQuery(document).ready(function ($) {
555
that.attr("wpf-tooltip", wpforo_phrase('Unsolved') );
556
}
557
}
558
- $('#wpforo-load').invisible();
559
});
560
});
561
562
wpforo_wrap.on('click','.wpforo-unsolved', function(){
563
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
564
var status_value = 'unsolved';
565
var postid_value = $(this).attr('id'),
566
that = $(this);
@@ -582,14 +570,14 @@ jQuery(document).ready(function ($) {
582
that.attr("wpf-tooltip", wpforo_phrase('Solved') );
583
}
584
}
585
- $('#wpforo-load').invisible();
586
});
587
});
588
589
590
// Close
591
wpforo_wrap.on('click','.wpforo-close', function(){
592
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
593
var status_value = 'close';
594
var postid_value = $(this).attr('id'),
595
that = $(this);
@@ -617,12 +605,12 @@ jQuery(document).ready(function ($) {
617
$(".wpf-answer-button").remove();
618
$(".wpf-add-comment-button").remove();
619
}
620
- $('#wpforo-load').invisible();
621
});
622
});
623
624
wpforo_wrap.on('click','.wpforo-open', function(){
625
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
626
var status_value = 'closed';
627
var postid_value = $(this).attr('id'),
628
that = $(this);
@@ -645,7 +633,7 @@ jQuery(document).ready(function ($) {
645
}
646
window.location.assign(response);
647
}
648
- $('#wpforo-load').invisible();
649
650
});
651
});
@@ -653,7 +641,7 @@ jQuery(document).ready(function ($) {
653
654
// Edit
655
wpforo_wrap.on('click','.wpforo-edit', function(){
656
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
657
658
$('#wpf-form-wrapper').show();
659
@@ -717,7 +705,7 @@ jQuery(document).ready(function ($) {
717
$( 'html, body' ).animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000);
718
}
719
720
- $('#wpforo-load').invisible();
721
722
});
723
});
@@ -725,7 +713,7 @@ jQuery(document).ready(function ($) {
725
726
// Delete
727
wpforo_wrap.on('click', '.wpforo-delete', function(){
728
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
729
730
var ok = confirm(wpforo_ucwords( wpforo_phrase('are you sure you want to delete?') ));
731
@@ -772,22 +760,22 @@ jQuery(document).ready(function ($) {
772
}else{
773
window.location.assign(response.location);
774
}
775
- $('#wpforo-load').invisible();
776
}else{
777
- $('#wpforo-load').invisible();
778
}
779
780
wpforo_notice_show(response.notice);
781
});
782
}else{
783
- $('#wpforo-load').invisible();
784
}
785
});
786
787
788
// Subscribe
789
wpforo_wrap.on('click','.wpf-subscribe-forum, .wpf-subscribe-topic', function(){
790
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
791
var type = '';
792
var status = 'subscribe';
793
var clases = $(this).attr('class');
@@ -820,9 +808,9 @@ jQuery(document).ready(function ($) {
820
if( response.stat == 1 ){
821
$("#wpfsubscribe-" + itemid).removeClass('wpf-subscribe-' + type).addClass('wpf-unsubscribe-' + type);
822
$("#wpfsubscribe-" + itemid).text( ' ' + wpforo_phrase('Unsubscribe') );
823
- $('#wpforo-load').invisible();
824
}else{
825
- $('#wpforo-load').invisible();
826
}
827
828
wpforo_notice_show(response.notice);
@@ -831,7 +819,7 @@ jQuery(document).ready(function ($) {
831
});
832
833
wpforo_wrap.on('click','.wpf-unsubscribe-forum, .wpf-unsubscribe-topic', function(){
834
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
835
var type = '';
836
var button_phrase = '';
837
var status = 'unsubscribe';
@@ -865,9 +853,9 @@ jQuery(document).ready(function ($) {
865
if( response.stat == 1 ){
866
$("#wpfsubscribe-" + itemid).removeClass('wpf-unsubscribe-' + type).addClass('wpf-subscribe-' + type);
867
$("#wpfsubscribe-" + itemid).text( ' ' + button_phrase );
868
- $('#wpforo-load').invisible();
869
}else{
870
- $('#wpforo-load').invisible();
871
}
872
873
wpforo_notice_show(response.notice);
@@ -879,7 +867,7 @@ jQuery(document).ready(function ($) {
879
if( tools.is(':visible') ){
880
tools.slideUp(250, 'linear');
881
}else{
882
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
883
tools.find('.wpf-tool-tabs .wpf-tool-tab').removeClass('wpf-tt-active');
884
tools.find('.wpf-tool-tabs .wpf-tool-tab:first-child').addClass('wpf-tt-active');
885
wpforo_topic_tools_tab_load();
@@ -948,6 +936,10 @@ jQuery(document).ready(function ($) {
948
var append = paged !== 0;
949
topics_list.data('paged', ++paged);
950
951
var i = $('.wpf-load-threads a.wpf-threads-filter[data-filter="' + filter + '"] i', wrap);
952
var i_class = i.attr('class');
953
var i_spin_class = 'fas fa-circle-notch fa-spin';
@@ -996,12 +988,12 @@ jQuery(document).ready(function ($) {
996
997
i.toggleClass(i_toggle_class);
998
if(append) i2.toggleClass(i2_toggle_class);
999
- // wpforo_notice_show(response.notice);
1000
});
1001
});
1002
1003
wpforo_wrap.on('click', '.wpforo-qa-show-rest-comments', function () {
1004
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
1005
var $this = $(this);
1006
var wrap = $this.parents('.wpforo-qa-item-wrap');
1007
var root_wrap = wrap.children('.post-wrap');
@@ -1024,11 +1016,248 @@ jQuery(document).ready(function ($) {
1024
if (response.stat === 1) {
1025
comments_list.append(response.output_html);
1026
$this.remove();
1027
- $('#wpforo-load').invisible();
1028
}
1029
});
1030
});
1031
1032
});
1033
1034
function wpforo_ucwords (str) {
@@ -1055,7 +1284,7 @@ function wpforo_topic_tools_tab_load() {
1055
jQuery('#wpf_tool_tab_content_wrap').html(response);
1056
jQuery('#wpf_moderation_tools').slideDown(400, 'linear');
1057
}
1058
- jQuery('#wpforo-load').invisible();
1059
});
1060
}
1061
}
36
37
// Like
38
wpforo_wrap.on('click', '.wpforo-like', function () {
39
+ wpforo_load_show();
40
var postid = $(this).data('postid'),
41
that = $(this);
42
$.ajax({
66
like_count = parseInt(like_count) + 1;
67
that.children(".wpf-like-count").text(like_count);
68
}
69
+ wpforo_load_hide();
70
wpforo_notice_show(response.notice);
71
});
72
});
73
// unlike
74
wpforo_wrap.on('click', '.wpforo-unlike', function () {
75
+ wpforo_load_show();
76
var postid = $(this).data('postid'),
77
that = $(this);
78
$.ajax({
102
like_count = parseInt(like_count) - 1;
103
that.children(".wpf-like-count").text(like_count);
104
}
105
+ wpforo_load_hide();
106
wpforo_notice_show(response.notice);
107
});
108
});
110
111
// Vote
112
wpforo_wrap.on('click', '.wpforo-voteup', function () {
113
+ wpforo_load_show();
114
var type = $(this).data('type'),
115
postid = $(this).data('postid'),
116
that = $(this);
134
count = wpfvote_num.text();
135
wpfvote_num.text(++count).fadeIn();
136
}
137
+ wpforo_load_hide();
138
wpforo_notice_show(response.notice);
139
});
140
});
141
142
wpforo_wrap.on('click', '.wpforo-votedown', function () {
143
+ wpforo_load_show();
144
var type = $(this).data('type'),
145
postid = $(this).data('postid'),
146
that = $(this);
164
count = wpfvote_num.text();
165
wpfvote_num.text(--count).fadeIn();
166
}
167
+ wpforo_load_hide();
168
wpforo_notice_show(response.notice);
169
});
170
});
172
173
// Answer
174
wpforo_wrap.on('click', '.wpf-toggle-answer', function () {
175
+ wpforo_load_show();
176
var postid = $(this).data('postid'),
177
that = $(this);
178
$.ajax({
195
window.location.reload();
196
}, 300);
197
}
198
+ wpforo_load_hide();
199
wpforo_notice_show(response.notice);
200
});
201
});
202
203
wpforo_wrap.on('click', '.wpf-toggle-not-answer', function () {
204
+ wpforo_load_show();
205
var postid = $(this).data('postid'),
206
that = $(this);
207
$.ajax({
224
window.location.reload();
225
}, 300);
226
}
227
+ wpforo_load_hide();
228
wpforo_notice_show(response.notice);
229
});
230
});
232
233
// Quote
234
wpforo_wrap.on('click', '.wpforo-quote', function () {
235
+ wpforo_load_show();
236
237
$('#wpf-form-wrapper').show();
238
274
wpforo_editor.set_content( response, wpforo_editor.get_main() );
275
276
$('html, body').animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000);
277
+ wpforo_load_hide();
278
});
279
});
280
281
// Report
282
wpforo_wrap.on('click', '.wpforo-report', function(){
283
+ wpforo_load_show();
284
var postid = $(this).data('postid');
285
$('#wpf_reportpostid').attr('value', postid);
286
304
});
305
306
dialog.dialog( "open" );
307
+ wpforo_load_hide();
308
});
309
310
$("#wpf_reportdialog").on('click', '#wpf_sendreport', function () {
311
+ wpforo_load_show();
312
var postid = $('#wpf_reportpostid').attr('value');
313
var messagecontent = $('#wpf_reportmessagecontent').attr('value');
314
327
console.log(e);
328
}
329
$("#wpf_reportdialog").dialog('close');
330
+ wpforo_load_hide();
331
wpforo_notice_show(response);
332
});
333
});
335
336
// Sticky
337
wpforo_wrap.on('click', '.wpforo-sticky', function () {
338
+ wpforo_load_show();
339
var topicid = $(this).data('topicid'),
340
that = $(this);
341
360
that.attr("wpf-tooltip", wpforo_phrase('Unsticky') );
361
}
362
}
363
+ wpforo_load_hide();
364
wpforo_notice_show(response.notice);
365
});
366
});
367
368
369
wpforo_wrap.on('click', '.wpforo-unsticky', function () {
370
+ wpforo_load_show();
371
var topicid = $(this).data('topicid'),
372
that = $(this);
373
392
that.attr("wpf-tooltip", wpforo_phrase('Sticky') );
393
}
394
}
395
+ wpforo_load_hide();
396
wpforo_notice_show(response.notice);
397
});
398
});
399
400
// Approve
401
wpforo_wrap.on('click','.wpforo-approve', function(){
402
+ wpforo_load_show();
403
var status_value = 'approve';
404
var postid_value = $(this).attr('id'),
405
that = $(this);
424
that.attr("wpf-tooltip", wpforo_phrase('Unapprove') );
425
}
426
}
427
+ wpforo_load_hide();
428
window.location.reload();
429
});
430
});
431
432
// Unapprove
433
wpforo_wrap.on('click','.wpforo-unapprove', function(){
434
+ wpforo_load_show();
435
var status_value = 'unapprove';
436
var postid_value = $(this).attr('id'),
437
that = $(this);
456
that.attr("wpf-tooltip", wpforo_phrase('Approve') );
457
}
458
}
459
+ wpforo_load_hide();
460
window.location.reload();
461
});
462
});
464
465
// Private
466
wpforo_wrap.on('click','.wpforo-private', function(){
467
+ wpforo_load_show();
468
var status_value = 'private';
469
var postid_value = $(this).attr('id'),
470
that = $(this);
487
that.attr("wpf-tooltip", wpforo_phrase('Public') );
488
}
489
}
490
+ wpforo_load_hide();
491
});
492
});
493
494
wpforo_wrap.on('click','.wpforo-public', function(){
495
+ wpforo_load_show();
496
var status_value = 'public';
497
var postid_value = $(this).attr('id'),
498
that = $(this);
515
that.attr("wpf-tooltip", wpforo_phrase('Private') );
516
}
517
}
518
+ wpforo_load_hide();
519
});
520
});
521
522
// Solved
523
wpforo_wrap.on('click','.wpforo-solved', function(){
524
+ wpforo_load_show();
525
var status_value = 'solved';
526
var postid_value = $(this).attr('id'),
527
that = $(this);
543
that.attr("wpf-tooltip", wpforo_phrase('Unsolved') );
544
}
545
}
546
+ wpforo_load_hide();
547
});
548
});
549
550
wpforo_wrap.on('click','.wpforo-unsolved', function(){
551
+ wpforo_load_show();
552
var status_value = 'unsolved';
553
var postid_value = $(this).attr('id'),
554
that = $(this);
570
that.attr("wpf-tooltip", wpforo_phrase('Solved') );
571
}
572
}
573
+ wpforo_load_hide();
574
});
575
});
576
577
578
// Close
579
wpforo_wrap.on('click','.wpforo-close', function(){
580
+ wpforo_load_show();
581
var status_value = 'close';
582
var postid_value = $(this).attr('id'),
583
that = $(this);
605
$(".wpf-answer-button").remove();
606
$(".wpf-add-comment-button").remove();
607
}
608
+ wpforo_load_hide();
609
});
610
});
611
612
wpforo_wrap.on('click','.wpforo-open', function(){
613
+ wpforo_load_show();
614
var status_value = 'closed';
615
var postid_value = $(this).attr('id'),
616
that = $(this);
633
}
634
window.location.assign(response);
635
}
636
+ wpforo_load_hide();
637
638
});
639
});
641
642
// Edit
643
wpforo_wrap.on('click','.wpforo-edit', function(){
644
+ wpforo_load_show();
645
646
$('#wpf-form-wrapper').show();
647
705
$( 'html, body' ).animate({scrollTop: $("#wpf-form-wrapper").offset().top}, 1000);
706
}
707
708
+ wpforo_load_hide();
709
710
});
711
});
713
714
// Delete
715
wpforo_wrap.on('click', '.wpforo-delete', function(){
716
+ wpforo_load_show();
717
718
var ok = confirm(wpforo_ucwords( wpforo_phrase('are you sure you want to delete?') ));
719
760
}else{
761
window.location.assign(response.location);
762
}
763
+ wpforo_load_hide();
764
}else{
765
+ wpforo_load_hide();
766
}
767
768
wpforo_notice_show(response.notice);
769
});
770
}else{
771
+ wpforo_load_hide();
772
}
773
});
774
775
776
// Subscribe
777
wpforo_wrap.on('click','.wpf-subscribe-forum, .wpf-subscribe-topic', function(){
778
+ wpforo_load_show();
779
var type = '';
780
var status = 'subscribe';
781
var clases = $(this).attr('class');
808
if( response.stat == 1 ){
809
$("#wpfsubscribe-" + itemid).removeClass('wpf-subscribe-' + type).addClass('wpf-unsubscribe-' + type);
810
$("#wpfsubscribe-" + itemid).text( ' ' + wpforo_phrase('Unsubscribe') );
811
+ wpforo_load_hide();
812
}else{
813
+ wpforo_load_hide();
814
}
815
816
wpforo_notice_show(response.notice);
819
});
820
821
wpforo_wrap.on('click','.wpf-unsubscribe-forum, .wpf-unsubscribe-topic', function(){
822
+ wpforo_load_show();
823
var type = '';
824
var button_phrase = '';
825
var status = 'unsubscribe';
853
if( response.stat == 1 ){
854
$("#wpfsubscribe-" + itemid).removeClass('wpf-unsubscribe-' + type).addClass('wpf-subscribe-' + type);
855
$("#wpfsubscribe-" + itemid).text( ' ' + button_phrase );
856
+ wpforo_load_hide();
857
}else{
858
+ wpforo_load_hide();
859
}
860
861
wpforo_notice_show(response.notice);
867
if( tools.is(':visible') ){
868
tools.slideUp(250, 'linear');
869
}else{
870
+ wpforo_load_show();
871
tools.find('.wpf-tool-tabs .wpf-tool-tab').removeClass('wpf-tt-active');
872
tools.find('.wpf-tool-tabs .wpf-tool-tab:first-child').addClass('wpf-tt-active');
873
wpforo_topic_tools_tab_load();
936
var append = paged !== 0;
937
topics_list.data('paged', ++paged);
938
939
+ var load_msg = wpforo_phrase('Loading Topics');
940
+
941
+ wpforo_load_show(load_msg);
942
+
943
var i = $('.wpf-load-threads a.wpf-threads-filter[data-filter="' + filter + '"] i', wrap);
944
var i_class = i.attr('class');
945
var i_spin_class = 'fas fa-circle-notch fa-spin';
988
989
i.toggleClass(i_toggle_class);
990
if(append) i2.toggleClass(i2_toggle_class);
991
+ wpforo_load_hide();
992
});
993
});
994
995
wpforo_wrap.on('click', '.wpforo-qa-show-rest-comments', function () {
996
+ wpforo_load_show();
997
var $this = $(this);
998
var wrap = $this.parents('.wpforo-qa-item-wrap');
999
var root_wrap = wrap.children('.post-wrap');
1016
if (response.stat === 1) {
1017
comments_list.append(response.output_html);
1018
$this.remove();
1019
+ wpforo_load_hide();
1020
}
1021
});
1022
});
1023
1024
+ wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_post_preview:not(.wpf-disabled)', function(){
1025
+ var $this = $(this);
1026
+ var ico = $('.wpf-rev-preview-ico', $this);
1027
+ var form = $this.closest('form[data-textareaid]');
1028
+
1029
+ //$('.wpforo_save_revision', form).click();
1030
+
1031
+ var textareaid = form.data('textareaid');
1032
+ var postid = $( 'input#wpf_formpostid', form ).val();
1033
+ var body = wpforo_editor.get_content('raw');
1034
+ var body_info = wpforo_editor.get_stats();
1035
+
1036
+ if( textareaid && body_info.has_content){
1037
+ wpforo_load_show();
1038
+ ico.toggleClass('fa-eye fa-circle-notch fa-spin');
1039
+ $.ajax({
1040
+ type: 'POST',
1041
+ data: {
1042
+ textareaid: textareaid,
1043
+ postid: postid,
1044
+ body: body,
1045
+ action: 'wpforo_post_preview'
1046
+ }
1047
+ }).done(function (response) {
1048
+ if( response ) {
1049
+ $('.wpforo-revisions-action-buttons .wpforo-revision-action-button', form).removeClass('wpf-rev-button-active');
1050
+ $this.addClass('wpf-rev-button-active');
1051
+ $('.wpforo-revisions-preview-wrap', form).html(response);
1052
+ }
1053
+ }).always(function(){
1054
+ wpforo_load_hide();
1055
+ ico.toggleClass('fa-eye fa-circle-notch fa-spin');
1056
+ });
1057
+ }
1058
+
1059
+ });
1060
+
1061
+ wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_save_revision', function () {
1062
+ if( $(this).is(':visible') ){
1063
+ var ico = $('.wpf-rev-save-ico', $(this));
1064
+ var form = $(this).closest('form[data-textareaid]');
1065
+ var textareaid = form.data('textareaid');
1066
+ var postid = $( 'input#wpf_formpostid', form ).val();
1067
+ var body = wpforo_editor.get_content('raw');
1068
+ var body_info = wpforo_editor.get_stats();
1069
+ if( textareaid && body_info.has_content && $.active === 0 ){
1070
+ wpforo_load_show('Saving Draft');
1071
+ ico.toggleClass('fa-save fa-circle-notch fa-spin');
1072
+ $.ajax({
1073
+ type: 'POST',
1074
+ data: {
1075
+ textareaid: textareaid,
1076
+ postid: postid,
1077
+ body: body,
1078
+ action: 'wpforo_save_revision'
1079
+ }
1080
+ }).done(function (response) {
1081
+ try{
1082
+ response = JSON.parse(response);
1083
+
1084
+ if( parseInt( response.revisionid ) ) {
1085
+ wpforo_deactivate_revision_action_buttons(form);
1086
+ $('.wpf-rev-history-count', form).text(response.revisions_count);
1087
+ if( response.revisionhtml && $('.wpforo_revisions_history', form).hasClass('wpf-rev-button-active') ){
1088
+ var revisions_preview_wrap = $('.wpforo-revisions-preview-wrap', form);
1089
+ revisions_preview_wrap.prepend(response.revisionhtml);
1090
+ var wpforo_revision = $('.wpforo-revision', revisions_preview_wrap);
1091
+ if( wpforo_revision.length >= wpforo.revision_options.max_drafts_per_page ){
1092
+ wpforo_revision.each(function (i) {
1093
+ if( i >= wpforo.revision_options.max_drafts_per_page ) $(this).remove();
1094
+ });
1095
+ }
1096
+ }
1097
+ }
1098
+ }catch (e) {
1099
+ console.log(e);
1100
+ }
1101
+ }).always(function(){
1102
+ wpforo_load_hide();
1103
+ ico.toggleClass('fa-save fa-circle-notch fa-spin');
1104
+ });
1105
+ }
1106
+ }
1107
+ });
1108
+
1109
+ wpforo_wrap.on('click', 'form[data-textareaid] .wpforo_revisions_history', function(){
1110
+ var $this = $(this);
1111
+ var ico = $('.wpf-rev-ico', $this);
1112
+ var form = $this.closest('form[data-textareaid]');
1113
+ var textareaid = form.data('textareaid');
1114
+ var postid = $( 'input#wpf_formpostid', form ).val();
1115
+
1116
+ if( textareaid && $.active === 0 ){
1117
+ wpforo_load_show();
1118
+ ico.toggleClass('fa-history fa-circle-notch fa-spin');
1119
+ $.ajax({
1120
+ type: 'POST',
1121
+ data: {
1122
+ textareaid: textareaid,
1123
+ postid: postid,
1124
+ action: 'wpforo_get_revisions_history'
1125
+ }
1126
+ }).done(function (response) {
1127
+ try{
1128
+ response = JSON.parse(response);
1129
+
1130
+ if( parseInt( response.revisions_count ) ) {
1131
+ $('.wpf-rev-history-count', form).text(response.revisions_count);
1132
+ $('.wpforo-revisions-action-buttons .wpforo-revision-action-button', form).removeClass('wpf-rev-button-active');
1133
+ $this.addClass('wpf-rev-button-active');
1134
+ $('.wpforo-revisions-preview-wrap', form).html(response.revisionhtml);
1135
+ }
1136
+ }catch (e) {
1137
+ console.log(e);
1138
+ }
1139
+ }).always(function(){
1140
+ wpforo_load_hide();
1141
+ ico.toggleClass('fa-history fa-circle-notch fa-spin');
1142
+ });
1143
+ }
1144
+ });
1145
+
1146
+ wpforo_wrap.on('click', 'form[data-textareaid] .wpforo-revision-action-restore', function(){
1147
+ var ico = $('.wpf-rev-ico', $(this));
1148
+ var form = $(this).closest('form[data-textareaid]');
1149
+ var rev_wrap = $(this).closest('.wpforo-revision[data-revisionid]');
1150
+ if( rev_wrap.length && $.active === 0 ){
1151
+ wpforo_load_show('Restore Revision');
1152
+ ico.toggleClass('fa-history fa-circle-notch fa-spin');
1153
+
1154
+ var revisionid = rev_wrap.data('revisionid');
1155
+ $.ajax({
1156
+ type: 'POST',
1157
+ data: {
1158
+ revisionid: revisionid,
1159
+ action: 'wpforo_get_revision'
1160
+ }
1161
+ }).done(function (response) {
1162
+ if( response ){
1163
+ try {
1164
+ response = JSON.parse(response);
1165
+ if( response.revisionid ){
1166
+ wpforo_editor.set_content(response.body);
1167
+ $('html, body').animate({ scrollTop: form.offset().top }, 500);
1168
+ }
1169
+ } catch (e) {
1170
+ console.log(e);
1171
+ }
1172
+ }
1173
+ }).always(function(){
1174
+ wpforo_load_hide();
1175
+ ico.toggleClass('fa-history fa-circle-notch fa-spin');
1176
+ });
1177
+ }
1178
+ });
1179
+
1180
+ wpforo_wrap.on('click', 'form[data-textareaid] .wpforo-revision-action-delete', function(){
1181
+ var ico = $('.wpf-rev-ico', $(this));
1182
+ var form = $(this).closest('form[data-textareaid]');
1183
+ var rev_wrap = $(this).closest('.wpforo-revision[data-revisionid]');
1184
+ if( rev_wrap.length && $.active === 0 ){
1185
+ wpforo_load_show('Deleting Revision');
1186
+ ico.toggleClass('fa-trash fa-circle-notch fa-spin');
1187
+
1188
+ var revisionid = rev_wrap.data('revisionid');
1189
+ $.ajax({
1190
+ type: 'POST',
1191
+ data: {
1192
+ revisionid: revisionid,
1193
+ action: 'wpforo_delete_revision'
1194
+ }
1195
+ }).done(function (response) {
1196
+ if( parseInt(response) ){
1197
+ rev_wrap.fadeOut(500, function(){
1198
+ rev_wrap.remove();
1199
+ var rev_history_count = $('.wpf-rev-history-count', form);
1200
+ rev_history_count.text( parseInt( rev_history_count.text() ) - 1 );
1201
+ });
1202
+ }
1203
+ }).always(function(){
1204
+ wpforo_load_hide();
1205
+ ico.toggleClass('fa-trash fa-circle-notch fa-spin');
1206
+ });
1207
+ }
1208
+ });
1209
+
1210
+ function wpforo_activate_revision_action_buttons(form){
1211
+ var rev_saved = $('.wpforo_revision_saved', form);
1212
+ if( rev_saved.is(':visible') ){
1213
+ rev_saved.fadeOut(1000, function(){
1214
+ var save_revision = $('.wpforo_save_revision', form);
1215
+ save_revision.show();
1216
+
1217
+ if( parseInt(wpforo.revision_options.is_draft_on) && parseInt(wpforo.revision_options.auto_draft_interval) && !save_revision.data('auto_draft') ){
1218
+ setInterval(function(){
1219
+ save_revision.click();
1220
+ }, wpforo.revision_options.auto_draft_interval);
1221
+ save_revision.data('auto_draft', true);
1222
+ }
1223
+ });
1224
+ }
1225
+ }
1226
+
1227
+ function wpforo_deactivate_revision_action_buttons(form){
1228
+ $('.wpforo_revision_saved', form).show();
1229
+ $('.wpforo_save_revision', form).hide();
1230
+ }
1231
+
1232
+ function wpforo_content_changed(){
1233
+ var form = $('form[data-textareaid="'+ wpforo_editor.active_textareaid +'"]');
1234
+ if( wpforo_editor.get_stats().has_content ){
1235
+ wpforo_activate_revision_action_buttons(form);
1236
+ $('.wpforo_post_preview', form).removeClass('wpf-disabled');
1237
+ }else{
1238
+ wpforo_deactivate_revision_action_buttons(form);
1239
+ $('.wpforo_post_preview', form).addClass('wpf-disabled');
1240
+ }
1241
+ }
1242
+
1243
+ function wpforo_content_ctrl_s(){
1244
+ $('form[data-textareaid="'+ wpforo_editor.active_textareaid +'"] .wpforo_save_revision').click();
1245
+ }
1246
+
1247
+ wpforo_wrap.on('change input propertychange', 'form[data-textareaid] textarea', function () {
1248
+ var event = new Event('wpforo_textarea_content_changed');
1249
+ document.dispatchEvent(event);
1250
+ });
1251
+
1252
+ wpforo_wrap.on('keypress', 'form[data-textareaid] textarea', function () {
1253
+ var event = new Event('wpforo_textarea_content_changed');
1254
+ document.dispatchEvent(event);
1255
+ });
1256
+
1257
+ document.addEventListener('wpforo_tinymce_content_changed', wpforo_content_changed);
1258
+ document.addEventListener('wpforo_textarea_content_changed', wpforo_content_changed);
1259
+ document.addEventListener('wpforo_tinymce_ctrl_s', wpforo_content_ctrl_s);
1260
+ document.addEventListener('wpforo_textarea_ctrl_s', wpforo_content_ctrl_s);
1261
});
1262
1263
function wpforo_ucwords (str) {
1284
jQuery('#wpf_tool_tab_content_wrap').html(response);
1285
jQuery('#wpf_moderation_tools').slideDown(400, 'linear');
1286
}
1287
+ wpforo_load_hide();
1288
});
1289
}
1290
}
wpf-assets/js/frontend.js CHANGED
@@ -45,20 +45,21 @@ function wpforo_tinymce_initializeIt(selector, do_not_focus) {
45
force_br_newlines: false,
46
force_p_newlines: true,
47
selector: selector,
48
- plugins: "hr,lists,textcolor,paste,wpautoresize,fullscreen,wpforo_pre_button,wpforo_link_button,wpforo_spoiler_button,wpforo_source_code_button,emoticons",
49
menubar: "",
50
- toolbar: "fontsizeselect,bold,italic,underline,forecolor,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,blockquote,pre,wpf_spoil,source_code,emoticons,fullscreen",
51
- content_style: 'p{color:#333333; font-weight: normal;} blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
52
branding: false,
53
elementpath: false,
54
- autoresize_on_init: true,
55
- wp_autoresize_on: true,
56
- min_height: 100,
57
- height: 100,
58
statusbar: true,
59
fix_list_elements: true,
60
browser_spellcheck: true,
61
- setup: 'wpforo_tinymce_setup'
62
}).then(function (e) {
63
if(!do_not_focus && e.length) {
64
wpforo_editor.focus(e[0].id);
@@ -71,10 +72,18 @@ function wpforo_tinymce_setup(editor) {
71
editor.on('focus', function(e) {
72
wpforo_editor.set_active(editor.id);
73
});
74
editor.on('paste', function(e) {
75
- jQuery('form[data-textareaid='+editor.id+']').trigger({type: 'paste', delegatedEvent: {originalEvent: {clipboardData: e.clipboardData}},originalEvent: {clipboardData: e.clipboardData}});
76
});
77
- editor.shortcuts.add('ctrl+13', 'submit', function(){jQuery('form[data-textareaid='+editor.id+']').find('[type=submit]').click();});
78
}
79
80
var wpforo_editor = {
@@ -211,13 +220,19 @@ var wpforo_editor = {
211
212
var text = this.get_content('text', textareaid);
213
var raw_text = this.get_content('raw', textareaid);
214
215
return {
216
- chars: text.length,
217
- words: text.split(/[\w\u2019'-]+/).length - 1,
218
- imgs: (raw_text.match(/<img[^<>]*?src=['"][^'"]+?['"][^<>]*?>/gi) || []).length,
219
- links: (raw_text.match(/<a[^<>]*?href=['"][^'"]+?['"][^<>]*?>.+?<\/a>/gi) || []).length,
220
- embeds: (raw_text.match(/<(iframe|embed)[^<>]*?>.*?<\/\1>/gi) || []).length
221
};
222
}
223
};
@@ -253,6 +268,20 @@ function wpforo_notice_show(notice, type){
253
});
254
}
255
256
function wpforo_phrase(phrase_key){
257
if( typeof wpforo_phrases === 'object' && Object.keys(wpforo_phrases).length ){
258
phrase_key = phrase_key.toLowerCase();
@@ -296,7 +325,7 @@ function wpforo_getTextSelection(){
296
}else{
297
mention = '';
298
}
299
- var editorContent = '<blockquote data-userid="'+ userid +'" data-postid="'+ postid +'" data-mention="'+ mention +'">'+ mention_html +'<p>' + container.innerHTML + '</p></blockquote><p></p>';
300
wpforo_editor.insert_content( editorContent, wpforo_editor.get_main() );
301
jQuery('html, body').animate({ scrollTop: jQuery("form.wpforo-main-form").offset().top }, 500);
302
jQuery(this).remove();
@@ -322,11 +351,10 @@ jQuery(document).ready(function($){
322
window.onbeforeunload = function(e) {
323
var forms = $('form[data-textareaid]');
324
if( forms.length ){
325
- var i, textareaid, textarea_stat;
326
for( i = 0; i < forms.length; i++ ){
327
textareaid = $( forms[i] ).data('textareaid');
328
- textarea_stat = wpforo_editor.get_stats(textareaid);
329
- if( textarea_stat.chars || textarea_stat.imgs || textarea_stat.links || textarea_stat.embeds ){
330
e = e || window.event;
331
e.returnValue = wpforo_phrase("Write something clever here..");
332
return wpforo_phrase("Write something clever here..");
@@ -353,9 +381,16 @@ jQuery(document).ready(function($){
353
wpforo_wrap.on('keydown', 'form[data-textareaid]', function (e) {
354
if (e.ctrlKey && e.keyCode === 13) {
355
$('[type=submit]', $(this)).click();
356
}
357
});
358
359
/**
360
* prevent multi submitting
361
* disable form elements for 10 seconds
@@ -386,12 +421,12 @@ jQuery(document).ready(function($){
386
}
387
}
388
389
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
390
wpforo_prev_submit_time = Date.now();
391
window.onbeforeunload = null;
392
setTimeout(function () {
393
wpforo_prev_submit_time = 0;
394
- $('#wpforo-load').invisible();
395
}, 10000);
396
}
397
});
@@ -460,10 +495,9 @@ jQuery(document).ready(function($){
460
});
461
462
wpforo_wrap.on('click', '.not_reg_user', function(){
463
- $("#wpf-msg-box").hide();
464
- $('#wpforo-load').visible();
465
$('#wpf-msg-box').show(150).delay(1000);
466
- $('#wpforo-load').invisible();
467
});
468
469
$(document).on('click', '#wpf-msg-box', function(){
@@ -472,8 +506,7 @@ jQuery(document).ready(function($){
472
473
/* Home page loyouts toipcs toglle */
474
wpforo_wrap.on('click', ".topictoggle", function(){
475
- var wpfload = $('#wpforo-load');
476
- wpfload.visible();
477
478
var id = $(this).attr( 'id' );
479
@@ -493,7 +526,7 @@ jQuery(document).ready(function($){
493
$( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
494
}
495
496
- wpfload.invisible();
497
});
498
499
/* Home page loyouts toipcs toglle */
@@ -525,7 +558,7 @@ jQuery(document).ready(function($){
525
526
//Reply
527
wpforo_wrap.on('click', ".wpforo-reply:not(.wpforo_layout_4)", function(){
528
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
529
$('#wpf-form-wrapper').show();
530
531
$("#wpf-reply-form-title").html( wpforo_phrase('Leave a reply') );
@@ -553,7 +586,7 @@ jQuery(document).ready(function($){
553
554
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
555
556
- $('#wpforo-load').invisible();
557
558
});
559
@@ -562,7 +595,7 @@ jQuery(document).ready(function($){
562
var phrase = wpforo_phrase('Save') ;
563
if( $(this).data('phrase') !== undefined ) phrase = $(this).data('phrase');
564
565
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
566
567
$('#wpf-form-wrapper').show();
568
@@ -585,7 +618,7 @@ jQuery(document).ready(function($){
585
586
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
587
588
- $('#wpforo-load').invisible();
589
590
});
591
@@ -594,7 +627,7 @@ jQuery(document).ready(function($){
594
var phrase = wpforo_phrase('Save') ;
595
if( $(this).data('phrase') !== undefined ) phrase = $(this).data('phrase');
596
597
- $("#wpf-msg-box").hide(); $('#wpforo-load').visible();
598
599
// $('#wpf-form-wrapper').show();
600
@@ -623,7 +656,7 @@ jQuery(document).ready(function($){
623
624
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 800);
625
626
- $('#wpforo-load').invisible();
627
});
628
629
wpforo_wrap.on('click', '.wpforo-qa-comment, .wpforo-reply.wpf-action.wpforo_layout_4', function () {
45
force_br_newlines: false,
46
force_p_newlines: true,
47
selector: selector,
48
+ plugins: wpforo.editor_settings.plugins,
49
menubar: "",
50
+ toolbar: wpforo.editor_settings.tinymce.toolbar1,
51
+ content_style: wpforo.editor_settings.tinymce.content_style,
52
branding: false,
53
elementpath: false,
54
+ autoresize_on_init: wpforo.editor_settings.tinymce.autoresize_on_init,
55
+ wp_autoresize_on: wpforo.editor_settings.tinymce.wp_autoresize_on,
56
+ object_resizing: wpforo.editor_settings.tinymce.object_resizing,
57
+ min_height: wpforo.editor_settings.editor_height,
58
+ height: wpforo.editor_settings.editor_height,
59
statusbar: true,
60
fix_list_elements: true,
61
browser_spellcheck: true,
62
+ setup: wpforo.editor_settings.tinymce.setup
63
}).then(function (e) {
64
if(!do_not_focus && e.length) {
65
wpforo_editor.focus(e[0].id);
72
editor.on('focus', function(e) {
73
wpforo_editor.set_active(editor.id);
74
});
75
+ editor.on('Dirty ExecCommand KeyPress SetContent', function(e) {
76
+ var event = new Event('wpforo_tinymce_content_changed');
77
+ document.dispatchEvent(event);
78
+ });
79
editor.on('paste', function(e) {
80
+ jQuery('form[data-textareaid="'+editor.id+'"]').trigger({type: 'paste', delegatedEvent: {originalEvent: {clipboardData: e.clipboardData}},originalEvent: {clipboardData: e.clipboardData}});
81
+ });
82
+ editor.shortcuts.add('ctrl+13', 'submit', function(){ jQuery('form[data-textareaid="'+editor.id+'"]').find('[type=submit]').click(); });
83
+ editor.shortcuts.add('ctrl+s', 'Save Draft', function(){
84
+ var event = new Event('wpforo_tinymce_ctrl_s');
85
+ document.dispatchEvent(event);
86
});
87
}
88
89
var wpforo_editor = {
220
221
var text = this.get_content('text', textareaid);
222
var raw_text = this.get_content('raw', textareaid);
223
+ var chars = text.length;
224
+ var words = text.split(/[\w\u2019'-]+/).length - 1;
225
+ var imgs = (raw_text.match(/<img[^<>]*?src=['"][^'"]+?['"][^<>]*?>/gi) || []).length;
226
+ var links = (raw_text.match(/<a[^<>]*?href=['"][^'"]+?['"][^<>]*?>.+?<\/a>/gi) || []).length;
227
+ var embeds = (raw_text.match(/<(iframe|embed)[^<>]*?>.*?<\/\1>/gi) || []).length;
228
229
return {
230
+ chars: chars,
231
+ words: words,
232
+ imgs: imgs,
233
+ links: links,
234
+ embeds: embeds,
235
+ has_content: !! (chars || imgs || links || embeds)
236
};
237
}
238
};
268
});
269
}
270
271
+ function wpforo_load_show(msg){
272
+ msg = typeof msg !== "undefined" ? msg : 'Working';
273
+ msg = String(msg);
274
+ msg = wpforo_phrase(msg);
275
+ var load = jQuery('#wpforo-load');
276
+ jQuery('.loadtext', load).text(msg);
277
+ jQuery("#wpf-msg-box").hide();
278
+ load.visible();
279
+ }
280
+
281
+ function wpforo_load_hide(){
282
+ jQuery('#wpforo-load').invisible();
283
+ }
284
+
285
function wpforo_phrase(phrase_key){
286
if( typeof wpforo_phrases === 'object' && Object.keys(wpforo_phrases).length ){
287
phrase_key = phrase_key.toLowerCase();
325
}else{
326
mention = '';
327
}
328
+ var editorContent = '<blockquote data-userid="'+ userid +'" data-postid="'+ postid +'" data-mention="'+ mention +'">'+ mention_html +'<p>' + container.innerHTML.replace(/\s*data-[\w-]+="[^"]*?"/gi, '') + '</p></blockquote><p></p>';
329
wpforo_editor.insert_content( editorContent, wpforo_editor.get_main() );
330
jQuery('html, body').animate({ scrollTop: jQuery("form.wpforo-main-form").offset().top }, 500);
331
jQuery(this).remove();
351
window.onbeforeunload = function(e) {
352
var forms = $('form[data-textareaid]');
353
if( forms.length ){
354
+ var i, textareaid;
355
for( i = 0; i < forms.length; i++ ){
356
textareaid = $( forms[i] ).data('textareaid');
357
+ if( wpforo_editor.get_stats(textareaid).has_content ){
358
e = e || window.event;
359
e.returnValue = wpforo_phrase("Write something clever here..");
360
return wpforo_phrase("Write something clever here..");
381
wpforo_wrap.on('keydown', 'form[data-textareaid]', function (e) {
382
if (e.ctrlKey && e.keyCode === 13) {
383
$('[type=submit]', $(this)).click();
384
+ }else if( (e.ctrlKey && e.which === 83) || e.which === 19 ){
385
+ var event = new Event('wpforo_textarea_ctrl_s');
386
+ document.dispatchEvent(event);
387
+ e.preventDefault();
388
+ return false;
389
}
390
});
391
392
+ if( $('.wpforo-recent-content .wpf-p-error', wpforo_wrap).length ){ $('.wpf-navi', wpforo_wrap).remove(); }
393
+
394
/**
395
* prevent multi submitting
396
* disable form elements for 10 seconds
421
}
422
}
423
424
+ wpforo_load_show();
425
wpforo_prev_submit_time = Date.now();
426
window.onbeforeunload = null;
427
setTimeout(function () {
428
wpforo_prev_submit_time = 0;
429
+ wpforo_load_hide();
430
}, 10000);
431
}
432
});
495
});
496
497
wpforo_wrap.on('click', '.not_reg_user', function(){
498
+ wpforo_load_show();
499
$('#wpf-msg-box').show(150).delay(1000);
500
+ wpforo_load_hide();
501
});
502
503
$(document).on('click', '#wpf-msg-box', function(){
506
507
/* Home page loyouts toipcs toglle */
508
wpforo_wrap.on('click', ".topictoggle", function(){
509
+ wpforo_load_show();
510
511
var id = $(this).attr( 'id' );
512
526
$( '#button-arrow-' + id ).removeClass('fa-chevron-up').addClass('fa-chevron-down');
527
}
528
529
+ wpforo_load_hide();
530
});
531
532
/* Home page loyouts toipcs toglle */
558
559
//Reply
560
wpforo_wrap.on('click', ".wpforo-reply:not(.wpforo_layout_4)", function(){
561
+ wpforo_load_show();
562
$('#wpf-form-wrapper').show();
563
564
$("#wpf-reply-form-title").html( wpforo_phrase('Leave a reply') );
586
587
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
588
589
+ wpforo_load_hide();
590
591
});
592
595
var phrase = wpforo_phrase('Save') ;
596
if( $(this).data('phrase') !== undefined ) phrase = $(this).data('phrase');
597
598
+ wpforo_load_show();
599
600
$('#wpf-form-wrapper').show();
601
618
619
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 500);
620
621
+ wpforo_load_hide();
622
623
});
624
627
var phrase = wpforo_phrase('Save') ;
628
if( $(this).data('phrase') !== undefined ) phrase = $(this).data('phrase');
629
630
+ wpforo_load_show();
631
632
// $('#wpf-form-wrapper').show();
633
656
657
$('html, body').animate({ scrollTop: $("#wpf-form-wrapper").offset().top }, 800);
658
659
+ wpforo_load_hide();
660
});
661
662
wpforo_wrap.on('click', '.wpforo-qa-comment, .wpforo-reply.wpf-action.wpforo_layout_4', function () {
wpf-includes/class-forms.php CHANGED
@@ -580,7 +580,7 @@ class wpForoForm{
580
$field_html = '<ul>
581
<li>
582
<input ' . $f['isRequired'] . ' name="' . esc_attr($f['varname']) . '[avatar_type]" id="wpfat_gravatar" value="gravatar" ' . ( $f['value'] == '' || $f['value'] == NULL ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp;
583
- <label for="wpfat_gravatar">' . wpforo_phrase('Wordpress avatar system', false) . '</label>
584
</li>
585
<li>
586
<input name="' . esc_attr($f['varname']) . '[avatar_type]" id="wpfat_remote" value="remote" ' . ( $f['value'] && strpos($f['value'], 'wpforo/avatars') === FALSE ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp;
580
$field_html = '<ul>
581
<li>
582
<input ' . $f['isRequired'] . ' name="' . esc_attr($f['varname']) . '[avatar_type]" id="wpfat_gravatar" value="gravatar" ' . ( $f['value'] == '' || $f['value'] == NULL ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp;
583
+ <label for="wpfat_gravatar">' . wpforo_phrase('Default avatar', false) . '</label>
584
</li>
585
<li>
586
<input name="' . esc_attr($f['varname']) . '[avatar_type]" id="wpfat_remote" value="remote" ' . ( $f['value'] && strpos($f['value'], 'wpforo/avatars') === FALSE ? 'checked="checked"' : '' ) . ' type="radio" />&nbsp;
wpf-includes/class-forums.php CHANGED
@@ -135,6 +135,7 @@ class wpForoForum{
135
$meta_desc = (isset($meta_desc)) ? sanitize_text_field($meta_desc) : '';
136
$parentid = (isset($parentid)) ? intval($parentid) : 0;
137
$slug = (isset($slug) && $slug) ? sanitize_title($slug) : ((isset($title)) ? sanitize_title($title) : md5(time()));
138
$slug = $this->unique_slug($slug, $parentid);
139
$icon = (isset($icon)) ? sanitize_text_field($icon) : '';
140
$topics = (isset($topics)) ? intval($topics) : 0;
@@ -220,6 +221,7 @@ class wpForoForum{
220
$meta_desc = (isset($meta_desc)) ? sanitize_text_field($meta_desc) : '';
221
$parentid = (isset($parentid)) ? ( $forumid == $parentid ? intval($forum['parentid']) : intval($parentid) ) : 0;
222
$slug = (isset($slug)) ? sanitize_title($slug) : ((isset($title)) ? sanitize_title($title) : md5(time()));
223
$slug = $this->unique_slug($slug, $parentid, $forumid);
224
$icon = (isset($icon)) ? sanitize_text_field($icon) : '';
225
$topics = (isset($topics)) ? intval($topics) : 0;
@@ -375,7 +377,7 @@ class wpForoForum{
375
$last_topicid = $last_topic['topicid'];
376
}
377
378
- $sql = "SELECT `postid` FROM `".WPF()->tables->posts."` WHERE `status` = 0 AND `private` = 0 AND `forumid` = %d ORDER BY `is_first_post` ASC, `created` DESC, `postid` DESC LIMIT 1";
379
if( $last_postid = WPF()->db->get_var( WPF()->db->prepare($sql, $forumid) ) ){
380
if( $last_post_data = WPF()->post->get_post($last_postid) ){
381
$last_postid = $last_post_data['postid'];
135
$meta_desc = (isset($meta_desc)) ? sanitize_text_field($meta_desc) : '';
136
$parentid = (isset($parentid)) ? intval($parentid) : 0;
137
$slug = (isset($slug) && $slug) ? sanitize_title($slug) : ((isset($title)) ? sanitize_title($title) : md5(time()));
138
+ if( !trim($slug) ) $slug = md5(time());
139
$slug = $this->unique_slug($slug, $parentid);
140
$icon = (isset($icon)) ? sanitize_text_field($icon) : '';
141
$topics = (isset($topics)) ? intval($topics) : 0;
221
$meta_desc = (isset($meta_desc)) ? sanitize_text_field($meta_desc) : '';
222
$parentid = (isset($parentid)) ? ( $forumid == $parentid ? intval($forum['parentid']) : intval($parentid) ) : 0;
223
$slug = (isset($slug)) ? sanitize_title($slug) : ((isset($title)) ? sanitize_title($title) : md5(time()));
224
+ if( !trim($slug) ) $slug = md5(time());
225
$slug = $this->unique_slug($slug, $parentid, $forumid);
226
$icon = (isset($icon)) ? sanitize_text_field($icon) : '';
227
$topics = (isset($topics)) ? intval($topics) : 0;
377
$last_topicid = $last_topic['topicid'];
378
}
379
380
+ $sql = "SELECT `postid` FROM `".WPF()->tables->posts."` WHERE `status` = 0 AND `private` = 0 AND `forumid` = %d ORDER BY `created` DESC, `postid` DESC LIMIT 1";
381
if( $last_postid = WPF()->db->get_var( WPF()->db->prepare($sql, $forumid) ) ){
382
if( $last_post_data = WPF()->post->get_post($last_postid) ){
383
$last_postid = $last_post_data['postid'];
wpf-includes/class-members.php CHANGED
@@ -19,8 +19,7 @@ class wpForoMember{
19
function __construct(){
20
$this->init_defaults();
21
$this->init_options();
22
-
23
- add_action('delete_user_form', array(&$this, 'show_delete_form'), 10, 2);
24
}
25
26
private function init_defaults(){
@@ -62,6 +61,12 @@ class wpForoMember{
62
$this->pass_min_length = $this->default->pass_min_length;
63
$this->pass_max_length = $this->default->pass_max_length;
64
}
65
66
public function get_cache( $var ){
67
if( isset(self::$cache[$var]) ) return self::$cache[$var];
@@ -783,6 +788,10 @@ class wpForoMember{
783
$profile_fields['rank'] = $data['rank'];
784
$profile_fields_types[] = '%d';
785
}
786
787
if( !empty($profile_fields) ){
788
$result_profile = WPF()->db->update(
@@ -1497,7 +1506,7 @@ class wpForoMember{
1497
$member_args = ( $userid ? $userid : array( 'user_nicename' => basename($arg) ) );
1498
$user = $this->get_member( $member_args );
1499
if(empty($user)) return wpforo_home_url();
1500
- $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) == 'id' ? $user['ID'] : $user['user_nicename'] );
1501
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1502
return apply_filters('wpforo_member_profile_url', $profile_url, $user, $template);
1503
}
@@ -1505,7 +1514,7 @@ class wpForoMember{
1505
public function profile_url( $member = array(), $template = 'profile' ){
1506
$template_slug = ( wpfkey( WPF()->tpl->slugs, $template ) ? WPF()->tpl->slugs[$template] : $template );
1507
if(isset($member['ID']) || isset($member['user_nicename'])){
1508
- $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) == 'id' ? $member['ID'] : $member['user_nicename'] );
1509
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1510
$profile_url = apply_filters( 'wpforo_profile_url', $profile_url, $member, $template );
1511
}
@@ -2900,4 +2909,12 @@ class wpForoMember{
2900
public function set_usergroups_secondary($userid, $group_ids = array()){
2901
//TODO: set_usergroups_secondary() method condition
2902
}
2903
}
19
function __construct(){
20
$this->init_defaults();
21
$this->init_options();
22
+ $this->init_hooks();
23
}
24
25
private function init_defaults(){
61
$this->pass_min_length = $this->default->pass_min_length;
62
$this->pass_max_length = $this->default->pass_max_length;
63
}
64
+
65
+ private function init_hooks(){
66
+ add_action('delete_user_form', array($this, 'show_delete_form'), 10, 2);
67
+ add_action('register_new_user', array($this, 'after_register_new_user'));
68
+ add_action('after_password_reset', array($this, 'after_password_reset'));
69
+ }
70
71
public function get_cache( $var ){
72
if( isset(self::$cache[$var]) ) return self::$cache[$var];
788
$profile_fields['rank'] = $data['rank'];
789
$profile_fields_types[] = '%d';
790
}
791
+ if( wpfkey($data, 'status') ){
792
+ $profile_fields['status'] = $data['status'];
793
+ $profile_fields_types[] = '%s';
794
+ }
795
796
if( !empty($profile_fields) ){
797
$result_profile = WPF()->db->update(
1506
$member_args = ( $userid ? $userid : array( 'user_nicename' => basename($arg) ) );
1507
$user = $this->get_member( $member_args );
1508
if(empty($user)) return wpforo_home_url();
1509
+ $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) === 'id' ? $user['ID'] : $user['user_nicename'] );
1510
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1511
return apply_filters('wpforo_member_profile_url', $profile_url, $user, $template);
1512
}
1514
public function profile_url( $member = array(), $template = 'profile' ){
1515
$template_slug = ( wpfkey( WPF()->tpl->slugs, $template ) ? WPF()->tpl->slugs[$template] : $template );
1516
if(isset($member['ID']) || isset($member['user_nicename'])){
1517
+ $user_slug = ( wpfo(WPF()->member->options['url_structure'], false) === 'id' ? $member['ID'] : $member['user_nicename'] );
1518
$profile_url = wpforo_home_url("$template_slug/$user_slug");
1519
$profile_url = apply_filters( 'wpforo_profile_url', $profile_url, $member, $template );
1520
}
2909
public function set_usergroups_secondary($userid, $group_ids = array()){
2910
//TODO: set_usergroups_secondary() method condition
2911
}
2912
+
2913
+ public function after_register_new_user($userid){
2914
+ $this->update_profile_fields( $userid, array('status' => 'inactive'), false );
2915
+ }
2916
+
2917
+ public function after_password_reset($user){
2918
+ $this->update_profile_fields( $user->ID, array('status' => 'active'), false );
2919
+ }
2920
}
wpf-includes/class-permissions.php CHANGED
@@ -448,6 +448,9 @@ class wpForoPermissions{
448
* @return bool
449
*/
450
public function can_post_now() {
451
if ( wpforo_is_admin() || ( defined( 'IS_GO2WPFORO' ) && IS_GO2WPFORO ) ) {
452
return true;
453
}
448
* @return bool
449
*/
450
public function can_post_now() {
451
+ date_default_timezone_set('UTC');
452
+ ini_set( 'date.timezone', 'UTC' );
453
+
454
if ( wpforo_is_admin() || ( defined( 'IS_GO2WPFORO' ) && IS_GO2WPFORO ) ) {
455
return true;
456
}
wpf-includes/class-phrases.php CHANGED
@@ -260,7 +260,7 @@ class wpForoPhrase{
260
$this->crawl_phrases($match . DIRECTORY_SEPARATOR .'*');
261
}elseif (is_file($match) && preg_match('#\.(php|js)$#isu', $match)){
262
if( $file_content = wpforo_get_file_content($match) ){
263
- if( preg_match_all('#(?:wpforo_phrase|WPF\(\)->notice->add)\([\r\n\t\s\0]*[\'\"](?P<phrase_key>.+?)[\'\"][\r\n\t\s\0\,\)]+#isu', $file_content, $phrases, PREG_SET_ORDER ) ){
264
foreach ( $phrases as $phrase ){
265
if( $phrase['phrase_key'] ){
266
$args = array(
260
$this->crawl_phrases($match . DIRECTORY_SEPARATOR .'*');
261
}elseif (is_file($match) && preg_match('#\.(php|js)$#isu', $match)){
262
if( $file_content = wpforo_get_file_content($match) ){
263
+ if( preg_match_all('#(?:wpforo_phrase|WPF\(\)->notice->add|wpforo_notice_show|wpforo_load_show)\([\r\n\t\s\0]*[\'\"](?P<phrase_key>.+?)[\'\"][\r\n\t\s\0\,\)]+#isu', $file_content, $phrases, PREG_SET_ORDER ) ){
264
foreach ( $phrases as $phrase ){
265
if( $phrase['phrase_key'] ){
266
$args = array(
wpf-includes/class-posts.php CHANGED
@@ -1017,8 +1017,8 @@ class wpForoPost{
1017
1018
$sql = "SELECT COUNT(*) FROM ". $from ." ".implode(' ', $innerjoins);
1019
if($wheres) $sql .= " WHERE " . implode( " AND ", $wheres );
1020
- if( $this->options['search_max_results'] ) $sql .= " LIMIT " . $this->options['search_max_results'];
1021
- $items_count = WPF()->db->get_var($sql);
1022
1023
$sql = "SELECT ".implode(', ', $selects)." FROM ". $from ." ".implode(' ', $innerjoins);
1024
if($wheres) $sql .= " WHERE " . implode( " AND ", $wheres );
1017
1018
$sql = "SELECT COUNT(*) FROM ". $from ." ".implode(' ', $innerjoins);
1019
if($wheres) $sql .= " WHERE " . implode( " AND ", $wheres );
1020
+ $items_count = (int) WPF()->db->get_var($sql);
1021
+ if( $this->options['search_max_results'] && $items_count > $this->options['search_max_results'] ) $items_count = (int) $this->options['search_max_results'];
1022
1023
$sql = "SELECT ".implode(', ', $selects)." FROM ". $from ." ".implode(' ', $innerjoins);
1024
if($wheres) $sql .= " WHERE " . implode( " AND ", $wheres );
wpf-includes/class-revisions.php ADDED
@@ -0,0 +1,458 @@
1
+ <?php
2
+ // Exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ class wpForoRevision {
8
+ public $options;
9
+ public $revision;
10
+ private $default;
11
+
12
+ public function __construct() {
13
+ add_action( 'wpforo_after_init', array( $this, 'init' ) );
14
+ }
15
+
16
+ public function init() {
17
+ $this->init_defaults();
18
+ $this->init_options();
19
+ $this->revision = $this->default->revision;
20
+ $this->init_hooks();
21
+ }
22
+
23
+ private function init_defaults() {
24
+ $this->default = new stdClass();
25
+ $this->default->options = array(
26
+ 'auto_draft_interval' => 30000,
27
+ 'max_drafts_per_page' => 3,
28
+ 'is_preview_on' => 1,
29
+ 'is_draft_on' => 1
30
+ );
31
+ $this->default->revision = array(
32
+ 'revisionid' => 0,
33
+ 'userid' => 0,
34
+ 'textareaid' => '',
35
+ 'postid' => 0,
36
+ 'body' => '',
37
+ 'created' => 0,
38
+ 'version' => 0,
39
+ 'email' => '',
40
+ 'url' => '',
41
+ );
42
+ $this->default->revision_format = array(
43
+ 'revisionid' => '%d',
44
+ 'userid' => '%d',
45
+ 'textareaid' => '%s',
46
+ 'postid' => '%d',
47
+ 'body' => '%s',
48
+ 'created' => '%d',
49
+ 'version' => '%d',
50
+ 'email' => '%s',
51
+ 'url' => '%s'
52
+ );
53
+ $this->default->sql_select_args = array(
54
+ 'include' => array(),
55
+ 'exclude' => array(),
56
+ 'userids_include' => array(),
57
+ 'userids_exclude' => array(),
58
+ 'textareaids_include' => array(),
59
+ 'textareaids_exclude' => array(),
60
+ 'postids_include' => array(),
61
+ 'postids_exclude' => array(),
62
+ 'urls_include' => array(),
63
+ 'urls_exclude' => array(),
64
+ 'emails_include' => array(),
65
+ 'emails_exclude' => array(),
66
+ 'orderby' => 'revisionid',
67
+ 'order' => 'DESC',
68
+ 'offset' => null,
69
+ 'row_count' => null
70
+ );
71
+ }
72
+
73
+ private function init_options() {
74
+ $this->options = get_wpf_option( 'wpforo_revision_options', $this->default->options );
75
+ }
76
+
77
+ private function init_hooks() {
78
+ if( $this->options['is_preview_on'] || $this->options['is_draft_on'] ){
79
+ add_action('wpforo_editor_topic_submit_after', array($this, 'show_html_into_form'));
80
+ add_action('wpforo_editor_post_submit_after', array($this, 'show_html_into_form'));
81
+ add_action('wpforo_portable_editor_post_submit_after', array($this, 'show_html_into_form'));
82
+
83
+ if( $this->options['is_preview_on'] ) add_action('wp_ajax_wpforo_post_preview', array($this, 'ajax_post_preview'));
84
+
85
+ if( $this->options['is_draft_on'] ){
86
+ add_action( 'wpforo_after_add_topic', array( $this, 'after_submit' ) );
87
+ add_action( 'wpforo_after_add_post', array( $this, 'after_submit' ) );
88
+ add_action( 'wpforo_after_edit_topic', array( $this, 'after_submit' ) );
89
+ add_action( 'wpforo_after_edit_post', array( $this, 'after_submit' ) );
90
+
91
+ add_action('wp_ajax_wpforo_save_revision', array($this, 'ajax_save_revision'));
92
+ add_action('wp_ajax_wpforo_get_revisions_history', array($this, 'ajax_get_revisions_history'));
93
+ add_action('wp_ajax_wpforo_get_revision', array($this, 'ajax_get_revision'));
94
+ add_action('wp_ajax_wpforo_delete_revision', array($this, 'ajax_delete_revision'));
95
+ }
96
+ }
97
+ }
98
+
99
+ private function get_current_url_query_vars_str(){
100
+ $url_query_vars_str = wpforo_get_url_query_vars_str();
101
+ if( !$url_query_vars_str ) $url_query_vars_str = 'wpforo_home_url';
102
+ return $url_query_vars_str;
103
+ }
104
+
105
+ private function parse_revision( $revision ) {
106
+ $revision = array_merge( $this->default->revision, $revision );
107
+ if( $revision['body'] ){
108
+ $revision['body'] = preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $revision['body']);
109
+ $revision['body'] = wpforo_kses(trim($revision['body']), 'post');
110
+ $revision['body'] = stripslashes($revision['body']);
111
+ }
112
+ return $revision;
113
+ }
114
+
115
+ private function parse_args( $args ) {
116
+ $args = wpforo_parse_args( $args, $this->default->sql_select_args );
117
+
118
+ $args['include'] = wpforo_parse_args( $args['include'] );
119
+ $args['exclude'] = wpforo_parse_args( $args['exclude'] );
120
+
121
+ $args['userids_include'] = wpforo_parse_args( $args['userids_include'] );
122
+ $args['userids_exclude'] = wpforo_parse_args( $args['userids_exclude'] );
123
+
124
+ $args['textareaids_include'] = wpforo_parse_args( $args['textareaids_include'] );
125
+ $args['textareaids_exclude'] = wpforo_parse_args( $args['textareaids_exclude'] );
126
+
127
+ $args['postids_include'] = wpforo_parse_args( $args['postids_include'] );
128
+ $args['postids_exclude'] = wpforo_parse_args( $args['postids_exclude'] );
129
+
130
+ $args['urls_include'] = wpforo_parse_args( $args['urls_include'] );
131
+ $args['urls_exclude'] = wpforo_parse_args( $args['urls_exclude'] );
132
+
133
+ $args['emails_include'] = wpforo_parse_args( $args['emails_include'] );
134
+ $args['emails_exclude'] = wpforo_parse_args( $args['emails_exclude'] );
135
+
136
+ return $args;
137
+ }
138
+
139
+ private function build_sql_where ( $args ){
140
+ $where = '';
141
+ $args = $this->parse_args( $args );
142
+
143
+ $wheres = array();
144
+ if ( ! empty( $args['include'] ) ) {
145
+ $wheres[] = "`revisionid` IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['include'] ) ) . ")";
146
+ }
147
+ if ( ! empty( $args['exclude'] ) ) {
148
+ $wheres[] = "`revisionid` NOT IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['exclude'] ) ) . ")";
149
+ }
150
+
151
+ if ( ! empty( $args['userids_include'] ) ) {
152
+ $wheres[] = "`userid` IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['userids_include'] ) ) . ")";
153
+ }
154
+ if ( ! empty( $args['userids_exclude'] ) ) {
155
+ $wheres[] = "`userid` NOT IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['userids_exclude'] ) ) . ")";
156
+ }
157
+
158
+ if ( ! empty( $args['textareaids_include'] ) ) {
159
+ $wheres[] = "`textareaid` IN('" . implode( "','", array_map( 'trim', $args['textareaids_include'] ) ) . "')";
160
+ }
161
+ if ( ! empty( $args['textareaids_exclude'] ) ) {
162
+ $wheres[] = "`textareaid` IN('" . implode( "','", array_map( 'trim', $args['textareaids_exclude'] ) ) . "')";
163
+ }
164
+
165
+ if ( ! empty( $args['postids_include'] ) ) {
166
+ $wheres[] = "`postid` IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['postids_include'] ) ) . ")";
167
+ }
168
+ if ( ! empty( $args['postids_exclude'] ) ) {
169
+ $wheres[] = "`postid` NOT IN(" . implode( ',', array_map( 'wpforo_bigintval', $args['postids_exclude'] ) ) . ")";
170
+ }
171
+
172
+ if ( ! empty( $args['urls_include'] ) ) {
173
+ $wheres[] = "`url` IN('" . implode( "','", array_map( 'trim', $args['urls_include'] ) ) . "')";
174
+ }
175
+ if ( ! empty( $args['urls_exclude'] ) ) {
176
+ $wheres[] = "`url` IN('" . implode( "','", array_map( 'trim', $args['urls_exclude'] ) ) . "')";
177
+ }
178
+
179
+ if ( ! empty( $args['emails_include'] ) ) {
180
+ $wheres[] = "`email` IN('" . implode( "','", array_map( 'trim', $args['emails_include'] ) ) . "')";
181
+ }
182
+ if ( ! empty( $args['emails_exclude'] ) ) {
183
+ $wheres[] = "`email` IN('" . implode( "','", array_map( 'trim', $args['emails_exclude'] ) ) . "')";
184
+ }
185
+
186
+ if ( $wheres ) {
187
+ $where = " WHERE " . implode( $wheres, " AND " );
188
+ }
189
+
190
+ return $where;
191
+ }
192
+
193
+ private function build_sql_select( $args ) {
194
+ $args = $this->parse_args( $args );
195
+ $sql = "SELECT * FROM " . WPF()->tables->post_revisions;
196
+ $sql .= $this->build_sql_where($args);
197
+ $sql .= " ORDER BY " . $args['orderby'] . " " . $args['order'];
198
+ if ( $args['row_count'] ) $sql .= " LIMIT " . wpforo_bigintval( $args['offset'] ) . "," . wpforo_bigintval( $args['row_count'] );
199
+ return $sql;
200
+ }
201
+
202
+ private function add( $data ) {
203
+ if ( empty( $data ) ) return false;
204
+ $revision = $this->parse_revision($data);
205
+ unset( $revision['revisionid'] );
206
+
207
+ if ( !$revision['created'] ) $revision['created'] = current_time( 'timestamp', 1 );
208
+ if ( !$revision['url'] ) $revision['url'] = $this->get_current_url_query_vars_str();
209
+ if ( !$revision['userid'] ) $revision['userid'] = WPF()->current_userid;
210
+ if ( !$revision['email'] ) $revision['email'] = WPF()->current_user_email;
211
+ if ( !$revision['textareaid'] || !$revision['url'] || !$revision['body'] || !($revision['userid'] || $revision['email']) ) return false;
212
+
213
+ if ( WPF()->db->insert(
214
+ WPF()->tables->post_revisions,
215
+ wpforo_array_ordered_intersect_key( $revision, $this->default->revision_format ),
216
+ wpforo_array_ordered_intersect_key( $this->default->revision_format, $revision )
217
+ )
218
+ ) {
219
+ return WPF()->db->insert_id;
220
+ }
221
+
222
+ return false;
223
+ }
224
+
225
+ private function edit( $data, $where ) {
226
+ if ( empty( $data ) || empty( $where ) ) return false;
227
+ if ( is_numeric( $where ) ) $where = array( 'revisionid' => $where );
228
+ $data = (array) $data;
229
+ $where = (array) $where;
230
+
231
+ if ( false !== WPF()->db->update(
232
+ WPF()->tables->post_revisions,
233
+ wpforo_array_ordered_intersect_key( $data, $this->default->revision_format ),
234
+ wpforo_array_ordered_intersect_key( $where, $this->default->revision_format ),
235
+ wpforo_array_ordered_intersect_key( $this->default->revision_format, $data ),
236
+ wpforo_array_ordered_intersect_key( $this->default->revision_format, $where )
237
+ )
238
+ ) {
239
+ return true;
240
+ }
241
+
242
+ return false;
243
+ }
244
+
245
+ private function delete( $where ) {
246
+ if( empty($where) ) return false;
247
+ if ( is_numeric( $where ) ) $where = array( 'revisionid' => $where );
248
+ $where = (array) $where;
249
+
250
+ if ( false !== WPF()->db->delete(
251
+ WPF()->tables->post_revisions,
252
+ wpforo_array_ordered_intersect_key( $where, $this->default->revision_format ),
253
+ wpforo_array_ordered_intersect_key( $this->default->revision_format, $where )
254
+ )
255
+ ) {
256
+ return true;
257
+ }
258
+
259
+ return false;
260
+ }
261
+
262
+ public function get_revision( $args ) {
263
+ if ( empty( $args ) ) return false;
264
+
265
+ return $this->parse_revision( WPF()->db->get_row( $this->build_sql_select( $args ), ARRAY_A ) );
266
+ }
267
+
268
+ public function get_revisions( $args ) {
269
+ if ( empty($args) ) return false;
270
+
271
+ return array_map( array( $this, 'parse_revision' ), WPF()->db->get_results( $this->build_sql_select( $args ), ARRAY_A ) );
272
+ }
273
+
274
+ /**
275
+ * @param array $args
276
+ *
277
+ * @return int
278
+ */
279
+ private function get_count( $args ){
280
+ $sql = "SELECT SQL_NO_CACHE COUNT(*) FROM " . WPF()->tables->post_revisions;
281
+ $sql .= $this->build_sql_where($args);
282
+ return intval( WPF()->db->get_var($sql) );
283
+ }
284
+
285
+ public function show_html_into_form(){
286
+ $args = array(
287
+ // 'textareaids_include' => (string) wpfval( $_POST, 'textareaid' ),
288
+ 'postids_include' => wpforo_bigintval( wpfval( $_POST, 'postid' ) ),
289
+ 'userids_include' => WPF()->current_userid,
290
+ 'emails_include' => WPF()->current_user_email,
291
+ 'urls_include' => $this->get_current_url_query_vars_str()
292
+ );
293
+ $revisions_count = $this->get_count($args);
294
+ ?>
295
+ <div class="wpf-clear"></div>
296
+ <div class="wpforo-revisions-wrap"><?php $this->show_wrap_inner_html($revisions_count); ?></div>
297
+ <?php
298
+ }
299
+
300
+ private function build_wrap_inner_html($revisions_count = null){
301
+ $buttons = '';
302
+ if( $this->options['is_preview_on'] ){
303
+ $buttons .= sprintf('<span class="wpforo-revision-action-button wpforo_post_preview wpf-disabled"> <i class="fas fa-eye wpf-rev-preview-ico"></i> %1$s </span>', wpforo_phrase('Preview', false) );
304
+ }
305
+ if( $this->options['is_draft_on'] ){
306
+ $revisions_count = intval($revisions_count);
307
+ $buttons .= sprintf('<span class="wpforo-revision-action-button wpforo_revisions_history"><i class="fas fa-history wpf-rev-ico"></i> %1$s </span>', sprintf( wpforo_phrase('%1$s Revisions', false), '<span class="wpf-rev-history-count">'.$revisions_count.'</span>' )) .
308
+ sprintf('<span class="wpforo-revision-action-button wpforo_save_revision" style="display: none;"><i class="fas fa-save wpf-rev-save-ico"></i> %1$s </span>', wpforo_phrase('Save Draft', false)) .
309
+ sprintf('<span class="wpforo-revision-action-button wpforo_revision_saved wpf-disabled"><i class="fas fa-check wpf-rev-saved-ico"></i> %1$s </span>', wpforo_phrase('Saved', false));
310
+ }
311
+ $html = sprintf('<div class="wpforo-revisions-action-buttons">%1$s</div><div class="wpforo-revisions-preview-wrap"></div>', $buttons );
312
+ return $html;
313
+ }
314
+
315
+ private function show_wrap_inner_html($revisions_count = null){
316
+ echo $this->build_wrap_inner_html($revisions_count);
317
+ }
318
+
319
+ private function build_preview($revision){
320
+ $html = sprintf('<div class="wpforo-revision" data-revisionid="%1$d" data-created="%2$d">
321
+ <div class="wpforo-revision-top">
322
+ <div class="wpforo-revision-created"><i class="fas fa-eye wpf-rev-ico"></i> %3$s</div>
323
+ </div>
324
+ <div class="wpforo-revision-body">%4$s</div>
325
+ </div>',
326
+ $revision['revisionid'],
327
+ $revision['created'],
328
+ wpforo_phrase('Preview', false),
329
+ wpforo_content($revision, false)
330
+ );
331
+ return $html;
332
+ }
333
+
334
+ private function show_preview($revision){
335
+ echo $this->build_preview($revision);
336
+ }
337
+
338
+ private function build_revision($revision){
339
+ $html = sprintf( '
340
+ <div class="wpforo-revision" data-revisionid="%1$d" data-created="%2$s">
341
+ <div class="wpforo-revision-top">
342
+ <div class="wpforo-revision-created"><i class="fas fa-clock wpf-rev-ico"></i> %3$s %4$s</div>
343
+ <div class="wpforo-revision-actions">
344
+ <span class="wpforo-revision-action-restore" style="cursor: pointer;"><i class="fas fa-history wpf-rev-ico"></i> %5$s</span>
345
+ &nbsp;|&nbsp;
346
+ <span class="wpforo-revision-action-delete" style="cursor: pointer;"><i class="fas fa-trash wpf-rev-ico"></i> %6$s</span>
347
+ </div>
348
+ </div>
349
+ <div class="wpforo-revision-body">%7$s</div>
350
+ </div>',
351
+ $revision['revisionid'],
352
+ $revision['created'],
353
+ wpforo_phrase('Revision', false),
354
+ wpforo_date($revision['created'], 'ago', false),
355
+ wpforo_phrase('Restore', false),
356
+ wpforo_phrase('Delete', false),
357
+ wpforo_content($revision, false)
358
+ );
359
+ return $html;
360
+ }
361
+
362
+ private function show_revision($revision){
363
+ echo $this->build_revision($revision);
364
+ }
365
+
366
+ public function ajax_save_revision() {
367
+ $args = array(
368
+ 'textareaid' => (string) wpfval($_POST, 'textareaid'),
369
+ 'postid' => wpforo_bigintval( wpfval($_POST, 'postid') ),
370
+ 'body' => (string) wpfval($_POST, 'body')
371
+ );
372
+
373
+ $revision = $this->parse_revision($args);
374
+ $revision['created'] = current_time( 'timestamp', 1 );
375
+ $revision['url'] = $this->get_current_url_query_vars_str();
376
+ $revision['userid'] = WPF()->current_userid;
377
+ $revision['email'] = WPF()->current_user_email;
378
+
379
+ if( $revisionid = $this->add($revision) ){
380
+ $args = array(
381
+ // 'textareaids_include' => $revision['textareaid'],
382
+ 'postids_include' => $revision['postid'],
383
+ 'userids_include' => $revision['userid'],
384
+ 'emails_include' => $revision['email'],
385
+ 'urls_include' => $revision['url']
386
+ );
387
+ $revisions_count = $this->get_count($args);
388
+ if( $revisions_count > $this->options['max_drafts_per_page'] ){
389
+ $sql = "DELETE FROM " . WPF()->tables->post_revisions . $this->build_sql_where($args) . "
390
+ ORDER BY `revisionid` ASC LIMIT %d";
391
+ $sql = WPF()->db->prepare($sql, ($revisions_count - $this->options['max_drafts_per_page']) );
392
+ if( WPF()->db->query($sql) !== false ) $revisions_count = $this->options['max_drafts_per_page'];
393
+ }
394
+ }else{
395
+ $revisions_count = 0;
396
+ $revisionid = 0;
397
+ }
398
+
399
+ $revision['revisionid'] = $revisionid;
400
+
401
+ echo json_encode(array(
402
+ 'revisionid' => $revisionid,
403
+ 'revisions_count' => $revisions_count,
404
+ 'revisionhtml' => $this->build_revision($revision)
405
+ ));
406
+ exit();
407
+ }
408
+
409
+ public function ajax_post_preview(){
410
+ $revision = $this->parse_revision($_POST);
411
+ $this->show_preview($revision);
412
+
413
+ exit();
414
+ }
415
+
416
+ public function ajax_get_revisions_history(){
417
+ $args = array(
418
+ // 'textareaids_include' => (string) wpfval( $_POST, 'textareaid' ),
419
+ 'postids_include' => wpforo_bigintval( wpfval( $_POST, 'postid' ) ),
420
+ 'userids_include' => WPF()->current_userid,
421
+ 'emails_include' => WPF()->current_user_email,
422
+ 'urls_include' => $this->get_current_url_query_vars_str()
423
+ );
424
+
425
+ $revisionhtml = '';
426
+ if( $revisions = $this->get_revisions($args) ){
427
+ foreach ($revisions as $revision) $revisionhtml .= $this->build_revision($revision);
428
+ }
429
+
430
+ echo json_encode(array(
431
+ 'revisions_count' => count($revisions),
432
+ 'revisionhtml' => $revisionhtml
433
+ ));
434
+ exit();
435
+ }
436
+
437
+ public function ajax_get_revision(){
438
+ if( $revisionid = wpforo_bigintval( wpfval($_POST, 'revisionid') ) ){
439
+ if( $revision = $this->get_revision( array('include' => $revisionid) ) ) echo json_encode( $revision );
440
+ }
441
+
442
+ exit();
443
+ }
444
+
445
+ public function ajax_delete_revision(){
446
+ if( $revisionid = wpforo_bigintval( wpfval($_POST, 'revisionid') ) ){
447
+ if( $this->delete( $revisionid ) ) echo $revisionid;
448
+ }
449
+
450
+ exit();
451
+ }
452
+
453
+ public function after_submit(){
454
+ $this->delete( array( 'userid' => WPF()->current_userid, 'email' => WPF()->current_user_email, 'url' => $this->get_current_url_query_vars_str() ) );
455
+ $sql = "SELECT EXISTS( SELECT * FROM ". WPF()->tables->post_revisions ." ) AS is_exists";
456
+ if( !WPF()->db->get_var($sql) ) WPF()->db->query("TRUNCATE " . WPF()->tables->post_revisions );
457
+ }
458
+ }
wpf-includes/class-template.php CHANGED
@@ -26,7 +26,7 @@ class wpForoTemplate{
26
27
private function init_hooks(){
28
if( is_wpforo_page() ){
29
- add_filter("mce_external_plugins", array($this, 'add_tinymce_buttons'), 15);
30
add_filter("tiny_mce_plugins", array($this, 'filter_tinymce_plugins'), 15);
31
add_filter("wp_mce_translation", array($this, 'add_tinymce_translations'));
32
add_filter("wpforo_editor_settings", array($this, 'editor_settings_required_params'), 999);
@@ -71,6 +71,33 @@ class wpForoTemplate{
71
'qa_display_answer_editor' => 1
72
);
73
74
$theme = get_option('wpforo_theme_options');
75
if(empty($theme)) $theme = $this->find_theme( 'classic' );
76
$this->default->options = $theme;
@@ -94,7 +121,7 @@ class wpForoTemplate{
94
define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
95
}
96
97
- function add_tinymce_buttons($plugin_array) {
98
$plugin_array = array();
99
$plugin_array['wpforo_pre_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-pre.js';
100
$plugin_array['wpforo_link_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-link.js';
@@ -1975,8 +2002,8 @@ class wpForoTemplate{
1975
public function add_footer_html(){
1976
?>
1977
<div id="wpforo-load" class="wpforo-load">
1978
- <i class="fas fa-3x fa-spinner fa-spin"></i>&nbsp;&nbsp;<br/>
1979
- <span class="loadtext"><?php wpforo_phrase('Working') ?></span>
1980
</div>
1981
1982
<div id="wpf-msg-box">
@@ -2058,7 +2085,7 @@ class wpForoTemplate{
2058
)
2059
);
2060
2061
- return apply_filters( 'wpforo_editor_settings', $settings[ $editor ] );
2062
}
2063
2064
public function editor_settings_required_params($settings){
@@ -2114,11 +2141,11 @@ class wpForoTemplate{
2114
<?php
2115
}
2116
2117
- public function do_spoilers($text){
2118
- $text = preg_replace('#(?:<(p|a|span|blockquote|b|i|pre|font|del|strike|strong|em|div|u|center|marquee|table|tr|td|th|tt|sup|sub|s|ul|ol|li|small|code|h\d)(?:[\r\n\t\s\0]+[^<>]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*[\'\"]([^\'\"]+)[\'\"])?[\r\n\t\s\0]*\](?:[\r\n\t\s\0]*</\1>)#isu', '<div class="wpf-spoiler-wrap"><div class="wpf-spoiler-head"><i class="wpf-spoiler-chevron-name">'. wpforo_phrase('Spoiler', false) .'</i><i class="wpf-spoiler-chevron fas fa-chevron-down"></i><div class="wpf-spoiler-title">$2</div></div><div class="wpf-spoiler-body">', $text);
2119
- $text = preg_replace('#\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*[\'\"]([^\'\"]+)[\'\"])?[\r\n\t\s\0]*\]#isu', '<div class="wpf-spoiler-wrap"><div class="wpf-spoiler-head"><i class="wpf-spoiler-chevron-name">'. wpforo_phrase('Spoiler', false) .'</i><i class="wpf-spoiler-chevron fas fa-chevron-down"></i><div class="wpf-spoiler-title">$1</div></div><div class="wpf-spoiler-body">', $text);
2120
- $text = preg_replace('#(?:<(p|a|span|blockquote|b|i|pre|font|del|strike|strong|em|div|u|center|marquee|table|tr|td|th|tt|sup|sub|s|ul|ol|li|small|code|h\d)(?:[\r\n\t\s\0]+[^<>]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*\](?:[\r\n\t\s\0]*</\1>)#isu', '</div></div>', $text);
2121
- $text = preg_replace('#\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*\]#isu', '</div></div>', $text);
2122
- return $text;
2123
- }
2124
}
26
27
private function init_hooks(){
28
if( is_wpforo_page() ){
29
+ add_filter("mce_external_plugins", array($this, 'add_mce_external_plugins' ), 15);
30
add_filter("tiny_mce_plugins", array($this, 'filter_tinymce_plugins'), 15);
31
add_filter("wp_mce_translation", array($this, 'add_tinymce_translations'));
32
add_filter("wpforo_editor_settings", array($this, 'editor_settings_required_params'), 999);
71
'qa_display_answer_editor' => 1
72
);
73
74
+ $this->default->editor_settings = array(
75
+ 'wpautop' => true,
76
+ 'media_buttons' => false,
77
+ 'textarea_name' => '',
78
+ 'textarea_rows' => 20,
79
+ 'tabindex' => '',
80
+ 'editor_height' => 180,
81
+ 'editor_css' => '',
82
+ 'editor_class' => '',
83
+ 'teeny' => false,
84
+ 'dfw' => false,
85
+ 'plugins' => 'hr,lists,textcolor,paste,wpautoresize,fullscreen,wpforo_pre_button,wpforo_link_button,wpforo_spoiler_button,wpforo_source_code_button,emoticons',
86
+ 'tinymce' => array(
87
+ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,wpf_spoil,undo,redo,pastetext,source_code,emoticons,fullscreen',
88
+ 'toolbar2' => '',
89
+ 'toolbar3' => '',
90
+ 'toolbar4' => '',
91
+ 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
92
+ 'object_resizing' => false,
93
+ 'autoresize_on_init' => true,
94
+ 'wp_autoresize_on' => true,
95
+ 'setup' => 'wpforo_tinymce_setup'
96
+ ),
97
+ 'quicktags' => false,
98
+ 'default_editor' => 'tinymce'
99
+ );
100
+
101
$theme = get_option('wpforo_theme_options');
102
if(empty($theme)) $theme = $this->find_theme( 'classic' );
103
$this->default->options = $theme;
121
define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
122
}
123
124
+ function add_mce_external_plugins($plugin_array) {
125
$plugin_array = array();
126
$plugin_array['wpforo_pre_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-pre.js';
127
$plugin_array['wpforo_link_button'] = WPFORO_URL . '/wpf-assets/js/tinymce-link.js';
2002
public function add_footer_html(){
2003
?>
2004
<div id="wpforo-load" class="wpforo-load">
2005
+ <div class="wpf-load-ico-wrap"><i class="fas fa-3x fa-spinner fa-spin"></i></div>
2006
+ <div class="wpf-load-txt-wrap"><span class="loadtext"></span></div>
2007
</div>
2008
2009
<div id="wpf-msg-box">
2085
)
2086
);
2087
2088
+ return array_merge( $this->default->editor_settings, apply_filters( 'wpforo_editor_settings', $settings[ $editor ] ) );
2089
}
2090
2091
public function editor_settings_required_params($settings){
2141
<?php
2142
}
2143
2144
+ public function do_spoilers($text){
2145
+ $text = preg_replace('#(?:<(p|a|span|blockquote|b|i|pre|font|del|strike|strong|em|div|u|center|marquee|table|tr|td|th|tt|sup|sub|s|ul|ol|li|small|code|h\d)(?:[\r\n\t\s\0]+[^<>]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*\"([^\"]+)\")?[\r\n\t\s\0]*\](?:[\r\n\t\s\0]*</\1>)#isu', '<div class="wpf-spoiler-wrap"><div class="wpf-spoiler-head"><i class="wpf-spoiler-chevron-name">'. wpforo_phrase('Spoiler', false) .'</i><i class="wpf-spoiler-chevron fas fa-chevron-down"></i><div class="wpf-spoiler-title">$2</div></div><div class="wpf-spoiler-body">', $text, -1, $count1);
2146
+ $text = preg_replace('#\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*\"([^\"]+)\")?[\r\n\t\s\0]*\]#isu', '<div class="wpf-spoiler-wrap"><div class="wpf-spoiler-head"><i class="wpf-spoiler-chevron-name">'. wpforo_phrase('Spoiler', false) .'</i><i class="wpf-spoiler-chevron fas fa-chevron-down"></i><div class="wpf-spoiler-title">$1</div></div><div class="wpf-spoiler-body">', $text, -1, $count2);
2147
+ $text = preg_replace('#(?:<(p|a|span|blockquote|b|i|pre|font|del|strike|strong|em|div|u|center|marquee|table|tr|td|th|tt|sup|sub|s|ul|ol|li|small|code|h\d)(?:[\r\n\t\s\0]+[^<>]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*\](?:[\r\n\t\s\0]*</\1>)#isu', '</div></div>', $text, $count1);
2148
+ $text = preg_replace('#\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*\]#isu', '</div></div>', $text, $count2);
2149
+ return $text;
2150
+ }
2151
}
wpf-includes/class-topics.php CHANGED
@@ -69,6 +69,7 @@ class wpForoTopic{
69
$args['title'] = wpforo_text($args['title'], 250, false);
70
$args['body'] = (isset($args['body']) ? preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $args['body']) : '' );
71
$args['slug'] = (isset($args['slug']) && $args['slug']) ? sanitize_title($args['slug']) : ((isset($args['title'])) ? sanitize_title($args['title']) : md5(time()));