PluginProbe
wpForo Forum / 1.1.2
wpForo Forum v1.1.2
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.2, at wpforo.php

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