options(); $this->setup(); } public function init(){ $this->member->init_current_user(); $this->init_current_object(); $this->moderation->init(); $this->tpl->init_member_templates(); $this->tpl->init_nav_menu(); wpforo_actions(); } private function options(){ global $wpdb; $this->db = $wpdb; $this->file = __FILE__; $this->error = NULL; $this->basename = plugin_basename( $this->file ); //OPTIONS $this->permastruct = trim( get_wpf_option('wpforo_permastruct'), '/' ); $this->use_home_url = get_wpf_option('wpforo_use_home_url'); $this->excld_urls = get_wpf_option('wpforo_excld_urls'); $this->url = ( $this->use_home_url ? esc_url( home_url('/') ) : esc_url( home_url('/') ) . $this->permastruct . "/" ); $this->general_options = get_wpf_option( 'wpforo_general_options'); $this->pageid = get_wpf_option( 'wpforo_pageid'); $this->default_groupid = get_wpf_option('wpforo_default_groupid') ? get_option('wpforo_default_groupid') : 3; $this->usergroup_cans = get_wpf_option('wpforo_usergroup_cans'); $this->forum_options = get_wpf_option('wpforo_forum_options'); $this->forum_cans = get_wpf_option('wpforo_forum_cans'); $this->post_options = get_wpf_option('wpforo_post_options'); $this->member_options = get_wpf_option('wpforo_member_options'); $this->subscribe_options = get_wpf_option('wpforo_subscribe_options'); $this->countries = get_wpf_option('wpforo_countries'); $this->features = get_wpf_option('wpforo_features'); $this->tools_antispam = get_wpf_option('wpforo_tools_antispam'); $this->style_options = get_wpf_option('wpforo_style_options'); $this->theme_options = get_wpf_option('wpforo_theme_options'); $this->theme = $this->theme_options['folder']; //CONSTANTS define('WPFORO_BASE_URL', $this->url ); define('WPFORO_THEME', $this->theme ); define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme ); define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme ); } private function setup(){ register_activation_hook($this->basename, 'do_wpforo_activation'); register_deactivation_hook($this->basename, 'do_wpforo_deactivation'); } public function phrases(){ if($this->general_options){ $phrases = $this->phrase->get_phrases( array( 'langid' => $this->general_options['lang'] ) ); foreach($phrases as $phrase){ $this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value']; } } } public function get_statistic(){ $stats = array(); $stats['forums'] = $this->forum->get_count(); $stats['topics'] = $this->topic->get_count(); $stats['posts'] = $this->post->get_count(); $stats['members'] = $this->member->get_count(); $stats['online_members_count'] = $this->member->online_members_count(); $stats['last_post_title'] = ''; $stats['last_post_url'] = ''; $posts = $this->topic->get_topics( array( 'orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1 ) ); if(isset($posts[0]) && !empty($posts[0])){ if( $this->perm->forum_can( 'vf', $posts[0]['forumid'] ) ){ $stats['last_post_title'] = $posts[0]['title']; $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']); } else{ $stats['last_post_title'] = ''; $stats['last_post_url'] = ''; } } $stats['newest_member_dname'] = ''; $stats['newest_member_profile_url'] = ''; $members = $this->member->get_members( array( 'orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1 ) ); if(isset($members[0]) && !empty($members[0])){ $stats['newest_member_dname'] = $members[0]['display_name'] ? $members[0]['display_name'] : urldecode($members[0]['user_nicename']); $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']); } return apply_filters('wpforo_get_statistic_array_filter', $stats); } public function init_current_object($url = ''){ $this->current_object = array('template' => '', 'paged' => 1); if(!$url) $url = wpforo_get_request_uri(); if( !is_wpforo_page($url) ) return; $current_url = wpforo_get_url_query_vars_str($url); if( $this->use_home_url ) $this->permastruct = ''; $current_object = array(); $current_object['template'] = ''; if(isset($_GET['wpfs'])) $current_object['template'] = 'search'; if( isset($_GET['wpforo']) ){ switch($_GET['wpforo']){ case 'signup': if(!is_user_logged_in()) $current_object['template'] = 'register'; break; case 'signin': if(!is_user_logged_in()) $current_object['template'] = 'login'; break; case 'logout': wp_logout(); wp_redirect( preg_replace('#\?.*$#is', '', wpforo_get_request_uri()) ); exit(); break; } } $wpf_url = preg_replace( '#^/?'.preg_quote($this->permastruct).'#isu', '' , $current_url, 1 ); $wpf_url = preg_replace('#\/?\?.*$#is', '', $wpf_url); $wpf_url_parse = array_filter( explode('/', trim($wpf_url, '/')) ); $wpf_url_parse = array_reverse($wpf_url_parse); if(in_array('paged', $wpf_url_parse)){ foreach($wpf_url_parse as $key => $value){ if( $value == 'paged'){ unset($wpf_url_parse[$key]); break; } if(is_numeric($value)) $paged = intval($value); unset($wpf_url_parse[$key]); } } if(isset($_GET['wpfpaged']) && intval($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']); $current_object['paged'] = (isset($paged) && $paged) ? $paged : 1; $wpf_url_parse = array_values($wpf_url_parse); if( !isset($current_object['template']) || !$current_object['template'] ) $current_object = apply_filters('wpforo_before_init_current_object', $current_object, $wpf_url_parse); if( !isset($current_object['template']) || !$current_object['template'] ) { if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){ $current_object['template'] = 'members'; }elseif(in_array('profile', $wpf_url_parse)){ $current_object['template'] = 'profile'; foreach($wpf_url_parse as $value){ if( $value == 'profile') break; if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value; } }elseif(in_array('account', $wpf_url_parse)){ $current_object['template'] = 'account'; foreach($wpf_url_parse as $value){ if( $value == 'account') break; if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value; } }elseif(in_array('activity', $wpf_url_parse)){ $current_object['template'] = 'activity'; foreach($wpf_url_parse as $value){ if( $value == 'activity') break; if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value; } }elseif(in_array('subscriptions', $wpf_url_parse)){ $current_object['template'] = 'subscriptions'; foreach($wpf_url_parse as $value){ if( $value == 'subscriptions') break; if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value; } }else{ $current_object['template'] = 'forum'; if( isset($wpf_url_parse[0]) ){ if( isset($wpf_url_parse[1]) ){ $current_object['topic_slug'] = $wpf_url_parse[0]; $current_object['forum_slug'] = $wpf_url_parse[1]; $current_object['template'] = 'post'; }else{ $current_object['forum_slug'] = $wpf_url_parse[0]; $current_object['template'] = 'topic'; } } } } if( isset($current_object['userid']) || isset($current_object['username']) ){ $args = array(); if(isset($current_object['userid'])) $args['userid'] = $current_object['userid']; if(isset($current_object['username'])) $args['username'] = $current_object['username']; $selected_user = $this->member->get_member($args); if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('username' => $current_object['userid'])); if(!empty($selected_user)){ $current_object['user'] = $selected_user; $current_object['userid'] = $selected_user['ID']; $current_object['username'] = $selected_user['user_nicename']; switch($current_object['template']){ case 'activity': $args = array( 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'], 'row_count' => $this->post_options['posts_per_page'], 'userid' => $current_object['userid'], 'order' => 'DESC', 'check_private' => true ); $current_object['items_count'] = 0; $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']); break; case 'subscriptions': $args = array( 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'], 'row_count' => $this->post_options['posts_per_page'], 'userid' => $current_object['userid'], 'order' => 'DESC' ); $current_object['items_count'] = 0; $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']); break; } }else{ $current_object['user'] = array(); $current_object['userid'] = 0; $current_object['username'] = ''; } } if(isset($current_object['forum_slug']) && $current_object['forum_slug']){ $forum = $this->forum->get_forum(array('slug' => $current_object['forum_slug']), TRUE); if(!empty($forum)){ $current_object['forum'] = $forum; $current_object['forumid'] = $forum['forumid']; $current_object['forum_desc'] = $forum['description']; $current_object['forum_meta_key'] = $forum['meta_key']; $current_object['forum_meta_desc'] = $forum['meta_desc']; }else{ $current_object['forum'] = array(); $current_object['forumid'] = 0; $current_object['forum_desc'] = ''; $current_object['forum_meta_key'] = ''; $current_object['forum_meta_desc'] = ''; } } if(isset($current_object['topic_slug']) && $current_object['topic_slug']){ $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']), TRUE); if(!empty($topic)){ $current_object['topic'] = $topic; $current_object['topicid'] = $topic['topicid']; }else{ $current_object['topic'] = array(); $current_object['topicid'] = 0; } } $this->current_object = apply_filters('wpforo_after_init_current_object', $current_object, $wpf_url_parse); } } $wpforo = new wpForo(); $wpforo->phrase = new wpForoPhrase( $wpforo ); $wpforo->phrases(); $wpforo->forum = new wpForoForum( $wpforo ); $wpforo->topic = new wpForoTopic( $wpforo ); $wpforo->post = new wpForoPost( $wpforo ); $wpforo->usergroup = new wpForoUsergroup( $wpforo ); $wpforo->member = new wpForoMember( $wpforo ); $wpforo->perm = new wpForoPermissions( $wpforo ); $wpforo->sbscrb = new wpForoSubscribe( $wpforo ); $wpforo->tpl = new wpForoTemplate( $wpforo ); $wpforo->notice = new wpForoNotices( $wpforo ); $wpforo->feed = new wpForoFeed( $wpforo ); $wpforo->moderation = new wpForoModeration( $wpforo ); if(wpforo_is_admin()) include( WPFORO_DIR .'/wpf-admin/admin.php' ); $GLOBALS['wpforo'] = $wpforo; add_action('init', array($wpforo, 'init')); //ADDONS///////////////////////////////////////////////////// $wpforo->addons = array( 'pm' => array('version' => '1.0.0', 'requires' => '1.1.2', 'class' => 'wpForoPMs', 'title' => 'Private Messages', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'pm' . '/header.png', 'desc' => __('Provides a safe way to communicate directly with other members. Messages are private and can only be viewed by conversation participants.', 'wpforo'), 'url' => 'http://gvectors.com/product/wpforo-private-messages/'), 'attachments' => array('version' => '1.0.0', 'requires' => '1.1.0', 'class' => 'wpForoAttachments', 'title' => 'Advanced Attachments', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'attachments' . '/header.png', 'desc' => __('Adds an advanced file attachment system to forum topics and posts. AJAX powered media uploading and displaying system with user specific library.', 'wpforo'), 'url' => 'http://gvectors.com/product/wpforo-advanced-attachments/'), 'embeds' => array('version' => '1.0.2', 'requires' => '1.1.0', 'class' => 'wpForoEmbeds', 'title' => 'Embeds', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'embeds' . '/header.png', 'desc' => __('Allows to embed hundreds of video, social network, audio and photo content providers in forum topics and posts.', 'wpforo'), 'url' => 'http://gvectors.com/product/wpforo-embeds/'), ); $wp_version = get_bloginfo('version'); if (version_compare($wp_version, '4.2.0', '>=')) { add_action('wp_ajax_dismiss_wpforo_addon_note', array($wpforo->notice, 'dismissAddonNote')); add_action('admin_notices', array($wpforo->notice, 'addonNote'));} ///////////////////////////////////////////////////////////// } ?>