wpForo Forum - Version 1.6.1

Version Description

Download this release

Release Info

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

Code changes from version 1.6.0 to 1.6.1

Files changed (48) hide show
  1. readme.txt +35 -3
  2. wpf-admin/xml/english.xml +2 -0
  3. wpf-assets/js/ajax.js +29 -2
  4. wpf-assets/js/frontend.js +4 -3
  5. wpf-includes/class-api.php +1 -1
  6. wpf-includes/class-forums.php +96 -90
  7. wpf-includes/class-logs.php +1 -1
  8. wpf-includes/class-members.php +2 -1
  9. wpf-includes/class-moderation.php +10 -2
  10. wpf-includes/class-permissions.php +83 -16
  11. wpf-includes/class-phrases.php +7 -5
  12. wpf-includes/class-posts.php +182 -125
  13. wpf-includes/class-template.php +188 -258
  14. wpf-includes/class-topics.php +76 -47
  15. wpf-includes/functions-template.php +146 -72
  16. wpf-includes/functions.php +13 -16
  17. wpf-includes/install-sql.php +2 -1
  18. wpf-includes/wpf-hooks.php +19 -0
  19. wpf-includes/wpf-phrases.php +4 -0
  20. wpf-languages/wpforo-he_IL.po +4 -4
  21. wpf-languages/wpforo-hu_HU.mo +0 -0
  22. wpf-languages/wpforo-hu_HU.po +524 -463
  23. wpf-languages/wpforo-pt_BR.mo +0 -0
  24. wpf-languages/wpforo-pt_BR.po +5293 -4876
  25. wpf-languages/wpforo.pot +145 -129
  26. wpf-themes/classic/colors.css +412 -402
  27. wpf-themes/classic/forum.php +49 -0
  28. wpf-themes/classic/functions.php +24 -2
  29. wpf-themes/classic/index.php +57 -311
  30. wpf-themes/classic/layouts/1/post.php +1 -3
  31. wpf-themes/classic/layouts/2/post.php +1 -1
  32. wpf-themes/classic/layouts/4/forum-sub.php +3 -3
  33. wpf-themes/classic/layouts/4/forum-thread.php +1 -1
  34. wpf-themes/classic/layouts/4/forum.php +3 -3
  35. wpf-themes/classic/layouts/4/post-thread.php +3 -0
  36. wpf-themes/classic/layouts/4/post.php +14 -2
  37. wpf-themes/classic/layouts/4/topic-thread.php +23 -23
  38. wpf-themes/classic/members.php +2 -1
  39. wpf-themes/classic/post.php +47 -0
  40. wpf-themes/classic/profile-activity.php +1 -1
  41. wpf-themes/classic/profile-subscriptions.php +2 -2
  42. wpf-themes/classic/style-rtl.css +42 -26
  43. wpf-themes/classic/style.css +43 -26
  44. wpf-themes/classic/styles/css.php +0 -641
  45. wpf-themes/classic/styles/matrix.css +638 -0
  46. wpf-themes/classic/tags.php +2 -7
  47. wpf-themes/classic/topic.php +51 -0
  48. wpforo.php +136 -29
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
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.1
6
- Stable tag: 1.6.0
7
Requires PHP: 5.5 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -160,6 +160,38 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
160
161
== Changelog ==
162
163
= wpForo Forum 1.6.0 | 01.03.2019 =
164
165
[wpForo v1.6.0 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-0-is-released/)
@@ -178,7 +210,7 @@ Find wpForo forum plugin addons on [gVectors Team website...](https://gvectors.c
178
* Added: Q&A Layout | Answers sorting options, by default "most voted"
179
* Added: Q&A Layout | Comments of answers are grouped, "see all comments" button
180
* Added: Q&A Layout | Either display Answer editor or Answer button (click to open)
181
- * Added: Q&A Layout | Add Comment button moved under each answer below comments
182
* Added: Q&A Layout | Opens editor under each answer on Add Comment button click
183
* Added: Q&A Layout | Visual and Text editor types for comments. Text by default
184
* Added: Q&A Layout | New options to manage layout specific things
2
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.1
7
Requires PHP: 5.5 and higher
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
160
161
== Changelog ==
162
163
+ = wpForo Forum 1.6.1 | 10.03.2019 =
164
+
165
+ [wpForo v1.6.1 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-1-is-released/)
166
+
167
+ * Added: Ordering of Threaded Layout forum list based on forum order in dashboard
168
+ * Added: Option to control thread replies depth (set 0 to disable reply nesting)
169
+ * Added: Option to disable reply button of first post in Threaded layout
170
+ * Added: Post liked users information under each reply in Threaded layout
171
+ * Added: Separator between first posts and replies of Threaded Layout topic
172
+ * Added: Breadcrumb SEO optimization with BreadcrumbList schema.
173
+ * Added: Automatic redirection to correct topic page if pagination rule is changed
174
+ * Fixed Bug: Unread forums and topics bold titles for Threaded Layout
175
+ * Fixed Bug: Widget "Display Avatar" option disabling problem
176
+ * Fixed Bug: Widget Recent Posts ordering issue
177
+ * Fixed Bug: reCAPTCHA style issues
178
+ * Fixed Bug: Wrong counting new users posts
179
+ * Fixed Bug: Localhost problems, especially on WAMP servers
180
+ * Fixed Bug: Reply editor, line-break, spellchecker, color and other issues
181
+ * Fixed Bug: Problems splitting and merging Threaded Layout topics
182
+ * Fixed Bug: Posts become unapproved, settings control issues.
183
+ * Fixed Bug: Many CSS issues and small bugs
184
+
185
+
186
+ IMPORTANT NOTES for UPDATE
187
+
188
+ - If you're updating from wpForo versions less than 1.6.0, please read the "Important notes and update" section of 1.6.0 version below.
189
+ - 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.
190
+ - To load your customized colors please refresh forum front-end page twice.
191
+ - If you have a Cache Plugin, please delete all caches after wpForo update.
192
+ - If you use CDN and found some issue please purge it.
193
+
194
+
195
= wpForo Forum 1.6.0 | 01.03.2019 =
196
197
[wpForo v1.6.0 Release Summary](https://wpforo.com/community/wpforo-announcements/wpforo-1-6-0-is-released/)
210
* Added: Q&A Layout | Answers sorting options, by default "most voted"
211
* Added: Q&A Layout | Comments of answers are grouped, "see all comments" button
212
* Added: Q&A Layout | Either display Answer editor or Answer button (click to open)
213
+ * Added: Q&A Layout | Add Comment button moved under each answer below
214
* Added: Q&A Layout | Opens editor under each answer on Add Comment button click
215
* Added: Q&A Layout | Visual and Text editor types for comments. Text by default
216
* Added: Q&A Layout | New options to manage layout specific things
wpf-admin/xml/english.xml CHANGED
@@ -668,4 +668,6 @@
668
<phrase name="Private Topics"><![CDATA[Private Topics]]></phrase>
669
<phrase name="Unapproved Posts"><![CDATA[Unapproved Posts]]></phrase>
670
<phrase name="Tag"><![CDATA[Tag]]></phrase>
671
</language>
668
<phrase name="Private Topics"><![CDATA[Private Topics]]></phrase>
669
<phrase name="Unapproved Posts"><![CDATA[Unapproved Posts]]></phrase>
670
<phrase name="Tag"><![CDATA[Tag]]></phrase>
671
+ <phrase name="%s Replies"><![CDATA[%s Replies]]></phrase>
672
+ <phrase name="%s Reply"><![CDATA[%s Reply]]></phrase>
673
</language>
wpf-assets/js/ajax.js CHANGED
@@ -5,8 +5,35 @@ jQuery.ajaxSetup({
5
}
6
});
7
8
jQuery(document).ready(function ($) {
9
var wpforo_wrap = $('#wpforo-wrap');
10
// Like
11
wpforo_wrap.on('click', '.wpforo-like', function () {
12
$("#wpf-msg-box").hide();
@@ -30,7 +57,7 @@ jQuery(document).ready(function ($) {
30
if (response.stat === 1) {
31
that.find('.wpforo-like-ico').removeClass('far').addClass('fas');
32
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Unlike'));
33
- that.parents('.post-wrap').find('.bleft').html(response.likers);
34
that.removeClass('wpforo-like').addClass('wpforo-unlike');
35
if( that.children(".wpf-like-icon").is("[wpf-tooltip]") ) {
36
that.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Unlike') );
@@ -67,7 +94,7 @@ jQuery(document).ready(function ($) {
67
if (response.stat === 1) {
68
that.find('.wpforo-like-ico').removeClass('fas').addClass('far');
69
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Like'));
70
- that.parents('.post-wrap').find('.bleft').html(response.likers);
71
that.removeClass('wpforo-unlike').addClass('wpforo-like');
72
if( that.children(".wpf-like-icon").is("[wpf-tooltip]") ) {
73
that.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Like') );
5
}
6
});
7
8
+ function wpforo_post_url_fixer(hash) {
9
+ var postid = 0;
10
+ var match = hash.match(/^#post-(\d+)#x2F;);
11
+ if ( match && (postid = match[1]) ) {
12
+ if (!jQuery(hash).length) {
13
+ jQuery.ajax({
14
+ type: 'POST',
15
+ data: {
16
+ postid: postid,
17
+ action: 'wpforo_post_url_fixer'
18
+ }
19
+ }).done(function (response) {
20
+ if( /^https?:\/\/[^\r\n\t\s\0'"]+#x2F;.test(response) ){
21
+ window.location.assign(response);
22
+ }
23
+ });
24
+ }
25
+ }
26
+ }
27
+
28
jQuery(document).ready(function ($) {
29
var wpforo_wrap = $('#wpforo-wrap');
30
+
31
+ //location hash ajax redirect fix
32
+ wpforo_post_url_fixer(window.location.hash);
33
+ window.onhashchange = function(){
34
+ wpforo_post_url_fixer(window.location.hash);
35
+ };
36
+
37
// Like
38
wpforo_wrap.on('click', '.wpforo-like', function () {
39
$("#wpf-msg-box").hide();
57
if (response.stat === 1) {
58
that.find('.wpforo-like-ico').removeClass('far').addClass('fas');
59
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Unlike'));
60
+ that.parents('.wpforo-post').find('.bleft').html(response.likers);
61
that.removeClass('wpforo-like').addClass('wpforo-unlike');
62
if( that.children(".wpf-like-icon").is("[wpf-tooltip]") ) {
63
that.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Unlike') );
94
if (response.stat === 1) {
95
that.find('.wpforo-like-ico').removeClass('fas').addClass('far');
96
that.find('.wpforo-like-txt').text(' ' + wpforo_phrase('Like'));
97
+ that.parents('.wpforo-post').find('.bleft').html(response.likers);
98
that.removeClass('wpforo-unlike').addClass('wpforo-like');
99
if( that.children(".wpf-like-icon").is("[wpf-tooltip]") ) {
100
that.children(".wpf-like-icon").attr("wpf-tooltip", wpforo_phrase('Like') );
wpf-assets/js/frontend.js CHANGED
@@ -21,13 +21,14 @@ function wpforo_tinymce_initializeIt(selector) {
21
plugins: "hr,lists,textcolor,paste,wpforo_pre_button,wpforo_link_button,wpforo_source_code_button,emoticons",
22
menubar: "",
23
toolbar: "fontsizeselect,bold,italic,underline,forecolor,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,blockquote,pre,source_code,emoticons",
24
- content_style: 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
25
branding: false,
26
elementpath: false,
27
min_height: 100,
28
height: 100,
29
statusbar: true,
30
- fix_list_elements: true
31
}).then(function (e) {
32
e[0].focus();
33
});
@@ -93,7 +94,7 @@ jQuery(document).ready(function($){
93
var add_wpftopic = '<i class="fas fa-times" aria-hidden="true"></i>';
94
if( !stat ) add_wpftopic = $("#wpf_formbutton").val();
95
$( "#add_wpftopic" ).html(add_wpftopic);
96
- $('html, body').animate({ scrollTop: ($(".wpforo-main").offset().top - 25) }, 415);
97
});
98
99
$(document).on('click', '.wpf-answer-button .wpf-button:not(.not_reg_user)', function(){
21
plugins: "hr,lists,textcolor,paste,wpforo_pre_button,wpforo_link_button,wpforo_source_code_button,emoticons",
22
menubar: "",
23
toolbar: "fontsizeselect,bold,italic,underline,forecolor,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,blockquote,pre,source_code,emoticons",
24
+ 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;}',
25
branding: false,
26
elementpath: false,
27
min_height: 100,
28
height: 100,
29
statusbar: true,
30
+ fix_list_elements: true,
31
+ browser_spellcheck: true
32
}).then(function (e) {
33
e[0].focus();
34
});
94
var add_wpftopic = '<i class="fas fa-times" aria-hidden="true"></i>';
95
if( !stat ) add_wpftopic = $("#wpf_formbutton").val();
96
$( "#add_wpftopic" ).html(add_wpftopic);
97
+ $('html, body').animate({ scrollTop: ($("#add_wpftopic").offset().top - 35) }, 415);
98
});
99
100
$(document).on('click', '.wpf-answer-button .wpf-button:not(.not_reg_user)', function(){
wpf-includes/class-api.php CHANGED
@@ -553,7 +553,7 @@ class wpForoAPI{
553
public function rc_enqueue_css() {
554
wp_register_style( 'wpforo-rc-style', false );
555
wp_enqueue_style( 'wpforo-rc-style' );
556
- $custom_css = "#wpforo_recaptcha_widget{ -webkit-transform:scale(0.9); transform:scale(0.9); -webkit-transform-origin:left 0; transform-origin:left 0; }";
557
wp_add_inline_style( 'wpforo-rc-style', $custom_css );
558
}
559
553
public function rc_enqueue_css() {
554
wp_register_style( 'wpforo-rc-style', false );
555
wp_enqueue_style( 'wpforo-rc-style' );
556
+ $custom_css = ".wpforo_recaptcha_widget{ -webkit-transform:scale(0.9); transform:scale(0.9); -webkit-transform-origin:left 0; transform-origin:left 0; }";
557
wp_add_inline_style( 'wpforo-rc-style', $custom_css );
558
}
559
wpf-includes/class-forums.php CHANGED
@@ -416,71 +416,61 @@ class wpForoForum{
416
}
417
418
function get_forum( $args ){
419
-
420
- $cache = WPF()->cache->on('memory_cashe');
421
-
422
- if(is_array($args)){
423
- $default = array(
424
- 'forumid' => NULL, // forumid
425
- 'slug' => '', // slug
426
- 'status' => NULL, // status forum 1 OR 0
427
- 'cat_layout' => 1, // forum layout
428
- 'type' => 'all' // category, forum
429
- );
430
- }else{
431
- $default = array(
432
- 'forumid' => ( is_numeric($args) ? intval($args) : NULL ), // forumid
433
- 'slug' => ( !is_numeric($args) ? $args : '' ), // slug
434
- 'cat_layout' => 1, // forum layout
435
- 'status' => NULL, // status forum 1 OR 0
436
- 'type' => 'all' // category, forum
437
- );
438
- }
439
$args = wpforo_parse_args( $args, $default );
440
-
441
- if( $cache && !empty($args['forumid']) ){
442
- if( !empty(self::$cache['forum'][$args['forumid']]) ){
443
- return self::$cache['forum'][$args['forumid']];
444
- }
445
- }
446
-
447
- if( $cache && !empty($args['slug']) ){
448
- if( !empty(self::$cache['forum'][addslashes($args['slug'])]) ){
449
- return self::$cache['forum'][addslashes($args['slug'])];
450
- }
451
}
452
- if(!empty($args)){
453
- extract($args, EXTR_OVERWRITE);
454
- $sql = "SELECT * FROM `".WPF()->tables->forums."`";
455
- $wheres = array();
456
- if($forumid != NULL) $wheres[] = "`forumid` = " . intval($forumid);
457
- if($status != NULL) $wheres[] = "`status` = " . intval($status);
458
- if($type == 'category'){
459
- $wheres[] = "`is_cat` = 1";
460
- }elseif($type == 'forum'){
461
- $wheres[] = "`is_cat` = 0";
462
- }
463
- if($slug != '') $wheres[] = "`slug` = '" . esc_sql($slug) . "'";
464
-
465
- if(!empty($wheres)){
466
- $sql .= " WHERE " . implode( " AND ", $wheres );
467
- }
468
- $forum = WPF()->db->get_row($sql, ARRAY_A);
469
- if(!empty($forum)) {
470
$forum['url'] = $this->get_forum_url( $forum );
471
}
472
- $forum = apply_filters('wpforo_get_forum', $forum);
473
- if($cache && isset($forumid)){
474
- self::$cache['forum'][addslashes($forum['slug'])] = $forum;
475
- return self::$cache['forum'][$forum['forumid']] = $forum;
476
- }
477
- else{
478
- return $forum;
479
- }
480
- }
481
}
482
483
- function get_forums($args = array(), &$items_count = 0 ){
484
485
$cache = WPF()->cache->on('object_cashe');
486
@@ -530,11 +520,13 @@ class wpForoForum{
530
if($parent_slug != '') $wheres[] = "`slug` = '" . esc_sql($parent_slug) . "'";
531
532
if(!empty($wheres)) $sql .= " WHERE " . implode( " AND ", $wheres );
533
-
534
- $item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
535
- $item_count_sql = preg_replace('#ORDER.+$#is', '', $item_count_sql);
536
- if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
537
-
538
$sql .= esc_sql(" ORDER BY `$orderby` " . $order);
539
540
if($row_count != NULL){
@@ -627,19 +619,31 @@ class wpForoForum{
627
628
}
629
}
630
-
631
- function get_childs($forumid, &$data){
632
- if(empty($data)) $data[] = $forumid;
633
- $sub_forums = WPF()->db->get_results("SELECT `forumid` FROM ".WPF()->tables->forums." WHERE `parentid` = ".intval($forumid) ." AND `forumid` <> " . intval($forumid), ARRAY_A);
634
- if(!empty($sub_forums)){
635
- foreach($sub_forums as $sub_forum){
636
- $data[] = $sub_forum['forumid'];
637
- $this->get_childs($sub_forum['forumid'], $data);
638
- }
639
- }
640
- }
641
-
642
-
643
// get forums tree for drop down menu
644
645
/**
@@ -659,17 +663,19 @@ class wpForoForum{
659
$this->count_depth($parentid, $depth);
660
}
661
}
662
-
663
function get_child_forums($parent){
664
- $children = WPF()->db->get_results("SELECT `forumid` AS childid FROM `".WPF()->tables->forums."` WHERE `parentid` = ".intval($parent)." AND `forumid` <> ".intval($parent)." ORDER BY `order`", ARRAY_A);
665
- if(!empty($children)){
666
- foreach( $children as $child ){
667
- $data[] = $child['childid'];
668
- }
669
- return $data;
670
- }else{
671
- return array();
672
- }
673
}
674
675
function forum_list( $forumids, $type = 'select_box', $selected = array(), $cats = TRUE, $disabled = array() ){
@@ -908,8 +914,8 @@ class wpForoForum{
908
* @return int layout id
909
*/
910
function get_layout($args = NULL){
911
- if(is_null($args) && wpfval(WPF()->current_object, 'forumid')) $args = WPF()->current_object['forumid'];
912
- if(!$args) return false;
913
if( $cat_layout = wpfval($args, 'cat_layout') ) return $cat_layout;
914
if(is_array($args)){
915
$default = array(
@@ -942,7 +948,7 @@ class wpForoForum{
942
}
943
}
944
945
- return 0;
946
}
947
948
function get_forum_url($forum){
416
}
417
418
function get_forum( $args ){
419
+ $forum = array();
420
+ if( !$args ) return $forum;
421
+
422
+ $default = array(
423
+ 'forumid' => NULL,
424
+ 'slug' => '',
425
+ 'status' => NULL,
426
+ 'type' => 'all'
427
+ );
428
+ if( !is_array($args) ){
429
+ if( is_numeric($args) ){
430
+ $default['forumid'] = intval($args);
431
+ }elseif ( is_string($args) ){
432
+ $default['slug'] = $args;
433
+ }
434
+ }
435
$args = wpforo_parse_args( $args, $default );
436
+
437
+ $cache = WPF()->cache->on('memory_cashe');
438
+ if( $cache ){
439
+ if( $args['forumid'] && $forum = wpfval(self::$cache, 'forum', $args['forumid']) ) return $forum;
440
+ if( $args['slug'] && $forum = wpfval(self::$cache, 'forum', addslashes($args['slug'])) ) return $forum;
441
}
442
+
443
+ $wheres = array();
444
+ if( $args['forumid'] ) $wheres[] = "`forumid` = " . intval($args['forumid']);
445
+ if( $args['slug'] ) $wheres[] = "`slug` = '" . esc_sql($args['slug']) . "'";
446
+ if( !is_null($args['status']) ) $wheres[] = "`status` = " . intval($args['status']);
447
+ switch ($args['type']){
448
+ case 'category':
449
+ $wheres[] = "`is_cat` = 1";
450
+ break;
451
+ case 'forum':
452
+ $wheres[] = "`is_cat` = 0";
453
+ break;
454
+ }
455
+
456
+ if($wheres){
457
+ $sql = "SELECT * FROM `".WPF()->tables->forums."` WHERE " . implode( " AND ", $wheres );
458
+ if( $forum = WPF()->db->get_row($sql, ARRAY_A) ){
459
+ if( !$forum['cat_layout'] ) $forum['cat_layout'] = 1;
460
$forum['url'] = $this->get_forum_url( $forum );
461
}
462
+ }
463
+ $forum = apply_filters('wpforo_get_forum', $forum, $args);
464
+
465
+ if($cache && $forum){
466
+ self::$cache['forum'][addslashes($forum['slug'])] = $forum;
467
+ self::$cache['forum'][$forum['forumid']] = $forum;
468
+ }
469
+
470
+ return $forum;
471
}
472
473
+ function get_forums($args = array(), &$items_count = 0, $count = false ){
474
475
$cache = WPF()->cache->on('object_cashe');
476
520
if($parent_slug != '') $wheres[] = "`slug` = '" . esc_sql($parent_slug) . "'";
521
522
if(!empty($wheres)) $sql .= " WHERE " . implode( " AND ", $wheres );
523
+
524
+ if( $count ){
525
+ $item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
526
+ // $item_count_sql = preg_replace('#ORDER.+$#is', '', $item_count_sql);
527
+ if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
528
+ }
529
+
530
$sql .= esc_sql(" ORDER BY `$orderby` " . $order);
531
532
if($row_count != NULL){
619
620
}
621
}
622
+
623
+ /**
624
+ * @param int|array $forumids
625
+ * @param array $data
626
+ * @param bool $merge_forumids_with_data
627
+ */
628
+ public function get_childs( $forumids, &$data, $merge_forumids_with_data = true ){
629
+ if( $forumids = array_map('intval', (array) $forumids) ){
630
+ $sql = "SELECT @forumids := GROUP_CONCAT(
631
+ @id := (
632
+ SELECT GROUP_CONCAT(`forumid` ORDER BY `order` ASC)
633
+ FROM `".WPF()->tables->forums."`
634
+ WHERE FIND_IN_SET( `parentid`, @id )
635
+ )
636
+ ) AS forumids
637
+ FROM ( SELECT @id := %s ) vars
638
+ STRAIGHT_JOIN `".WPF()->tables->forums."`
639
+ WHERE @id IS NOT NULL";
640
+ if( $grouped_forumids = WPF()->db->get_var( WPF()->db->prepare($sql, implode(',', $forumids)) ) ){
641
+ $data = explode(',', $grouped_forumids);
642
+ }
643
+ if($merge_forumids_with_data) $data = array_merge($forumids, $data);
644
+ }
645
+ }
646
+
647
// get forums tree for drop down menu
648
649
/**
663
$this->count_depth($parentid, $depth);
664
}
665
}
666
+
667
+ /**
668
+ * @param int $parent
669
+ *
670
+ * @return array
671
+ */
672
function get_child_forums($parent){
673
+ $sql = "SELECT `forumid`
674
+ FROM `".WPF()->tables->forums."`
675
+ WHERE `parentid` = ".intval($parent)."
676
+ AND `forumid` <> ".intval($parent)."
677
+ ORDER BY `order`";
678
+ return (array) WPF()->db->get_col($sql);
679
}
680
681
function forum_list( $forumids, $type = 'select_box', $selected = array(), $cats = TRUE, $disabled = array() ){
914
* @return int layout id
915
*/
916
function get_layout($args = NULL){
917
+ if( is_null($args) ) $args = WPF()->current_object['forum'];
918
+ if(!$args) return 1;
919
if( $cat_layout = wpfval($args, 'cat_layout') ) return $cat_layout;
920
if(is_array($args)){
921
$default = array(
948
}
949
}
950
951
+ return 1;
952
}
953
954
function get_forum_url($forum){
wpf-includes/class-logs.php CHANGED
@@ -33,7 +33,7 @@ class wpForoLogs{
33
} elseif( wpfval($data, 'topic', 'last_post') ) {
34
$last_postid = $data['topic']['last_post'];
35
}
36
- $this->read_item( $data['forumid'], $last_postid, 'wpf_read_forums' );
37
} else {
38
foreach( $topics as $topic ){
39
if( wpfval($topic, 'last_post') ){
33
} elseif( wpfval($data, 'topic', 'last_post') ) {
34
$last_postid = $data['topic']['last_post'];
35
}
36
+ if( !empty($last_postid) ) $this->read_item( $data['forumid'], $last_postid, 'wpf_read_forums' );
37
} else {
38
foreach( $topics as $topic ){
39
if( wpfval($topic, 'last_post') ){
wpf-includes/class-members.php CHANGED
@@ -1791,6 +1791,8 @@ class wpForoMember{
1791
WPF()->current_user_display_name = $guest['name'];
1792
}
1793
1794
WPF()->usergroup->init_current();
1795
}
1796
@@ -2891,5 +2893,4 @@ class wpForoMember{
2891
public function set_usergroups_secondary($userid, $group_ids = array()){
2892
//TODO: set_usergroups_secondary() method condition
2893
}
2894
-
2895
}
1791
WPF()->current_user_display_name = $guest['name'];
1792
}
1793
1794
+ WPF()->current_user_accesses = WPF()->perm->get_forum_accesses_by_usergroup();
1795
+
1796
WPF()->usergroup->init_current();
1797
}
1798
2893
public function set_usergroups_secondary($userid, $group_ids = array()){
2894
//TODO: set_usergroups_secondary() method condition
2895
}
2896
}
wpf-includes/class-moderation.php CHANGED
@@ -316,9 +316,17 @@ class wpForoModeration
316
}
317
}
318
319
$must_have_one_approved = apply_filters('wpforo_post_moderation_must_have_one_approved', true );
320
- if( $must_have_one_approved && !$this->has_approved( WPF()->current_userid ) ){
321
- $item['status'] = 1;
322
}
323
324
return $item;
316
}
317
}
318
319
+ // Don't track users as "a user without approved posts" if he/she no posts.
320
+ // Just check the number of unapproved posts before initiating this rule,
321
+ // if no unapproved posts then we don't need to set the first post of this user unapproved.
322
+ // This checking is already done by New User options when we set "1" post for New User status and turn on the "must be manually approved" option.
323
$must_have_one_approved = apply_filters('wpforo_post_moderation_must_have_one_approved', true );
324
+ if( $must_have_one_approved && $this->has_unapproved( WPF()->current_userid ) ){
325
+ // So this rule will only work from the second post,
326
+ // it'll always keep new posts unapproved if previous posts are not approved yet.
327
+ if( !$this->has_approved( WPF()->current_userid ) ){
328
+ $item['status'] = 1;
329
+ }
330
}
331
332
return $item;
wpf-includes/class-permissions.php CHANGED
@@ -4,7 +4,7 @@
4
5
6
class wpForoPermissions{
7
- private $access;
8
9
static $cache = array();
10
@@ -13,7 +13,9 @@ class wpForoPermissions{
13
public function init(){
14
if( WPF()->is_installed() ){
15
if( $accesses = $this->get_accesses() ){
16
- foreach( $accesses as $access ) $this->access[$access['access']] = $access;
17
}
18
}
19
}
@@ -26,8 +28,8 @@ class wpForoPermissions{
26
*/
27
function get_access($access){
28
$access = sanitize_text_field($access);
29
- if( !empty($this->access[$access]) ){
30
- return $this->access[$access];
31
}else{
32
$sql = "SELECT * FROM `".WPF()->tables->accesses."` WHERE `access` = '" . esc_sql($access) . "'";
33
return WPF()->db->get_row($sql, ARRAY_A);
@@ -173,19 +175,49 @@ class wpForoPermissions{
173
}
174
175
function forum_can( $do, $forumid = NULL, $groupid = NULL, $second_usergroupids = NULL ){
176
-
177
$can = 0;
178
$second_can = 0;
179
- if( !WPF()->current_user_groupid && is_null($groupid) ) return 0;
180
-
181
- if( is_null($forumid) && isset(WPF()->current_object['forumid']) ) {
182
- $forumid = WPF()->current_object['forumid'];
183
- }
184
- $forumid = intval($forumid);
185
-
186
- if( is_null($groupid) ) {
187
- $groupid = WPF()->current_user_groupid;
188
- }
189
if( is_null($second_usergroupids) && WPF()->current_user_secondary_groupids ) {
190
$second_usergroupids = explode(',', WPF()->current_user_secondary_groupids );
191
}
@@ -193,7 +225,7 @@ class wpForoPermissions{
193
$second_usergroupids = explode(',', $second_usergroupids);
194
}
195
196
- if( $forum = WPF()->forum->get_forum($forumid) ){
197
$permissions = unserialize($forum['permissions']);
198
//Primary Usergroup
199
if( isset($permissions[$groupid]) ){
@@ -431,5 +463,40 @@ class wpForoPermissions{
431
}
432
return true;
433
}
434
435
}
4
5
6
class wpForoPermissions{
7
+ public $accesses;
8
9
static $cache = array();
10
13
public function init(){
14
if( WPF()->is_installed() ){
15
if( $accesses = $this->get_accesses() ){
16
+ foreach( $accesses as $access ) {
17
+ $this->accesses[$access['access']] = $access;
18
+ }
19
}
20
}
21
}
28
*/
29
function get_access($access){
30
$access = sanitize_text_field($access);
31
+ if( !empty($this->accesses[$access]) ){
32
+ return $this->accesses[$access];
33
}else{
34
$sql = "SELECT * FROM `".WPF()->tables->accesses."` WHERE `access` = '" . esc_sql($access) . "'";
35
return WPF()->db->get_row($sql, ARRAY_A);
175
}
176
177
function forum_can( $do, $forumid = NULL, $groupid = NULL, $second_usergroupids = NULL ){
178
$can = 0;
179
$second_can = 0;
180
+ $secondary_can = 0;
181
+ if( !WPF()->current_user_groupid && is_null($groupid) || !$do ) return 0;
182
+
183
+ //User Forum accesses from Current Object of Current user
184
+ if( !empty(WPF()->current_user_accesses) && is_null($groupid) ){
185
+ if( is_null($forumid) && wpfval(WPF()->current_object, 'forum', 'forumid') ) {
186
+ $forum_id = WPF()->current_object['forum']['forumid']; } else { $forum_id = ( is_array($forumid) && wpfkey($forumid, 'forumid') ) ? $forumid['forumid'] : $forumid;
187
+ }
188
+ if( $forum_id ){
189
+ //Primary Usergroup
190
+ $primary_can = wpfval( WPF()->current_user_accesses, 'primary', $forum_id, $do );
191
+ //Secondary Usergroup
192
+ if( wpfval(WPF()->current_user_accesses, 'secondary') ) {
193
+ $secondary_accesses = wpfval( WPF()->current_user_accesses, 'secondary' );
194
+ foreach( $secondary_accesses as $secondary_access ){
195
+ $secondary_can = wpfval($secondary_access, $forum_id, $do); if( $secondary_can ) break;
196
+ }
197
+ }
198
+ //Return Access
199
+ if( !$primary_can && $secondary_can ){
200
+ return $secondary_can;
201
+ } else {
202
+ return $primary_can;
203
+ }
204
+ }
205
+ }
206
+
207
+ //Use Custom User Forum Accesses
208
+ if( is_null($forumid) ) {
209
+ $forum = WPF()->current_object['forum'];
210
+ }else{
211
+ if( is_array($forumid) && wpfkey($forumid, 'forumid') ){
212
+ $forum = $forumid;
213
+ }else{
214
+ $forum = WPF()->forum->get_forum($forumid);
215
+ }
216
+ }
217
+
218
+ if( is_null($groupid) ) {
219
+ $groupid = WPF()->current_user_groupid;
220
+ }
221
if( is_null($second_usergroupids) && WPF()->current_user_secondary_groupids ) {
222
$second_usergroupids = explode(',', WPF()->current_user_secondary_groupids );
223
}
225
$second_usergroupids = explode(',', $second_usergroupids);
226
}
227
228
+ if( $forum ){
229
$permissions = unserialize($forum['permissions']);
230
//Primary Usergroup
231
if( isset($permissions[$groupid]) ){
463
}
464
return true;
465
}
466
+
467
+ public function get_forum_accesses_by_usergroup( $usergroup = 0, $secondary_usergroups = '' ){
468
+
469
+ $user_accesses = array('primary' => array(), 'secondary' => array() );
470
+ $forums = WPF()->forum->get_forums();
471
+ $usergroup = ( $usergroup ) ? $usergroup : WPF()->current_user_groupid;
472
+ $secondary_usergroups = ( $secondary_usergroups ) ? $secondary_usergroups : WPF()->current_user_secondary_groupids;
473
+ $secondary_usergroups = ( $secondary_usergroups ) ? explode( ',', $secondary_usergroups ) : array();
474
+ if(!empty($forums)){
475
+ foreach( $forums as $forum ){
476
+ if( wpfval( $forum, 'permissions' ) ){
477
+ $permissions = unserialize( $forum['permissions'] );
478
+ if( !empty($permissions) ){
479
+ //Primary Usergroup Access
480
+ if( wpfval( $permissions, $usergroup ) ){
481
+ if(wpfval($this->accesses, $permissions[ $usergroup ], 'cans')){
482
+ $user_accesses['primary'][ $forum['forumid'] ] = unserialize($this->accesses[ $permissions[ $usergroup ] ] ['cans']);
483
+ }
484
+ }
485
+ //Secondary Usergroup Access
486
+ if( !empty($secondary_usergroups) ){
487
+ foreach( $secondary_usergroups as $secondary_usergroup ){
488
+ if( wpfval( $permissions, $secondary_usergroup ) ){
489
+ if(wpfval($this->accesses, $permissions[ $secondary_usergroup ], 'cans')){
490
+ $user_accesses['secondary'][ $secondary_usergroup ][ $forum['forumid'] ] = unserialize($this->accesses[ $permissions[ $secondary_usergroup ] ] ['cans']);
491
+ }
492
+ }
493
+ }
494
+ }
495
+ }
496
+ }
497
+ }
498
+ }
499
+ return $user_accesses;
500
+ }
501
502
}
wpf-includes/class-phrases.php CHANGED
@@ -10,7 +10,7 @@ class wpForoPhrase{
10
11
public function init(){
12
if( WPF()->is_installed() ) {
13
- if ( $phrases = $this->get_phrases( array('langid' => WPF()->general_options['lang']) ) ) {
14
foreach ($phrases as $phrase) {
15
$this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
16
$this->__phrases[addslashes(strtolower($phrase['phrase_key']))] = wpforo_phrase($phrase['phrase_key'], false);
@@ -66,7 +66,7 @@ class wpForoPhrase{
66
return WPF()->db->get_row($sql, ARRAY_A);
67
}
68
69
- function get_phrases($args = array(), &$items_count = 0){
70
$default = array(
71
'include' => array(), // array( 2, 10, 25 )
72
'exclude' => array(), // array( 2, 10, 25 )
@@ -101,9 +101,11 @@ class wpForoPhrase{
101
$sql .= " WHERE " . implode($wheres, " AND ");
102
}
103
104
- $item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
105
- $item_count_sql = preg_replace('#ORDER.+$#is', '', $item_count_sql);
106
- if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
107
108
$sql .= esc_sql(" ORDER BY `$orderby` " . $order);
109
10
11
public function init(){
12
if( WPF()->is_installed() ) {
13
+ if ( $phrases = $this->get_phrases() ) {
14
foreach ($phrases as $phrase) {
15
$this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
16
$this->__phrases[addslashes(strtolower($phrase['phrase_key']))] = wpforo_phrase($phrase['phrase_key'], false);
66
return WPF()->db->get_row($sql, ARRAY_A);
67
}
68
69
+ function get_phrases($args = array(), &$items_count = 0, $count = false){
70
$default = array(
71
'include' => array(), // array( 2, 10, 25 )
72
'exclude' => array(), // array( 2, 10, 25 )
101
$sql .= " WHERE " . implode($wheres, " AND ");
102
}
103
104
+ if( $count ){
105
+ $item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql);
106
+ // $item_count_sql = preg_replace('#ORDER.+$#is', '', $item_count_sql);
107
+ if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
108
+ }
109
110
$sql .= esc_sql(" ORDER BY `$orderby` " . $order);
111
wpf-includes/class-posts.php CHANGED
@@ -13,6 +13,10 @@ class wpForoPost{
13
$this->init_options();
14
}
15
16
public function reset(){
17
self::$cache = array( 'posts' => array(), 'post' => array(), 'item' => array(), 'topic_slug' => array(), 'forum_slug' => array(), 'post_url' => array() );
18
}
@@ -41,7 +45,9 @@ class wpForoPost{
41
'layout_threaded_posts_per_page' => 5,
42
'layout_qa_posts_per_page' => 15,
43
'layout_qa_comments_limit_count' => 3,
44
'layout_threaded_nesting_level' => 5,
45
'eor_durr' => 300,
46
'dor_durr' => 300,
47
'max_upload_size' => $upload_max_filesize,
@@ -62,6 +68,11 @@ class wpForoPost{
62
$this->options = get_wpf_option('wpforo_post_options', $this->default->options);
63
}
64
65
public function get_option_items_per_page($layout = null){
66
switch ( $layout ) {
67
case 4:
@@ -75,17 +86,18 @@ class wpForoPost{
75
break;
76
}
77
78
- return apply_filters('wpforo_post_get_option_items_per_page', $items_per_page, $layout);
79
}
80
81
- public function get_cache( $var ){
82
- if( isset(self::$cache[$var]) ) return self::$cache[$var];
83
- }
84
-
85
- public function get_union_first_post($layout){
86
$layout = intval($layout);
87
$union_first_post = (bool) wpfval($this->options['union_first_post'], $layout);
88
- return apply_filters('wpforo_post_options_get_union_first_post', $union_first_post, $layout);
89
}
90
91
public function add( $args = array() ){
@@ -198,7 +210,11 @@ class wpForoPost{
198
$post['private'] = $private;
199
$post['posturl'] = $this->get_post_url($postid);
200
201
- if ( ! $status ) {
202
$answ_incr = '';
203
$comm_incr = '';
204
if ( WPF()->forum->get_layout($forum) == 3 ) {
@@ -209,7 +225,6 @@ class wpForoPost{
209
}
210
}
211
WPF()->db->query( "UPDATE `" . WPF()->tables->profiles . "` SET `posts` = `posts` + 1 $answ_incr $comm_incr WHERE `userid` = " . wpforo_bigintval( $userid ) );
212
- if( $root_exists ) WPF()->topic->rebuild_threads( $topic, $root );
213
WPF()->topic->rebuild_first_last( $topic );
214
WPF()->topic->rebuild_stats( $topic );
215
WPF()->forum->rebuild_last_infos( $forum['forumid'] );
@@ -486,11 +501,13 @@ class wpForoPost{
486
}
487
488
/**
489
- * Returns merged arguments array from defined and default arguments.
490
*
491
* @since 1.0.0
492
*
493
- * @param array
494
*
495
* @return array
496
*/
@@ -530,100 +547,51 @@ class wpForoPost{
530
531
$args = wpforo_parse_args( $args, $default );
532
533
if( strtoupper( $args['order'] ) != 'DESC' && strtoupper( $args['order'] ) != 'ASC' ) $args['order'] = '';
534
-
535
- if(is_array($args) && !empty($args)){
536
-
537
- extract($args, EXTR_OVERWRITE);
538
-
539
- if( $row_count === 0 ) return array();
540
-
541
- $include = wpforo_parse_args( $include );
542
- $exclude = wpforo_parse_args( $exclude );
543
- $forumids = wpforo_parse_args( $forumids );
544
-
545
- $guest = array();
546
- $wheres = array();
547
- $table_as_prefix = '`'.WPF()->tables->posts.'`.';
548
- if(!is_user_logged_in()) $guest = WPF()->member->get_guest_cookies();
549
- if(!wpforo_root_exist() && !is_null($root) ) { $parentid = $root; $root = NULL; }
550
-
551
- if(!empty($include)) $wheres[] = $table_as_prefix . "`postid` IN(" . implode(',', array_map('wpforo_bigintval', $include)) . ")";
552
- if(!empty($exclude)) $wheres[] = $table_as_prefix . "`postid` NOT IN(" . implode(',', array_map('wpforo_bigintval', $exclude)) . ")";
553
- if(!empty($forumids)) $wheres[] = $table_as_prefix . "`forumid` IN(" . implode(',', array_map('intval', $forumids)) . ")";
554
-
555
- if(!is_null($topicid)) $wheres[] = $table_as_prefix . "`topicid` = " . wpforo_bigintval($topicid);
556
- if(!is_null($parentid)) $wheres[] = $table_as_prefix . "`parentid` = " . wpforo_bigintval($parentid);
557
- if(!is_null($root)) $wheres[] = $table_as_prefix . "`root` = " . wpforo_bigintval($root);
558
- if(!is_null($userid)) $wheres[] = $table_as_prefix . "`userid` = " . wpforo_bigintval($userid);
559
- if(!is_null($status)) $wheres[] = $table_as_prefix . "`status` = " . intval( (bool) $status);
560
- if(!is_null($private)) $wheres[] = $table_as_prefix . "`private` = " . intval( (bool) $private);
561
- if(!is_null($is_first_post)) $wheres[] = $table_as_prefix . "`is_first_post` = " . intval( (bool) $is_first_post);
562
- if(!is_null($is_answer)) $wheres[] = $table_as_prefix . "`is_answer` = " . intval( (bool) $is_answer);
563
- if(!is_null($email)) $wheres[] = $table_as_prefix . "`email` = '" . esc_sql($email) . "' ";
564
- if(!is_null($where)) $wheres[] = $table_as_prefix . $where;
565
-
566
- if( isset($forumid) && $forumid ){
567
- if( WPF()->perm->forum_can('au', $forumid) ){
568
- if(!is_null($status)) $wheres[] = $table_as_prefix . " `status` = " . intval($status);
569
- }
570
- elseif( !WPF()->perm->forum_can('vr', $forumid) ){
571
- $wheres[] = $table_as_prefix . " `is_first_post` = 1";
572
- }
573
- elseif( isset(WPF()->current_userid) && WPF()->current_userid ){
574
- $wheres[] = " ( " . $table_as_prefix . "`status` = 0 OR (" . $table_as_prefix . "`status` = 1 AND " . $table_as_prefix . "`userid` = " .intval(WPF()->current_userid). ") )";
575
- }
576
- elseif( wpfval($guest, 'email') ){
577
- $wheres[] = " ( " . $table_as_prefix . "`status` = 0 OR (" . $table_as_prefix . "`status` = 1 AND " . $table_as_prefix . "`email` = '" . sanitize_email($guest['email']) . "') )";
578
- }
579
- else{
580
- $wheres[] = " " . $table_as_prefix . "`status` = 0";
581
- }
582
}
583
-
584
- $ordering = ( $orderby ? " ORDER BY $orderby " . $order : '' );
585
- $limiting = ( $row_count ? " LIMIT " . intval( $offset ) . "," . intval( $row_count ) : '' );
586
-
587
- if( $limit_per_topic = intval($args['limit_per_topic']) ){
588
- $sql = "SELECT p.* FROM `".WPF()->tables->posts."` p
589
- INNER JOIN
590
- (SELECT `topicid` as g_topicid,
591
- GROUP_CONCAT(`postid` ". $ordering .") AS g_postids
592
- FROM `".WPF()->tables->posts."`".
593
- ($wheres ? " WHERE " . implode(" AND ", $wheres) : '')
594
- ." GROUP BY `topicid` ORDER BY `topicid` $order $limiting) g
595
- ON g.`g_topicid` = p.`topicid`
596
- AND (FIND_IN_SET(p.`postid`, g.`g_postids`) BETWEEN 1 AND $limit_per_topic)";
597
- }else{
598
- $sql = "SELECT * FROM `".WPF()->tables->posts."`";
599
- if(!empty($wheres)){
600
- $sql .= " WHERE " . implode(" AND ", $wheres);
601
- }
602
- }
603
-
604
if( $count ){
605
$item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql, 1);
606
if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
607
}
608
609
- $sql .= $ordering;
610
- if( !$limit_per_topic ) $sql .= $limiting;
611
612
- if( $args['union_first_post'] && $args['topicid'] && !$parentid && $items_count > intval( $offset ) ){
613
$sql = "( SELECT * FROM `".WPF()->tables->posts."`
614
- WHERE `topicid` = ".wpforo_bigintval($args['topicid'])."
615
- AND `is_first_post` = 1 )
616
- UNION
617
- ( " . $sql . " )";
618
}
619
-
620
if( $cache ){
621
- $object_key = md5( $sql . WPF()->current_user_groupid );
622
- $object_cache = WPF()->cache->get($object_key);
623
- if(!empty($object_cache)){
624
- return $object_cache['items'];
625
- }
626
- else{
627
$hach = serialize($request);
628
$cache_args_key = md5( $hach . WPF()->current_user_groupid );
629
$object_cache = WPF()->cache->get($cache_args_key, 'loop', 'post');
@@ -635,58 +603,147 @@ class wpForoPost{
635
636
$posts = WPF()->db->get_results($sql, ARRAY_A);
637
$posts = apply_filters('wpforo_get_posts', $posts);
638
-
639
- if( $check_private ){
640
- $posts = $this->access_filter( $posts, $owner );
641
}
642
643
- if($cache && isset($object_key) && !empty($posts)){
644
- self::$cache['posts'][$object_key]['items'] = $posts;
645
self::$cache['posts'][$object_key]['items_count'] = $items_count;
646
- if(isset($cache_args_key) && $cache_type == 'args' ){
647
- WPF()->cache->create_custom( $request, $posts, 'post', $items_count );
648
- }
649
}
650
return $posts;
651
}
652
}
653
654
- function access_filter( $posts, $owner = NULL ){
655
- foreach($posts as $key => $post){
656
- if( isset($post['forumid']) && !WPF()->perm->forum_can('vf', $post['forumid']) ){
657
- unset($posts[$key]);
658
}
659
- if( isset($post['forumid']) && !wpfval($post, 'is_first_post') && !WPF()->perm->forum_can('vr', $post['forumid']) ){
660
- unset($posts[$key]);
661
}
662
- if( isset($post['forumid']) && isset($post['private']) && $post['private'] && !$owner ){
663
- if(!WPF()->perm->forum_can('vp', $post['forumid'])){
664
- if(is_null($owner)){
665
- $topic_userid = wpforo_topic($post['topicid'], 'userid');
666
- if(!wpforo_is_owner($topic_userid) && !wpforo_is_owner($post['userid'])){
667
- unset($posts[$key]);
668
- }
669
- }else{
670
- unset($posts[$key]);
671
- }
672
- }
673
}
674
- if( isset($post['forumid']) && isset($post['status']) && $post['status'] && !wpforo_is_owner($post['userid'], $post['email']) ){
675
- if( !WPF()->perm->forum_can('au', $post['forumid']) ){
676
- unset($posts[$key]);
677
- }
678
}
679
}
680
return $posts;
681
}
682
683
function replies( array $posts, $topic = array(), $forum = array(), $level = 0 ) {
684
$level++;
685
if( function_exists('wpforo_thread_reply') ){
686
if( wpfval($posts, 'posts') ){
687
$key = key($posts['posts']);
688
$parentid = (wpfval($posts, 'posts', $key,'parentid')) ? $posts['posts'][$key]['parentid'] : 0;
689
- echo '<div id="wpf-post-replies-'.intval($parentid).'" class="wpf-post-replies level-'. $level .'">';
690
foreach ( $posts['posts'] as $post ) {
691
$parents = ( wpfval($posts, 'parents') ) ? $posts['parents'] : array();
692
wpforo_thread_reply( $post, $topic, $forum, $level, $parents );
@@ -1157,7 +1214,7 @@ class wpForoPost{
1157
$postid = $post['postid'];
1158
}
1159
1160
- if ( is_array( $post ) && ! empty( $post ) && $postid ) {
1161
1162
$forum_slug = (wpfval($post, 'forumid')) ? wpforo_forum($post['forumid'], 'slug') : $this->get_forumslug_byid( $postid );
1163
$topic_slug = (wpfval($post, 'topicid')) ? wpforo_topic($post['topicid'], 'slug') : $this->get_topicslug_byid( $postid );
13
$this->init_options();
14
}
15
16
+ public function get_cache( $var ){
17
+ if( isset(self::$cache[$var]) ) return self::$cache[$var];
18
+ }
19
+
20
public function reset(){
21
self::$cache = array( 'posts' => array(), 'post' => array(), 'item' => array(), 'topic_slug' => array(), 'forum_slug' => array(), 'post_url' => array() );
22
}
45
'layout_threaded_posts_per_page' => 5,
46
'layout_qa_posts_per_page' => 15,
47
'layout_qa_comments_limit_count' => 3,
48
+ 'layout_qa_first_post_reply' => 1,
49
'layout_threaded_nesting_level' => 5,
50
+ 'layout_threaded_first_post_reply' => 0,
51
'eor_durr' => 300,
52
'dor_durr' => 300,
53
'max_upload_size' => $upload_max_filesize,
68
$this->options = get_wpf_option('wpforo_post_options', $this->default->options);
69
}
70
71
+ /**
72
+ * @param int $layout
73
+ *
74
+ * @return int items_per_page
75
+ */
76
public function get_option_items_per_page($layout = null){
77
switch ( $layout ) {
78
case 4:
86
break;
87
}
88
89
+ return (int) apply_filters('wpforo_post_get_option_items_per_page', $items_per_page, $layout);
90
}
91
92
+ /**
93
+ * @param int $layout
94
+ *
95
+ * @return bool
96
+ */
97
+ public function get_option_union_first_post($layout){
98
$layout = intval($layout);
99
$union_first_post = (bool) wpfval($this->options['union_first_post'], $layout);
100
+ return (bool) apply_filters('wpforo_post_options_get_union_first_post', $union_first_post, $layout);
101
}
102
103
public function add( $args = array() ){
210
$post['private'] = $private;
211
$post['posturl'] = $this->get_post_url($postid);
212
213
+ if( $root_exists ) {
214
+ WPF()->topic->rebuild_threads( $topic, $root );
215
+ }
216
+
217
+ if ( !$status ) {
218
$answ_incr = '';
219
$comm_incr = '';
220
if ( WPF()->forum->get_layout($forum) == 3 ) {
225
}
226
}
227
WPF()->db->query( "UPDATE `" . WPF()->tables->profiles . "` SET `posts` = `posts` + 1 $answ_incr $comm_incr WHERE `userid` = " . wpforo_bigintval( $userid ) );
228
WPF()->topic->rebuild_first_last( $topic );
229
WPF()->topic->rebuild_stats( $topic );
230
WPF()->forum->rebuild_last_infos( $forum['forumid'] );
501
}
502
503
/**
504
+ * get all posts based on provided arguments
505
*
506
* @since 1.0.0
507
*
508
+ * @param array $args
509
+ * @param int $items_count
510
+ * @param bool $count
511
*
512
* @return array
513
*/
547
548
$args = wpforo_parse_args( $args, $default );
549
550
+ if( $args['row_count'] === 0 ) return array();
551
+ if( $args['forumid'] && $args['check_private'] && !WPF()->perm->forum_can('vf', $args['forumid']) ) return array();
552
if( strtoupper( $args['order'] ) != 'DESC' && strtoupper( $args['order'] ) != 'ASC' ) $args['order'] = '';
553
+ if(!wpforo_root_exist() && !is_null($args['root']) ) { $args['parentid'] = $args['root']; $args['root'] = NULL; }
554
+
555
+ $wheres = $this->get_posts_conditions( $args );
556
+
557
+ $ordering = ( $args['orderby'] ? " ORDER BY " . esc_sql( $args['orderby'] . ' ' . $args['order'] ) : '' );
558
+ $limiting = ( $args['row_count'] ? " LIMIT " . intval( $args['offset'] ) . "," . intval( $args['row_count'] ) : '' );
559
+
560
+ if( $limit_per_topic = intval($args['limit_per_topic']) ){
561
+ $sql = "SELECT SUBSTRING_INDEX( GROUP_CONCAT(`postid` ORDER BY `created` DESC), ',', " . $limit_per_topic . " ) postids
562
+ FROM `".WPF()->tables->posts."` ".
563
+ ($wheres ? " WHERE " . implode(" AND ", $wheres) : '')
564
+ ." GROUP BY `topicid` ORDER BY MAX(`postid`) DESC " . $limiting;
565
+ return WPF()->db->get_col($sql);
566
+ } else {
567
+ $sql = "SELECT * FROM `".WPF()->tables->posts."`";
568
+ if(!empty($wheres)){
569
+ $sql .= " WHERE " . implode(" AND ", $wheres);
570
}
571
if( $count ){
572
$item_count_sql = preg_replace('#SELECT.+?FROM#isu', 'SELECT count(*) FROM', $sql, 1);
573
if( $item_count_sql ) $items_count = WPF()->db->get_var($item_count_sql);
574
}
575
576
+ $sql .= $ordering . $limiting;
577
578
+ if( $args['union_first_post'] && $args['topicid'] && !$args['parentid'] && $items_count > intval( $args['offset'] ) ){
579
$sql = "( SELECT * FROM `".WPF()->tables->posts."`
580
+ WHERE `topicid` = ".wpforo_bigintval($args['topicid'])."
581
+ AND `is_first_post` = 1 )
582
+ UNION
583
+ ( " . $sql . " )";
584
}
585
+
586
if( $cache ){
587
+ if( $args['cache_type'] == 'sql' ){
588
+ $object_key = md5( $sql . WPF()->current_user_groupid );
589
+ $object_cache = WPF()->cache->get($object_key);
590
+ if(!empty($object_cache)){
591
+ return $object_cache['items'];
592
+ }
593
+ }
594
+ if( $args['cache_type'] == 'args' ){
595
$hach = serialize($request);
596
$cache_args_key = md5( $hach . WPF()->current_user_groupid );
597
$object_cache = WPF()->cache->get($cache_args_key, 'loop', 'post');
603
604
$posts = WPF()->db->get_results($sql, ARRAY_A);
605
$posts = apply_filters('wpforo_get_posts', $posts);
606
+
607
+ if( $args['check_private'] && !$args['forumid'] ){
608
+ $posts = $this->access_filter( $posts, $args['owner'] );
609
}
610
611
+ if($cache && isset($object_key) && !empty($posts)){
612
+ self::$cache['posts'][$object_key]['items'] = $posts;
613
self::$cache['posts'][$object_key]['items_count'] = $items_count;
614
+ if(isset($cache_args_key) && $args['cache_type'] == 'args' ){
615
+ WPF()->cache->create_custom( $request, $posts, 'post', $items_count );
616
+ }
617
}
618
return $posts;
619
}
620
}
621
622
+ function get_posts_conditions( $args = array() ){
623
+
624
+ $wheres = array();
625
+ $guest = array();
626
+ $table_as_prefix = '`'.WPF()->tables->posts.'`.';
627
+ if(!is_user_logged_in()) $guest = WPF()->member->get_guest_cookies();
628
+
629
+ $args['include'] = wpforo_parse_args( $args['include'] );
630
+ $args['exclude'] = wpforo_parse_args( $args['exclude'] );
631
+ $args['forumids'] = wpforo_parse_args( $args['forumids'] );
632
+
633
+ if(!empty($args['include'])) $wheres[] = $table_as_prefix . "`postid` IN(" . implode(',', array_map('wpforo_bigintval', $args['include'])) . ")";
634
+ if(!empty($args['exclude'])) $wheres[] = $table_as_prefix . "`postid` NOT IN(" . implode(',', array_map('wpforo_bigintval', $args['exclude'])) . ")";
635
+ if(!empty($args['forumids'])) $wheres[] = $table_as_prefix . "`forumid` IN(" . implode(',', array_map('intval', $args['forumids'])) . ")";
636
+
637
+ if(!is_null($args['topicid'])) $wheres[] = $table_as_prefix . "`topicid` = " . wpforo_bigintval($args['topicid']);
638
+ if(!is_null($args['parentid'])) $wheres[] = $table_as_prefix . "`parentid` = " . wpforo_bigintval($args['parentid']);
639
+ if(!is_null($args['root'])) $wheres[] = $table_as_prefix . "`root` = " . wpforo_bigintval($args['root']);
640
+ if(!is_null($args['userid'])) $wheres[] = $table_as_prefix . "`userid` = " . wpforo_bigintval($args['userid']);
641
+ if(!is_null($args['status'])) $wheres[] = $table_as_prefix . "`status` = " . intval( (bool) $args['status']);
642
+ if(!is_null($args['private'])) $wheres[] = $table_as_prefix . "`private` = " . intval( (bool) $args['private']);
643
+ if(!is_null($args['is_first_post'])) $wheres[] = $table_as_prefix . "`is_first_post` = " . intval( (bool) $args['is_first_post']);
644
+ if(!is_null($args['is_answer'])) $wheres[] = $table_as_prefix . "`is_answer` = " . intval( (bool) $args['is_answer']);
645
+ if(!is_null($args['email'])) $wheres[] = $table_as_prefix . "`email` = '" . esc_sql($args['email']) . "' ";
646
+ if(!is_null($args['where'])) $wheres[] = $table_as_prefix . $args['where'];
647
+
648
+ if(wpfval($args, 'forumid') && $args['check_private']){
649
+
650
+ /////Check "View Reply" Access//////////////////////////////
651
+ if( !WPF()->perm->forum_can('vr', $args['forumid']) ){
652
+ $wheres[] = $table_as_prefix . " `is_first_post` = 1";
653
}
654
+
655
+ /////Check Private Post Access//////////////////////////////
656
+ if( WPF()->perm->forum_can('vp', $args['forumid']) ){
657
+ //Check "View Private Posts" Access
658
+ if(!is_null($args['private'])) $wheres[] = $table_as_prefix . " `private` = " . intval($args['status']);
659
}
660
+ elseif( isset(WPF()->current_userid) && WPF()->current_userid ){
661
+ //Allow Users see own private posts
662
+ $wheres[] = " ( " . $table_as_prefix . "`private` = 0 OR (" . $table_as_prefix . "`private` = 1 AND " . $table_as_prefix . "`userid` = " .intval(WPF()->current_userid). ") )";
663
}
664
+ elseif( wpfval($guest, 'email') ){
665
+ //Allow Guests see own private posts
666
+ $wheres[] = " ( " . $table_as_prefix . "`private` = 0 OR (" . $table_as_prefix . "`private` = 1 AND " . $table_as_prefix . "`email` = '" . sanitize_email($guest['email']) . "') )";
667
+ }
668
+ else{
669
+ //If doesn't have "View Private Posts" access and not Owner, only return public posts
670
+ $wheres[] = " " . $table_as_prefix . "`private` = 0";
671
+ }
672
+
673
+ /////Check Unapproved Post Access////////////////////////////
674
+ if( WPF()->perm->forum_can('au', $args['forumid']) ){
675
+ //Check "Can Approve/Unapprove Posts" Access (View Unapproved Posts)
676
+ if(!is_null($args['status'])) $wheres[] = $table_as_prefix . " `status` = " . intval($args['status']);
677
+ }
678
+ elseif( isset(WPF()->current_userid) && WPF()->current_userid ){
679
+ //Allow Users see own unapproved posts
680
+ $wheres[] = " ( " . $table_as_prefix . "`status` = 0 OR (" . $table_as_prefix . "`status` = 1 AND " . $table_as_prefix . "`userid` = " .intval(WPF()->current_userid). ") )";
681
+ }
682
+ elseif( wpfval($guest, 'email') ){
683
+ //Allow Guests see own unapproved posts
684
+ $wheres[] = " ( " . $table_as_prefix . "`status` = 0 OR (" . $table_as_prefix . "`status` = 1 AND " . $table_as_prefix . "`email` = '" . sanitize_email($guest['email']) . "') )";
685
+ }
686
+ else{
687
+ //If doesn't have "Can Approve/Unapprove Posts" access and not Owner, only return approved posts
688
+ $wheres[] = " " . $table_as_prefix . "`status` = 0";
689
+ }
690
+ }
691
+ return $wheres;
692
+ }
693
+
694
+ function access_filter( $posts, $owner = NULL ){
695
+ if( !empty($posts) ){
696
+ foreach($posts as $key => $post){
697
+ if(!$this->access($post, $owner)) unset($posts[$key]);
698
}
699
}
700
return $posts;
701
}
702
703
+
704
+ function access( $post, $owner = NULL ){
705
+ if( isset($post['forumid']) && !WPF()->perm->forum_can('vf', $post['forumid']) ){
706
+ return false;
707
+ }
708
+ if( isset($post['forumid']) && !wpfval($post, 'is_first_post') && !WPF()->perm->forum_can('vr', $post['forumid']) ){
709
+ return false;
710
+ }
711
+ if( isset($post['forumid']) && isset($post['private']) && $post['private'] && !$owner ){
712
+ if(!WPF()->perm->forum_can('vp', $post['forumid'])){
713
+ if(is_null($owner)){
714
+ $topic_userid = wpforo_topic($post['topicid'], 'userid');
715
+ if(!wpforo_is_owner($topic_userid) && !wpforo_is_owner($post['userid'])){
716
+ return false;
717
+ }
718
+ }else{
719
+ return false;
720
+ }
721
+ }
722
+ }
723
+ if( isset($post['forumid']) && isset($post['status']) && $post['status'] && !wpforo_is_owner($post['userid'], $post['email']) ){
724
+ if( !WPF()->perm->forum_can('au', $post['forumid']) ){
725
+ return false;
726
+ }
727
+ }
728
+ return true;
729
+ }
730
+
731
+
732
function replies( array $posts, $topic = array(), $forum = array(), $level = 0 ) {
733
$level++;
734
if( function_exists('wpforo_thread_reply') ){
735
if( wpfval($posts, 'posts') ){
736
$key = key($posts['posts']);
737
$parentid = (wpfval($posts, 'posts', $key,'parentid')) ? $posts['posts'][$key]['parentid'] : 0;
738
+ $max_level = $this->options['layout_threaded_nesting_level'];
739
+ if( !$max_level ){
740
+ $class = ( $level > 1 ) ? '' : ' level-1';
741
+ } elseif( $level > ( $max_level + 1 ) ) {
742
+ $class = '';
743
+ } else {
744
+ $class = ' level-' . $level;
745
+ }
746
+ echo '<div id="wpf-post-replies-'.intval($parentid).'" class="wpf-post-replies '. $class .'">';
747
foreach ( $posts['posts'] as $post ) {
748
$parents = ( wpfval($posts, 'parents') ) ? $posts['parents'] : array();
749
wpforo_thread_reply( $post, $topic, $forum, $level, $parents );
1214
$postid = $post['postid'];
1215
}
1216
1217
+ if ( ! empty( $post ) && is_array( $post ) && !empty($postid) ) {
1218
1219
$forum_slug = (wpfval($post, 'forumid')) ? wpforo_forum($post['forumid'], 'slug') : $this->get_forumslug_byid( $postid );
1220
$topic_slug = (wpfval($post, 'topicid')) ? wpforo_topic($post['topicid'], 'slug') : $this->get_topicslug_byid( $postid );
wpf-includes/class-template.php CHANGED
@@ -154,7 +154,7 @@ class wpForoTemplate{
154
</div>
155
<div class="wpf-topic-forum-wrap" style="width: 70%; margin: 0px auto; padding-bottom: 15px; min-width: 280px; border-bottom: 1px dashed #cccccc;">
156
<select class="wpf-topic-form-forumid" name="topic[forumid]" style="width: 100%;">
157
- <option class="wpf-topic-form-no-selected-forum" value="0">-- <?php _e('No forum selected', 'wpforo'); ?> --</option>
158
<?php WPF()->forum->tree('select_box', false, array(), true, array(), $forumid); ?>
159
</select>
160
</div>
@@ -618,7 +618,9 @@ class wpForoTemplate{
618
<?php
619
}
620
621
- function pagenavi($paged, $items_count, $items_per_page = null, $permalink = TRUE, $class = ''){
622
if( is_null($items_per_page) ) $items_per_page = WPF()->current_object['items_per_page'];
623
624
if($items_count <= $items_per_page) return;
@@ -626,7 +628,7 @@ class wpForoTemplate{
626
$pages_count = ceil($items_count/$items_per_page);
627
628
$current_url = ( WPF()->current_url ? WPF()->current_url : wpforo_get_request_uri() );
629
- $sanitized_current_url = trim( preg_replace(array('#/'. preg_quote( $this->slugs['paged'] ) .'/?\d*/?#isu', '#[\&\?]wpfpaged=\d*#isu'), '', $current_url), '/' );
630
631
if($permalink){
632
$rtrimed_url = '';
@@ -735,9 +737,9 @@ class wpForoTemplate{
735
foreach($buttons as $button){
736
737
switch($button){
738
-
739
case 'reply':
740
- if($is_closed || $is_approve) break;
741
if( WPF()->perm->forum_can('cr', $forumid) ){
742
$layout = WPF()->forum->get_layout($forumid);
743
$layout_class = 'wpforo_layout_' . intval($layout);
@@ -757,7 +759,7 @@ class wpForoTemplate{
757
}
758
break;
759
case 'comment':
760
- if($is_closed || $is_approve) break;
761
$title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false);
762
if( WPF()->perm->forum_can('cr', $forumid) ) {
763
$button_html[] = '<span id="parentpostid'.wpforo_bigintval($postid).'" class="wpforo-qa-comment wpf-button" title="'.esc_attr($title).'" data-phrase="' . esc_attr( wpforo_phrase('Add a comment', false) ) . '"><i class="far fa-comment"></i><span class="wpf-button-text">' . wpforo_phrase('Add a comment', false).'</span></span>';
@@ -766,7 +768,7 @@ class wpForoTemplate{
766
}
767
break;
768
case 'comment_raw':
769
- if($is_closed || $is_approve) break;
770
$title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false);
771
if( WPF()->perm->forum_can('cr', $forumid) ) {
772
$button_html[] = '<a class="wpforo-qa-comment" title="'.esc_attr($title).'" data-phrase="' . esc_attr( wpforo_phrase('Add a comment', false, 'lower') ) . '"><i class="far fa-comment"></i><span class="wpf-button-text">' . wpforo_phrase('Add a comment', false, 'lower').'</span></a>';
@@ -936,217 +938,119 @@ class wpForoTemplate{
936
937
function breadcrumb($url_data){
938
939
- extract($url_data, EXTR_OVERWRITE);
940
941
- $lenght = apply_filters( 'wpforo_breadcrumb_text_length', 19 );
942
-
943
- switch($template) :
944
- case 'search': ?>
945
-
946
- <div class="wpf-breadcrumb">
947
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
948
-
949
- <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
950
-
951
- <a href="#" class="wpf-end">&nbsp;</a>
952
- </div>
953
-
954
- <?php break;
955
- case 'signup': ?>
956
-
957
- <div class="wpf-breadcrumb">
958
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
959
-
960
- <a href="#" class="active"><?php wpforo_phrase('Register') ?></a>
961
-
962
- <a href="#" class="wpf-end">&nbsp;</a>
963
- </div>
964
-
965
- <?php break;
966
- case 'signin': ?>
967
-
968
- <div class="wpf-breadcrumb">
969
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
970
-
971
- <a href="#" class="active"><?php wpforo_phrase('Login') ?></a>
972
-
973
- <a href="#" class="wpf-end">&nbsp;</a>
974
- </div>
975
-
976
- <?php break;
977
- case 'members': ?>
978
-
979
- <div class="wpf-breadcrumb">
980
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
981
-
982
- <?php if(isset($_GET['wpfms'])) : ?>
983
-
984
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
985
- <a href="#" class="active"><?php wpforo_phrase('Search') ?></a>
986
-
987
- <?php else : ?>
988
-
989
- <a href="#" class="active"><?php wpforo_phrase('Members') ?></a>
990
-
991
- <?php endif ?>
992
-
993
- <a href="#" class="wpf-end">&nbsp;</a>
994
- </div>
995
-
996
- <?php break;
997
- case 'recent': ?>
998
-
999
- <div class="wpf-breadcrumb">
1000
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
1001
- <?php if( wpfval($_GET, 'view') && $_GET['view'] == 'unread' ): ?>
1002
- <a href="#" class="active"><?php wpforo_phrase('Unread Posts') ?></a>
1003
<?php else: ?>
1004
- <a href="#" class="active"><?php wpforo_phrase('Recently Added') ?></a>
1005
<?php endif; ?>
1006
- <a href="#" class="wpf-end">&nbsp;</a>
1007
- </div>
1008
-
1009
- <?php break;
1010
- case 'tags': ?>
1011
-
1012
- <div class="wpf-breadcrumb">
1013
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
1014
-
1015
- <a href="#" class="active"><?php wpforo_phrase('Tags') ?></a>
1016
-
1017
<a href="#" class="wpf-end">&nbsp;</a>
1018
- </div>
1019
-
1020
<?php break;
1021
- case 'profile': ?>
1022
-
1023
- <div class="wpf-breadcrumb">
1024
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
1025
-
1026
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
1027
- <a href="#" class="active"><?php @wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></a>
1028
-
1029
- <a href="#" class="wpf-end">&nbsp;</a>
1030
- </div>
1031
-
1032
- <?php break;
1033
- case 'account': ?>
1034
-
1035
- <div class="wpf-breadcrumb">
1036
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i>
1037
-
1038
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
1039
- <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></a>
1040
- <a href="#" class="active"><?php wpforo_phrase('Account') ?></a>
1041
-
1042
- <a href="#" class="wpf-end">&nbsp;</a>
1043
- </div>
1044
-
1045
- <?php break;
1046
- case 'activity': ?>
1047
-
1048
- <div class="wpf-breadcrumb">
1049
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i>
1050
-
1051
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
1052
- <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></a>
1053
- <a href="#" class="active"><?php wpforo_phrase('Activity') ?></a>
1054
-
1055
- <a href="#" class="wpf-end">&nbsp;</a>
1056
- </div>
1057
-
1058
- <?php break;
1059
- case 'subscriptions': ?>
1060
-
1061
- <div class="wpf-breadcrumb">
1062
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i>
1063
-
1064
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
1065
- <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></a>
1066
- <a href="#" class="active"><?php wpforo_phrase('Subscriptions') ?></a>
1067
-
1068
- <a href="#" class="wpf-end">&nbsp;</a>
1069
- </div>
1070
-
1071
- <?php break;
1072
- // TODO: move code to pm plugin
1073
- case 'messages': ?>
1074
-
1075
- <div class="wpf-breadcrumb">
1076
- <a href="<?php echo wpforo_home_url() ?>" class="wpf-root" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i>
1077
-
1078
- <a href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a>
1079
-
1080
- <?php if(!empty($user)) : ?>
1081
-
1082
- <a href="<?php echo esc_url($user['profile_url']) ?>"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></a>
1083
-
1084
- <?php endif ?>
1085
-
1086
- <a href="#" class="active"><?php wpforo_phrase('Messages') ?></a>
1087
-
1088
- <a href="#" class="wpf-end">&nbsp;</a>
1089
- </div>
1090
-
1091
- <?php break;
1092
- case 'topic': ?>
1093
-
1094
- <div class="wpf-breadcrumb">
1095
- <a href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
1096
-
1097
- <?php if(isset($forumid)) : ?>
1098
- <?php $relative_ids = array();
1099
- WPF()->forum->get_all_relative_ids($forumid, $relative_ids);
1100
- foreach( $relative_ids as $key => $rel_forumid ) : ?>
1101
- <?php $forum = wpforo_forum($rel_forumid) ?>
1102
<?php if(!empty($forum)): ?>
1103
- <?php if( $key != ( count($relative_ids) - 1 ) ) : ?>
1104
- <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], $lenght) ?></a>
1105
<?php else : ?>
1106
- <a href="#" class="active" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], $lenght) ?></a>
1107
<?php endif ?>
1108
<?php endif ?>
1109
- <?php endforeach ?>
1110
- <?php endif ?>
1111
-
1112
- <a href="#" class="wpf-end">&nbsp;</a>
1113
- </div>
1114
-
1115
- <?php break;
1116
- case 'post': ?>
1117
-
1118
- <div class="wpf-breadcrumb">
1119
- <a href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" class="wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i></a>
1120
-
1121
- <?php if(isset($forumid)) : ?>
1122
- <?php $relative_ids = array();
1123
- WPF()->forum->get_all_relative_ids($forumid, $relative_ids);
1124
- foreach( $relative_ids as $key => $rel_forumid ) : ?>
1125
- <?php $forum = wpforo_forum($rel_forumid) ?>
1126
- <?php if(!empty($forum)): ?>
1127
- <a href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><?php wpforo_text($forum['title'], $lenght) ?></a>
1128
- <?php endif ?>
1129
- <?php endforeach ?>
1130
- <?php endif ?>
1131
- <?php if(!empty($topic)) : ?>
1132
-
1133
- <a href="#" class="active" title="<?php echo esc_attr($topic['title']) ?>"><?php wpforo_text($topic['title'], $lenght) ?></a>
1134
-
1135
- <?php endif ?>
1136
- <a href="#" class="wpf-end">&nbsp;</a>
1137
- </div>
1138
-
1139
- <?php break;
1140
- default: ?>
1141
-
1142
- <div class="wpf-breadcrumb">
1143
- <a href="#" class="wpf-root active"><?php wpforo_phrase('Forums') ?></a>
1144
- <a href="#" class="wpf-end">&nbsp;</a>
1145
- </div>
1146
-
1147
- <?php
1148
- endswitch;
1149
-
1150
}
1151
1152
function icon($type, $item = array(), $echo = true, $data = 'icon' ){
@@ -1626,19 +1530,24 @@ class wpForoTemplate{
1626
public function generate_dynamic_css( $theme = '' ) {
1627
$css = '';
1628
$COLORS = array();
1629
1630
$style = wpfval($this->options, 'style');
1631
$styles = wpfval($this->options, 'styles');
1632
if ( ! empty( $style ) && ! empty( $styles ) ) {
1633
foreach ( $styles[ $style ] as $color_key => $color_value ) {
1634
- if ( $color_value ) $COLORS[ 'WPFCOLOR_' . $color_key ] = $color_value;
1635
}
1636
}
1637
1638
- $dynamic_css_matrix = ( $theme ? WPFORO_THEME_DIR . '/' . $theme : WPFORO_TEMPLATE_DIR ) . '/styles/css.php';
1639
- if ( file_exists( $dynamic_css_matrix ) ) {
1640
- extract( $COLORS, EXTR_OVERWRITE );
1641
- require_once( $dynamic_css_matrix );
1642
}
1643
1644
$css = apply_filters( 'wpforo_dynamic_css_filter', $css, $COLORS );
@@ -2001,49 +1910,70 @@ class wpForoTemplate{
2001
}
2002
}
2003
2004
- public function editor_buttons( $editor = 'post' ){
2005
- $buttons = array( 'topic' => array(
2006
- 'wpautop' => true,
2007
- 'media_buttons'=> FALSE,
2008
- 'textarea_name'=> 'topic[body]',
2009
- 'textarea_rows'=> get_option('default_post_edit_rows', 20),// rows = "..."
2010
- 'tabindex'=> '',
2011
- 'editor_height' => '180',
2012
- 'editor_css' => '',
2013
- 'editor_class'=> '',
2014
- 'teeny'=> FALSE,
2015
- 'dfw'=> false,
2016
- 'tinymce'=> array(
2017
- 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code,emoticons',
2018
- 'toolbar2' => '',
2019
- 'toolbar3' => '',
2020
- 'toolbar4' => '',
2021
- 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
2022
- 'object_resizing' => false
2023
- ),
2024
- 'quicktags'=> true,
2025
- 'default_editor' => 'tinymce' ),
2026
- 'post' => array(
2027
- 'wpautop' => true,
2028
- 'media_buttons'=> FALSE,
2029
- 'textarea_name'=> 'post[body]',
2030
- 'textarea_rows'=> get_option('default_post_edit_rows', 5),
2031
- 'editor_class'=> 'wpeditor',
2032
- 'teeny'=> false,
2033
- 'dfw'=> false,
2034
- 'editor_height' => 180,
2035
- 'tinymce'=> array(
2036
- 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code,emoticons',
2037
- 'toolbar2' => '',
2038
- 'toolbar3' => '',
2039
- 'toolbar4' => '',
2040
- 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
2041
- 'object_resizing' => false
2042
- ),
2043
- 'quicktags'=> true,
2044
- 'default_editor' => 'tinymce' )
2045
- );
2046
2047
- return apply_filters( 'wpforo_editor_settings' , $buttons[ $editor ] );
2048
- }
2049
}
154
</div>
155
<div class="wpf-topic-forum-wrap" style="width: 70%; margin: 0px auto; padding-bottom: 15px; min-width: 280px; border-bottom: 1px dashed #cccccc;">
156
<select class="wpf-topic-form-forumid" name="topic[forumid]" style="width: 100%;">
157
+ <option class="wpf-topic-form-no-selected-forum" value="0">-- <?php wpforo_phrase('No forum selected'); ?> --</option>
158
<?php WPF()->forum->tree('select_box', false, array(), true, array(), $forumid); ?>
159
</select>
160
</div>
618
<?php
619
}
620
621
+ function pagenavi($paged = null, $items_count = null, $items_per_page = null, $permalink = TRUE, $class = ''){
622
+ if( is_null($paged) ) $paged = WPF()->current_object['paged'];
623
+ if( is_null($items_count) ) $items_count = WPF()->current_object['items_count'];
624
if( is_null($items_per_page) ) $items_per_page = WPF()->current_object['items_per_page'];
625
626
if($items_count <= $items_per_page) return;
628
$pages_count = ceil($items_count/$items_per_page);
629
630
$current_url = ( WPF()->current_url ? WPF()->current_url : wpforo_get_request_uri() );
631
+ $sanitized_current_url = trim( WPF()->strip_url_paged_var($current_url), '/' );
632
633
if($permalink){
634
$rtrimed_url = '';
737
foreach($buttons as $button){
738
739
switch($button){
740
+
741
case 'reply':
742
+ if($is_closed || $is_approve || ($is_topic && !WPF()->post->options['layout_threaded_first_post_reply']) ) break;
743
if( WPF()->perm->forum_can('cr', $forumid) ){
744
$layout = WPF()->forum->get_layout($forumid);
745
$layout_class = 'wpforo_layout_' . intval($layout);
759
}
760
break;
761
case 'comment':
762
+ if($is_closed || $is_approve || ($is_topic && !WPF()->post->options['layout_qa_first_post_reply'])) break;
763
$title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false);
764
if( WPF()->perm->forum_can('cr', $forumid) ) {
765
$button_html[] = '<span id="parentpostid'.wpforo_bigintval($postid).'" class="wpforo-qa-comment wpf-button" title="'.esc_attr($title).'" data-phrase="' . esc_attr( wpforo_phrase('Add a comment', false) ) . '"><i class="far fa-comment"></i><span class="wpf-button-text">' . wpforo_phrase('Add a comment', false).'</span></span>';
768
}
769
break;
770
case 'comment_raw':
771
+ if($is_closed || $is_approve || ($is_topic && !WPF()->post->options['layout_qa_first_post_reply'])) break;
772
$title = wpforo_phrase('Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false);
773
if( WPF()->perm->forum_can('cr', $forumid) ) {
774
$button_html[] = '<a class="wpforo-qa-comment" title="'.esc_attr($title).'" data-phrase="' . esc_attr( wpforo_phrase('Add a comment', false, 'lower') ) . '"><i class="far fa-comment"></i><span class="wpf-button-text">' . wpforo_phrase('Add a comment', false, 'lower').'</span></a>';
938
939
function breadcrumb($url_data){
940
941
+ extract($url_data, EXTR_OVERWRITE); $lenght = apply_filters( 'wpforo_breadcrumb_text_length', 19 ); ?>
942
943
+ <style>.wpf-item-element{display: inline;}</style>
944
+ <div class="wpf-breadcrumb" itemscope="" itemtype="http://schema.org/BreadcrumbList">
945
+ <?php switch($template) :
946
+ case 'search': ?>
947
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root" ><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
948
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Search') ?></span><meta itemprop="position" content="2"></div>
949
+ <a href="#" class="wpf-end">&nbsp;</a>
950
+ <?php break; case 'signup': ?>
951
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root" ><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
952
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Register') ?></span><meta itemprop="position" content="2"></div>
953
+ <a href="#" class="wpf-end">&nbsp;</a>
954
+ <?php break; case 'signin': ?>
955
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root" ><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
956
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Login') ?></span><meta itemprop="position" content="2"></div>
957
+ <a href="#" class="wpf-end">&nbsp;</a>
958
+ <?php break; case 'members': ?>
959
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root" ><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
960
+ <?php if(isset($_GET['wpfms'])) : ?>
961
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><?php wpforo_phrase('Members') ?></a><meta itemprop="position" content="2"></div>
962
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Search') ?></span></div>
963
+ <?php else : ?>
964
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Members') ?></span><meta itemprop="position" content="2"></div>
965
+ <?php endif ?>
966
+ <a href="#" class="wpf-end">&nbsp;</a>
967
+ <?php break; case 'recent': ?>
968
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
969
+ <?php if( wpfval($_GET, 'view') && $_GET['view'] == 'unread' ): ?>
970
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Unread Posts') ?></span><meta itemprop="position" content="2"></div>
971
<?php else: ?>
972
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Recently Added') ?></span><meta itemprop="position" content="2"></div>
973
<?php endif; ?>
974
<a href="#" class="wpf-end">&nbsp;</a>
975
+ <?php break; case 'tags': ?>
976
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
977
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Tags') ?></span><meta itemprop="position" content="2"></div>
978
+ <a href="#" class="wpf-end">&nbsp;</a>
979
+ <?php break; case 'profile': ?>
980
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
981
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><span itemprop="name"><?php wpforo_phrase('Members') ?></span></a><meta itemprop="position" content="2"></div>
982
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php @wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></span><meta itemprop="position" content="3"></div>
983
+ <a href="#" class="wpf-end">&nbsp;</a>
984
+ <?php break; case 'account': ?>
985
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
986
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><span itemprop="name"><?php wpforo_phrase('Members') ?></span></a><meta itemprop="position" content="2"></div>
987
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo esc_url($user['profile_url']) ?>"><span itemprop="name"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></span></a><meta itemprop="position" content="3"></div>
988
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><?php wpforo_phrase('Account') ?><meta itemprop="position" content="4"></div>
989
+ <a href="#" class="wpf-end">&nbsp;</a>
990
<?php break;
991
+ case 'activity': ?>
992
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
993
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element" ><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><span itemprop="name"><?php wpforo_phrase('Members') ?></span></a><meta itemprop="position" content="2"></div>
994
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element" ><a itemprop="item" href="<?php echo esc_url($user['profile_url']) ?>"><span itemprop="name"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></span></a><meta itemprop="position" content="3"></div>
995
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><?php wpforo_phrase('Activity') ?><meta itemprop="position" content="4"></div>
996
+ <a href="#" class="wpf-end">&nbsp;</a>
997
+ <?php break;
998
+ case 'subscriptions': ?>
999
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
1000
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><span itemprop="name"><?php wpforo_phrase('Members') ?></span></a><meta itemprop="position" content="2"></div>
1001
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo esc_url($user['profile_url']) ?>"><span itemprop="name"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></span></a><meta itemprop="position" content="3"></div>
1002
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><?php wpforo_phrase('Subscriptions') ?><meta itemprop="position" content="4"></div>
1003
+ <a href="#" class="wpf-end">&nbsp;</a>
1004
+ <?php break;
1005
+ case 'messages': ?>
1006
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-root"><a itemprop="item" href="<?php echo wpforo_home_url() ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
1007
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo wpforo_home_url($this->slugs['members']) ?>"><span itemprop="name"><?php wpforo_phrase('Members') ?></span></a><meta itemprop="position" content="2"></div>
1008
+ <?php if(!empty($user)) : ?>
1009
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo esc_url($user['profile_url']) ?>"><span itemprop="name"><?php wpforo_text( wpforo_make_dname($user['display_name'], $user['user_nicename']), $lenght ) ?></span></a><meta itemprop="position" content="3"></div>
1010
+ <?php endif ?>
1011
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_phrase('Messages') ?></span></div>
1012
+ <a class="wpf-end">&nbsp;</a>
1013
+ <?php break;
1014
+ case 'topic': ?>
1015
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>"><a itemprop="item" href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
1016
+ <?php if(isset($forumid)) : ?>
1017
+ <?php $relative_ids = array();
1018
+ WPF()->forum->get_all_relative_ids($forumid, $relative_ids);
1019
+ foreach( $relative_ids as $key => $rel_forumid ) : ?>
1020
+ <?php $forum = wpforo_forum($rel_forumid) ?>
1021
<?php if(!empty($forum)): ?>
1022
+ <?php if( $key != ( count($relative_ids) - 1 ) ) : ?>
1023
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element"><a itemprop="item" href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><span itemprop="name"><?php wpforo_text($forum['title'], $lenght) ?></span></a><meta itemprop="position" content="<?php echo $key+2; ?>"></div>
1024
<?php else : ?>
1025
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_text($forum['title'], $lenght) ?></span><meta itemprop="position" content="<?php echo count($relative_ids) + 1; ?>"></div>
1026
<?php endif ?>
1027
<?php endif ?>
1028
+ <?php endforeach ?>
1029
+ <?php endif ?>
1030
+ <a href="#" class="wpf-end">&nbsp;</a>
1031
+ <?php break;
1032
+ case 'post': $key = 0; ?>
1033
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root<?php echo ( !isset($forumid) ? ' active' : '' ) ?>"><a itemprop="item" href="<?php echo ( !isset($forumid) ? '#' : wpforo_home_url() ) ?>" title="<?php esc_attr( wpforo_phrase('Forums') ) ?>"><i class="fas fa-home"></i><span itemprop="name" style="display:none;"><?php wpforo_phrase('Forums') ?></span></a><meta itemprop="position" content="1"></div>
1034
+ <?php if(isset($forumid)) : ?>
1035
+ <?php $relative_ids = array();
1036
+ WPF()->forum->get_all_relative_ids($forumid, $relative_ids);
1037
+ foreach( $relative_ids as $key => $rel_forumid ) : ?>
1038
+ <?php $forum = wpforo_forum($rel_forumid) ?>
1039
+ <?php if(!empty($forum)): ?>
1040
+ <div class="wpf-item-element" itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem"><a itemprop="item" href="<?php echo esc_url( $forum['url'] ) ?>" title="<?php echo esc_attr($forum['title']) ?>"><span itemprop="name"><?php wpforo_text($forum['title'], $lenght) ?></span></a><meta itemprop="position" content="<?php echo $key+2; ?>"></div>
1041
+ <?php endif ?>
1042
+ <?php endforeach ?>
1043
+ <?php endif ?>
1044
+ <?php if(!empty($topic)) : ?>
1045
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element active"><span itemprop="name"><?php wpforo_text($topic['title'], $lenght) ?></span><meta itemprop="position" content="<?php echo count($relative_ids) + 2; ?>"></div>
1046
+ <?php endif ?>
1047
+ <a href="#" class="wpf-end">&nbsp;</a>
1048
+ <?php break; default: ?>
1049
+ <div itemprop="itemListElement" itemscope="" itemtype="https://schema.org/ListItem" class="wpf-item-element wpf-root active"><span itemprop="name"><?php wpforo_phrase('Forums') ?></span><meta itemprop="position" content="1"></div>
1050
+ <a href="#" class="wpf-end">&nbsp;</a>
1051
+ <?php endswitch; ?>
1052
+ </div>
1053
+ <?php
1054
}
1055
1056
function icon($type, $item = array(), $echo = true, $data = 'icon' ){
1530
public function generate_dynamic_css( $theme = '' ) {
1531
$css = '';
1532
$COLORS = array();
1533
+ $search = array();
1534
+ $replace = array();
1535
1536
$style = wpfval($this->options, 'style');
1537
$styles = wpfval($this->options, 'styles');
1538
if ( ! empty( $style ) && ! empty( $styles ) ) {
1539
foreach ( $styles[ $style ] as $color_key => $color_value ) {
1540
+ if ( $color_value ) {
1541
+ $search[] = '__WPFCOLOR_' . $color_key . '__';
1542
+ $replace[] = $color_value;
1543
+ $COLORS[ 'WPFCOLOR_' . $color_key ] = $color_value;
1544
+ }
1545
}
1546
}
1547
1548
+ $css_matrix = ( $theme ? WPFORO_THEME_DIR . '/' . $theme : WPFORO_TEMPLATE_DIR ) . '/styles/matrix.css';
1549
+ if ( file_exists( $css_matrix ) ) {
1550
+ $css = str_replace( $search, $replace, wpforo_get_file_content( $css_matrix ) );
1551
}
1552
1553
$css = apply_filters( 'wpforo_dynamic_css_filter', $css, $COLORS );
1910
}
1911
}
1912
1913
+ public function editor_buttons( $editor = 'post' ) {
1914
+ $buttons = array(
1915
+ 'topic' => array(
1916
+ 'wpautop' => true,
1917
+ 'media_buttons' => false,
1918
+ 'textarea_name' => 'topic[body]',
1919
+ 'textarea_rows' => get_option( 'default_post_edit_rows', 20 ),// rows = "..."
1920
+ 'tabindex' => '',
1921
+ 'editor_height' => '180',
1922
+ 'editor_css' => '',
1923
+ 'editor_class' => '',
1924
+ 'teeny' => false,
1925
+ 'dfw' => false,
1926
+ 'tinymce' => array(
1927
+ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code,emoticons',
1928
+ 'toolbar2' => '',
1929
+ 'toolbar3' => '',
1930
+ 'toolbar4' => '',
1931
+ 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
1932
+ 'object_resizing' => false
1933
+ ),
1934
+ 'quicktags' => true,
1935
+ 'default_editor' => 'tinymce'
1936
+ ),
1937
+ 'post' => array(
1938
+ 'wpautop' => true,
1939
+ 'media_buttons' => false,
1940
+ 'textarea_name' => 'post[body]',
1941
+ 'textarea_rows' => get_option( 'default_post_edit_rows', 5 ),
1942
+ 'editor_class' => 'wpeditor',
1943
+ 'teeny' => false,
1944
+ 'dfw' => false,
1945
+ 'editor_height' => 180,
1946
+ 'tinymce' => array(
1947
+ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,undo,redo,pastetext,source_code,emoticons',
1948
+ 'toolbar2' => '',
1949
+ 'toolbar3' => '',
1950
+ 'toolbar4' => '',
1951
+ 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;}',
1952
+ 'object_resizing' => false
1953
+ ),
1954
+ 'quicktags' => true,
1955
+ 'default_editor' => 'tinymce'
1956
+ )
1957
+ );
1958
1959
+ return apply_filters( 'wpforo_editor_settings', $buttons[ $editor ] );
1960
+ }
1961
+
1962
+ public function add_topic_button( $forumid = null ) {
1963
+ if ( WPF()->perm->forum_can( 'ct', $forumid ) ): ?>
1964
+ <button id="add_wpftopic" class="wpf-button">
1965
+ <?php
1966
+ if ( WPF()->forum->get_layout( $forumid ) == 3 ) {
1967
+ wpforo_phrase( 'Ask a question' );
1968
+ } else {
1969
+ wpforo_phrase( 'Add topic' );
1970
+ }
1971
+ ?>
1972
+ </button>
1973
+ <?php elseif ( WPF()->current_user_groupid == 4 ) : ?>
1974
+ <button id="add_wpftopic" class="wpf-button not_reg_user">
1975
+ <?php wpforo_phrase( 'Add topic' ) ?>
1976
+ </button>
1977
+ <?php endif;
1978
+ }
1979
}
wpf-includes/class-topics.php CHANGED
@@ -613,7 +613,7 @@ class wpForoTopic{
613
'order' => 'DESC', // ASC DESC
614
'offset' => null, // this use when you give row_count
615
'row_count' => null, // 4 or 1 ...
616
- 'permgroup' => null, //Đ¢reat permissions based on attribute value not on current user usergroup
617
'read' => null, //true / false
618
'where' => null
619
);
@@ -729,37 +729,63 @@ class wpForoTopic{
729
}
730
}
731
732
- if( $cache ){ $object_key = md5( $sql . WPF()->current_user_groupid ); $object_cache = WPF()->cache->get( $object_key ); if( !empty($object_cache) ){ return $object_cache['items']; }}
733
734
$topics = WPF()->db->get_results($sql, ARRAY_A);
735
$topics = apply_filters('wpforo_get_topics', $topics);
736
-
737
- if(!empty($forumids) || !$forumid){
738
- foreach($topics as $key => $topic){
739
- if( !WPF()->perm->forum_can('vf', $topic['forumid'], $permgroup) ){
740
- unset($topics[$key]);
741
- }
742
- if( isset($topics[$key]) && isset($topic['private']) && $topic['private'] && !wpforo_is_owner($topic['userid'], $topic['email']) ){
743
- if( !WPF()->perm->forum_can('vp', $topic['forumid'], $permgroup) ){
744
- unset($topics[$key]);
745
- }
746
- }
747
- if( isset($topics[$key]) && isset($topic['status']) && $topic['status'] && !wpforo_is_owner($topic['userid'], $topic['email']) ){
748
- if( !WPF()->perm->forum_can('au', $topic['forumid'], $permgroup) ){
749
- unset($topics[$key]);
750
- }
751
- }
752
- }
753
- }
754
-
755
- if($cache && isset($object_key) && !empty($topics)){
756
- self::$cache['topics'][$object_key]['items'] = $topics;
757
- self::$cache['topics'][$object_key]['items_count'] = $items_count;
758
- }
759
return $topics;
760
}
761
}
762
-
763
function get_topics_filtered( $args = array() ){
764
$topics = array();
765
$topics = $this->get_topics( $args, $items_count, false );
@@ -979,6 +1005,7 @@ class wpForoTopic{
979
}else{
980
$this->rebuild_first_last($current);
981
$this->rebuild_stats($current);
982
wpforo_clean_cache('topic', $current['topicid'], $current);
983
}
984
@@ -1074,7 +1101,6 @@ class wpForoTopic{
1074
)
1075
){
1076
$args['topicid'] = $topicid = WPF()->db->insert_id;
1077
- $this->rebuild_threads($topicid);
1078
1079
if( $this->merge( WPF()->current_object['topic'], $args, $args['postids'], $to_target_title, 0 ) ){
1080
WPF()->notice->clear();
@@ -1145,7 +1171,6 @@ class wpForoTopic{
1145
if($status) {
1146
do_action( 'wpforo_topic_unapprove', $topic );
1147
if( wpfval($topic, 'tags') ) $this->remove_tags( $topic['tags'] );
1148
-
1149
if( WPF()->forum->get_layout($topic) == 3 ){
1150
$questions = ' `questions` = IF( (`questions` - 1) < 0, 0, `questions` - 1 ) ';
1151
WPF()->db->query(
@@ -1157,10 +1182,10 @@ class wpForoTopic{
1157
} else {
1158
do_action( 'wpforo_topic_approve', $topic );
1159
if( wpfval($topic, 'tags') ) $this->add_tags( $topic['tags'] );
1160
-
1161
- $questions = '';
1162
- if( WPF()->forum->get_layout($topic) == 3 ) $questions = ', `questions` = `questions` + 1 ';
1163
- WPF()->db->query( "UPDATE ".WPF()->tables->profiles." SET `posts` = `posts` + 1 $questions WHERE `userid` = " . wpforo_bigintval($topic['userid']) );
1164
}
1165
1166
WPF()->member->reset($topic['userid']);
@@ -1246,21 +1271,25 @@ class wpForoTopic{
1246
1247
function rebuild_threads( $topicid, $root = NULL ){
1248
if( !is_null($root) && $root <= 0 ) return;
1249
- if( is_array($topicid) ) $topicid = wpfval($topicid, 'topicid');
1250
- $posts = WPF()->db->get_results("SELECT * FROM `".WPF()->tables->posts."` WHERE `topicid` = " . intval($topicid), ARRAY_A );
1251
- if( !empty($posts) ){
1252
- foreach( $posts as $post ) {
1253
- $threads[ $post['postid'] ] = array('postid' => $post['postid'], 'parentid' => $post['parentid']);
1254
- }
1255
- unset($posts);
1256
- foreach( $threads as $item ){
1257
- if( !is_null($root) && $root != $item['postid'] ) continue;
1258
- if( !$item['parentid'] ){
1259
- $thread = WPF()->post->build_thread_data($item['postid'], $threads);
1260
- if(wpfval($thread, 'children')){
1261
- $children = implode(',', $thread['children']);
1262
- WPF()->db->query("UPDATE `".WPF()->tables->posts."` SET `root` = 0 WHERE `postid` = " . intval($item['postid']) );
1263
- WPF()->db->query("UPDATE `".WPF()->tables->posts."` SET `root` = " . intval($item['postid']) . " WHERE `postid` IN(" . esc_sql($children) . ")" );
1264
}
1265
}
1266
}
613
'order' => 'DESC', // ASC DESC
614
'offset' => null, // this use when you give row_count
615
'row_count' => null, // 4 or 1 ...
616
+ 'permgroup' => null, //Checks permissions based on attribute value not on current user usergroup
617
'read' => null, //true / false
618
'where' => null
619
);
729
}
730
}
731
732
+ if( $cache ){
733
+ $object_key = md5( $sql . WPF()->current_user_groupid );
734
+ $object_cache = WPF()->cache->get( $object_key );
735
+ if( !empty($object_cache) ){
736
+ if( !empty($object_cache['items']) ){
737
+ $access_filter = apply_filters('wpforo_topic_access_filter_cache', true);
738
+ if( $access_filter ){
739
+ return $this->access_filter( $object_cache['items'], $permgroup );
740
+ } else {
741
+ return $object_cache['items'];
742
+ }
743
+ }
744
+ }
745
+ }
746
747
$topics = WPF()->db->get_results($sql, ARRAY_A);
748
$topics = apply_filters('wpforo_get_topics', $topics);
749
+
750
+ if($cache && isset($object_key) && !empty($topics)){
751
+ self::$cache['topics'][$object_key]['items'] = $topics;
752
+ self::$cache['topics'][$object_key]['items_count'] = $items_count;
753
+ }
754
+
755
+ if( !empty($forumids) || !$forumid ){
756
+ $topics = $this->access_filter( $topics, $permgroup );
757
+ }
758
+
759
return $topics;
760
}
761
}
762
+
763
+ function access_filter( $topics, $permgroup = NULL ){
764
+ if( !empty($topics) ){
765
+ foreach( $topics as $key => $topic){
766
+ if( !$this->access($topic, $permgroup) ) unset($topics[$key]);
767
+ }
768
+ }
769
+ return $topics;
770
+ }
771
+
772
+ function access( $topic, $permgroup = NULL ){
773
+ if( !WPF()->perm->forum_can('vf', $topic['forumid'], $permgroup) ){
774
+ return false;
775
+ }
776
+ if( wpfval($topic, 'private') && !wpforo_is_owner($topic['userid'], $topic['email']) ){
777
+ if( !WPF()->perm->forum_can('vp', $topic['forumid'], $permgroup) ){
778
+ return false;
779
+ }
780
+ }
781
+ if( wpfval($topic, 'status') && !wpforo_is_owner($topic['userid'], $topic['email']) ){
782
+ if( !WPF()->perm->forum_can('au', $topic['forumid'], $permgroup) ){
783
+ return false;
784
+ }
785
+ }
786
+ return true;
787
+ }
788
+
789
function get_topics_filtered( $args = array() ){
790
$topics = array();
791
$topics = $this->get_topics( $args, $items_count, false );
1005
}else{
1006
$this->rebuild_first_last($current);
1007
$this->rebuild_stats($current);
1008
+ $this->rebuild_threads($current);
1009
wpforo_clean_cache('topic', $current['topicid'], $current);
1010
}
1011
1101
)
1102
){
1103
$args['topicid'] = $topicid = WPF()->db->insert_id;
1104
1105
if( $this->merge( WPF()->current_object['topic'], $args, $args['postids'], $to_target_title, 0 ) ){
1106
WPF()->notice->clear();
1171
if($status) {
1172
do_action( 'wpforo_topic_unapprove', $topic );
1173
if( wpfval($topic, 'tags') ) $this->remove_tags( $topic['tags'] );
1174
if( WPF()->forum->get_layout($topic) == 3 ){
1175
$questions = ' `questions` = IF( (`questions` - 1) < 0, 0, `questions` - 1 ) ';
1176
WPF()->db->query(
1182
} else {
1183
do_action( 'wpforo_topic_approve', $topic );
1184
if( wpfval($topic, 'tags') ) $this->add_tags( $topic['tags'] );
1185
+ if( WPF()->forum->get_layout($topic) == 3 ) {
1186
+ $questions = ' `questions` = `questions` + 1 ';
1187
+ WPF()->db->query( "UPDATE ".WPF()->tables->profiles." SET $questions WHERE `userid` = " . wpforo_bigintval($topic['userid']) );
1188
+ }
1189
}
1190
1191
WPF()->member->reset($topic['userid']);
1271
1272
function rebuild_threads( $topicid, $root = NULL ){
1273
if( !is_null($root) && $root <= 0 ) return;
1274
+ if( is_array($topicid) && wpfval($topicid, 'topicid') ) $topicid = $topicid['topicid'];
1275
+ if( $topicid ){
1276
+ $posts = WPF()->db->get_results("SELECT * FROM `".WPF()->tables->posts."` WHERE `topicid` = " . intval($topicid), ARRAY_A );
1277
+ if( !empty($posts) ){
1278
+ foreach( $posts as $post ) {
1279
+ $threads[ $post['postid'] ] = array('postid' => $post['postid'], 'parentid' => $post['parentid']);
1280
+ }
1281
+ unset($posts);
1282
+ foreach( $threads as $item ){
1283
+ if( !is_null($root) && $root != $item['postid'] ) continue;
1284
+ if( !$item['parentid'] ){
1285
+ $thread = WPF()->post->build_thread_data($item['postid'], $threads);
1286
+ if(wpfval($thread, 'children')){
1287
+ $children = implode(',', $thread['children']);
1288
+ WPF()->db->query("UPDATE `".WPF()->tables->posts."` SET `root` = 0 WHERE `postid` = " . intval($item['postid']) );
1289
+ WPF()->db->query("UPDATE `".WPF()->tables->posts."` SET `root` = " . intval($item['postid']) . " WHERE `postid` IN(" . esc_sql($children) . ")" );
1290
+ }
1291
+ } elseif( !wpfkey($threads, $item['parentid']) ) {
1292
+ WPF()->db->query("UPDATE `".WPF()->tables->posts."` SET `root` = 0, `parentid` = 0 WHERE `postid` = " . intval($item['postid']) );
1293
}
1294
}
1295
}
wpf-includes/functions-template.php CHANGED
@@ -416,7 +416,7 @@ class wpForo_Widget_recent_topics extends WP_Widget {
416
'orderby' => 'created',
417
'order' => 'DESC',
418
'count' => 9,
419
- 'display_avatar' => true,
420
'forumids_filter' => false,
421
'current_forumid_filter' => false
422
);
@@ -579,7 +579,7 @@ class wpForo_Widget_recent_replies extends WP_Widget {
579
'order' => 'DESC',
580
'count' => 9,
581
'limit_per_topic' => 0,
582
- 'display_avatar' => true,
583
'forumids_filter' => false,
584
'current_forumid_filter' => false
585
);
@@ -607,6 +607,8 @@ class wpForo_Widget_recent_replies extends WP_Widget {
607
$private = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL;
608
$status = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL;
609
// widget content from front end
610
$posts_args = array(
611
'forumids' => ( $instance['forumids'] ? $instance['forumids'] : $this->default_instance['forumids'] ),
612
'orderby' => ( key_exists( $instance['orderby'], $this->orderby_fields ) ? $instance['orderby'] : $this->default_instance['orderby'] ),
@@ -615,34 +617,72 @@ class wpForo_Widget_recent_replies extends WP_Widget {
615
'limit_per_topic' => ( ( $limit = intval( $instance['limit_per_topic'] ) ) ? $limit : $this->default_instance['limit_per_topic'] ),
616
'private' => $private,
617
'status' => $status,
618
);
619
- $recent_posts = WPF()->post->get_posts_filtered($posts_args);
620
- $ug_can_va = WPF()->perm->usergroup_can('va');
621
- $is_avatar = wpforo_feature('avatars');
622
echo '<div class="wpforo-widget-content"><ul>';
623
- foreach( $recent_posts as $post ){
624
- $post_url = wpforo_post( $post['postid'], 'url' );
625
- $member = wpforo_member( $post );
626
- ?>
627
- <li>
628
- <div class="wpforo-list-item">
629
- <?php if( $instance['display_avatar'] ): ?>
630
- <?php if( $ug_can_va && $is_avatar ): ?>
631
- <div class="wpforo-list-item-left">
632
- <?php echo WPF()->member->avatar($member); ?>
633
</div>
634
- <?php endif; ?>
635
- <?php endif; ?>
636
- <div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>>
637
- <p class="posttitle"><a href="<?php echo esc_url($post_url) ?>"><?php echo esc_html($post['title']) ?></a></p>
638
- <p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p>
639
- <p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <?php esc_html(wpforo_date($post['created'])) ?></p>
640
- </div>
641
- <div class="wpf-clear"></div>
642
- </div>
643
- </li>
644
- <?php
645
- }
646
echo '</ul></div>';
647
echo '</div>';
648
echo $args['after_widget'];//This is a HTML content//
@@ -669,49 +709,65 @@ class wpForo_Widget_recent_replies extends WP_Widget {
669
input.wpf_wdg_forumids_filter:checked ~ select.wpf_wdg_forumids {
670
display: block;
671
}
672
</style>
673
- <p>
674
- <label for="<?php echo $this->get_field_id('title') ?>"><?php _e('Title', 'wpforo'); ?>:</label>
675
- <input id="<?php echo $this->get_field_id('title') ?>" class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
676
- </p>
677
- <p>
678
- <label for="<?php echo $this->get_field_id('forumids_filter') ?>"><?php _e('Filter by forums', 'wpforo'); ?>:</label>
679
- <input id="<?php echo $this->get_field_id('forumids_filter') ?>" class="wpf_wdg_forumids_filter" name="<?php echo esc_attr( $this->get_field_name( 'forumids_filter' ) ); ?>" <?php checked( $forumids_filter ); ?> type="checkbox">
680
- <select id="<?php echo $this->get_field_id('forumids') ?>" class="wpf_wdg_forumids" name="<?php echo esc_attr( $this->get_field_name( 'forumids' ) ); ?>[]" multiple>
681
- <?php WPF()->forum->tree( 'select_box', false, $selected ) ?>
682
- </select>
683
- </p>
684
- <p>
685
- <label for="<?php echo $this->get_field_id('current_forumid_filter') ?>"><?php _e('Autofilter by current forum', 'wpforo'); ?>:</label>
686
- <input id="<?php echo $this->get_field_id('current_forumid_filter') ?>" name="<?php echo esc_attr( $this->get_field_name( 'current_forumid_filter' ) ); ?>" <?php checked( $current_forumid_filter ); ?> type="checkbox">
687
- </p>
688
- <p>
689
- <label for="<?php echo $this->get_field_id('orderby') ?>"><?php _e('Order by', 'wpforo'); ?>:</label>
690
- <select name="<?php echo esc_attr($this->get_field_name( 'orderby' )); ?>" id="<?php echo $this->get_field_id('orderby') ?>">
691
- <?php foreach ($this->orderby_fields as $orderby_key => $orderby_field ) : ?>
692
- <option value="<?php echo $orderby_key; ?>"<?php echo ( $orderby_key == $orderby ? ' selected' : '' ); ?>><?php echo $orderby_field; ?></option>
693
- <?php endforeach; ?>
694
- </select>
695
- <select name="<?php echo esc_attr($this->get_field_name( 'order' )); ?>">
696
- <?php foreach ($this->order_fields as $order_key => $order_field ) : ?>
697
- <option value="<?php echo $order_key; ?>"<?php echo ( $order_key == $order ? ' selected' : '' ); ?>><?php echo $order_field; ?></option>
698
- <?php endforeach; ?>
699
- </select>
700
- </p>
701
- <p>
702
- <label for="<?php echo $this->get_field_id('limit_per_topic') ?>"><?php _e('Limit Per Topic', 'wpforo'); ?></label>&nbsp;
703
- <input id="<?php echo $this->get_field_id('limit_per_topic') ?>" type="number" min="0" style="width: 53px;" name="<?php echo esc_attr($this->get_field_name( 'limit_per_topic' )); ?>" value="<?php echo esc_attr($limit_per_topic) ; ?>">
704
- <span style="color: #aaa;"><?php _e('set 0 to remove this limit', 'wpforo') ?></span>
705
- </p>
706
- <p>
707
- <label for="<?php echo $this->get_field_id('count') ?>"><?php _e('Number of Items', 'wpforo'); ?></label>&nbsp;
708
- <input id="<?php echo $this->get_field_id('count') ?>" type="number" min="1" style="width: 53px;" name="<?php echo esc_attr($this->get_field_name( 'count' )); ?>" value="<?php echo esc_attr($count) ; ?>">
709
- </p>
710
- <p>
711
- <label for="<?php echo $this->get_field_id('display_avatar') ?>">
712
- <input id="<?php echo $this->get_field_id('display_avatar') ?>" <?php checked( $display_avatar ); ?> type="checkbox" name="<?php echo esc_attr($this->get_field_name( 'display_avatar' )); ?>" >
713
- <?php _e('Display with Avatars', 'wpforo'); ?></label>
714
- </p>
715
<?php
716
}
717
public function update( $new_instance, $old_instance ) {
@@ -2336,16 +2392,22 @@ function wpforo_like_button( $post = array(), $type = 'icon-count', $echo = true
2336
if( WPF()->perm->forum_can('l', $forumid) && $login && WPF()->current_userid != $post['userid'] ) {
2337
$like_status = ( WPF()->post->is_liked( $postid, WPF()->current_userid ) === FALSE ? 'wpforo-like' : 'wpforo-unlike' );
2338
$like_icon = ( $like_status == 'wpforo-like') ? 'far' : 'fas';
2339
- $liked_users = strip_tags( WPF()->tpl->likers($post['postid']) );
2340
- $liked = ($liked_users) ? 'wpf-tooltip="'.esc_attr( $liked_users ).'" wpf-tooltip-size="medium"' : '';
2341
$icon = ( $type == 'icon' || $type == 'icon-text' || $type == 'icon-count' ) ? '<i class="'. esc_attr($like_icon) .' fa-thumbs-up wpfsx wpforo-like-ico"></i>' : '';
2342
- $number = ( $type == 'icon-count' ) ? '<span class="wpf-like-count" ' . $liked . '>' . intval($post['likes_count']) . '</span>' : '';
2343
$phrase = ( $type == 'text' || $type == 'icon-text' ) ? '<span class="wpforo-like-txt">' . wpforo_phrase( str_replace('wpforo-', '', $like_status), false) . '</span>' : '';
2344
$button_html = '<span class="wpf-action '. $like_status .'" data-postid="'. wpforo_bigintval($postid) .'">' .'<span class="wpf-like-icon" wpf-tooltip="'.esc_attr(wpforo_phrase( str_replace('wpforo-', '', $like_status), false)).'">'. $icon .'</span>'. $phrase . $number . '</span>';
2345
}
2346
if(!$echo) return $button_html; echo $button_html;
2347
}
2348
2349
function wpforo_thread_breadcrumb( $post = array(), $parents = array() ){
2350
$html = ''; $gab = false;
2351
if( wpfval($post, 'parentid') ){
@@ -2396,4 +2458,16 @@ function wpforo_check_threads( $posts = array() ){
2396
2397
function wpforo_posts_ordering_dropdown($orderby = null, $topicid = null){
2398
WPF()->tpl->posts_ordering_dropdown($orderby, $topicid);
2399
}
416
'orderby' => 'created',
417
'order' => 'DESC',
418
'count' => 9,
419
+ 'display_avatar' => false,
420
'forumids_filter' => false,
421
'current_forumid_filter' => false
422
);
579
'order' => 'DESC',
580
'count' => 9,
581
'limit_per_topic' => 0,
582
+ 'display_avatar' => false,
583
'forumids_filter' => false,
584
'current_forumid_filter' => false
585
);
607
$private = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL;
608
$status = (!is_user_logged_in() || !WPF()->perm->usergroup_can('aum')) ? 0 : NULL;
609
// widget content from front end
610
+ $ug_can_va = WPF()->perm->usergroup_can('va');
611
+ $is_avatar = wpforo_feature('avatars');
612
$posts_args = array(
613
'forumids' => ( $instance['forumids'] ? $instance['forumids'] : $this->default_instance['forumids'] ),
614
'orderby' => ( key_exists( $instance['orderby'], $this->orderby_fields ) ? $instance['orderby'] : $this->default_instance['orderby'] ),
617
'limit_per_topic' => ( ( $limit = intval( $instance['limit_per_topic'] ) ) ? $limit : $this->default_instance['limit_per_topic'] ),
618
'private' => $private,
619
'status' => $status,
620
+ 'check_private' => false
621
);
622
+
623
echo '<div class="wpforo-widget-content"><ul>';
624
+
625
+ if( $posts_args['limit_per_topic'] ) {
626
+ if( $grouped_postids = WPF()->post->get_posts($posts_args) ){
627
+ $grouped_postids = implode(',', $grouped_postids);
628
+ $postids = array_filter( array_map('wpforo_bigintval', explode(',', $grouped_postids)) );
629
+ rsort($postids);
630
+
631
+ foreach( $postids as $postid ){
632
+ $post = wpforo_post( $postid );
633
+ $member = wpforo_member( $post );
634
+ ?>
635
+ <li>
636
+ <div class="wpforo-list-item">
637
+ <?php if( $instance['display_avatar'] ): ?>
638
+ <?php if( $ug_can_va && $is_avatar ): ?>
639
+ <div class="wpforo-list-item-left">
640
+ <?php echo WPF()->member->avatar($member); ?>
641
+ </div>
642
+ <?php endif; ?>
643
+ <?php endif; ?>
644
+ <div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>>
645
+ <p class="posttitle"><a href="<?php echo esc_url($post['url']) ?>"><?php echo esc_html($post['title']) ?></a></p>
646
+ <p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p>
647
+ <p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <?php esc_html(wpforo_date($post['created'])) ?></p>
648
+ </div>
649
+ <div class="wpf-clear"></div>
650
</div>
651
+ </li>
652
+ <?php
653
+ }
654
+
655
+ }
656
+ }else{
657
+ if( $recent_posts = WPF()->post->get_posts($posts_args) ){
658
+
659
+ foreach( $recent_posts as $post ){
660
+ $post_url = wpforo_post( $post['postid'], 'url' );
661
+ $member = wpforo_member( $post );
662
+ ?>
663
+ <li>
664
+ <div class="wpforo-list-item">
665
+ <?php if( $instance['display_avatar'] ): ?>
666
+ <?php if( $ug_can_va && $is_avatar ): ?>
667
+ <div class="wpforo-list-item-left">
668
+ <?php echo WPF()->member->avatar($member); ?>
669
+ </div>
670
+ <?php endif; ?>
671
+ <?php endif; ?>
672
+ <div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>>
673
+ <p class="posttitle"><a href="<?php echo esc_url($post_url) ?>"><?php echo esc_html($post['title']) ?></a></p>
674
+ <p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p>
675
+ <p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <?php esc_html(wpforo_date($post['created'])) ?></p>
676
+ </div>
677
+ <div class="wpf-clear"></div>
678
+ </div>
679
+ </li>
680
+ <?php
681
+ }
682
+
683
+ }
684
+ }
685
+
686
echo '</ul></div>';
687
echo '</div>';
688
echo $args['after_widget'];//This is a HTML content//
709
input.wpf_wdg_forumids_filter:checked ~ select.wpf_wdg_forumids {
710
display: block;
711
}
712
+
713
+ .wpf_wdg_limit_per_topic{
714
+ width: 53px;
715
+ }
716
</style>
717
+ <script type="text/javascript">
718
+ jQuery(document).ready(function ($) {
719
+ $('.wpf_wdg_limit_per_topic').change(function(){
720
+ var wrap = $(this).parents('.wpf_wdg_form_wrap');
721
+ var disabled = $(this).val() > 0;
722
+ $('.wpf_wdg_orderby', wrap).attr('disabled', disabled);
723
+ $('.wpf_wdg_order', wrap).attr('disabled', disabled);
724
+ });
725
+ });
726
+ </script>
727
+ <div class="wpf_wdg_form_wrap">
728
+ <p>
729
+ <label for="<?php echo $this->get_field_id('title') ?>"><?php _e('Title', 'wpforo'); ?>:</label>
730
+ <input id="<?php echo $this->get_field_id('title') ?>" class="widefat" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
731
+ </p>