esc_html__( 'wpForo Menu', 'wpforo' ), ) ); function wpforo_login_url(){ if(isset(WPF()->member->options['login_url']) && 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() ? wpforo_home_url('?wpforo=signin') : wpforo_home_url( $request_uri . '?wpforo=signin' ) ); } return esc_url($wp_login_url); } function wpforo_register_url(){ if(isset(WPF()->member->options['register_url']) && WPF()->member->options['register_url']){ $wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['register_url'] , '/'); } else{ $wp_register_url = wpforo_home_url('?wpforo=signup'); } return esc_url($wp_register_url); } function wpforo_lostpass_url(){ if(isset(WPF()->member->options['lost_password_url']) && WPF()->member->options['lost_password_url']){ $wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim(WPF()->member->options['lost_password_url'] , '/'); } else{ $wp_lostpass_url = wp_lostpassword_url( wpforo_get_request_uri() ); } 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(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, '?wpforo') !== 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 .= "\r\n
\r\n"; $menu_html = apply_filters( 'wpforo_profile_plugin_menu_filter', $menu_html, $userid ); echo $menu_html; //This is a HTML content// } } 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 = join( ' ', 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_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 ) { echo $args['before_widget']; //This is a HTML content// echo ''; } } if( $echo ) { echo $edit_html; } else{ return $edit_html; } } function wpforo_hide_title($title, $id = 0) { if( !wpforo_feature('page-title') ){ if( $wpforo_base_slug = basename( wpforo_home_url() ) ) $wpforo_page = get_page_by_path($wpforo_base_slug); if(!empty($wpforo_page)){ if (in_the_loop() && is_page($wpforo_page->ID) && $id == get_the_ID()) { $title = ''; } } } return $title; } add_filter('the_title', 'wpforo_hide_title', 10, 2); function wpforo_validate_gravatar( $email ) { $hashkey = md5(strtolower(trim($email))); $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; $data = wp_cache_get($hashkey); if (false === $data) { $response = wp_remote_head($uri); if( is_wp_error($response) ) { $data = 'not200'; } else { $data = $response['response']['code']; } wp_cache_set($hashkey, $data, $group = '', $expire = 60*5); } if ($data == '200'){ return true; } else { return false; } } function wpforo_member_title( $member = array(), $echo = true, $before = '', $after = '' ){ $title = array(); if(empty($member) || !$member['groupid']) return ''; $rating_title_ug_enabled = ( isset(WPF()->member->options['rating_title_ug'][$member['groupid']]) && WPF()->member->options['rating_title_ug'][$member['groupid']] ) ? true : false ; $usergroup_title_ug_enabled = ( isset(WPF()->member->options['title_usergroup'][$member['groupid']]) && WPF()->member->options['title_usergroup'][$member['groupid']] ) ? true : false ; if( wpforo_feature('rating_title') && $rating_title_ug_enabled && isset($member['stat']['title']) ){ $title[] = '' . esc_html($member['stat']['title']) . ''; } if( empty($title) && WPF()->member->options['custom_title_is_on'] ){ $title[] = '' . wpforo_phrase($member['title'], false) . ''; }else{ $before = $after = ''; } if( $usergroup_title_ug_enabled ){ $class = ''; if( $member['groupid'] == 1 ) $class = ' wpfbg-6 wpfcl-3'; if( $member['groupid'] == 2 ) $class = ' wpfbg-5 wpfcl-3'; if( $member['groupid'] == 4 ) $class = ' wpfbg-2 wpfcl-3'; $title[] = '' . esc_html($member['groupname']) . ''; } if( !empty($title) ){ $title_html = $before . implode(' ', $title) . $after; $title_html = apply_filters('wpforo_member_title', $title_html, $member); if( $echo ) { echo $title_html; } else{ return $title_html; } } } function wpforo_member_badge( $member = array(), $sep = '', $type = 'full' ){ $rating_badge_ug_enabled = ( isset(WPF()->member->options['rating_badge_ug'][$member['groupid']]) && WPF()->member->options['rating_badge_ug'][$member['groupid']] ) ? true : false ; if( wpforo_feature('rating') && $rating_badge_ug_enabled && isset($member['stat']['rating']) ): ?>
member->rating_badge($member['stat']['rating'], $type); ?>
';} if( $bracket ) $nicename .= '('; $nicename .= $prefix . urldecode($member['user_nicename']); if( $bracket ) $nicename .= ')'; if( $wrap ){ $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 ); } elseif( !$cache && $var == 'is_answer' ){ $topic['is_answer'] = WPF()->topic->is_solved( $topicid ); } else{ $topic = WPF()->topic->get_topic($topicid); if( !empty($topic) ){ $topic['url'] = WPF()->topic->get_topic_url($topic); $topic['is_answer'] = WPF()->topic->is_solved( $topic['topicid'] ); 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 = array(); 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'] ){ $member['fields'] = json_decode($member['fields'], true); } } if( $var != 'item' && $var ){ if( isset($member[$var]) ){ $member = $member[$var]; } elseif( isset($member['fields']) && isset($member['fields'][$var]) ){ $member = $member['fields'][$var]; } } if( $echo ){ echo $member; } else{ return $member; } } 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 = ($member['display_name']) ? 'title="' . esc_attr($member['display_name']) . '"' : ''; if( wpfval($member, 'profile_url') ){ ?> >

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()->tpl->form_fields( $fields ); if( $echo ){ echo $html; } else{ return $html; } } ################################################################################################## /** * Collects Registration Page POST data and sends to field generator function * * @since 1.4.0 * * @param array $fields arguments * * @return NULL */ function wpforo_register_page_field_values( $fields ){ WPF()->form['value']['user_login'] = (isset($_POST['wpfreg']['user_login'])) ? sanitize_user($_POST['wpfreg']['user_login']) : ''; WPF()->form['value']['user_email'] = (isset($_POST['wpfreg']['user_email'])) ? sanitize_email($_POST['wpfreg']['user_email']) : ''; WPF()->form['varname'] = 'wpfreg'; } add_action( 'wpforo_register_page_start', 'wpforo_register_page_field_values', 10, 1 ); ################################################################################################## /** * Collects Account Page field data and sends to field generator function * * @since 1.4.0 * * @param array $fields arguments * * @return NULL */ function wpforo_account_page_field_values( $fields ){ if( isset(WPF()->current_object['user']) && !empty(WPF()->current_object['user']) ){ $user = WPF()->current_object['user']; $user = apply_filters('wpforo_profile_header_obj', $user); WPF()->form['value'] = $user; WPF()->form['varname'] = 'member'; } } add_action( 'wpforo_account_page_start', 'wpforo_account_page_field_values', 10, 1 ); ################################################################################################## /** * Collects Profile Page field data and sends to field generator function * * @since 1.4.0 * * @param array $fields arguments * * @return NULL */ function wpforo_profile_page_field_values( $fields ){ if( isset(WPF()->current_object['user']) && !empty(WPF()->current_object['user']) ){ $user = WPF()->current_object['user']; WPF()->form['value'] = $user; } } add_action( 'wpforo_profile_page_start', 'wpforo_profile_page_field_values', 10, 1 ); function wpforo_search_page_field_values( $fields ){ WPF()->form['value'] = ( !empty($_GET) ? (array) $_GET : array() ); WPF()->form['varname'] = ''; } add_action( 'wpforo_search_page_start', 'wpforo_search_page_field_values', 10, 1 ); function wpforo_user_avatar( $user, $size, $attr = '', $lastmod = false ){ $avatar_html = ''; if( is_int($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() ){ $signature = ''; $default = array('nofollow' => 1, 'kses' => 1, 'echo' => 1); if( empty($args) ){ $args = $default; }else{ $args = wpforo_parse_args( $args, $default ); } if( is_int($member) && $member > 0 ){ $member = wpforo_member( $member ); $signature = ( isset($member['signature']) ) ? $member['signature'] : ''; } elseif( 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'))); } $signature = wpforo_text($signature, 0, 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' => 'fa-search', 'name' => 'wpfms', 'canBeInactive' => 0, 'can' => '', 'isSearchable' => 1 ) ) ) ); } return $fields; } function wpforo_unread_forum( $logid, $return = 'class', $echo = true ){ $unread = false; if(!wpforo_feature('view-logging')) return; $viwed_ids = wpforo_getcookie( 'wpf_viewed_forums', true ); if( empty($viwed_ids) ) $unread = true; if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true; 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 = false; if(!wpforo_feature('view-logging')) return; $viwed_ids = wpforo_getcookie( 'wpf_viewed_topics', true ); if( empty($viwed_ids) ) $unread = true; if( is_array($viwed_ids) && !in_array( $logid, $viwed_ids ) ) $unread = true; 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 = WPF()->post->get_posts( array('topicid' => WPF()->current_object['topicid']) ); $tabs[] = array('title' => wpforo_phrase('Move Topic', false), 'id' => 'topic_move_form', 'class' => 'wpft-move', 'icon' => 'far fa-share-square'); if( count($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( count($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'] || !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'] = $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'] = $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; } } } function wpforo_content( $post, $echo = true ){ 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 ){ echo $content; } else{ return $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); ?>