PluginProbe
wpForo Forum / 1.1.1
wpForo Forum v1.1.1
3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 All 137 releases
wpforo / wpforo.php

wpforo.php in wpForo Forum 1.1.1, at wpforo.php

350 lines 15.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Forum - wpForo
4 * Plugin URI: http://wpforo.com
5 * Description: Next Generation of WordPress Forum Softwares. Everything you need to run an efficient and professional community. Powerful and beautiful bulletin board with unique features.
6 * Author: gVectors Team (A. Chakhoyan, R. Hovhannisyan)
7 * Author URI: http://gvectors.com/
8 * Version: 1.1.1
9 * Text Domain: wpforo
10 * Domain Path: /wpf-languages
11 */
12
13 // Exit if accessed directly
14 if( !defined( 'ABSPATH' ) ) exit;
15 if( !defined( 'WPFORO_VERSION' ) ) define('WPFORO_VERSION', '1.1.1');
16
17 function wpforo_load_plugin_textdomain() { load_plugin_textdomain( 'wpforo', FALSE, basename( dirname( __FILE__ ) ) . '/wpf-languages/' ); }
18 add_action( 'plugins_loaded', 'wpforo_load_plugin_textdomain' );
19
20 if( !class_exists( 'wpForo' ) ) {
21
22 define('WPFORO_DIR', rtrim( plugin_dir_path( __FILE__ ), '/'));
23 define('WPFORO_URL', rtrim( plugins_url( plugin_basename(dirname(__FILE__))), '/'));
24 define('WPFORO_FOLDER', rtrim( plugin_basename(dirname(__FILE__)), '/'));
25 define('WPFORO_BASENAME', plugin_basename(__FILE__)); //wpforo/wpforo.php
26
27 define('WPFORO_THEME_DIR', WPFORO_DIR . '/wpf-themes' );
28 define('WPFORO_THEME_URL', WPFORO_URL . '/wpf-themes' );
29
30 include( WPFORO_DIR . '/wpf-includes/wpf-hooks.php' );
31 include( WPFORO_DIR . '/wpf-includes/wpf-actions.php');
32 include( WPFORO_DIR . '/wpf-includes/functions.php' );
33 if(wpforo_is_admin()) {
34 include( WPFORO_DIR . '/wpf-includes/functions-installation.php' );
35 }
36 include( WPFORO_DIR . '/wpf-includes/functions-integration.php' );
37 include( WPFORO_DIR . '/wpf-includes/functions-template.php' );
38 include( WPFORO_DIR . '/wpf-includes/class-forums.php' );
39 include( WPFORO_DIR . '/wpf-includes/class-topics.php' );
40 include( WPFORO_DIR . '/wpf-includes/class-posts.php' );
41 include( WPFORO_DIR . '/wpf-includes/class-usergroups.php' );
42 include( WPFORO_DIR . '/wpf-includes/class-members.php' );
43 include( WPFORO_DIR . '/wpf-includes/class-permissions.php' );
44 include( WPFORO_DIR . '/wpf-includes/class-phrases.php');
45 include( WPFORO_DIR . '/wpf-includes/class-subscribes.php' );
46 include( WPFORO_DIR . '/wpf-includes/class-template.php' );
47 include( WPFORO_DIR . '/wpf-includes/class-notices.php' );
48 include( WPFORO_DIR . '/wpf-includes/class-feed.php' );
49
50 class wpForo{
51
52 public $options = array();
53 public $db;
54 public $phrases;
55 public $theme;
56 public $addons = array();
57 public $current_object;
58 public $menu = array();
59
60 public function __construct(){
61 $this->options();
62 $this->setup();
63 }
64
65 public function init(){
66 $this->member->init_current_user();
67 $this->init_current_object();
68 $this->tpl->init_member_templates();
69 $this->tpl->init_nav_menu();
70 wpforo_actions();
71 }
72
73 private function options(){
74 global $wpdb;
75 $this->db = $wpdb;
76 $this->file = __FILE__;
77 $this->error = NULL;
78 $this->basename = plugin_basename( $this->file );
79
80 //OPTIONS
81 $this->permastruct = trim( get_wpf_option('wpforo_permastruct'), '/' );
82 $this->use_home_url = get_wpf_option('wpforo_use_home_url');
83 $this->excld_urls = get_wpf_option('wpforo_excld_urls');
84 $this->url = ( $this->use_home_url ? esc_url( home_url('/') ) : esc_url( home_url('/') ) . $this->permastruct . "/" );
85 $this->general_options = get_wpf_option( 'wpforo_general_options');
86 $this->pageid = get_wpf_option( 'wpforo_pageid');
87 $this->default_groupid = get_wpf_option('wpforo_default_groupid') ? get_option('wpforo_default_groupid') : 3;
88 $this->usergroup_cans = get_wpf_option('wpforo_usergroup_cans');
89 $this->forum_options = get_wpf_option('wpforo_forum_options');
90 $this->forum_cans = get_wpf_option('wpforo_forum_cans');
91 $this->post_options = get_wpf_option('wpforo_post_options');
92 $this->member_options = get_wpf_option('wpforo_member_options');
93 $this->subscribe_options = get_wpf_option('wpforo_subscribe_options');
94 $this->countries = get_wpf_option('wpforo_countries');
95 $this->features = get_wpf_option('wpforo_features');
96 $this->style_options = get_wpf_option('wpforo_style_options');
97 $this->theme_options = get_wpf_option('wpforo_theme_options');
98 $this->theme = $this->theme_options['folder'];
99 //CONSTANTS
100 define('WPFORO_BASE_URL', $this->url );
101 define('WPFORO_THEME', $this->theme );
102 define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme );
103 define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
104 }
105
106 private function setup(){
107 register_activation_hook($this->basename, 'do_wpforo_activation');
108 register_deactivation_hook($this->basename, 'do_wpforo_deactivation');
109 }
110
111 public function phrases(){
112 if($this->general_options){
113 $phrases = $this->phrase->get_phrases( array( 'langid' => $this->general_options['lang'] ) );
114 foreach($phrases as $phrase){
115 $this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
116 }
117 }
118 }
119
120 public function get_statistic(){
121 $stats = array();
122 $stats['forums'] = $this->forum->get_count();
123 $stats['topics'] = $this->topic->get_count();
124 $stats['posts'] = $this->post->get_count();
125 $stats['members'] = $this->member->get_count();
126 $stats['online_members_count'] = $this->member->online_members_count();
127
128 $stats['last_post_title'] = '';
129 $stats['last_post_url'] = '';
130
131 $posts = $this->topic->get_topics( array( 'orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1 ) );
132 if(isset($posts[0]) && !empty($posts[0])){
133 $stats['last_post_title'] = $posts[0]['title'];
134 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
135 }
136
137 $stats['newest_member_dname'] = '';
138 $stats['newest_member_profile_url'] = '';
139
140 $members = $this->member->get_members( array( 'orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1 ) );
141 if(isset($members[0]) && !empty($members[0])){
142 $stats['newest_member_dname'] = $members[0]['display_name'] ? $members[0]['display_name'] : urldecode($members[0]['user_nicename']);
143 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
144 }
145
146 return apply_filters('wpforo_get_statistic_array_filter', $stats);
147 }
148
149 public function init_current_object($url = ''){
150 $this->current_object = array('template' => '', 'paged' => 1);
151 if(!$url) $url = wpforo_get_request_uri();
152
153 if( !is_wpforo_page($url) ) return;
154
155 $current_url = wpforo_get_url_query_vars_str($url);
156
157 if( $this->use_home_url ) $this->permastruct = '';
158
159 $current_object = array();
160 $current_object['template'] = '';
161
162 $wpf_url = preg_replace( '#^/?'.preg_quote($this->permastruct).'#isu', '' , $current_url, 1 );
163 $wpf_url = preg_replace('#\/?\?.*$#is', '', $wpf_url);
164 $wpf_url_parse = explode('/', trim($wpf_url, '/'));
165 $wpf_url_parse = array_reverse($wpf_url_parse);
166
167 if(isset($_GET['wpfs'])){
168 $current_object['template'] = 'search';
169 }
170
171 if( isset($_GET['wpforo']) ){
172 switch($_GET['wpforo']){
173 case 'signup':
174 if(!is_user_logged_in()) $current_object['template'] = 'register';
175 break;
176 case 'signin':
177 if(!is_user_logged_in()) $current_object['template'] = 'login';
178 break;
179 case 'logout':
180 wp_logout();
181 wp_redirect( preg_replace('#\?.*$#is', '', wpforo_get_request_uri()) );
182 exit();
183 break;
184 }
185 }
186
187 if(in_array('paged', $wpf_url_parse)){
188 foreach($wpf_url_parse as $key => $value){
189 if( $value == 'paged'){
190 unset($wpf_url_parse[$key]);
191 break;
192 }
193 if(is_numeric($value)) $paged = intval($value);
194
195 unset($wpf_url_parse[$key]);
196 }
197 }
198 if(isset($_GET['wpfpaged']) && intval($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']);
199 $current_object['paged'] = (isset($paged) && $paged) ? $paged : 1;
200
201 $wpf_url_parse = array_values($wpf_url_parse);
202
203 if( !isset($current_object['template']) || !$current_object['template'] ) {
204 if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){
205 $current_object['template'] = 'members';
206 }elseif(in_array('profile', $wpf_url_parse)){
207 $current_object['template'] = 'profile';
208 foreach($wpf_url_parse as $value){
209 if( $value == 'profile') break;
210 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
211 }
212 }elseif(in_array('messages', $wpf_url_parse)){
213 $current_object['template'] = 'messages';
214 foreach($wpf_url_parse as $value){
215 if( $value == 'messages') break;
216 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
217 }
218 }elseif(in_array('account', $wpf_url_parse)){
219 $current_object['template'] = 'account';
220 foreach($wpf_url_parse as $value){
221 if( $value == 'account') break;
222 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
223 }
224 }elseif(in_array('activity', $wpf_url_parse)){
225 $current_object['template'] = 'activity';
226 foreach($wpf_url_parse as $value){
227 if( $value == 'activity') break;
228 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
229 }
230 }elseif(in_array('subscriptions', $wpf_url_parse)){
231 $current_object['template'] = 'subscriptions';
232 foreach($wpf_url_parse as $value){
233 if( $value == 'subscriptions') break;
234 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
235 }
236 }else{
237 $current_object['template'] = 'forum';
238 if($wpf_url_parse[0] && $wpf_url_parse[0] != 'wpforo'){
239
240 if(isset($wpf_url_parse[1])){
241 $current_object['topic_slug'] = $wpf_url_parse[0];
242 $current_object['forum_slug'] = $wpf_url_parse[1];
243 $current_object['template'] = 'post';
244 }else{
245 $current_object['forum_slug'] = $wpf_url_parse[0];
246 $current_object['template'] = 'topic';
247 }
248 }
249 }
250 }
251
252 if( isset($current_object['userid']) || isset($current_object['username']) ){
253 $args = array();
254 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
255 if(isset($current_object['username'])) $args['username'] = $current_object['username'];
256 $selected_user = $this->member->get_member($args);
257 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('username' => $current_object['userid']));
258 if(!empty($selected_user)){
259 $current_object['user'] = $selected_user;
260 $current_object['userid'] = $selected_user['ID'];
261 $current_object['username'] = $selected_user['user_nicename'];
262
263 switch($current_object['template']){
264 case 'activity':
265 $args = array(
266 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
267 'row_count' => $this->post_options['posts_per_page'],
268 'userid' => $current_object['userid'],
269 'order' => 'DESC'
270 );
271 $current_object['items_count'] = 0;
272 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
273 break;
274 case 'subscriptions':
275 $args = array(
276 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
277 'row_count' => $this->post_options['posts_per_page'],
278 'userid' => $current_object['userid'],
279 'order' => 'DESC'
280 );
281 $current_object['items_count'] = 0;
282 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
283 break;
284 }
285
286 }else{
287 $current_object['user'] = array();
288 $current_object['userid'] = 0;
289 $current_object['username'] = '';
290 }
291 }
292
293 if(isset($current_object['forum_slug']) && $current_object['forum_slug']){
294 $forum = $this->forum->get_forum(array('slug' => $current_object['forum_slug']), TRUE);
295 if(!empty($forum)){
296 $current_object['forum'] = $forum;
297 $current_object['forumid'] = $forum['forumid'];
298 $current_object['forum_desc'] = $forum['description'];
299 $current_object['forum_meta_key'] = $forum['meta_key'];
300 $current_object['forum_meta_desc'] = $forum['meta_desc'];
301 }else{
302 $current_object['forum'] = array();
303 $current_object['forumid'] = 0;
304 $current_object['forum_desc'] = '';
305 $current_object['forum_meta_key'] = '';
306 $current_object['forum_meta_desc'] = '';
307 }
308 }
309
310 if(isset($current_object['topic_slug']) && $current_object['topic_slug']){
311 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']), TRUE);
312 if(!empty($topic)){
313 $current_object['topic'] = $topic;
314 $current_object['topicid'] = $topic['topicid'];
315 }else{
316 $current_object['topic'] = array();
317 $current_object['topicid'] = 0;
318 }
319 }
320
321 $this->current_object = apply_filters('wpforo_current_object_filter', $current_object);
322 }
323 }
324
325 $wpforo = new wpForo();
326 $wpforo->phrase = new wpForoPhrase( $wpforo );
327 $wpforo->phrases();
328 $wpforo->forum = new wpForoForum( $wpforo );
329 $wpforo->topic = new wpForoTopic( $wpforo );
330 $wpforo->post = new wpForoPost( $wpforo );
331 $wpforo->usergroup = new wpForoUsergroup( $wpforo );
332 $wpforo->member = new wpForoMember( $wpforo );
333 $wpforo->perm = new wpForoPermissions( $wpforo );
334 $wpforo->sbscrb = new wpForoSubscribe( $wpforo );
335 $wpforo->tpl = new wpForoTemplate( $wpforo );
336 $wpforo->notice = new wpForoNotices( $wpforo );
337 $wpforo->feed = new wpForoFeed( $wpforo );
338 if(wpforo_is_admin()) include( WPFORO_DIR .'/wpf-admin/admin.php' );
339 $GLOBALS['wpforo'] = $wpforo;
340 add_action('init', array($wpforo, 'init'));
341
342 //ADDONS/////////////////////////////////////////////////////
343 $wpforo->addons = array(
344 '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/'),
345 '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/'),
346 );
347 $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'));}
348 /////////////////////////////////////////////////////////////
349 }
350 ?>