esc_html__( 'wpForo Menu', 'wpforo' ), ) ); function wpforo_login_url(){ global $wpforo; if(isset($wpforo->member->options['login_url']) && $wpforo->member->options['login_url']){ $wp_login_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->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(){ global $wpforo; if(isset($wpforo->member->options['register_url']) && $wpforo->member->options['register_url']){ $wp_register_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->member->options['register_url'] , '/'); } else{ $wp_register_url = wpforo_home_url('?wpforo=signup'); } return esc_url($wp_register_url); } function wpforo_lostpass_url(){ global $wpforo; if(isset($wpforo->member->options['lost_password_url']) && $wpforo->member->options['lost_password_url']){ $wp_lostpass_url = trim(get_bloginfo('url') , '/') . '/' . ltrim($wpforo->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 ) { global $wpforo; 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($wpforo->menu) && isset($wpforo->menu[$shortcode])){ if(isset($wpforo->menu[$shortcode]['href'])) $item->url = $wpforo->menu[$shortcode]['href']; if(isset($wpforo->menu[$shortcode]['attr']) && strpos($wpforo->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(' '; } if($url = wpforo_has_profile_plugin($userid)){ $forum_profile = true; $menu_html .= '
'; } if( $forum_profile ) { $menu_html .= '
'; $menu_html = '
'; $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 ) { global $wpforo; 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) { global $wpforo; if( !wpforo_feature('page-title', $wpforo) ){ 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, $usergroup = true ){ global $wpforo; $title = array(); if(empty($member) || !$member['groupid']) return; $rating_title_ug_enabled = ( isset($wpforo->member->options['rating_title_ug'][$member['groupid']]) && $wpforo->member->options['rating_title_ug'][$member['groupid']] ) ? true : false ; $usergroup_title_ug_enabled = ( isset($wpforo->member->options['title_usergroup'][$member['groupid']]) && $wpforo->member->options['title_usergroup'][$member['groupid']] ) ? true : false ; if( wpforo_feature('rating_title', $wpforo) && $rating_title_ug_enabled && isset($member['stat']['title']) ){ $title[] = '' . esc_html($member['stat']['title']) . ''; } if( empty($title) ){ $title[] = '' . wpforo_phrase($member['title'], false) . ''; } 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 = implode(' ', $title); $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' ){ global $wpforo; $rating_badge_ug_enabled = ( isset($wpforo->member->options['rating_badge_ug'][$member['groupid']]) && $wpforo->member->options['rating_badge_ug'][$member['groupid']] ) ? true : false ; if( wpforo_feature('rating', $wpforo) && $rating_badge_ug_enabled && isset($member['stat']['rating']) ): ?>
member->rating_badge($member['stat']['rating'], $type); ?>
cache->on('object_cashe'); if( $cache ){ $post = $wpforo->cache->get_item( $postid, 'post' ); } if( empty($post) ){ if( !$cache && $var == 'url' ){ $post['url'] = $wpforo->post->get_post_url($postid); } elseif( !$cache && $var == 'is_answered' ){ $post['is_answered'] = $wpforo->post->is_answered($postid); } elseif( !$cache && $var == 'votes_sum' ){ $post['votes_sum'] = $wpforo->post->get_post_votes_sum($postid); } elseif( !$cache && $var == 'likes_count' ){ $post['likes_count'] = $wpforo->post->get_post_likes_count($postid); } elseif( !$cache && $var == 'likers_usernames' ){ $post['likers_usernames'] = $wpforo->post->get_likers_usernames($postid); } else{ $post = $wpforo->post->get_post($postid); if( !empty($post) ){ $post['url'] = $wpforo->post->get_post_url($post); if( $cache ){ $post['is_answered'] = $wpforo->post->is_answered($postid); $post['votes_sum'] = $wpforo->post->get_post_votes_sum($postid); $post['likes_count'] = $wpforo->post->get_post_likes_count($postid); $post['likers_usernames'] = $wpforo->post->get_likers_usernames($postid); } if(!empty($post)){ $cache_item = array( $postid => $post ); $wpforo->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 ){ global $wpforo; $topic = ( $var == 'item' ) ? array() : ''; if( !$topicid ) return $topic; $cache = $wpforo->cache->on('object_cashe'); if( $cache ) $topic = $wpforo->cache->get_item( $topicid, 'topic' ); if( empty($topic) ){ if( !$cache && $var == 'url' ){ $topic['url'] = $wpforo->topic->get_topic_url( $topicid ); } elseif( !$cache && $var == 'is_answer' ){ $topic['is_answer'] = $wpforo->topic->is_solved( $topicid ); } else{ $topic = $wpforo->topic->get_topic($topicid); if( !empty($topic) ){ $topic['url'] = $wpforo->topic->get_topic_url($topic); $topic['is_answer'] = $wpforo->topic->is_solved( $topic['topicid'] ); if(!empty($topic)){ $cache_item = array( $topicid => $topic ); $wpforo->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 ){ global $wpforo; $data = array(); $forum = ( $var == 'item' ) ? array() : ''; $cache = $wpforo->cache->on('object_cashe'); if( !$forumid ) return $forum; if( $cache ) $forum = $wpforo->cache->get_item( $forumid, 'forum' ); if( empty($forum) ){ if( !$cache && ($var == 'childs' || $var == 'counts') ){ if( $var == 'childs' ) { $wpforo->forum->get_childs($forumid, $data); $forum['childs'] = $data; } else{ $wpforo->forum->get_childs($forumid, $data); $forum['childs'] = $data; $forum['counts'] = $wpforo->forum->get_counts( $data ); } } else{ $forum = $wpforo->forum->get_forum($forumid); if( !empty($forum) ){ if( $cache ){ $wpforo->forum->get_childs($forum['forumid'], $data); $forum['childs'] = $data; $forum['counts'] = $wpforo->forum->get_counts( $data ); } if(!empty($forum)){ $cache_item = array( $forumid => $forum ); $wpforo->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 ){ global $wpforo; $member = array(); if( empty( $object ) ) return $member; if( is_array( $object ) && isset($object['userid']) && $object['userid'] == 0 ){ $member = $wpforo->member->get_guest( $object ); } else{ $userid = ( is_array( $object ) && isset($object['userid']) ) ? intval($object['userid']) : intval($object); $member = $wpforo->member->get_member( $userid ); } if( $var != 'item' && $var ){ $member = ( isset($member[$var]) ) ? $member[$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); $nofollow = ( !wpforo_feature('seo-profile')) ? ' rel="nofollow" ' : ''; if( isset($member['profile_url']) && $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 ''; global $wpforo; $fields = apply_filters( 'wpforo_form_fields', $fields ); $html = $wpforo->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 ){ global $wpforo; $wpforo->form['value']['user_login'] = (isset($_POST['wpfreg']['user_login'])) ? sanitize_user($_POST['wpfreg']['user_login']) : ''; $wpforo->form['value']['user_email'] = (isset($_POST['wpfreg']['user_email'])) ? sanitize_email($_POST['wpfreg']['user_email']) : ''; $wpforo->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 ){ global $wpforo; if( isset($wpforo->current_object['user']) && !empty($wpforo->current_object['user']) ){ $user = $wpforo->current_object['user']; $user = apply_filters('wpforo_profile_header_obj', $user); $wpforo->form['value'] = $user; $wpforo->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 ){ global $wpforo; if( isset($wpforo->current_object['user']) && !empty($wpforo->current_object['user']) ){ $user = $wpforo->current_object['user']; $wpforo->form['value'] = $user; } } add_action( 'wpforo_profile_page_start', 'wpforo_profile_page_field_values', 10, 1 ); function wpforo_search_page_field_values( $fields ){ global $wpforo; $wpforo->form['value'] = ( !empty($_GET) ? (array) $_GET : array() ); $wpforo->form['varname'] = ''; } add_action( 'wpforo_search_page_start', 'wpforo_search_page_field_values', 10, 1 ); function wpforo_user_avatar( $user, $size, $attr = '', $lastmod = false ){ global $wpforo; $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); //'alt="'.esc_html($display_name).'"' } if( $lastmod ){ $url = wpforo_avatar_url( $avatar_html ); if($url){ $avatar_html = str_replace($url, $url . '?lm=' . time(), $avatar_html); } } return $avatar_html; } function wpforo_register_fields(){ global $wpforo; $fields = $wpforo->member->get_register_fields(); do_action( 'wpforo_register_page_start', $fields ); return $fields; } function wpforo_account_fields(){ global $wpforo; $fields = $wpforo->member->get_account_fields(); do_action( 'wpforo_account_page_start', $fields ); return $fields; } function wpforo_profile_fields(){ global $wpforo; $fields = $wpforo->member->get_profile_fields(); do_action( 'wpforo_profile_page_start', $fields ); return $fields; } function wpforo_search_fields(){ global $wpforo; $fields = $wpforo->member->get_search_fields(); do_action( 'wpforo_search_page_start', $fields ); if( $wpforo->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; }