PluginProbe
wpForo Forum / 1.2.0
wpForo Forum v1.2.0
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.2.0, at wpforo.php

356 lines 15.7 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.2.0
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.2.0');
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( '', __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 include( WPFORO_DIR . '/wpf-includes/class-moderation.php' );
50
51 class wpForo{
52
53 public $options = array();
54 public $db;
55 public $phrases;
56 public $access;
57 public $theme;
58 public $addons = array();
59 public $current_object;
60 public $menu = array();
61
62 public function __construct(){
63 $this->options();
64 $this->setup();
65 }
66
67 public function init(){
68 $this->member->init_current_user();
69 $this->init_current_object();
70 $this->moderation->init();
71 $this->tpl->init_member_templates();
72 $this->tpl->init_nav_menu();
73 wpforo_actions();
74 }
75
76 private function options(){
77 global $wpdb;
78 $this->db = $wpdb;
79 $this->file = __FILE__;
80 $this->error = NULL;
81 $this->basename = plugin_basename( $this->file );
82
83 //OPTIONS
84 $this->permastruct = trim( get_wpf_option('wpforo_permastruct'), '/' );
85 $this->use_home_url = get_wpf_option('wpforo_use_home_url');
86 $this->excld_urls = get_wpf_option('wpforo_excld_urls');
87 $this->url = ( $this->use_home_url ? esc_url( home_url('/') ) : esc_url( home_url('/') ) . $this->permastruct . "/" );
88 $this->general_options = get_wpf_option( 'wpforo_general_options');
89 $this->pageid = get_wpf_option( 'wpforo_pageid');
90 $this->default_groupid = get_wpf_option('wpforo_default_groupid') ? get_option('wpforo_default_groupid') : 3;
91 $this->usergroup_cans = get_wpf_option('wpforo_usergroup_cans');
92 $this->forum_options = get_wpf_option('wpforo_forum_options');
93 $this->forum_cans = get_wpf_option('wpforo_forum_cans');
94 $this->post_options = get_wpf_option('wpforo_post_options');
95 $this->member_options = get_wpf_option('wpforo_member_options');
96 $this->subscribe_options = get_wpf_option('wpforo_subscribe_options');
97 $this->countries = get_wpf_option('wpforo_countries');
98 $this->features = get_wpf_option('wpforo_features');
99 $this->tools_antispam = get_wpf_option('wpforo_tools_antispam');
100 $this->style_options = get_wpf_option('wpforo_style_options');
101 $this->theme_options = get_wpf_option('wpforo_theme_options');
102 $this->theme = $this->theme_options['folder'];
103 //CONSTANTS
104 define('WPFORO_BASE_URL', $this->url );
105 define('WPFORO_THEME', $this->theme );
106 define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme );
107 define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
108 }
109
110 private function setup(){
111 register_activation_hook($this->basename, 'do_wpforo_activation');
112 register_deactivation_hook($this->basename, 'do_wpforo_deactivation');
113 }
114
115 public function phrases(){
116 if($this->general_options){
117 $phrases = $this->phrase->get_phrases( array( 'langid' => $this->general_options['lang'] ) );
118 foreach($phrases as $phrase){
119 $this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
120 }
121 }
122 }
123
124 public function get_statistic(){
125 $stats = array();
126 $stats['forums'] = $this->forum->get_count();
127 $stats['topics'] = $this->topic->get_count();
128 $stats['posts'] = $this->post->get_count();
129 $stats['members'] = $this->member->get_count();
130 $stats['online_members_count'] = $this->member->online_members_count();
131
132 $stats['last_post_title'] = '';
133 $stats['last_post_url'] = '';
134
135 $posts = $this->topic->get_topics( array( 'orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1 ) );
136 if(isset($posts[0]) && !empty($posts[0])){
137 if( $this->perm->forum_can( 'vf', $posts[0]['forumid'] ) ){
138 $stats['last_post_title'] = $posts[0]['title'];
139 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
140 }
141 else{
142 $stats['last_post_title'] = '';
143 $stats['last_post_url'] = '';
144 }
145 }
146
147 $stats['newest_member_dname'] = '';
148 $stats['newest_member_profile_url'] = '';
149
150 $members = $this->member->get_members( array( 'orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1 ) );
151 if(isset($members[0]) && !empty($members[0])){
152 $stats['newest_member_dname'] = $members[0]['display_name'] ? $members[0]['display_name'] : urldecode($members[0]['user_nicename']);
153 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
154 }
155
156 return apply_filters('wpforo_get_statistic_array_filter', $stats);
157 }
158
159 public function init_current_object($url = ''){
160 $this->current_object = array('template' => '', 'paged' => 1);
161 if(!$url) $url = wpforo_get_request_uri();
162
163 if( !is_wpforo_page($url) ) return;
164
165 $current_url = wpforo_get_url_query_vars_str($url);
166
167 if( $this->use_home_url ) $this->permastruct = '';
168
169 $current_object = array();
170 $current_object['template'] = '';
171
172 if(isset($_GET['wpfs'])) $current_object['template'] = 'search';
173 if( isset($_GET['wpforo']) ){
174 switch($_GET['wpforo']){
175 case 'signup':
176 if(!is_user_logged_in()) $current_object['template'] = 'register';
177 break;
178 case 'signin':
179 if(!is_user_logged_in()) $current_object['template'] = 'login';
180 break;
181 case 'logout':
182 wp_logout();
183 wp_redirect( preg_replace('#\?.*$#is', '', wpforo_get_request_uri()) );
184 exit();
185 break;
186 }
187 }
188
189 $wpf_url = preg_replace( '#^/?'.preg_quote($this->permastruct).'#isu', '' , $current_url, 1 );
190 $wpf_url = preg_replace('#\/?\?.*$#is', '', $wpf_url);
191 $wpf_url_parse = array_filter( explode('/', trim($wpf_url, '/')) );
192 $wpf_url_parse = array_reverse($wpf_url_parse);
193
194 if(in_array('paged', $wpf_url_parse)){
195 foreach($wpf_url_parse as $key => $value){
196 if( $value == 'paged'){
197 unset($wpf_url_parse[$key]);
198 break;
199 }
200 if(is_numeric($value)) $paged = intval($value);
201
202 unset($wpf_url_parse[$key]);
203 }
204 }
205 if(isset($_GET['wpfpaged']) && intval($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']);
206 $current_object['paged'] = (isset($paged) && $paged) ? $paged : 1;
207
208 $wpf_url_parse = array_values($wpf_url_parse);
209
210 if( !isset($current_object['template']) || !$current_object['template'] )
211 $current_object = apply_filters('wpforo_before_init_current_object', $current_object, $wpf_url_parse);
212
213 if( !isset($current_object['template']) || !$current_object['template'] ) {
214 if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){
215 $current_object['template'] = 'members';
216 }elseif(in_array('profile', $wpf_url_parse)){
217 $current_object['template'] = 'profile';
218 foreach($wpf_url_parse as $value){
219 if( $value == 'profile') break;
220 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
221 }
222 }elseif(in_array('account', $wpf_url_parse)){
223 $current_object['template'] = 'account';
224 foreach($wpf_url_parse as $value){
225 if( $value == 'account') break;
226 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
227 }
228 }elseif(in_array('activity', $wpf_url_parse)){
229 $current_object['template'] = 'activity';
230 foreach($wpf_url_parse as $value){
231 if( $value == 'activity') break;
232 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
233 }
234 }elseif(in_array('subscriptions', $wpf_url_parse)){
235 $current_object['template'] = 'subscriptions';
236 foreach($wpf_url_parse as $value){
237 if( $value == 'subscriptions') break;
238 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
239 }
240 }else{
241 $current_object['template'] = 'forum';
242 if( isset($wpf_url_parse[0]) ){
243 if( isset($wpf_url_parse[1]) ){
244 $current_object['topic_slug'] = $wpf_url_parse[0];
245 $current_object['forum_slug'] = $wpf_url_parse[1];
246 $current_object['template'] = 'post';
247 }else{
248 $current_object['forum_slug'] = $wpf_url_parse[0];
249 $current_object['template'] = 'topic';
250 }
251 }
252 }
253 }
254
255 if( isset($current_object['userid']) || isset($current_object['username']) ){
256 $args = array();
257 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
258 if(isset($current_object['username'])) $args['username'] = $current_object['username'];
259 $selected_user = $this->member->get_member($args);
260 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('username' => $current_object['userid']));
261 if(!empty($selected_user)){
262 $current_object['user'] = $selected_user;
263 $current_object['userid'] = $selected_user['ID'];
264 $current_object['username'] = $selected_user['user_nicename'];
265
266 switch($current_object['template']){
267 case 'activity':
268 $args = array(
269 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
270 'row_count' => $this->post_options['posts_per_page'],
271 'userid' => $current_object['userid'],
272 'order' => 'DESC',
273 'check_private' => true
274 );
275 $current_object['items_count'] = 0;
276 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
277 break;
278 case 'subscriptions':
279 $args = array(
280 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
281 'row_count' => $this->post_options['posts_per_page'],
282 'userid' => $current_object['userid'],
283 'order' => 'DESC'
284 );
285 $current_object['items_count'] = 0;
286 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
287 break;
288 }
289
290 }else{
291 $current_object['user'] = array();
292 $current_object['userid'] = 0;
293 $current_object['username'] = '';
294 }
295 }
296
297 if(isset($current_object['forum_slug']) && $current_object['forum_slug']){
298 $forum = $this->forum->get_forum(array('slug' => $current_object['forum_slug']), TRUE);
299 if(!empty($forum)){
300 $current_object['forum'] = $forum;
301 $current_object['forumid'] = $forum['forumid'];
302 $current_object['forum_desc'] = $forum['description'];
303 $current_object['forum_meta_key'] = $forum['meta_key'];
304 $current_object['forum_meta_desc'] = $forum['meta_desc'];
305 }else{
306 $current_object['forum'] = array();
307 $current_object['forumid'] = 0;
308 $current_object['forum_desc'] = '';
309 $current_object['forum_meta_key'] = '';
310 $current_object['forum_meta_desc'] = '';
311 }
312 }
313
314 if(isset($current_object['topic_slug']) && $current_object['topic_slug']){
315 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']), TRUE);
316 if(!empty($topic)){
317 $current_object['topic'] = $topic;
318 $current_object['topicid'] = $topic['topicid'];
319 }else{
320 $current_object['topic'] = array();
321 $current_object['topicid'] = 0;
322 }
323 }
324
325 $this->current_object = apply_filters('wpforo_after_init_current_object', $current_object, $wpf_url_parse);
326 }
327 }
328
329 $wpforo = new wpForo();
330 $wpforo->phrase = new wpForoPhrase( $wpforo );
331 $wpforo->phrases();
332 $wpforo->forum = new wpForoForum( $wpforo );
333 $wpforo->topic = new wpForoTopic( $wpforo );
334 $wpforo->post = new wpForoPost( $wpforo );
335 $wpforo->usergroup = new wpForoUsergroup( $wpforo );
336 $wpforo->member = new wpForoMember( $wpforo );
337 $wpforo->perm = new wpForoPermissions( $wpforo );
338 $wpforo->sbscrb = new wpForoSubscribe( $wpforo );
339 $wpforo->tpl = new wpForoTemplate( $wpforo );
340 $wpforo->notice = new wpForoNotices( $wpforo );
341 $wpforo->feed = new wpForoFeed( $wpforo );
342 $wpforo->moderation = new wpForoModeration( $wpforo );
343 if(wpforo_is_admin()) include( WPFORO_DIR .'/wpf-admin/admin.php' );
344 $GLOBALS['wpforo'] = $wpforo;
345 add_action('init', array($wpforo, 'init'));
346
347 //ADDONS/////////////////////////////////////////////////////
348 $wpforo->addons = array(
349 '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/'),
350 '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/'),
351 '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/'),
352 );
353 $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'));}
354 /////////////////////////////////////////////////////////////
355 }
356 ?>