PluginProbe
wpForo Forum / beta-3
wpForo Forum vbeta-3
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 beta-3, at wpforo.php

313 lines 12.6 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: beta-3
9 * Text Domain: wpforo
10 * Domain Path: /wpf-languages
11 */
12
13 // Exit if accessed directly
14 if( !defined( 'ABSPATH' ) ) exit;
15
16 function wpforo_load_plugin_textdomain() {
17 load_plugin_textdomain( 'wpforo', FALSE, basename( dirname( __FILE__ ) ) . '/wpf-languages/' );
18 }
19 add_action( 'plugins_loaded', 'wpforo_load_plugin_textdomain' );
20
21 if( !class_exists( 'wpForo' ) ) {
22
23 define('WPFORO_DIR', rtrim( plugin_dir_path( __FILE__ ), '/'));
24 define('WPFORO_URL', rtrim( plugins_url( plugin_basename(dirname(__FILE__))), '/'));
25 define('WPFORO_FOLDER', rtrim( plugin_basename(dirname(__FILE__)), '/'));
26 define('WPFORO_BASENAME', plugin_basename(__FILE__)); //wpforo/wpforo.php
27
28 define('WPFORO_THEME_DIR', WPFORO_DIR . '/wpf-themes' );
29 define('WPFORO_THEME_URL', WPFORO_URL . '/wpf-themes' );
30 define('WPFORO_PLUGIN_DIR', WPFORO_DIR . '/wpf-plugins' );
31 define('WPFORO_PLUGIN_URL', WPFORO_URL . '/wpf-plugins' );
32
33 include( WPFORO_DIR . '/wpf-includes/wpf-hooks.php' );
34 include( WPFORO_DIR . '/wpf-includes/wpf-actions.php');
35 include( WPFORO_DIR . '/wpf-includes/functions.php' );
36 include( WPFORO_DIR . '/wpf-includes/functions-installation.php' );
37 include( WPFORO_DIR . '/wpf-includes/functions-integration.php' );
38 include( WPFORO_DIR . '/wpf-includes/functions-template.php' );
39 include( WPFORO_DIR . '/wpf-includes/class-forums.php' );
40 include( WPFORO_DIR . '/wpf-includes/class-topics.php' );
41 include( WPFORO_DIR . '/wpf-includes/class-posts.php' );
42 include( WPFORO_DIR . '/wpf-includes/class-usergroups.php' );
43 include( WPFORO_DIR . '/wpf-includes/class-members.php' );
44 include( WPFORO_DIR . '/wpf-includes/class-permissions.php' );
45 include( WPFORO_DIR . '/wpf-includes/class-phrases.php');
46 include( WPFORO_DIR . '/wpf-includes/class-subscribes.php' );
47 include( WPFORO_DIR . '/wpf-includes/class-template.php' );
48 include( WPFORO_DIR . '/wpf-includes/class-notices.php' );
49 include( WPFORO_DIR . '/wpf-includes/class-feed.php' );
50
51 class wpForo{
52
53 public $version = 'Beta-3';
54 public $options = array();
55 public $db;
56 public $phrases;
57 public $theme;
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->url = trim( get_option('wpforo_url'), '/' ) . "/";
83 $this->general_options = get_option( 'wpforo_general_options');
84 $this->notices = get_option( 'wpforo_notices');
85 $this->pageid = get_option( 'wpforo_pageid');
86 $this->default_groupid = get_option('wpforo_default_groupid') ? get_option('wpforo_default_groupid') : 3;
87 $this->usergroup_cans = get_option('wpforo_usergroup_cans');
88 $this->forum_options = get_option('wpforo_forum_options');
89 $this->forum_cans = get_option('wpforo_forum_cans');
90 $this->post_options = get_option('wpforo_post_options');
91 $this->member_options = get_option('wpforo_member_options');
92 $this->subscribe_options = get_option('wpforo_subscribe_options');
93 $this->countries = get_option('wpforo_countries');
94 $this->features = get_option('wpforo_features');
95 $this->theme_options = get_option('wpforo_theme_options');
96 $this->theme = $this->theme_options['folder'];
97 //CONSTANTS
98 define('WPFORO_BASE_URL', $this->url );
99 define('WPFORO_THEME', $this->theme );
100 define('WPFORO_TEMPLATE_DIR', WPFORO_THEME_DIR . '/' . $this->theme );
101 define('WPFORO_TEMPLATE_URL', WPFORO_THEME_URL . '/' . $this->theme );
102 }
103
104 private function setup(){
105 add_action( 'activate_' . $this->basename, 'wpforo_activation' );
106 add_action( 'deactivate_' . $this->basename, 'wpforo_deactivation' );
107 }
108
109 public function phrases(){
110 if($this->general_options){
111 $phrases = $this->phrase->get_phrases( array( 'langid' => $this->general_options['lang'] ) );
112 foreach($phrases as $phrase){
113 $this->phrases[addslashes(strtolower($phrase['phrase_key']))] = $phrase['phrase_value'];
114 }
115 }
116 }
117
118 public function get_statistic(){
119 $stats = array();
120 $stats['forums'] = $this->forum->get_count();
121 $stats['topics'] = $this->topic->get_count();
122 $stats['posts'] = $this->post->get_count();
123 $stats['members'] = $this->member->get_count();
124 $stats['online_members_count'] = $this->member->online_members_count();
125
126 $stats['last_post_title'] = '';
127 $stats['last_post_url'] = '';
128
129 $posts = $this->topic->get_topics( array( 'orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1 ) );
130 if(isset($posts[0]) && !empty($posts[0])){
131 $stats['last_post_title'] = $posts[0]['title'];
132 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
133 }
134
135 $stats['newest_member_dname'] = '';
136 $stats['newest_member_profile_url'] = '';
137
138 $members = $this->member->get_members( array( 'orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1 ) );
139 if(isset($members[0]) && !empty($members[0])){
140 $stats['newest_member_dname'] = $members[0]['display_name'] ? $members[0]['display_name'] : $members[0]['user_nicename'];
141 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
142 }
143
144 return apply_filters('wpforo_get_statistic_array_filter', $stats);
145 }
146
147 private function init_current_object($url = ''){
148 $this->current_object = array('template' => '', 'paged' => 1);
149 if(!$url) $url = wpforo_full_url();
150 if( strpos($url, WPFORO_BASE_URL) === FALSE ) return;
151
152 $current_object = array();
153 $current_object['template'] = '';
154
155 $wpf_url = str_replace( WPFORO_BASE_URL, '' , $url );
156 $wpf_url = preg_replace('#\/?\?.*$#is', '', $wpf_url);
157 $wpf_url_parse = explode('/', trim($wpf_url, '/'));
158 $wpf_url_parse = array_reverse($wpf_url_parse);
159
160 if(in_array('paged', $wpf_url_parse)){
161 foreach($wpf_url_parse as $key => $value){
162 if( $value == 'paged'){
163 unset($wpf_url_parse[$key]);
164 break;
165 }
166 if(is_numeric($value)) $paged = intval($value);
167
168 unset($wpf_url_parse[$key]);
169 }
170 }
171 if(isset($_GET['wpfpaged']) && intval($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']);
172 $current_object['paged'] = (isset($paged) && $paged) ? $paged : 1;
173
174 $wpf_url_parse = array_values($wpf_url_parse);
175
176 if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){
177 $current_object['template'] = 'members';
178 }elseif(in_array('profile', $wpf_url_parse)){
179 $current_object['template'] = 'profile';
180 foreach($wpf_url_parse as $value){
181 if( $value == 'profile') break;
182 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
183 }
184 }elseif(in_array('messages', $wpf_url_parse)){
185 $current_object['template'] = 'messages';
186 foreach($wpf_url_parse as $value){
187 if( $value == 'messages') break;
188 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
189 }
190 }elseif(in_array('account', $wpf_url_parse)){
191 $current_object['template'] = 'account';
192 foreach($wpf_url_parse as $value){
193 if( $value == 'account') break;
194 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
195 }
196 }elseif(in_array('activity', $wpf_url_parse)){
197 $current_object['template'] = 'activity';
198 foreach($wpf_url_parse as $value){
199 if( $value == 'activity') break;
200 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
201 }
202 }elseif(in_array('subscriptions', $wpf_url_parse)){
203 $current_object['template'] = 'subscriptions';
204 foreach($wpf_url_parse as $value){
205 if( $value == 'subscriptions') break;
206 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['username'] = $value;
207 }
208 }else{
209 $current_object['template'] = 'forum';
210 if($wpf_url_parse[0] && $wpf_url_parse[0] != 'wpforo'){
211
212 if(isset($wpf_url_parse[1])){
213 $current_object['topic_slug'] = $wpf_url_parse[0];
214 $current_object['forum_slug'] = $wpf_url_parse[1];
215 $current_object['template'] = 'post';
216 }else{
217 $current_object['forum_slug'] = $wpf_url_parse[0];
218 $current_object['template'] = 'topic';
219 }
220 }
221 }
222
223 if( isset($current_object['userid']) || isset($current_object['username']) ){
224 $args = array();
225 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
226 if(isset($current_object['username'])) $args['username'] = $current_object['username'];
227 $selected_user = $this->member->get_member($args);
228 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('username' => $current_object['userid']));
229 if(!empty($selected_user)){
230 $current_object['user'] = $selected_user;
231 $current_object['userid'] = $selected_user['ID'];
232 $current_object['username'] = $selected_user['user_nicename'];
233
234 switch($current_object['template']){
235 case 'activity':
236 $args = array(
237 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
238 'row_count' => $this->post_options['posts_per_page'],
239 'userid' => $current_object['userid'],
240 'order' => 'DESC'
241 );
242 $current_object['items_count'] = 0;
243 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
244 break;
245 case 'subscriptions':
246 $args = array(
247 'offset' => ($current_object['paged'] - 1) * $this->post_options['posts_per_page'],
248 'row_count' => $this->post_options['posts_per_page'],
249 'userid' => $current_object['userid'],
250 'order' => 'DESC'
251 );
252 $current_object['items_count'] = 0;
253 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
254 break;
255 }
256
257 }else{
258 $current_object['user'] = array();
259 $current_object['userid'] = 0;
260 $current_object['username'] = '';
261 }
262 }
263
264 if(isset($current_object['forum_slug']) && $current_object['forum_slug']){
265 $forum = $this->forum->get_forum(array('slug' => $current_object['forum_slug']));
266 if(!empty($forum)){
267 $current_object['forum'] = $forum;
268 $current_object['forumid'] = $forum['forumid'];
269 $current_object['forum_desc'] = $forum['description'];
270 $current_object['forum_meta_key'] = $forum['meta_key'];
271 $current_object['forum_meta_desc'] = $forum['meta_desc'];
272 }else{
273 $current_object['forum'] = array();
274 $current_object['forumid'] = 0;
275 $current_object['forum_desc'] = '';
276 $current_object['forum_meta_key'] = '';
277 $current_object['forum_meta_desc'] = '';
278 }
279 }
280
281 if(isset($current_object['topic_slug']) && $current_object['topic_slug']){
282 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']));
283 if(!empty($topic)){
284 $current_object['topic'] = $topic;
285 $current_object['topicid'] = $topic['topicid'];
286 }else{
287 $current_object['topic'] = array();
288 $current_object['topicid'] = 0;
289 }
290 }
291
292 $this->current_object = apply_filters('wpforo_current_object_filter', $current_object);
293 }
294 }
295
296 $wpforo = new wpForo();
297 $wpforo->phrase = new wpForoPhrase( $wpforo );
298 $wpforo->phrases();
299 $wpforo->forum = new wpForoForum( $wpforo );
300 $wpforo->topic = new wpForoTopic( $wpforo );
301 $wpforo->post = new wpForoPost( $wpforo );
302 $wpforo->usergroup = new wpForoUsergroup( $wpforo );
303 $wpforo->member = new wpForoMember( $wpforo );
304 $wpforo->perm = new wpForoPermissions( $wpforo );
305 $wpforo->sbscrb = new wpForoSubscribe( $wpforo );
306 $wpforo->tpl = new wpForoTemplate( $wpforo );
307 $wpforo->notice = new wpForoNotices( $wpforo );
308 $wpforo->feed = new wpForoFeed( $wpforo );
309 if(is_admin()) include( WPFORO_DIR .'/wpf-admin/admin.php' );
310 $GLOBALS['wpforo'] = $wpforo;
311 add_action('init', array($wpforo, 'init'));
312 }
313 ?>