PluginProbe
wpForo Forum / beta-4
wpForo Forum vbeta-4
3.2.2 3.2.1 3.2.0 3.1.7 3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 All 142 releases
← All changes | wpf-includes/functions-template.php +78 -587 1.4.1 → beta-4 View file →
@@ -9,15 +9,14 @@
9 9
10 10
11 11 function wpforo_login_url(){
12 12 global $wpforo;
13 - if(isset($wpforo->member->options['login_url']) && $wpforo->member->options['login_url']){
14 - $wp_login_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member->options['login_url'] , '/');
15 - }else{
16 - $request_uri = preg_replace( '#/?\?.*$#isu', '', wpforo_get_request_uri() );
17 - $wp_login_url = (!is_wpforo_page() ? wpforo_home_url('?wpforo=signin') : wpforo_home_url( $request_uri . '?wpforo=signin' ) );
13 + if(isset($wpforo->member_options['login_url']) && $wpforo->member_options['login_url']){
14 + $wp_login_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member_options['login_url'] , '/');
18 15 }
19 -
16 + else{
17 + $wp_login_url = ((!is_wpforo_page() ? WPFORO_BASE_URL : '') . '?wpforo=login');
18 + }
20 19 return esc_url($wp_login_url);
21 20 }
22 21
23 22
@@ -22,13 +21,13 @@
22 21
23 22
24 23 function wpforo_register_url(){
25 24 global $wpforo;
26 - if(isset($wpforo->member->options['register_url']) && $wpforo->member->options['register_url']){
27 - $wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member->options['register_url'] , '/');
25 + if(isset($wpforo->member_options['register_url']) && $wpforo->member_options['register_url']){
26 + $wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member_options['register_url'] , '/');
28 27 }
29 28 else{
30 - $wp_register_url = wpforo_home_url('?wpforo=signup');
29 + $wp_register_url = WPFORO_BASE_URL . '?wpforo=register';
31 30 }
32 31 return esc_url($wp_register_url);
33 32 }
34 33
@@ -34,13 +33,13 @@
34 33
35 34
36 35 function wpforo_lostpass_url(){
37 36 global $wpforo;
38 - if(isset($wpforo->member->options['lost_password_url']) && $wpforo->member->options['lost_password_url']){
39 - $wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member->options['lost_password_url'] , '/');
37 + if(isset($wpforo->member_options['lost_password_url']) && $wpforo->member_options['lost_password_url']){
38 + $wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member_options['lost_password_url'] , '/');
40 39 }
41 40 else{
42 - $wp_lostpass_url = wp_lostpassword_url( wpforo_get_request_uri() );
41 + $wp_lostpass_url = wp_lostpassword_url( wpforo_full_url() );
43 42 }
44 43 return esc_url($wp_lostpass_url);
45 44 }
46 45
@@ -46,9 +45,9 @@
46 45
47 46
48 47 function wpforo_menu_filter( $items, $menu ) {
49 48 global $wpforo;
50 - if ( !wpforo_is_admin() ) {
49 + if ( !is_admin() ) {
51 50 foreach ( $items as $key => $item ) {
52 51 if(isset($item->url)){
53 52 if( strpos($item->url, '%wpforo-') !== FALSE ){
54 53 $shortcode = trim(str_replace(array('https://', 'http://', '/', '%'), '', $item->url));
@@ -66,46 +65,37 @@
66 65 return $items;
67 66 }
68 67 add_filter( 'wp_get_nav_menu_items', 'wpforo_menu_filter', 1, 2 );
69 68
70 -function wpforo_menu_nofollow_items($item_output, $item, $depth, $args) {
71 - if( isset($item->url) && strpos($item->url, '?wpforo') !== FALSE ) {
72 - $item_output = str_replace('<a ', '<a rel="nofollow" ', $item_output);
73 - }
74 - return $item_output;
75 -}
76 -add_filter('walker_nav_menu_start_el', 'wpforo_menu_nofollow_items', 1, 4);
77 -
78 69 function wpforo_profile_plugin_menu( $userid = 0 ){
79 -
80 - $forum_profile = false;
70 +
71 + $menu_html = '<div class="wpf-profile-plugin-menu">';
72 +
81 73 if($url = wpforo_has_shop_plugin($userid)){
82 - $forum_profile = true;
83 74 $menu_html .= '<div id="wpf-pp-shop-menu" class="wpf-pp-menu">
84 75 <a class="wpf-pp-menu-item" href="' . esc_url($url) . '">
85 - <i class="fa fa-shopping-cart" title="'.wpforo_phrase('Shop Account', false).'"></i>
76 + <i class="fa fa-shopping-cart"></i><span>'.wpforo_phrase('Shop Account', false).'</span>
86 77 </a>
87 78 </div>';
88 79 }
89 80 if($url = wpforo_has_profile_plugin($userid)){
90 - $forum_profile = true;
91 - $menu_html .= '<div id="wpf-pp-site-menu" class="wpf-pp-menu">
92 - <a class="wpf-pp-menu-item" href="' . esc_url($url) . '">
93 - <i class="fa fa-user" title="'.wpforo_phrase('Site Profile', false).'"></i>
94 - </a>
95 - </div>';
81 + $menu_html .= '<div id="wpf-pp-site-menu" class="wpf-pp-menu">
82 + <a class="wpf-pp-menu-item" href="' . esc_url($url) . '">
83 + <i class="fa fa-user"></i>
84 + <span>'.wpforo_phrase('Site Profile', false).'</span>
85 + </a>
86 + </div>';
96 87 }
97 - if( $forum_profile ) {
98 - $menu_html .= '<div id="wpf-pp-forum-menu" class="wpf-pp-menu">
88 + $menu_html .= '<div id="wpf-pp-forum-menu" class="wpf-pp-menu">
99 89 <div class="wpf-pp-menu-item">
100 - <i class="fa fa-comments" title="' . wpforo_phrase('Forum Profile', false) . '"></i>
90 + <i class="fa fa-comments"></i>
91 + <span>'.wpforo_phrase('Forum Profile', false).'</span>
101 92 </div>
102 93 </div>';
103 - $menu_html = '<div class="wpf-profile-plugin-menu">';
104 - $menu_html .= "\r\n<div class=\"wpf-clear\"></div>\r\n</div>";
105 - $menu_html = apply_filters( 'wpforo_profile_plugin_menu_filter', $menu_html, $userid );
106 - echo $menu_html; //This is a HTML content//
107 - }
94 +
95 + $menu_html .= "\r\n<div class=\"wpf-clear\"></div>\r\n</div>";
96 + $menu_html = apply_filters( 'wpforo_profile_plugin_menu_filter', $menu_html, $userid );
97 + echo $menu_html; //This is a HTML content//
108 98 }
109 99 add_action( 'wpforo_profile_plugin_menu_action', 'wpforo_profile_plugin_menu', 1 );
110 100
111 101 class wpforo_menu_walker extends Walker_Nav_Menu {
@@ -164,9 +154,9 @@
164 154 'before_title' => '<h3 class="widget-title">',
165 155 'after_title' => '</h3>',
166 156 ));
167 157 }
168 -add_action('widgets_init', 'wpforo_widgets_init', 11);
158 +add_action('widgets_init', 'wpforo_widgets_init', 1);
169 159
170 160 class wpForo_Widget_search extends WP_Widget {
171 161 function __construct() {
172 162 parent::__construct(
@@ -183,10 +173,9 @@
183 173 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; //This is a HTML content//
184 174 }
185 175 echo '<div class="wpforo-widget-content">';
186 176 ?>
187 - <form action="<?php echo wpforo_home_url() ?>" method="get">
188 - <?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
177 + <form action="<?php echo WPFORO_BASE_URL ?>" method="get">
189 178 <input type="text" placeholder="<?php wpforo_phrase('Search...') ?>" name="wpfs" class="wpfw-70" value="<?php echo isset($_GET['wpfs']) ? esc_attr(sanitize_text_field($_GET['wpfs'])) : '' ?>" ><input type="submit" class="wpfw-20" value="&raquo;">
190 179 </form>
191 180 <?php
192 181 echo '</div></div>';
@@ -229,9 +218,9 @@
229 218 <?php extract($wpforo->current_object, EXTR_OVERWRITE); extract($wpforo->current_user, EXTR_OVERWRITE); ?>
230 219 <div class="wpforo-profile-wrap">
231 220 <div class="wpforo-profile-head">
232 221 <div class="h-header">
233 - <?php if( $wpforo->perm->usergroup_can('va') && wpforo_feature('avatars', $wpforo) ): $rsz =''; ?>
222 + <?php if( wpforo_feature('avatars', $wpforo) ): $rsz =''; ?>
234 223 <div class="h-left"><?php echo $wpforo->member->get_avatar($userid, 'alt="'.esc_attr($display_name).'"', 150); ?></div>
235 224 <?php else: $rsz = ' style="margin-left:10px;"'; endif; ?>
236 225 <div class="h-right" <?php echo $rsz; ?>>
237 226 <div class="h-top">
@@ -236,9 +225,9 @@
236 225 <div class="h-right" <?php echo $rsz; ?>>
237 226 <div class="h-top">
238 227 <div class="profile-display-name">
239 228 <?php $wpforo->member->show_online_indicator($userid) ?>
240 - <?php echo $display_name ? esc_html($display_name) : esc_html(urldecode($user_nicename)) ?>
229 + <?php echo $display_name ? esc_html($display_name) : esc_html($user_nicename) ?>
241 230 </div>
242 231 <div class="profile-stat-data">
243 232 <div class="profile-stat-data-item"><?php wpforo_phrase('Group') ?>: <?php wpforo_phrase($groupname) ?></div>
244 233 <div class="profile-stat-data-item"><?php wpforo_phrase('Joined') ?>: <?php esc_html(wpforo_date($user_registered, 'Y/m/d')) ?></div>
@@ -282,10 +271,10 @@
282 271 <td class="wpf-login-field">
283 272 <p class="wpf-extra wpfcl-1">
284 273 <input type="checkbox" value="1" name="rememberme" id="wpf-login-remember">
285 274 <label for="wpf-login-remember"><?php wpforo_phrase('Remember Me') ?> |</label>
286 - <a href="<?php echo esc_url(wp_lostpassword_url(wpforo_get_request_uri())); ?>" class="wpf-forgot-pass"><?php wpforo_phrase('Lost your password?') ?></a>
287 - <a href="<?php echo esc_url( wpforo_home_url('?wpforo=register') ) ?>"><?php wpforo_phrase('register') ?></a>
275 + <a href="<?php echo esc_url(wp_lostpassword_url(wpforo_full_url())); ?>" class="wpf-forgot-pass"><?php wpforo_phrase('Lost your password?') ?></a>
276 + <a href="<?php echo esc_url(WPFORO_BASE_URL) ?>?wpforo=register"><?php wpforo_phrase('register') ?></a>
288 277 </p>
289 278 <input type="submit" name="wpforologin" value="<?php wpforo_phrase('Sign In') ?>" />
290 279 </td>
291 280 </tr>
@@ -403,33 +392,33 @@
403 392 if ( ! empty( $instance['title'] ) ) {
404 393 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];//This is a HTML content//
405 394 }
406 395 // widget content from front end
407 - $topic_args = array( // forumid, order, parentid
408 - 'orderby' => 'created',
396 + $topic_args = array(
397 + 'orderby' => 'modified', // forumid, order, parentid
409 398 'order' => 'DESC', // ASC DESC
410 399 'row_count' => $instance['count'] // 4 or 1 ...
411 400 );
412 - $topics = $wpforo->topic->get_topics_filtered($topic_args);
413 - $ug_can_va = $wpforo->perm->usergroup_can('va');
414 - $is_avatar = wpforo_feature('avatars', $wpforo);
401 + $topics = $wpforo->topic->get_topics($topic_args);
415 402 echo '<div class="wpforo-widget-content"><ul>';
416 403 foreach( $topics as $topic ){
417 - $topic_url = wpforo_topic($topic['topicid'], 'url');
418 - $member = wpforo_member($topic);
404 + if( !$wpforo->perm->forum_can( $topic['forumid'], 'vf' ) ) continue;
405 + $topic_url = $wpforo->topic->get_topic_url( $topic );
406 + $member = $wpforo->member->get_member( $topic['userid'] );
407 + $post = $wpforo->post->get_post($topic['first_postid']);
419 408 ?>
420 409 <li>
421 410 <div class="wpforo-list-item">
422 411 <?php if( $instance['display_avatar'] ): ?>
423 - <?php if( $ug_can_va && $is_avatar ): ?>
424 - <div class="wpforo-list-item-left">
425 - <?php echo $wpforo->member->get_avatar( $topic['userid']); ?>
426 - </div>
427 - <?php endif; ?>
428 - <?php endif; ?>
412 + <div class="wpforo-list-item-left">
413 + <?php echo $wpforo->member->get_avatar( $topic['userid'], 'style="width:95%;"'); ?>
414 + </div>
415 + <?php endif; ?>
429 416 <div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>>
430 417 <p class="posttitle"><a href="<?php echo esc_url($topic_url) ?>"><?php echo esc_html($topic['title']) ?></a></p>
431 - <p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <span style="white-space:nowrap;"><?php esc_html(wpforo_date($topic['created'])) ?></span></p>
418 + <p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p>
419 + <p class="postuser"><?php wpforo_phrase('by') ?> <a href="<?php echo esc_url($wpforo->member->profile_url($member)) ?>"><?php echo esc_html($member['display_name']) ?></a></p>
420 + <p class="postdate"><?php wpforo_phrase('posted') ?>&nbsp;<?php esc_html(wpforo_date($topic['created'])) ?></p>
432 421 </div>
433 422 <div class="wpf-clear"></div>
434 423 </div>
435 424 </li>
@@ -473,9 +462,8 @@
473 462 'wpForo Recent Posts', // Name
474 463 array( 'description' => 'Your forum\'s recent posts.' ) // Args
475 464 );
476 465 }
477 -
478 466 public function widget( $args, $instance ) {
479 467 global $wpforo;
480 468 echo $args['before_widget'];//This is a HTML content//
481 469 echo '<div id="wpf-widget-recent-replies" class="wpforo-widget-wrap">';
@@ -483,34 +471,31 @@
483 471 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];//This is a HTML content//
484 472 }
485 473 // widget content from front end
486 474 $posts_args = array(
487 - 'orderby' => 'created',
488 - 'order' => 'DESC',
489 - 'row_count' => $instance['count'],
490 - 'check_private' => true
475 + 'orderby' => 'modified', // forumid, order, parentid
476 + 'order' => 'DESC', // ASC DESC
477 + 'row_count' => $instance['count'] // 4 or 1 ...
491 478 );
492 - $recent_posts = $wpforo->post->get_posts_filtered($posts_args);
493 - $ug_can_va = $wpforo->perm->usergroup_can('va');
494 - $is_avatar = wpforo_feature('avatars', $wpforo);
479 + $recent_posts = $wpforo->post->get_posts($posts_args);
495 480 echo '<div class="wpforo-widget-content"><ul>';
496 481 foreach( $recent_posts as $post ){
497 - $post_url = wpforo_post( $post['postid'], 'url' );
498 - $member = wpforo_member( $post );
482 + if( !$wpforo->perm->forum_can( $post['forumid'], 'vf' ) ) continue;
483 + $post_url = $wpforo->post->get_post_url( $post );
484 + $member = $wpforo->member->get_member( $post['userid'] );
499 485 ?>
500 486 <li>
501 487 <div class="wpforo-list-item">
502 488 <?php if( $instance['display_avatar'] ): ?>
503 - <?php if( $ug_can_va && $is_avatar ): ?>
504 - <div class="wpforo-list-item-left">
505 - <?php echo $wpforo->member->get_avatar( $post['userid']); ?>
506 - </div>
507 - <?php endif; ?>
489 + <div class="wpforo-list-item-left">
490 + <?php echo $wpforo->member->get_avatar( $post['userid'], 'style="width:95%;"'); ?>
491 + </div>
508 492 <?php endif; ?>
509 493 <div class="wpforo-list-item-right" <?php if( !$instance['display_avatar'] ): ?> style="width:100%"<?php endif; ?>>
510 494 <p class="posttitle"><a href="<?php echo esc_url($post_url) ?>"><?php echo esc_html($post['title']) ?></a></p>
511 495 <p class="posttext"><?php echo esc_html(wpforo_text($post['body'], 55)); ?></p>
512 - <p class="postuser"><?php wpforo_phrase('by') ?> <?php wpforo_member_link($member) ?>, <?php esc_html(wpforo_date($post['created'])) ?></p>
496 + <p class="postuser"><?php wpforo_phrase('by') ?> <a href="<?php echo esc_url($wpforo->member->profile_url($member)) ?>"><?php echo esc_html($member['display_name']) ?></a></p>
497 + <p class="postdate"><?php wpforo_phrase('posted') ?>&nbsp;<?php esc_html(wpforo_date($post['created'])) ?></p>
513 498 </div>
514 499 <div class="wpf-clear"></div>
515 500 </div>
516 501 </li>
@@ -634,12 +619,12 @@
634 619 return $edit_html;
635 620 }
636 621 }
637 622
638 -function wpforo_hide_title($title, $id = 0) {
623 +function wpforo_hide_title($title, $id) {
639 624 global $wpforo;
640 625 if( !wpforo_feature('page-title', $wpforo) ){
641 - if( $wpforo_base_slug = basename( wpforo_home_url() ) ) $wpforo_page = get_page_by_path($wpforo_base_slug);
626 + if( $wpforo_base_slug = basename(WPFORO_BASE_URL) ) $wpforo_page = get_page_by_path($wpforo_base_slug);
642 627 if(!empty($wpforo_page)){
643 628 if (in_the_loop() && is_page($wpforo_page->ID) && $id == get_the_ID()) {
644 629 $title = '';
645 630 }
@@ -669,529 +654,35 @@
669 654 return false;
670 655 }
671 656 }
672 657
673 -function wpforo_member_title( $member = array(), $echo = true, $usergroup = true ){
658 +function wpforo_member_title( $member = array(), $echo = true ){
674 659 global $wpforo;
675 - $title = array();
676 -
677 660 if(empty($member) || !$member['groupid']) return;
678 - $rating_title_ug_enabled = ( isset($wpforo->member->options['rating_title_ug'][$member['groupid']]) && $wpforo->member->options['rating_title_ug'][$member['groupid']] ) ? true : false ;
679 - $usergroup_title_ug_enabled = ( isset($wpforo->member->options['title_usergroup'][$member['groupid']]) && $wpforo->member->options['title_usergroup'][$member['groupid']] ) ? true : false ;
661 + $enabled_for_usergroup = ( isset($wpforo->member_options['rating_title_ug'][$member['groupid']]) && $wpforo->member_options['rating_title_ug'][$member['groupid']] ) ? true : false ;
680 662
681 - if( wpforo_feature('rating_title', $wpforo) && $rating_title_ug_enabled && isset($member['stat']['title']) ){
682 - $title[] = '<span class="wpf-member-title wpfrt" title="' . wpforo_phrase('Rating Title', false) . '">' . esc_html($member['stat']['title']) . '</span>';
683 - }
684 - if( empty($title) ){
685 - $title[] = '<span class="wpf-member-title wpfct" title="' . wpforo_phrase('User Title', false) . '">' . wpforo_phrase($member['title'], false) . '</span>';
663 + if( wpforo_feature('rating_title', $wpforo) && $enabled_for_usergroup ){
664 + $title = esc_html($member['stat']['title']);
665 + }
666 + else{
667 + $title = wpforo_phrase($member['title']);
686 668 }
687 - if( $usergroup_title_ug_enabled ){
688 - $class = '';
689 - if( $member['groupid'] == 1 ) $class = ' wpfbg-6 wpfcl-3';
690 - if( $member['groupid'] == 2 ) $class = ' wpfbg-5 wpfcl-3';
691 - if( $member['groupid'] == 4 ) $class = ' wpfbg-2 wpfcl-3';
692 - $title[] = '<span class="wpf-member-title wpfut wpfug-' . intval($member['groupid']) . $class . '" title="' . wpforo_phrase('Usergroup', false) . '">' . esc_html($member['groupname']) . '</span>';
669 +
670 + if( $echo ) {
671 + echo $title;
693 672 }
694 - if( !empty($title) ){
695 - $title_html = implode(' ', $title);
696 - $title_html = apply_filters('wpforo_member_title', $title_html, $member);
697 - if( $echo ) {
698 - echo $title_html;
699 - }
700 - else{
701 - return $title_html;
702 - }
673 + else{
674 + return $title;
703 675 }
704 676 }
705 677
706 678 function wpforo_member_badge( $member = array(), $sep = '', $type = 'full' ){
707 679 global $wpforo;
708 - $rating_badge_ug_enabled = ( isset($wpforo->member->options['rating_badge_ug'][$member['groupid']]) && $wpforo->member->options['rating_badge_ug'][$member['groupid']] ) ? true : false ;
709 - if( wpforo_feature('rating', $wpforo) && $rating_badge_ug_enabled && isset($member['stat']['rating']) ): ?>
680 + $enabled_for_usergroup = ( isset($wpforo->member_options['rating_badge_ug'][$member['groupid']]) && $wpforo->member_options['rating_badge_ug'][$member['groupid']] ) ? true : false ;
681 + if( wpforo_feature('rating', $wpforo) && $enabled_for_usergroup ): ?>
710 682 <div class="author-rating-<?php echo esc_attr($type) ?>" style="color:<?php echo esc_attr($member['stat']['color']) ?>" title="<?php wpforo_phrase('Member Rating Badge') ?>">
711 683 <?php echo $wpforo->member->rating_badge($member['stat']['rating'], $type); ?>
712 684 </div><?php if($sep): ?><span class="author-rating-sep"><?php echo esc_html($sep); ?></span><?php endif; ?>
713 685 <?php endif;
714 -
715 - do_action('wpforo_after_member_badge', $member);
716 686 }
717 687
718 -add_filter( 'body_class', 'wpforo_page_class', 1, 10 );
719 -function wpforo_page_class( $classes ) {
720 - if(!empty($classes)){
721 - if( function_exists('is_wpforo_page') ){
722 - if ( is_wpforo_page() ) {
723 - return array_merge( $classes, array( 'wpforo' ) );
724 - }
725 - }
726 - }
727 - return (array)$classes;
728 -}
729 -
730 -###############################################################################
731 -########################## THEME API FUNCTIONS ################################
732 -###############################################################################
733 -
734 -function wpforo_post( $postid, $var = 'item', $echo = false ){
735 -
736 - global $wpforo;
737 - $post = ( $var == 'item' ) ? array() : '';
738 - if( !$postid ) return $post;
739 - $cache = $wpforo->cache->on('object_cashe');
740 - if( $cache ){
741 - $post = $wpforo->cache->get_item( $postid, 'post' );
742 - }
743 - if( empty($post) ){
744 - if( !$cache && $var == 'url' ){
745 - $post['url'] = $wpforo->post->get_post_url($postid);
746 - }
747 - elseif( !$cache && $var == 'is_answered' ){
748 - $post['is_answered'] = $wpforo->post->is_answered($postid);
749 - }
750 - elseif( !$cache && $var == 'votes_sum' ){
751 - $post['votes_sum'] = $wpforo->post->get_post_votes_sum($postid);
752 - }
753 - elseif( !$cache && $var == 'likes_count' ){
754 - $post['likes_count'] = $wpforo->post->get_post_likes_count($postid);
755 - }
756 - elseif( !$cache && $var == 'likers_usernames' ){
757 - $post['likers_usernames'] = $wpforo->post->get_likers_usernames($postid);
758 - }
759 - else{
760 - $post = $wpforo->post->get_post($postid);
761 - if( !empty($post) ){
762 - $post['url'] = $wpforo->post->get_post_url($post);
763 - if( $cache ){
764 - $post['is_answered'] = $wpforo->post->is_answered($postid);
765 - $post['votes_sum'] = $wpforo->post->get_post_votes_sum($postid);
766 - $post['likes_count'] = $wpforo->post->get_post_likes_count($postid);
767 - $post['likers_usernames'] = $wpforo->post->get_likers_usernames($postid);
768 - }
769 - if(!empty($post)){
770 - $cache_item = array( $postid => $post );
771 - $wpforo->cache->create('item', $cache_item, 'post');
772 - }
773 - }
774 - }
775 - }
776 -
777 - if( $var != 'item' && $var ){
778 - $post = ( isset($post[$var]) ) ? $post[$var] : '';
779 - }
780 -
781 - if( $echo ){
782 - echo $post;
783 - }
784 - else{
785 - return $post;
786 - }
787 -}
788 -
789 -function wpforo_topic( $topicid, $var = 'item', $echo = false ){
790 -
791 - global $wpforo;
792 - $topic = ( $var == 'item' ) ? array() : '';
793 - if( !$topicid ) return $topic;
794 - $cache = $wpforo->cache->on('object_cashe');
795 - if( $cache ) $topic = $wpforo->cache->get_item( $topicid, 'topic' );
796 -
797 - if( empty($topic) ){
798 - if( !$cache && $var == 'url' ){
799 - $topic['url'] = $wpforo->topic->get_topic_url( $topicid );
800 - }
801 - elseif( !$cache && $var == 'is_answer' ){
802 - $topic['is_answer'] = $wpforo->topic->is_solved( $topicid );
803 - }
804 - else{
805 - $topic = $wpforo->topic->get_topic($topicid);
806 - if( !empty($topic) ){
807 - $topic['url'] = $wpforo->topic->get_topic_url($topic);
808 - $topic['is_answer'] = $wpforo->topic->is_solved( $topic['topicid'] );
809 - if(!empty($topic)){
810 - $cache_item = array( $topicid => $topic );
811 - $wpforo->cache->create('item', $cache_item, 'topic');
812 - }
813 - }
814 - }
815 - }
816 -
817 - if( $var != 'item' && $var ){
818 - $topic = ( isset($topic[$var]) ) ? $topic[$var] : '';
819 - }
820 -
821 - if( $echo ){
822 - echo $topic;
823 - }
824 - else{
825 - return $topic;
826 - }
827 -}
828 -
829 -
830 -function wpforo_forum( $forumid, $var = 'item', $echo = false ){
831 -
832 - global $wpforo;
833 - $data = array();
834 - $forum = ( $var == 'item' ) ? array() : '';
835 - $cache = $wpforo->cache->on('object_cashe');
836 - if( !$forumid ) return $forum;
837 - if( $cache ) $forum = $wpforo->cache->get_item( $forumid, 'forum' );
838 -
839 - if( empty($forum) ){
840 - if( !$cache && ($var == 'childs' || $var == 'counts') ){
841 - if( $var == 'childs' ) {
842 - $wpforo->forum->get_childs($forumid, $data);
843 - $forum['childs'] = $data;
844 - }
845 - else{
846 - $wpforo->forum->get_childs($forumid, $data);
847 - $forum['childs'] = $data;
848 - $forum['counts'] = $wpforo->forum->get_counts( $data );
849 - }
850 - }
851 - else{
852 - $forum = $wpforo->forum->get_forum($forumid);
853 - if( !empty($forum) ){
854 - if( $cache ){
855 - $wpforo->forum->get_childs($forum['forumid'], $data);
856 - $forum['childs'] = $data;
857 - $forum['counts'] = $wpforo->forum->get_counts( $data );
858 - }
859 - if(!empty($forum)){
860 - $cache_item = array( $forumid => $forum );
861 - $wpforo->cache->create('item', $cache_item, 'forum');
862 - }
863 - }
864 - }
865 - }
866 -
867 - if( $var != 'item' && $var ){
868 - $forum = ( isset($forum[$var]) ) ? $forum[$var] : '';
869 - }
870 -
871 - if( $echo ){
872 - echo $forum;
873 - }
874 - else{
875 - return $forum;
876 - }
877 -}
878 -
879 -function wpforo_member( $object, $var = 'item', $echo = false ){
880 -
881 - global $wpforo;
882 - $member = array();
883 - if( empty( $object ) ) return $member;
884 -
885 - if( is_array( $object ) && isset($object['userid']) && $object['userid'] == 0 ){
886 - $member = $wpforo->member->get_guest( $object );
887 - }
888 - else{
889 - $userid = ( is_array( $object ) && isset($object['userid']) ) ? intval($object['userid']) : intval($object);
890 - $member = $wpforo->member->get_member( $userid );
891 - }
892 -
893 - if( $var != 'item' && $var ){
894 - $member = ( isset($member[$var]) ) ? $member[$var] : '';
895 - }
896 -
897 - if( $echo ){
898 - echo $member;
899 - }
900 - else{
901 - return $member;
902 - }
903 -}
904 -
905 -function wpforo_member_link( $member, $prefix = '', $length = 30, $class = '', $echo = true ){
906 - $display_name = ( isset($member['display_name']) && $member['display_name'] ) ? $member['display_name'] : wpforo_phrase('Anonymous', false);
907 - $nofollow = ( !wpforo_feature('seo-profile')) ? ' rel="nofollow" ' : '';
908 - if( isset($member['profile_url']) && $member['profile_url'] ){
909 - ?><a href="<?php echo esc_url($member['profile_url']) ?>" <?php echo $nofollow ?>><?php if( strpos($prefix, '%s') !== FALSE ): ?><?php echo sprintf( wpforo_phrase($prefix, FALSE), esc_html(wpforo_text($display_name, $length, FALSE)) ); ?><?php else: ?><?php if( $prefix ){ echo wpforo_phrase( $prefix, false) . ' '; } ?><?php if( $length ){ echo esc_html(wpforo_text($display_name, $length, false)); } else { echo esc_html($display_name); } ?><?php endif; ?></a><?php
910 - }
911 - else{
912 - ?><?php if( strpos($prefix, '%s') !== FALSE ): ?><?php echo sprintf( wpforo_phrase($prefix, FALSE), esc_html(wpforo_text($display_name, $length, FALSE)) ); ?><?php else: ?><?php if( $prefix ){ echo wpforo_phrase( $prefix, false) . ' '; } ?><?php if( $length ){ echo esc_html(wpforo_text($display_name, $length, false)); } else { echo esc_html($display_name); } ?><?php endif; ?><?php
913 - }
914 -}
915 -
916 -add_shortcode('wpforo-lostpassword', 'wpforo_lostpassword');
917 -function wpforo_lostpassword(){ ?>
918 - <p id="wpforo-title"><?php wpforo_phrase('Reset Password') ?></p>
919 -
920 - <form name="wpflogin" action="<?php echo wp_lostpassword_url(); ?>" method="POST">
921 - <div class="wpforo-login-wrap">
922 - <div class="wpforo-login-content">
923 - <table class="wpforo-login-table wpfcl-1" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%; display:table;">
924 - <tbody style="width:100%;">
925 - <tr class="wpfbg-9">
926 - <td class="wpf-login-label">
927 - <p class="wpf-label wpfcl-1">
928 - <label for="userlogin"><?php wpforo_phrase('Email or Username') ?>:</label>
929 - </p>
930 - </td>
931 - <td class="wpf-login-field">
932 - <input id="userlogin" autofocus required type="text" name="user_login" class="wpf-login-text wpfw-60" />
933 - <p><?php wpforo_phrase('Enter your email address and we\'ll send you a link you can use to pick a new password.') ?></p>
934 - </td>
935 - </tr>
936 - <tr class="wpfbg-9">
937 - <td class="wpf-login-label">&nbsp;</td>
938 - <td class="wpf-login-field">
939 - <input type="submit" name="submit" value="<?php wpforo_phrase('Reset Password') ?>" />
940 - </td>
941 - </tr>
942 - </tbody>
943 - </table>
944 - </div>
945 - </div>
946 - </form>
947 -
948 - <?php
949 -}
950 -
951 -add_shortcode('wpforo-resetpassword', 'wpforo_resetpassword');
952 -function wpforo_resetpassword(){ ?>
953 - <p id="wpforo-title"><?php wpforo_phrase('Reset Password') ?></p>
954 -
955 - <form name="wpflogin" action="<?php echo site_url( 'wp-login.php?action=resetpass' ); ?>" method="POST" autocomplete="off">
956 - <input type="hidden" name="rp_key" value="<?php echo $_REQUEST['rp_key'] ?>">
957 - <input type="hidden" name="rp_login" value="<?php echo $_REQUEST['rp_login'] ?>">
958 - <div class="wpforo-login-wrap">
959 - <div class="wpforo-login-content">
960 - <table class="wpforo-login-table wpfcl-1" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%; display:table;">
961 - <tbody style="width:100%;">
962 - <tr class="wpfbg-9">
963 - <td class="wpf-login-label">
964 - <p class="wpf-label wpfcl-1">
965 - <label for="pass1"><?php wpforo_phrase('New password') ?></label>
966 - </p>
967 - </td>
968 - <td class="wpf-login-field">
969 - <input type="password" name="pass1" id="pass1" class="input" size="20" value="" autocomplete="off" required autofocus />
970 - </td>
971 - </tr>
972 - <tr class="wpfbg-9">
973 - <td class="wpf-login-label">
974 - <p class="wpf-label wpfcl-1">
975 - <label for="pass2"><?php wpforo_phrase('Repeat new password') ?></label>
976 - </p>
977 - </td>
978 - <td class="wpf-login-field">
979 - <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" required />
980 - </td>
981 - </tr>
982 - <tr class="wpfbg-9">
983 - <td colspan="2">
984 - <p class="description" style="text-align: center;"><?php echo wp_get_password_hint(); ?></p>
985 - </td>
986 - </tr>
987 - <tr class="wpfbg-9">
988 - <td class="wpf-login-label">&nbsp;</td>
989 - <td class="wpf-login-field">
990 - <input type="submit" name="submit" value="<?php wpforo_phrase('Reset Password'); ?>" />
991 - </td>
992 - </tr>
993 - </tbody>
994 - </table>
995 - </div>
996 - </div>
997 - </form>
998 -
999 - <?php
1000 -}
1001 -
1002 -#############################################################################################
1003 -/**
1004 - * Generates according page form fields using tpl->form_fields() function
1005 - *
1006 - * @since 1.4.0
1007 - *
1008 - * @param array $fields arguments
1009 - * @param boolean $echo
1010 - *
1011 - * @return string form fields HTML
1012 - */
1013 -function wpforo_fields( $fields, $echo = true ){
1014 - if( empty($fields) ) return '';
1015 - global $wpforo;
1016 - $fields = apply_filters( 'wpforo_form_fields', $fields );
1017 - $html = $wpforo->tpl->form_fields( $fields );
1018 - if( $echo ){
1019 - echo $html;
1020 - }
1021 - else{
1022 - return $html;
1023 - }
1024 -}
1025 -
1026 -##################################################################################################
1027 -/**
1028 - * Collects Registration Page POST data and sends to field generator function
1029 - *
1030 - * @since 1.4.0
1031 - *
1032 - * @param array $fields arguments
1033 - *
1034 - * @return NULL
1035 - */
1036 -
1037 -function wpforo_register_page_field_values( $fields ){
1038 - global $wpforo;
1039 - $wpforo->form['value']['user_login'] = (isset($_POST['wpfreg']['user_login'])) ? sanitize_user($_POST['wpfreg']['user_login']) : '';
1040 - $wpforo->form['value']['user_email'] = (isset($_POST['wpfreg']['user_email'])) ? sanitize_email($_POST['wpfreg']['user_email']) : '';
1041 - $wpforo->form['varname'] = 'wpfreg';
1042 -}
1043 -add_action( 'wpforo_register_page_start', 'wpforo_register_page_field_values', 10, 1 );
1044 -
1045 -
1046 -##################################################################################################
1047 -/**
1048 - * Collects Account Page field data and sends to field generator function
1049 - *
1050 - * @since 1.4.0
1051 - *
1052 - * @param array $fields arguments
1053 - *
1054 - * @return NULL
1055 - */
1056 -
1057 -function wpforo_account_page_field_values( $fields ){
1058 - global $wpforo;
1059 -
1060 - if( isset($wpforo->current_object['user']) && !empty($wpforo->current_object['user']) ){
1061 - $user = $wpforo->current_object['user'];
1062 - $user = apply_filters('wpforo_profile_header_obj', $user);
1063 - $wpforo->form['value'] = $user;
1064 - $wpforo->form['varname'] = 'member';
1065 - }
1066 -}
1067 -add_action( 'wpforo_account_page_start', 'wpforo_account_page_field_values', 10, 1 );
1068 -
1069 -
1070 -##################################################################################################
1071 -/**
1072 - * Collects Profile Page field data and sends to field generator function
1073 - *
1074 - * @since 1.4.0
1075 - *
1076 - * @param array $fields arguments
1077 - *
1078 - * @return NULL
1079 - */
1080 -
1081 -function wpforo_profile_page_field_values( $fields ){
1082 - global $wpforo;
1083 -
1084 - if( isset($wpforo->current_object['user']) && !empty($wpforo->current_object['user']) ){
1085 - $user = $wpforo->current_object['user'];
1086 - $wpforo->form['value'] = $user;
1087 - }
1088 -}
1089 -add_action( 'wpforo_profile_page_start', 'wpforo_profile_page_field_values', 10, 1 );
1090 -
1091 -
1092 -function wpforo_search_page_field_values( $fields ){
1093 - global $wpforo;
1094 - $wpforo->form['value'] = ( !empty($_GET) ? (array) $_GET : array() );
1095 - $wpforo->form['varname'] = '';
1096 -}
1097 -add_action( 'wpforo_search_page_start', 'wpforo_search_page_field_values', 10, 1 );
1098 -
1099 -function wpforo_user_avatar( $user, $size, $attr = '', $lastmod = false ){
1100 - global $wpforo;
1101 - $avatar_html = '';
1102 - if( is_int($user) && $user ){
1103 - $avatar_html = ($size) ? get_avatar($user, $size) : get_avatar($user);
1104 - if($attr) $avatar_html = str_replace('<img', '<img ' . $attr, $avatar_html);
1105 - }
1106 - elseif( is_array($user) && !empty($user) ){
1107 - $avatar_html = $wpforo->member->avatar($user, $attr, $size); //'alt="'.esc_html($display_name).'"'
1108 - }
1109 -
1110 - if( $lastmod ){
1111 - $url = wpforo_avatar_url( $avatar_html );
1112 - if($url){
1113 - $avatar_html = str_replace($url, $url . '?lm=' . time(), $avatar_html);
1114 - }
1115 - }
1116 - return $avatar_html;
1117 -}
1118 -
1119 -function wpforo_register_fields(){
1120 - global $wpforo;
1121 -
1122 - $fields = $wpforo->member->get_register_fields();
1123 - do_action( 'wpforo_register_page_start', $fields );
1124 -
1125 - return $fields;
1126 -}
1127 -
1128 -function wpforo_account_fields(){
1129 - global $wpforo;
1130 -
1131 - $fields = $wpforo->member->get_account_fields();
1132 - do_action( 'wpforo_account_page_start', $fields );
1133 -
1134 - return $fields;
1135 -}
1136 -
1137 -function wpforo_profile_fields(){
1138 - global $wpforo;
1139 -
1140 - $fields = $wpforo->member->get_profile_fields();
1141 - do_action( 'wpforo_profile_page_start', $fields );
1142 -
1143 - return $fields;
1144 -}
1145 -
1146 -function wpforo_search_fields(){
1147 - global $wpforo;
1148 -
1149 - $fields = $wpforo->member->get_search_fields();
1150 - do_action( 'wpforo_search_page_start', $fields );
1151 -
1152 - if( $wpforo->member->options['search_type'] == 'search' ){
1153 - $fields = array(
1154 - array(
1155 - array(
1156 - array(
1157 - 'type' => 'search',
1158 - 'isDefault' => 1,
1159 - 'isRemovable' => 0,
1160 - 'isRequired' => 0,
1161 - 'isEditable' => 1,
1162 - 'class' => 'wpf-member-search-field',
1163 - 'label' => wpforo_phrase('Find a member', false),
1164 - 'title' => wpforo_phrase('Find a member', false),
1165 - 'placeholder' => wpforo_phrase('Display Name or Nicename', false),
1166 - 'faIcon' => 'fa-search',
1167 - 'name' => 'wpfms',
1168 - 'canBeInactive' => 0,
1169 - 'can' => '',
1170 - 'isSearchable' => 1
1171 - )
1172 - )
1173 - )
1174 - );
1175 - }
1176 -
1177 - return $fields;
1178 -}
1179 -
1180 -
1181 -function wpforo_unread_forum( $logid, $return = 'class', $echo = true ){
1182 - $unread = false;
1183 - if(!wpforo_feature('view-logging')) return;
1184 - $viwed_ids = wpforo_getcookie( 'wpf_viewed_forums', true );
1185 - if( empty($viwed_ids) ) $unread = true;
1186 - if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true;
1187 - if( $unread ){ if( $return == 'class' ){ $log = 'wpf_forum_unread'; } else{ $log = true; } if( $echo ){ echo $log; } else { return $log; } }
1188 -}
1189 -
1190 -function wpforo_unread_topic( $logid, $return = 'class', $echo = true ){
1191 - $unread = false;
1192 - if(!wpforo_feature('view-logging')) return;
1193 - $viwed_ids = wpforo_getcookie( 'wpf_viewed_topics', true );
1194 - if( empty($viwed_ids) ) $unread = true;
1195 - if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true;
1196 - if( $unread ){ if( $return == 'class' ){ $log = 'wpf_topic_unread'; } else{ $log = true; } if( $echo ){ echo $log; } else { return $log; } }
1197 -}
688 +?>