esc_html__( 'wpForo Menu', 'wpforo' ), ) ); function wpforo_login_url(){ if(WPF()->member->options['login_url']){ $wp_login_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['login_url'] , '/'); }else{ $request_uri = preg_replace( '#/?\?.*$#isu', '', wpforo_get_request_uri() ); $wp_login_url = (!(is_wpforo_page() && !is_wpforo_shortcode_page()) ? wpforo_home_url('?foro=signin') : wpforo_home_url( $request_uri . '?foro=signin' ) ); } $wp_login_url = apply_filters('wpforo_login_url', $wp_login_url); return esc_url($wp_login_url); } function wpforo_register_url(){ if(WPF()->member->options['register_url']){ $wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['register_url'] , '/'); }else{ $request_uri = preg_replace( '#/?\?.*$#isu', '', wpforo_get_request_uri() ); $wp_register_url = (!(is_wpforo_page() && !is_wpforo_shortcode_page()) ? wpforo_home_url('?foro=signup') : wpforo_home_url( $request_uri . '?foro=signup' ) ); } $wp_register_url = apply_filters('wpforo_register_url', $wp_register_url); return esc_url($wp_register_url); } function wpforo_lostpass_url(){ if( WPF()->member->options['lost_password_url'] ){ $wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['lost_password_url'] , '/'); } else{ if( wpforo_feature('resetpass-url') ){ $wp_lostpass_url = wpforo_home_url( '?foro=lostpassword' ); }else{ $wp_lostpass_url = wp_lostpassword_url( wpforo_get_request_uri() ); } } $wp_lostpass_url = apply_filters('wpforo_lostpass_url', $wp_lostpass_url); return esc_url($wp_lostpass_url); } function wpforo_menu_filter( $items, $menu ) { if ( !wpforo_is_admin() ) { foreach ( $items as $key => $item ) { if(isset($item->url)){ if( strpos($item->url, '%wpforo-') !== FALSE ){ $shortcode = trim(str_replace(array('https://', 'http://', '/', '%'), '', $item->url)); if(isset(WPF()->menu) && isset(WPF()->menu[$shortcode])){ if(isset(WPF()->menu[$shortcode]['href'])) $item->url = WPF()->menu[$shortcode]['href']; if( wpfval(WPF()->menu[$shortcode], 'is_active') || (isset(WPF()->menu[$shortcode]['attr']) && strpos(WPF()->menu[$shortcode]['attr'], 'wpforo-active') !== FALSE) ) $item->classes[] = 'wpforo-active'; } else{ unset($items[$key]); } } } } } return $items; } add_filter( 'wp_get_nav_menu_items', 'wpforo_menu_filter', 1, 2 ); function wpforo_menu_nofollow_items($item_output, $item, $depth, $args) { //if( isset($item->url) && strpos($item->url, '?foro') !== FALSE ) { //$item_output = str_replace(' '.wpforo_phrase('Shop Account', false).' '; } if($url = wpforo_has_profile_plugin($userid)){ $forum_profile = true; $menu_html .= '
'.wpforo_phrase('Site Profile', false).'
'; } if( $forum_profile ) { $menu_html .= '
' . wpforo_phrase('Forum Profile', false) . '
'; $menu_html = apply_filters( 'wpforo_profile_plugin_menu_filter', $menu_html, $userid ); } $menu_html = apply_filters( 'wpforo_profile_top_bar', $menu_html, $userid ); if($menu_html) echo '
' . $menu_html . '
'; } add_action( 'wpforo_profile_plugin_menu_action', 'wpforo_profile_plugin_menu', 1 ); class wpforo_menu_walker extends Walker_Nav_Menu { public function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "\n$indent\n"; } public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $args = apply_filters( 'wpforo_nav_menu_item_args', $args, $item, $depth ); $class_names = implode( ' ', apply_filters( 'wpforo_nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; $id = apply_filters( 'wpforo_nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $atts = array(); $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; $atts['target'] = ! empty( $item->target ) ? $item->target : ''; $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; $atts['href'] = ! empty( $item->url ) ? $item->url : ''; $atts = apply_filters( 'wpforo_nav_menu_link_attributes', $atts, $item, $args, $depth ); $attributes = ''; foreach ( $atts as $attr => $value ) { if ( ! empty( $value ) ) { $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $title = apply_filters( 'wpforo_the_title', $item->title, $item->ID ); $title = apply_filters( 'wpforo_nav_menu_item_title', $title, $item, $args, $depth ); $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . $title . $args->link_after; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters( 'wpforo_walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } public function end_el( &$output, $item, $depth = 0, $args = array() ) { $output .= ""; } } function wpforo_widgets_init() { register_sidebar(array( 'name' => __('wpForo Sidebar', 'wpforo'), 'description' => __("NOTE: If you're going to add widgets in this sidebar, please use 'Full Width' template for wpForo index page to avoid sidebar duplication.", 'wpforo'), 'id' => 'forum-sidebar', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', )); } add_action('widgets_init', 'wpforo_widgets_init', 11); class wpForo_Widget_profile extends WP_Widget { function __construct() { parent::__construct( 'wpForo_Widget_profile', // Base ID 'wpForo User Profile & Notifications', // Name array( 'description' => 'wpForo profile data and notifications' ) // Args ); $this->init_local_vars(); } private function init_local_vars(){ $this->default_instance = array( 'title' => __('My Profile', 'wpforo'), 'title_guest' => __('Join Us!', 'wpforo'), 'hide_avatar' => false, 'hide_name' => false, 'hide_notification' => false, 'hide_data' => false, 'hide_buttons' => false, 'hide_for_guests' => false ); } public function widget( $args, $instance ) { $display_widget = ( !is_user_logged_in() ) ? ( wpfval($instance, 'hide_for_guests') ? false : true ) : true; if ( $display_widget ) { $class = ( isset(WPF()->tpl->options['style']) ) ? 'wpf-' . WPF()->tpl->options['style'] : ''; echo $args['before_widget']; echo '
'; if ( wpfval($instance, 'title') && is_user_logged_in() ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; } elseif ( !is_user_logged_in() ) { $title_guest = wpfval($instance, 'title_guest') ? wpfval($instance, 'title_guest') : apply_filters( 'wpforo_profile_widget_guest_title', __('Join Us!', 'wpforo')); echo $args['before_title'] . apply_filters( 'widget_title', $title_guest ). $args['after_title']; } echo '
'; $member = WPF()->current_user; ?>
member->show_online_indicator( $member['userid'] ) ?>
activity->bell('wpf-widget-alerts'); ?>
' . esc_html( wpfval($member, 'stat', 'title') ) . '' ?>
'; echo $args['after_widget']; } } public function form( $instance ) { $title = isset( $instance['title'] ) ? $instance['title'] : __('My Profile', 'wpforo'); $title_guest = isset( $instance['title_guest'] ) ? $instance['title_guest'] : __('Join Us!', 'wpforo'); $hide_avatar = isset( $instance['hide_avatar'] ) ? (bool) $instance['hide_avatar'] : false; $hide_name = isset( $instance['hide_name'] ) ? (bool) $instance['hide_name'] : false; $hide_notification = isset( $instance['hide_notification'] ) ? (bool) $instance['hide_notification'] : false; $hide_data = isset( $instance['hide_data'] ) ? (bool) $instance['hide_data'] : false; $hide_buttons = isset( $instance['hide_buttons'] ) ? (bool) $instance['hide_buttons'] : false; $hide_for_guests = isset( $instance['hide_for_guests'] ) ? (bool) $instance['hide_for_guests'] : false; ?>

type="checkbox">

type="checkbox">

type="checkbox">

type="checkbox">

type="checkbox">

type="checkbox">

default_instance['hide_avatar']; $instance['hide_name'] = isset( $new_instance['hide_name'] ) ? (bool) $new_instance['hide_name'] : $this->default_instance['hide_name']; $instance['hide_notification'] = isset( $new_instance['hide_notification'] ) ? (bool) $new_instance['hide_notification'] : $this->default_instance['hide_notification']; $instance['hide_data'] = isset( $new_instance['hide_data'] ) ? (bool) $new_instance['hide_data'] : $this->default_instance['hide_data']; $instance['hide_buttons'] = isset( $new_instance['hide_buttons'] ) ? (bool) $new_instance['hide_buttons'] : $this->default_instance['hide_buttons']; $instance['hide_for_guests'] = isset( $new_instance['hide_for_guests'] ) ? (bool) $new_instance['hide_for_guests'] : $this->default_instance['hide_for_guests']; return $instance; } } // widget user profile class wpForo_Widget_search extends WP_Widget { function __construct() { parent::__construct( 'wpForo_Widget_search', // Base ID 'wpForo Search', // Name array( 'description' => 'wpForo search form' ) // Args ); } public function widget( $args, $instance ) { //wp_enqueue_script('wpforo-widgets-js'); echo $args['before_widget']; //This is a HTML content// echo '';} $nicename = apply_filters('wpforo_member_nicename', $nicename); if( $echo ){ echo $nicename; } else{ return $nicename; } } add_filter( 'body_class', 'wpforo_page_class', 1, 10 ); function wpforo_page_class( $classes ) { if(!empty($classes)){ if( function_exists('is_wpforo_page') ){ if ( is_wpforo_page() ) { return array_merge( $classes, array( 'wpforo' ) ); } } } return (array)$classes; } ############################################################################### ########################## THEME API FUNCTIONS ################################ ############################################################################### function wpforo_post( $postid, $var = 'item', $echo = false ){ $post = ( $var == 'item' ) ? array() : ''; if( !$postid ) return $post; $cache = WPF()->cache->on('object_cashe'); if( $cache ){ $post = WPF()->cache->get_item( $postid, 'post' ); } if( empty($post) ){ $post = array(); if( !$cache && $var == 'url' ){ $post['url'] = WPF()->post->get_post_url($postid); } elseif( !$cache && $var == 'is_answered' ){ $post['is_answered'] = WPF()->post->is_answered($postid); } elseif( !$cache && $var == 'votes_sum' ){ $post = WPF()->post->get_post($postid); $post['votes_sum'] = $post['votes']; } elseif( !$cache && $var == 'likes_count' ){ $post['likes_count'] = WPF()->post->get_post_likes_count($postid); } elseif( !$cache && $var == 'likers_usernames' ){ $post['likers_usernames'] = WPF()->post->get_likers_usernames($postid); } else{ $post = WPF()->post->get_post($postid); if( !empty($post) ){ $post['url'] = WPF()->post->get_post_url($post); if( $cache ){ $post['is_answered'] = WPF()->post->is_answered($postid); $post['votes_sum'] = $post['votes']; $post['likes_count'] = WPF()->post->get_post_likes_count($postid); $post['likers_usernames'] = WPF()->post->get_likers_usernames($postid); } if(!empty($post)){ $cache_item = array( $postid => $post ); WPF()->cache->create('item', $cache_item, 'post'); } } } } if( $var != 'item' && $var ){ $post = ( isset($post[$var]) ) ? $post[$var] : ''; } if( $echo ){ echo $post; } else{ return $post; } } function wpforo_topic( $topicid, $var = 'item', $echo = false ){ $topic = ( $var == 'item' ) ? array() : ''; if( !$topicid ) return $topic; $cache = WPF()->cache->on('object_cashe'); if( $cache ) $topic = WPF()->cache->get_item( $topicid, 'topic' ); if( empty($topic) ){ $topic = array(); if( !$cache && $var == 'url' ){ $topic['url'] = WPF()->topic->get_topic_url( $topicid ); }else{ $topic = WPF()->topic->get_topic($topicid); if( !empty($topic) ){ $topic['url'] = WPF()->topic->get_topic_url($topic); if(!empty($topic)){ $cache_item = array( $topicid => $topic ); WPF()->cache->create('item', $cache_item, 'topic'); } } } } if( $var != 'item' && $var ){ $topic = ( isset($topic[$var]) ) ? $topic[$var] : ''; } if( $echo ){ echo $topic; } else{ return $topic; } } function wpforo_forum( $forumid, $var = 'item', $echo = false ){ $data = array(); $forum = ( $var == 'item' ) ? array() : ''; $cache = WPF()->cache->on('object_cashe'); if( !$forumid ) return $forum; if( $cache ) $forum = WPF()->cache->get_item( $forumid, 'forum' ); if( empty($forum) ){ $forum = array(); if( !$cache && ($var == 'childs' || $var == 'counts') ){ if( $var == 'childs' ) { WPF()->forum->get_childs($forumid, $data); $forum['childs'] = $data; } else{ WPF()->forum->get_childs($forumid, $data); $forum['childs'] = $data; $forum['counts'] = WPF()->forum->get_counts( $data ); } } else{ $forum = WPF()->forum->get_forum($forumid); if( !empty($forum) ){ if( $cache ){ WPF()->forum->get_childs($forum['forumid'], $data); $forum['childs'] = $data; $forum['counts'] = WPF()->forum->get_counts( $data ); } if(!empty($forum)){ $cache_item = array( $forumid => $forum ); WPF()->cache->create('item', $cache_item, 'forum'); } } } } if( $var != 'item' && $var ){ $forum = ( isset($forum[$var]) ) ? $forum[$var] : ''; } if( $echo ){ echo $forum; } else{ return $forum; } } function wpforo_member( $object, $var = 'item', $echo = false ){ $member = null; if( empty( $object ) ) return $member; if( is_array( $object ) && isset($object['userid']) && !$object['userid'] ){ $member = WPF()->member->get_guest( $object ); } else{ $userid = ( is_array( $object ) && isset($object['userid']) ) ? intval($object['userid']) : intval($object); $member = WPF()->member->get_member( $userid ); if( isset($member['fields']) && $member['fields'] && is_string($member['fields']) ){ $member['fields'] = json_decode($member['fields'], true); } } if( $var != 'item' && $var ) $member = wpfval($member, $var); if($echo) echo $member; return $member; } function wpforo_current_usermeta( $key ){ if( wpfkey( WPF()->current_usermeta, $key ) ){ if( wpfkey( WPF()->current_usermeta[ $key ], 0) ){ $meta = maybe_unserialize( WPF()->current_usermeta[$key][0] ); return $meta; } } } function wpforo_tag( $tagid, $var = 'item', $echo = false ){ $tag = ( $var == 'item' ) ? array() : ''; if( !$tagid ) return $tag; $cache = WPF()->cache->on('object_cashe'); if( $cache ) $tag = WPF()->cache->get_item( md5($tagid), 'tag' ); if( empty($tag) ){ $tag = array(); if( !$cache && $var == 'url' && wpfval($tag, 'tag') ){ $tag['url'] = wpforo_home_url() . '?wpfin=tag&wpfs=' . $tag['tag']; } else{ $tag = WPF()->topic->get_tag($tagid); if( !empty($tag) ){ $tag['url'] = wpforo_home_url() . '?wpfin=tag&wpfs=' . $tag['tag']; if(!empty($tag)){ $cache_item = array( md5($tagid) => $tag ); WPF()->cache->create('item', $cache_item, 'tag'); } } } } if( $var != 'item' && $var ){ $tag = ( isset($tag[$var]) ) ? $tag[$var] : ''; } if( $echo ){ echo $tag; } else{ return $tag; } } function wpforo_member_link( $member, $prefix = '', $length = 30, $class = '', $echo = true ){ $display_name = ( isset($member['display_name']) && $member['display_name'] ) ? $member['display_name'] : wpforo_phrase('Anonymous', false); $color = (isset($member['color']) && $member['color'] ) ? 'style="color:' . $member['color'] . '"' : ''; $class = ($class) ? 'class="' . $class . '"' : ''; $title = ($display_name) ? 'title="' . esc_attr($display_name) . '"' : ''; if( wpfval($member, 'profile_url') ){ $link = '' . ( strpos($prefix, '%s') !== FALSE ? sprintf( wpforo_phrase($prefix, FALSE), esc_html( wpforo_text($display_name, $length, FALSE) ) ) : ( $prefix ? wpforo_phrase($prefix, false) . ' ' : '') . ( $length ? esc_html( wpforo_text($display_name, $length, false) ) : esc_html($display_name) ) ) . ''; } else{ $link = ( strpos($prefix, '%s') !== FALSE ? sprintf( wpforo_phrase($prefix, FALSE), esc_html( wpforo_text($display_name, $length, FALSE))) : ( ( $prefix ? wpforo_phrase( $prefix, false) . ' ' : '' ) . ( $length ? esc_html( wpforo_text($display_name, $length, false) ) : esc_html($display_name) ) ) ); } if( $echo ){ echo $link; } else { return $link; } } add_shortcode('wpforo-lostpassword', 'wpforo_lostpassword'); function wpforo_lostpassword(){ $ob_exists = function_exists('ob_start') && function_exists('ob_get_clean'); if($ob_exists) ob_start(); ?>

tpl->get_template_path('login') ) include( $path ); return ($ob_exists) ? trim( ob_get_clean() ) : ''; } ############################################################################################# /** * Generates according page form fields using tpl->form_fields() function * * @since 1.4.0 * * @param array $fields arguments * @param boolean $echo * * @return string form fields HTML */ function wpforo_fields( $fields, $echo = true ){ if( empty($fields) ) return ''; $fields = apply_filters( 'wpforo_form_fields', $fields ); $html = WPF()->form->build( $fields ); if( $echo ){ echo $html; } else{ return $html; } } function wpforo_user_avatar( $user, $size, $attr = '', $lastmod = false ){ $avatar_html = ''; if( is_numeric($user) && $user ){ $avatar_html = ($size) ? get_avatar($user, $size) : get_avatar($user); if($attr) $avatar_html = str_replace('member->avatar($user, $attr, $size); } if( $lastmod ){ $url = wpforo_avatar_url( $avatar_html ); if($url){ if( strpos($url, '?') === FALSE ){ $avatar_html = str_replace($url, $url . '?lm=' . time(), $avatar_html); } } } return $avatar_html; } function wpforo_signature( $member, $args = array() ){ if( is_numeric($member) ) $member = wpforo_member( $member ); if( WPF()->current_userid != wpfval($member, 'userid') && !WPF()->perm->usergroup_can('vms') ) return ''; $signature = ''; $default = array('nofollow' => 1, 'kses' => 1, 'echo' => 1); if( empty($args) ){ $args = $default; }else{ $args = wpforo_parse_args( $args, $default ); } if( is_array($member) && !empty($member) ){ $signature = ( isset($member['signature']) ) ? $member['signature'] : ''; } elseif( is_string($member) ){ $signature = $member; } $signature = stripslashes($signature); if(!empty($args)){ extract($args, EXTR_OVERWRITE); if(isset($kses) && $kses) $signature = wpforo_kses($signature, 'user_description'); if(isset($nofollow) && $nofollow) $signature = wpforo_nofollow_tag($signature); } else{ $signature = wpautop(wpforo_nofollow(wpforo_kses($signature, 'user_description'))); } $length = apply_filters('wpforo_signature_length', 0); $signature = wpforo_text($signature, $length, false, false, false, false); $signature = wpautop($signature); if($echo){ echo $signature; }else{ return $signature; } } function wpforo_register_fields(){ $fields = WPF()->member->get_register_fields(); do_action( 'wpforo_register_page_start', $fields ); return $fields; } function wpforo_account_fields(){ $fields = WPF()->member->get_account_fields(); do_action( 'wpforo_account_page_start', $fields ); return $fields; } function wpforo_profile_fields(){ $fields = WPF()->member->get_profile_fields(); do_action( 'wpforo_profile_page_start', $fields ); return $fields; } function wpforo_search_fields(){ $fields = WPF()->member->get_search_fields(); do_action( 'wpforo_search_page_start', $fields ); if( WPF()->member->options['search_type'] === 'search' ){ $fields = array( array( array( array( 'type' => 'search', 'isDefault' => 1, 'isRemovable' => 0, 'isRequired' => 0, 'isEditable' => 1, 'class' => 'wpf-member-search-field', 'label' => wpforo_phrase('Find a member', false), 'title' => wpforo_phrase('Find a member', false), 'placeholder' => wpforo_phrase('Display Name or Nicename', false), 'faIcon' => 'fas fa-search', 'name' => 'wpfms', 'cantBeInactive' => array('search'), 'can' => '', 'isSearchable' => 1 ) ) ) ); } return $fields; } function wpforo_unread( $itemid, $item, $echo = true, $postid = 0 ){ $class = ''; $unread = false; $login = is_user_logged_in(); $login = apply_filters( 'wpforo_unread_logging_for_guests', $login ); if( $login ){ if( $item == 'forum' ){ $class = 'wpf-unread-forum'; $unread = WPF()->log->unread( $itemid, 'forum' ); $unread = apply_filters( 'wpforo_unread_forum', $unread, $itemid ); } elseif( $item == 'topic' ) { $class = 'wpf-unread-topic'; $unread = WPF()->log->unread( $itemid, 'topic' ); $unread = apply_filters( 'wpforo_unread_topic', $unread, $itemid ); } elseif( $item == 'post' ) { $class = 'wpf-unread-post'; $unread = WPF()->log->unread( $itemid, 'post', $postid ); $unread = apply_filters( 'wpforo_unread_post', $unread, $itemid, $postid ); } } $class = ( $unread ) ? apply_filters( 'wpforo_unread_class', $class, $itemid, $item ) : ''; if( $echo ){ echo $class; } else { return $class; } } function wpforo_unread_forum( $logid, $return = 'class', $echo = true ){ $unread = WPF()->log->unread( $logid, 'forum' ); if( $unread ){ if( $return == 'class' ){ $log = 'wpf_forum_unread'; } else { $log = true; } if( $echo ){ echo $log; } else { return $log; } } } function wpforo_unread_topic( $logid, $return = 'class', $echo = true ){ $unread = WPF()->log->unread( $logid, 'topic' ); if( $unread ){ if( $return == 'class' ){ $log = 'wpf_topic_unread'; } else{ $log = true; } if( $echo ){ echo $log; } else { return $log; } } } if( !function_exists('custom_wpforo_get_account_fields') ){ function custom_wpforo_get_account_fields($fields){ $hide = array( 'user_email', 'user_nicename' ); foreach ( $fields as $row_key => $row ){ foreach ( $row as $col_key => $col ){ foreach ( $col as $key => $field ){ if( in_array($field['fieldKey'], $hide) ){ unset($fields[$row_key][$col_key][$key]); } } } } return $fields; } } function wpforo_moderation_tools(){ if( empty(WPF()->current_object['forumid']) || empty(WPF()->current_object['topicid']) ) return; ?>
perm->forum_can('mt') ){ $posts = (int) wpfval(WPF()->current_object, 'topic', 'posts'); $tabs[] = array('title' => wpforo_phrase('Move Topic', false), 'id' => 'topic_move_form', 'class' => 'wpft-move', 'icon' => 'far fa-share-square'); if( $posts > 1 ) { $tabs[] = array('title' => wpforo_phrase('Move Reply', false), 'id' => 'reply_move_form', 'class' => 'wpft-reply-move', 'icon' => 'far fa-share-square'); } $tabs[] = array('title' => wpforo_phrase('Merge Topics', false), 'id' => 'topic_merge_form', 'class' => 'wpft-merge', 'icon' => 'fas fa-code-branch'); if( $posts > 1 ) { $tabs[] = array('title' => wpforo_phrase('Split Topic', false), 'id' => 'topic_split_form', 'class' => 'wpft-split', 'icon' => 'fas fa-cut'); } } WPF()->tpl->topic_moderation_tabs($tabs); ?>
current_object['user_is_same_current_user'] || ( wpforo_feature('subscribe_conf') && !wpforo_current_user_is('admin') && !WPF()->sbscrb->is_email_confirmed() ) ) return; $sbs = array(); $allposts_checked = ''; $alltopics_checked = ''; if( WPF()->sbscrb->get_subscribes(array('type' => 'forums-topics', 'userid' => WPF()->current_userid)) ) $allposts_checked = ' checked'; if( WPF()->sbscrb->get_subscribes(array('type' => 'forums', 'userid' => WPF()->current_userid)) ) $alltopics_checked = ' checked'; if( !$allposts_checked && !$alltopics_checked ){ if( $sbs_forum = WPF()->sbscrb->get_subscribes(array('type' => 'forum', 'userid' => WPF()->current_userid)) ) foreach ($sbs_forum as $s) $sbs[$s['itemid']] = $s['type']; if( $sbs_forum_topic = WPF()->sbscrb->get_subscribes(array('type' => 'forum-topic', 'userid' => WPF()->current_userid)) ) foreach ($sbs_forum_topic as $s) $sbs[$s['itemid']] = $s['type']; } ?>

>
>
    forum->tree('subscribe_manager_form', false, $sbs); ?>
'', 'title' => '', 'content' => '', 'component' => 'community', 'type' => '', 'primary_link' => '', 'user_id' => '', 'item_id'=> '', 'date_recorded' => ''); $args = wpforo_parse_args( $args, $default ); //BuddyPress Member Activity if( wpforo_feature('bp_activity') && function_exists('wpforo_bp_activity') ){ wpforo_bp_activity( $args ); } } function wpforo_activity_delete( $args = array() ){ $default = array( 'action' => '', 'title' => '', 'content' => '', 'component' => 'community', 'type' => '', 'primary_link' => '', 'user_id' => '', 'item_id'=> '', 'date_recorded' => ''); $args = wpforo_parse_args( $args, $default ); //Delete BuddyPress Member Activity if( wpforo_feature('bp_activity') && function_exists('wpforo_bp_activity_delete') ){ wpforo_bp_activity_delete( $args ); } } function wpforo_activity_content( $item = array() ){ $args = array(); if( empty($item) ) return false; if((isset($item['status']) && $item['status']) || (isset($item['private']) && $item['private'])) return false; if( isset($item['forumid']) && $item['forumid'] ){ $private_for_usergroups = array(3, 4, 5); $private_for_usergroups = apply_filters( 'wpforo_activity_private_for_usergroups', $private_for_usergroups ); if( !empty($private_for_usergroups) && WPF()->forum->private_forum($item['forumid'], $private_for_usergroups) ){ return false; } } if( isset($item['first_postid']) && $item['first_postid'] ) { $args['item_id'] = $item['first_postid']; } elseif( isset($item['postid']) && $item['postid'] ){ $args['item_id'] = $item['postid']; } $args['user_id'] = ( isset($item['userid']) && $item['userid'] ) ? $item['userid'] : $args['user_id'] = WPF()->current_userid; $member = wpforo_member( $args['user_id'] ); if( isset($item['topicurl']) ){ $args['type'] = 'wpforo_topic'; $args['content'] = ( wpfval($item, 'body') ) ? $item['body'] : ''; $args['primary_link'] = $item['topicurl']; if( isset($item['title']) ) $args['title'] = $item['title']; if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; $args['action'] = sprintf( wpforo_phrase('%s posted a new topic %s', false), '', ''); } elseif( isset($item['posturl']) ){ $args['type'] = 'wpforo_post'; $args['content'] = ( wpfval($item, 'body') ) ? $item['body'] : ''; $args['primary_link'] = $item['posturl']; if( isset($item['title']) ) $args['title'] = preg_replace('|^.+?\:\s*|is', '', $item['title']); if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; $args['action'] = sprintf( wpforo_phrase('%s replied to the topic %s', false), '', ''); } if( $args['content'] ) { $content_words = explode(' ', $args['content']); $content_words = count($content_words); $content_words_cut = apply_filters( 'wpforo_activity_content_words', '40' ); if( (int)$content_words_cut < (int)$content_words && $args['primary_link'] ){ $more = '...   ' . wpforo_phrase('read more', false) . '»'; $args['content'] = wp_trim_words( $args['content'], 40, $more ); } } wpforo_activity( $args ); } function wpforo_activity_content_delete( $item = array() ){ $args = array(); if( empty($item) ) return false; if( wpfval($item, 'first_postid') ){ $args['item_id'] = $item['first_postid']; $args['type'] = 'wpforo_topic'; } elseif( wpfval($item, 'is_first_post') ) { $args['item_id'] = $item['postid']; $args['type'] = 'wpforo_topic'; } elseif( wpfval($item, 'postid') ){ $args['item_id'] = $item['postid']; $args['type'] = 'wpforo_post'; } if( wpfval($args, 'item_id') && wpfval($args, 'type') ) wpforo_activity_delete( $args ); } function wpforo_activity_content_on_post_status_change( $postid, $status = 0 ) { if( !$postid ) return; $post = WPF()->post->get_post($postid); if(!empty($post)){ $post['status'] = $status; $post['posturl'] = WPF()->post->get_post_url($postid); if( !wpfval($post, 'is_first_post') ){ if( $status ){ wpforo_activity_content_delete( $post ); } else{ wpforo_activity_content( $post ); } } } } add_action( 'wpforo_post_status_update', 'wpforo_activity_content_on_post_status_change', 9, 2 ); function wpforo_activity_content_on_topic_status_change( $topicid, $status = 0 ) { if( !$topicid ) return; $topic = WPF()->topic->get_topic($topicid); if(!empty($topic)){ $topic['status'] = $status; $topic['topicurl'] = WPF()->topic->get_topic_url($topicid); if( $status ){ wpforo_activity_content_delete( $topic ); } else{ wpforo_activity_content( $topic ); } } } add_action( 'wpforo_topic_status_update', 'wpforo_activity_content_on_topic_status_change', 9, 2 ); function wpforo_activity_like( $item = array() ){ $args = array(); if( empty($item) ) return false; if((isset($item['status']) && $item['status']) || (isset($item['private']) && $item['private'])) return false; if( isset($item['forumid']) && $item['forumid'] ){ $private_for_usergroups = array(3, 4, 5); $private_for_usergroups = apply_filters( 'wpforo_activity_private_for_usergroups', $private_for_usergroups ); if( !empty($private_for_usergroups) && WPF()->forum->private_forum($item['forumid'], $private_for_usergroups) ){ return false; } } if( isset($item['postid']) && $item['postid'] ) $args['item_id'] = $item['postid']; $args['user_id'] = WPF()->current_userid; $member = wpforo_member( $args['user_id'] ); $args['type'] = 'wpforo_like'; $item = wpforo_post($item['postid']); if( isset($item['url']) && $item['url'] ) $args['primary_link'] = $item['url']; if( isset($item['title']) ) $args['title'] = preg_replace('|^.+?\:\s*|is', '', $item['title']); if( $args['title'] ) $args['title'] = ' "' . esc_html($args['title']) . '"'; $args['action'] = sprintf( wpforo_phrase('%s liked forum post %s', false), '', ''); wpforo_activity( $args ); } function wpforo_activity_like_delete( $item = array() ){ $args = array(); if( empty($item) ) return false; if( isset($item['postid']) && $item['postid'] ){ $args['item_id'] = $item['postid']; $args['type'] = 'wpforo_like'; } if($args['item_id'] && $args['type']) wpforo_activity_delete( $args ); } add_action( 'wpforo_after_add_topic', 'wpforo_activity_content', 9 ); add_action( 'wpforo_after_add_post', 'wpforo_activity_content', 9 ); add_action( 'wpforo_like', 'wpforo_activity_like', 9 ); add_action( 'wpforo_after_delete_post', 'wpforo_activity_content_delete', 9 ); add_action( 'wpforo_after_delete_post', 'wpforo_activity_like_delete', 9 ); function wpforo_user_field( $field = '', $userid = 0, $echo = true ){ $userid = ( !$userid ) ? WPF()->current_userid : $userid; if( !$field || !$userid ) return false; $field = wpforo_member( $userid, $field ); $field = apply_filters( 'wpforo_user_field', $field, $userid ); if( !is_array($field) && $field ){ if( $echo ){ echo $field; } else{ return $field; } } } /** * @param array $post * @param bool $echo * * @return string|void */ function wpforo_content( $post, $echo = true ){ $content = ''; if(is_array($post) && isset($post['body'])){ $content = apply_filters('wpforo_content_before', $post['body'], $post); $content = wpforo_kses( $content, 'post' ); $content = apply_filters('wpforo_content', $content, $post); $content = wpforo_content_filter( $content ); $content = apply_filters('wpforo_content_after', $content, $post); } if( !$echo ) return $content; echo $content; } function wpforo_share_toggle( $url = '', $text = '', $location = 'side', $custom = false ){ $set = WPF()->api->options; $position = (($set['sb_location_toggle'] == 'left' || $set['sb_location_toggle'] == 'right')) ? 'side' : $set['sb_location_toggle']; if( !$set['sb_toggle_on'] || ( $position != $location && !$custom ) ) return false; $location_class = ( $custom ) ? $location : $set['sb_location_toggle']; ?>
api->share_toggle($url, $text); ?>
api->options; if( !$set['sb_on'] || (!wpfval($set, 'sb_location', $location) && !$custom) ) return false; ?>
api->share_buttons($url); ?>
tools_misc['admin_note_pages']; $usergroups = WPF()->tools_misc['admin_note_groups']; if( !wpfval(WPF()->tools_misc, 'admin_note_pages') ) return false; if( !wpfval(WPF()->tools_misc, 'admin_note_groups') ) return false; if( in_array(WPF()->current_user_groupid, $usergroups) ){ if( wpfval(WPF()->current_object, 'template') && in_array(WPF()->current_object['template'], $templates) ){ $display = true; } else { $display = false; } } if( $display ){ $note = wpforo_kses( wpforo_unslashe( trim( WPF()->tools_misc['admin_note'] ) ) ); $note = apply_filters( 'wpforo_admin_note', $note ); if( $note ){ ?>
tpl->icon('topic', $topic, false) ){ $icon = WPF()->tpl->icon_base( $topic['posts'] ); $icon = implode(' ', $icon); } $html = sprintf( $wrap,''); } else { if( ($type == 'all' || $type == 'base') && wpfkey($topic, 'posts') ){ $icon = WPF()->tpl->icon_base( $topic['posts'] ); $icon = implode(' ', $icon); $html .= sprintf( $wrap, ''); } if( $type == 'all' || $type == 'status' ) { $icon = WPF()->tpl->icon_status( $topic ); if( !empty($icon) ){ $html = ''; foreach( $icon as $i ){ if( !$color ) $i['color'] = ''; $classes = $i['class'] . ' ' . $i['color']; $html .= sprintf( $wrap,''); } } } } if( $echo ) echo $html; else return $html; } function wpforo_topic_icons( $topic, $type = 'all' ){ $icon = array(); if( is_numeric($topic) ) $topic = wpforo_topic($topic); if( $type == 'mixed' ) { $icon = WPF()->tpl->icon('topic', $topic, false); } else { if( ($type == 'all' || $type == 'base') && wpfkey($topic, 'posts') ){ $icon_base = WPF()->tpl->icon_base( $topic['posts'] ); if( !empty($icon_base) && is_array($icon_base) ) $icon = array( 'base' => $icon_base ); } if( $type == 'all' || $type == 'status' ) { $icon_status = WPF()->tpl->icon_status( $topic ); if( !empty($icon_status) && is_array($icon_status) ) $icon = $icon_status; } $icon = array_filter($icon); } return $icon; } function wpforo_tags( $topic, $wrap = true, $type = 'medium', $count = false ){ if( is_numeric($topic) && $topic > 0) { $topic = wpforo_topic($topic); } if( wpfval($topic, 'tags') ){ $tags = WPF()->topic->sanitize_tags($topic['tags'],true); if( !empty($tags) ){ if( $wrap ){ ?>
, '; ?>
topic->sanitize_tags($topic['tags'],true); if( !empty($tags) ){ foreach( $tags as $tag ){ if($tag) $wheres[] = "`tags` LIKE '%" . esc_sql($tag) . "%'"; } if($wheres) $args['where'] = '(' . implode(' OR ', $wheres) . ')'; $args['order'] = 'DESC'; $args['row_count'] = 5; $args['orderby'] = 'modified'; $args['forumid'] = $topic['forumid']; $args['exclude'] = array( $topic['topicid'] ); $args = apply_filters('wpforo_related_topics_args', $args); $topics = WPF()->topic->get_topics($args); if( !empty($topics) ){ $html .= '
'.wpforo_phrase('Related Topics', false).'
    '; foreach( $topics as $item ){ $data = wpforo_topic($item['topicid']); $html .= '
  • ' . wpforo_topic_icon( $item, 'all', true, false ) . ' ' . esc_html($item['title']) . '
    ' . wpforo_date( $item['modified'], 'ago', false ) . '
  • '; } $html .= '
'; echo '
' . $html . '
'; } else { echo '
'; } } } } } function wpforo_topic_navi( $topic ){ if( !empty($topic) ){ if( wpfval($topic, 'topicid') && wpfval($topic, 'forumid') ){ $all_html = ''; $prev_html = ''; $next_html = ''; $navi_topics = WPF()->db->get_col("SELECT `topicid` FROM `". WPF()->tables->topics ."` WHERE ( `topicid` = IFNULL((SELECT min(`topicid`) FROM `". WPF()->tables->topics ."` WHERE `topicid` > " . intval($topic['topicid']) . " AND `forumid` = " . intval($topic['forumid']) . " AND `status` = 0 AND `private` = 0),0) OR `topicid` = IFNULL((SELECT max(`topicid`) FROM `". WPF()->tables->topics ."` WHERE `topicid` < " . intval($topic['topicid']) . " AND `forumid` = " . intval($topic['forumid']) . " AND `status` = 0 AND `private` = 0),0) ) "); if( !empty($navi_topics) ){ $prev = ( wpfkey($navi_topics, 0) ) ? $navi_topics[0] : false; $next = ( wpfkey($navi_topics, 1) ) ? $navi_topics[1] : false; if( $prev && !$next ){ if( $topic['topicid'] < $prev ){ $next = $prev; $prev = false; } } if( $prev ){ $prev_data = wpforo_topic( $prev ); if( !empty($prev_data) ){ $prev_html = '  ' . wpforo_phrase('Previous Topic', false) . ''; } } if( $next ){ $next_data = wpforo_topic( $next ); if( !empty($next_data) ){ $next_html = '' . wpforo_phrase('Next Topic', false) . '  '; } } if( wpfval( WPF()->current_object, 'forum') && wpfval( WPF()->current_object, 'forum', 'url') ){ $forum_url = WPF()->current_object['forum']['url']; $forum_title = WPF()->current_object['forum']['title']; } else { $forum_url = wpforo_forum( $topic['forumid'], 'url' ); $forum_title = wpforo_forum( $topic['forumid'], 'title' ); } if( $forum_url ){ $all_html = '  ' . wpforo_phrase('All forum topics', false) . ''; } if( $prev_html || $next_html ){ $html = '
' . $all_html . '
' . $prev_html . '
' . $next_html . '
'; echo '
' . $html . '
'; } } } } } function wpforo_topic_visitors( $topic ){ if( !empty($topic) ){ $html = ''; $users = ''; $guests = ''; $users_visited = ''; $visitors = WPF()->log->visitors( $topic ); if( !empty( $visitors ) ){ if( wpfval( $visitors, 'users') ){ if( wpfval( $visitors, 'users', 'viewing') && WPF()->post->options['display_current_viewers'] ){ $count = count($visitors['users']['viewing']); if( $count ){ if( $count > 1 ){ $users = wpforo_phrase('%d users ( %s )', false); } elseif( $count == 1 ) { $users = wpforo_phrase('%d user ( %s )', false); } $user_html = array(); foreach( $visitors['users']['viewing'] as $user ){ if( wpfval( $user, 'userid' ) ){ $member = wpforo_member( $user['userid'] ); if( wpfval($member, 'display_name') ) { $user_html[] = wpforo_member_link($member, '', 30, 'wpf-topic-visitor-link', false ); } } } $user_html = implode(', ', $user_html ); $users = sprintf( $users, $count, $user_html ); } $users = apply_filters( 'wpforo_topic_viewing_users', $users, $visitors['users']['viewing'] ); } if( wpfval( $visitors, 'users', 'viewed') && WPF()->post->options['display_recent_viewers'] ){ $users_visited = wpforo_phrase( 'Recently viewed by users: %s.', false ); $track_users_link = array(); foreach( $visitors['users']['viewed'] as $user ){ if( wpfval( $user, 'userid' ) ){ $member = wpforo_member( $user['userid'] ); if( wpfval($member, 'display_name') ) { $track_users_link[] = wpforo_member_link($member, '', 30, 'wpf-topic-visitor-link', false ) . ' ' . wpforo_date( $user['time'], 'ago', false ); } } } $track_users_link = implode(', ', $track_users_link ); $users_visited = sprintf( $users_visited, $track_users_link ); $users_visited = '

' . $users_visited . '

'; $users_visited = apply_filters( 'wpforo_topic_viewed_users', $users_visited, $visitors['users']['viewed'] ); } } if( wpfval( $visitors, 'guests') && WPF()->post->options['display_current_viewers'] ){ $count = count($visitors['guests']); if( $count > 1 ){ $guests = sprintf( wpforo_phrase('%s guests', false), $count ); } elseif( $count == 1 ) { $guests = sprintf( wpforo_phrase('%s guest', false), $count ); } } if( $users || $guests ){ $and = ( $users && $guests ) ? wpforo_phrase('and', false, 'lower') : '' ; $html .= '

' . sprintf( wpforo_phrase('Currently viewing this topic %s %s %s.', false), $users, $and, $guests) . '

'; } $html .= $users_visited; $html = apply_filters( 'wpforo_topic_visitors_info', $html, $visitors ); } echo $html; } } function wpforo_viewing( $item, $echo = true ){ if( !empty($item) && WPF()->forum->options['display_current_viewers'] ){ $phrase = wpforo_phrase('(%d viewing)', false, 'lower'); $visitors = WPF()->log->visitors( $item ); $users = ( wpfval($visitors, 'users', 'viewing') ) ? count($visitors['users']['viewing']) : 0; $guests = ( wpfval($visitors, 'guests') ) ? count($visitors['guests']) : 0; $viewing = (int) $users + (int) $guests; if( $viewing > 0 ){ $phrase = '' . sprintf( $phrase, $viewing ) . ''; if( $echo ){ echo $phrase; } else { return $phrase; } } } } function wpforo_topic_footer(){ if( wpfval( WPF()->current_object, 'topic') && wpfval( WPF()->current_object, 'template') && WPF()->current_object['template'] == 'post' ){ $topic = WPF()->current_object['topic']; ?> 3) ? ' style="flex-wrap: wrap;"' : ''; if(!empty($thread['icons'])){ foreach( $thread['icons'] as $icon ){ $thread['icons_html'] .= ''; } } if(!empty($thread['user']) || !empty($thread['last_user'])) { $thread['usergroup_can_va'] = WPF()->perm->usergroup_can('va'); $thread['feature_avatars'] = wpforo_feature('avatars'); $thread['users_html'] .= '
'; if( $thread['usergroup_can_va'] && $thread['feature_avatars'] ) { if( !empty( $thread['user'] ) ) { $thread['user_avatar'] = WPF()->member->avatar($thread['user'], 'alt="'.esc_attr($thread['user']['display_name']).'"', 40); $thread['users_html'] .= ''; } if( $thread['replies'] && !empty( $thread['last_user'] ) ) { $thread['last_user_avatar'] = WPF()->member->avatar($thread['last_user'], 'alt="'.esc_attr($thread['last_user']['display_name']).'"', 24); $thread['users_html'] .= ''; } } else { $thread['users_html'] .= wpforo_member_link( $thread['user'], 'by', 9, '', false ); } $thread['users_html'] .= '
'; } return $thread; } /** * @param string $type * @param array $buttons * @param array $forum * @param array $topic * @param array $post * @param bool $echo * * @return string */ function wpforo_post_buttons($type = 'icon-text', $buttons = array(), $forum = array(), $topic = array(), $post = array(), $echo = true){ $buttons = WPF()->tpl->buttons( $buttons, $forum, $topic, $post, false ); if( $type === 'icon' ){ $buttons = preg_replace('#[\r\n\t\s\0]*]*>.*?#isu', '', $buttons); }elseif( $type === 'text' ){ $buttons = preg_replace('#]*>[\r\n\t\s\0]*[\r\n\t\s\0]*#isu', '', $buttons); $buttons = preg_replace('#\swpf-tooltip=[\'\"][^\'\"]+?[\'\"]#isu', '', $buttons); }else{ $buttons = preg_replace('#\swpf-tooltip=[\'\"][^\'\"]+?[\'\"]#isu', '', $buttons); } if($echo) echo $buttons; return $buttons; } function wpforo_like_button( $post = array(), $type = 'icon-count', $echo = true ){ $login = is_user_logged_in(); $button_html = ''; $forumid = (isset($post['forumid'])) ? $post['forumid'] : 0; $postid = (isset($post['postid'])) ? $post['postid'] : 0; if( WPF()->perm->forum_can('l', $forumid) && $login && WPF()->current_userid != $post['userid'] ) { $like_status = ( WPF()->post->is_liked( $postid, WPF()->current_userid ) === FALSE ? 'wpforo-like' : 'wpforo-unlike' ); $like_icon = ( $like_status == 'wpforo-like') ? 'far' : 'fas'; $icon = ( $type == 'icon' || $type == 'icon-text' || $type == 'icon-count' ) ? '' : ''; $number = ( $type == 'icon-count' ) ? '' . intval($post['likes_count']) . '' : ''; $phrase = ( $type == 'text' || $type == 'icon-text' ) ? '' . wpforo_phrase( str_replace('wpforo-', '', $like_status), false) . '' : ''; $button_html = '' .''. $icon .''. $phrase . $number . ''; } if(!$echo) return $button_html; echo $button_html; } function wpforo_post_likers( $postid ){ if( $postid ){ $likers = '
' . WPF()->tpl->likers( $postid ) . '
'; $likers = apply_filters('wpforo_post_likers', $likers, $postid); } echo $likers; } function wpforo_thread_breadcrumb( $post = array(), $parents = array() ){ $html = ''; $gab = false; if( wpfval($post, 'parentid') ){ $html .= ''; $parent = wpforo_post($post['parentid']); $member = wpforo_member($parent); $parent_url = ( wpfval($parent, 'url') ) ? $parent['url'] : '#post-' . $parent['parentid'] ; $avatar = WPF()->member->avatar( $member, 'alt="'.esc_attr($member['display_name']).'"', 18 ); $member_name = ( wpfval($member, 'display_name') ) ? $member['display_name'] : wpforo_phrase('Guest', false); $html .= ''; if( wpfval($parents, $post['parentid']) ){ $topic = wpforo_topic( $post['topicid'] ); $limit = apply_filters('wpforo_thread_breadcrumb_limit', 3); $items = array_reverse( $parents[ $post['parentid'] ] ); $last = key( array_slice( $items, -1, 1, TRUE ) ); foreach( $items as $key => $parentid ){ if( $key < $limit || $key == $last ){ $parent = wpforo_post($parentid); $starter = ( $topic['userid'] == $parent['userid'] ) ? true : false; $class = ( $starter ) ? ' wpf-starter' : ''; if( !empty($parent) ){ $member = wpforo_member($parent); $name = (wpfval($member, 'display_name')) ? $member['display_name'] : ''; $tooltip = ( $starter ) ? ' wpf-tooltip="' . esc_attr(wpforo_phrase('Topic Author', false) . ' - ' . $name ) . '" wpf-tooltip-size="medium"' : ' wpf-tooltip="' . esc_attr( wpforo_phrase('Reply by', false) . ' ' . $name ) . '" wpf-tooltip-size="medium"'; $parent_url = ( wpfval($parent, 'url') ) ? $parent['url'] : '#post-' . $parent['parentid'] ; $avatar = WPF()->member->avatar( $member, 'alt="'.esc_attr($member['display_name']).'"', 18 ); if(!$gab) $html .= ''; $html .= ''; } } else{ if(!$gab) $html .= ''; $gab = true; } } } } echo $html; } function wpforo_check_threads( $posts = array() ){ $post = array_shift($posts ); if( wpfkey($post, 'root') ){ if( is_null($post['root']) && wpfval($post, 'topicid') ){ WPF()->topic->rebuild_threads( $post['topicid'] ); wpforo_clean_cache(); } } } function wpforo_posts_ordering_dropdown($orderby = null, $topicid = null){ WPF()->tpl->posts_ordering_dropdown($orderby, $topicid); } function wpforo_template_pagenavi( $class = '', $permalink = true, $paged = null, $items_count = null, $items_per_page = null ) { WPF()->tpl->pagenavi( $paged, $items_count, $items_per_page, $permalink, $class ); } function wpforo_template_add_topic_button($forumid = null){ if( !wpforo_is_bot() ) WPF()->tpl->add_topic_button($forumid); } function wpforo_feed_rss2_url($echo = true, $general = false){ WPF()->feed->rss2_url($echo, $general); } function wpforo_template_topic_portable_form($forumid = null){ WPF()->tpl->topic_form_forums_selectbox($forumid); } function wpforo_notifications(){ WPF()->activity->notifications(); } function wpforo_unread_url( $topicid = 0, $url = '', $echo = true, $force = false ){ //Only for loggedin users $enabled = true; if( !$force ){ $enabled = wpforo_feature('goto-unread') ? true : false; } if( WPF()->current_userid && $enabled && $topicid && $url ){ //Get read topics $topics = WPF()->log->get_read_topics(); if( $last_read_id = wpfval($topics, $topicid) ){ //Make sure the post still located in current topic. When admin split a topic //and move the last reply to other topic, the users unread topic array isn't updated, //It's not reasonable to update usermeta of each user, so it's better to check //the post topic ID here. if the reply is split and moved to other topic use the //topic last post id. $last_read_post = wpforo_post($last_read_id); if( $topicid == wpfval($last_read_post, 'topicid') ){ $first_unread_id = 0; $jump_to_first_unread = apply_filters('wpforo_jump_to_first_unread', true); if( $jump_to_first_unread ) { //Get first unread postid $first_unread_id = WPF()->post->next_post( $last_read_id, $topicid ); } //Decide to whether execute more SQLs and create direct URLs or not $direct_url = apply_filters('wpforo_build_direct_unread_post_url', false); //Create new URLs if( $first_unread_id ){ //Change URL to first unread post if( $direct_url ) { $url = wpforo_post($first_unread_id, 'url'); } else { $url = (strpos($url, '#') !== FALSE) ? preg_replace('|\#.+$|', '#post-' . intval($first_unread_id) , $url) : $url . '#post-' . intval($first_unread_id); } } else{ //Change URL to last read post if( $direct_url ) { $url = wpforo_post($last_read_id, 'url'); } else { $url = (strpos($url, '#') !== FALSE) ? preg_replace('|\#.+$|', '#post-' . intval($last_read_id) , $url) : $url . '#post-' . intval($last_read_id); } } } elseif( $last_postid = wpforo_topic($topicid, 'last_post') ){ $url = wpforo_post($last_postid, 'url'); } } } else { $direct_topic_url = apply_filters( 'wpforo_direct_topic_url', true ); if( $direct_topic_url ){ $url = preg_replace( '|\#post\-\d+|i', '', $url); } } if( !$echo ) return esc_url($url); echo esc_url($url); } function wpforo_unread_button( $topicid = 0, $url = '', $echo = true, $postid = 0 ){ $button = ''; if( !$postid && $topicid && $url && WPF()->current_userid && wpforo_feature('goto-unread-button') ){ $unread = wpforo_unread( $topicid, 'topic', false ); if( $unread ){ $button_link = apply_filters('wpforo_jump_to_unread_button_link', false); $button_text = str_replace(array('{','}'), '', wpforo_phrase('{new}', false) ); if( wpforo_feature('goto-unread') ){ if( $button_link ){ $url = wpforo_unread_url( $topicid, $url, false, true ); } } else { $url = wpforo_unread_url( $topicid, $url, false, true ); $button_link = true; } $button = ( $button_link ) ? '' . $button_text . '' : '' . $button_text . ''; } } elseif( $postid && $topicid && WPF()->current_userid ){ $unread = wpforo_unread( $topicid, 'post', false, $postid ); if( $unread ){ $button_text = str_replace(array('{','}'), '', wpforo_phrase('{new}', false) ); $button = '' . $button_text . ''; } } if( !$echo ) return $button; echo $button; } /** * @param array|string $forum * @param string $before * @param string $after * @param bool $echo * * @return string */ function wpforo_forum_title($forum, $before = '', $after = '', $echo = true){ $title = is_array($forum) ? (string) wpfval($forum, 'title') : $forum; $title = esc_html($title); $title = apply_filters('wpforo_forum_title', $title); if($title) $title = $before . $title . $after; if($echo) echo $title; return $title; } /** * @param array|string $forum * @param string $before * @param string $after * @param bool $echo * * @return string */ function wpforo_forum_description($forum, $before = '', $after = '', $echo = true){ $description = is_array($forum) ? (string) wpfval($forum, 'description') : $forum; $description = apply_filters('wpforo_forum_description', $description); if($description) $description = $before . $description . $after; if($echo) echo $description; return $description; } function wpforo_admin_cpanel(){ if( WPF()->current_object['template'] === 'forum' && wpforo_feature('admin-cp') && wpforo_current_user_is( 'admin' ) ){ $toggle = get_user_meta( WPF()->current_userid, 'wpf-acp-toggle', true ); if( !$toggle || $toggle === 'open' ){ $display = 'block'; $title = wpforo_phrase('Close', false); $icon = ''; } else { $display = 'none'; $title = wpforo_phrase('Open', false); $icon = ''; } ?> tpl->member_template(); } /** * show member menu */ function wpforo_member_tabs(){ WPF()->tpl->member_menu(); } /** * get current object user or empty array * * @return array */ function wpforo_get_current_object_user(){ return WPF()->current_object['user']; } /** * @param array|string $template * * @return bool */ function wpforo_is_member_template($template = null){ WPF()->tpl->init_member_tpls(); if( $template = WPF()->tpl->get_template($template) ) return wpfkey(WPF()->member_tpls, $template['key']); return false; } /** * show wpforo template * * @param array|string $template */ function wpforo_template($template = null){ $template = apply_filters('wpforo_template', $template); if( !$template ) $template = WPF()->current_object['template'] ? WPF()->current_object['template'] : '404'; if( WPF()->tpl->can_view_template($template, WPF()->current_object['user']) ){ if( $path = WPF()->tpl->get_template_path($template) ){ /** -START- to be removed in next versions */ extract(WPF()->current_object, EXTR_OVERWRITE); extract(WPF()->current_object['user'], EXTR_OVERWRITE); /** -END- to be removed in next versions */ include($path); }else{ WPF()->tpl->show_template($template); } }else{ WPF()->tpl->show_msg( wpforo_phrase('You do not have permission to view this page', false) ); } } /** * @param array|string $template * * @return string */ function wpforo_get_template_slug($template = null){ $key = WPF()->tpl->get_key($template); $slug = wpfval(WPF()->tpl->slugs, $key); if(!$slug) $slug = $key; return $slug; } /** * @param string $html * * @return string */ function wpforo_apply_ucf_shortcode($html){ return preg_replace_callback('#\[wpfucf\s([^\[\]]+?)\]#iu', function($shortcode){ if( preg_match('#(?:^|\s)field=[\'\"]([^\'\"]+?)[\'\"]#iu', $shortcode[1], $field) ){ if( $field_key = trim($field[1]) ){ $userid = 0; if( preg_match('#(?:^|\s)id=[\'\"]([^\'\"]+?)[\'\"]#iu', $shortcode[1], $id) ) $userid = wpforo_bigintval($id[1]); if(!$userid) $userid = WPF()->current_object['userid'] ? WPF()->current_object['userid'] : WPF()->current_userid; if($f = WPF()->member->get_field($field_key)){ if( wpfval($f, 'type') === 'html' && ($html = trim(wpfval($f, 'html'))) ){ return (string) WPF()->form->field_html($f); }elseif( WPF()->form->can_view($f) && WPF()->form->can_show_value($f) ){ $f['value'] = wpforo_member($userid, $field_key); $f = WPF()->form->prepare_values( WPF()->form->esc_field($f), $userid ); return $f['value']; } } } } return ''; // if that field has not found }, $html); } /** * @param array|string $template * @param array|int $member * @param string $default * * @return string */ function wpforo_member_url($template = null, $member = null, $default = ''){ $member_url = $default; $template = WPF()->tpl->get_template($template); if( $template && wpforo_is_member_template($template) ){ if( !$member ) $member = WPF()->current_object['user'] ? WPF()->current_object['user'] : WPF()->current_user; $profile_url = is_array($member) ? WPF()->member->profile_url($member, $template['key']) : WPF()->member->get_profile_url($member, $template['key']); if($profile_url) $member_url = $profile_url; } return $member_url; } function wpforo_mark_all_read_link(){ if( !wpforo_is_bot() ) : ?>
tpl->post_search_form($values); } function wpforo_member_search_form(){ WPF()->tpl->member_search_form(); } function wpforo_member_buttons($member){ WPF()->tpl->member_buttons($member); } function wpforo_sanitize_search_body($body, $needle){ $body = wpforo_content_filter($body); $body = wpforo_text($body, 0, false); $words = explode(' ', trim($needle)); if(!empty($words)){ $body_len = apply_filters('wpforo_search_results_body_length', 564); $pos = mb_stripos( $body, " ".trim($words[0]), 0, get_option('blog_charset') ); if( strlen($body) > $body_len && $pos !== FALSE ){ if($pos > ($body_len/2)){ $bef_body = "... "; $start = mb_stripos( $body, " ", ($body_len/2), get_option('blog_charset') ); }else{ $bef_body = ""; $start = 0; } if( (mb_strlen($body, get_option('blog_charset')) - $start) > $body_len ){ $aft_body = " ..."; }else{ $aft_body = ""; } $body = $bef_body . mb_substr( $body, $start, $body_len, get_option('blog_charset') ) . $aft_body; } foreach($words as $word){ $word = trim($word); $body = preg_replace('#(?:^|\s+)'. preg_quote( esc_html($word) ) .'#iu', ' ' . esc_html($word) . '', $body); } } return $body; }