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

620 lines 29.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: wpForo - Forums
4 * Plugin URI: https://wpforo.com
5 * Description: WordPress Foum plugin. wpForo is a full-fledged forum solution for your community. Comes with multiple modern forum layouts.
6 * Author: gVectors Team (A. Chakhoyan, R. Hovhannisyan)
7 * Author URI: https://gvectors.com/
8 * Version: 1.4.4
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.4.4');
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 final class wpForo{
28 private static $_instance = NULL;
29
30 public $file;
31 public $basename;
32 public $error;
33
34 public $db;
35 public $addons = array();
36 public $current_object;
37 public $menu = array();
38 public $form = array();
39 public $default;
40
41 public $current_user = array();
42 public $current_user_groupid = 4;
43 public $current_userid = 0;
44 public $current_username = '';
45 public $current_user_email = '';
46 public $current_user_display_name = '';
47 public $current_user_status = '';
48
49 public $use_trailing_slashes;
50 public $use_home_url;
51 public $excld_urls;
52 public $base_permastruct;
53 public $permastruct;
54 public $url;
55 public $pageid;
56
57 public $general_options;
58 public $features;
59 public $tools_antispam;
60 public $tools_cleanup;
61 public $tools_misc;
62
63 public $cache;
64 public $phrase;
65 public $forum;
66 public $topic;
67 public $post;
68 public $usergroup;
69 public $member;
70 public $perm;
71 public $sbscrb;
72 public $tpl;
73 public $notice;
74 public $api;
75 public $feed;
76 public $moderation;
77
78 public static function instance(){
79 if ( is_null(self::$_instance) ) self::$_instance = new self();
80 return self::$_instance;
81 }
82
83 private function __construct(){
84 global $wpdb;
85 $this->db = $wpdb;
86 $this->file = __FILE__;
87 $this->error = NULL;
88 $this->basename = plugin_basename( $this->file );
89
90 $this->includes();
91 $this->init_defaults();
92 $this->init_options();
93 $this->setup();
94
95 $this->cache = new wpForoCache();
96 $this->phrase = new wpForoPhrase();
97 $this->forum = new wpForoForum();
98 $this->topic = new wpForoTopic();
99 $this->post = new wpForoPost();
100 $this->usergroup = new wpForoUsergroup();
101 $this->member = new wpForoMember();
102 $this->perm = new wpForoPermissions();
103 $this->sbscrb = new wpForoSubscribe();
104 $this->tpl = new wpForoTemplate();
105 $this->notice = new wpForoNotices();
106 $this->api = new wpForoAPI();
107 $this->feed = new wpForoFeed();
108 $this->moderation = new wpForoModeration();
109
110 add_action('init', array($this, 'init'));
111 }
112
113 private function includes(){
114 include( WPFORO_DIR . '/wpf-includes/wpf-hooks.php' );
115 include( WPFORO_DIR . '/wpf-includes/wpf-actions.php');
116 include( WPFORO_DIR . '/wpf-includes/functions.php' );
117 include( WPFORO_DIR . '/wpf-includes/functions-integration.php' );
118 include( WPFORO_DIR . '/wpf-includes/functions-template.php' );
119 if(wpforo_is_admin()) {
120 include( WPFORO_DIR . '/wpf-includes/functions-installation.php' );
121 include( WPFORO_DIR .'/wpf-admin/admin.php' );
122 }
123
124 include( WPFORO_DIR . '/wpf-includes/class-cache.php' );
125 include( WPFORO_DIR . '/wpf-includes/class-forums.php' );
126 include( WPFORO_DIR . '/wpf-includes/class-topics.php' );
127 include( WPFORO_DIR . '/wpf-includes/class-posts.php' );
128 include( WPFORO_DIR . '/wpf-includes/class-usergroups.php' );
129 include( WPFORO_DIR . '/wpf-includes/class-members.php' );
130 include( WPFORO_DIR . '/wpf-includes/class-permissions.php' );
131 include( WPFORO_DIR . '/wpf-includes/class-phrases.php');
132 include( WPFORO_DIR . '/wpf-includes/class-subscribes.php' );
133 include( WPFORO_DIR . '/wpf-includes/class-template.php' );
134 include( WPFORO_DIR . '/wpf-includes/class-notices.php' );
135 include( WPFORO_DIR . '/wpf-includes/class-api.php' );
136 include( WPFORO_DIR . '/wpf-includes/class-feed.php' );
137 include( WPFORO_DIR . '/wpf-includes/class-moderation.php' );
138 }
139
140 public function init(){
141 $this->phrase->init();
142 $this->perm->init();
143 $this->member->init_current_user();
144 $this->init_current_object();
145 $this->moderation->init();
146 $this->tpl->init();
147 $this->api->hooks();
148 add_action( 'wp_loaded', 'wpforo_actions');
149
150 if( wpforo_is_admin() ){
151 if( !wpforo_feature('user-synch') && get_option('wpforo_version') ){
152 $users = $this->db->get_var("SELECT COUNT(*) FROM `" . $this->db->prefix . "users`");
153 $profiles = $this->db->get_var("SELECT COUNT(*) FROM `" . $this->db->prefix . "wpforo_profiles`");
154 $delta = $users - $profiles;
155 if( $users > 100 && $delta > 2 ){ add_action( 'admin_notices', 'wpforo_profile_notice' ); }
156 }
157 $db_version = get_option('wpforo_version_db');
158 if( !$db_version || version_compare( $db_version, WPFORO_VERSION, '<') ){
159 add_action( 'admin_notices', 'wpforo_update_db_notice' );
160 }
161 }
162 }
163
164 private function init_defaults(){
165 $this->default = new stdClass;
166
167 $this->default->use_home_url = 0;
168 $this->default->excld_urls = '';
169 $this->default->permastruct = 'community';
170
171 $blogname = get_option('blogname', '');
172 $this->default->general_options = array(
173 'title' => $blogname . ' ' . __('Forum', 'wpforo'),
174 'description' => $blogname . ' ' . __('Discussion Board', 'wpforo'),
175 'lang' => 1
176 );
177
178 $this->default->features = array(
179 'user-admin-bar' => 0,
180 'page-title' => 1,
181 'top-bar' => 1,
182 'top-bar-search' => 1,
183 'breadcrumb' => 1,
184 'footer-stat' => 1,
185 'mention-nicknames' => 1,
186 'view-logging' => 1,
187 'author-link' => 0,
188 'comment-author-link' => 0,
189 'user-register' => 1,
190 'user-register-email-confirm' => 0,
191 'register-url' => 0,
192 'login-url' => 0,
193 'resetpass-url' => 0, //In most cases incompatible with security and antispam plugins
194 'replace-avatar' => 1,
195 'avatars' => 1,
196 'custom-avatars' => 1,
197 'signature' => 1,
198 'rating' => 1,
199 'rating_title' => 1,
200 'member_cashe' => 1,
201 'object_cashe' => 1,
202 'html_cashe' => 0,
203 'memory_cashe' => 1,
204 'seo-title' => 1,
205 'seo-meta' => 1,
206 'seo-profile' => 1,
207 'rss-feed' => 1,
208 'font-awesome' => 1,
209 'user-synch' => 0,
210 'output-buffer' => 1,
211 'wp-date-format' => 0,
212 'subscribe_conf' => 1,
213 'subscribe_checkbox_on_post_editor' => 1,
214 'subscribe_checkbox_default_status' => 0,
215 'attach-media-lib' => 1,
216 'debug-mode' => 0,
217 'copyright' => 1
218 );
219
220 $this->default->tools_antispam = array(
221 'spam_filter' => 1,
222 'spam_filter_level_topic' => mt_rand(30, 60),
223 'spam_filter_level_post' => mt_rand(30, 60),
224 'spam_user_ban' => 0,
225 'new_user_max_posts' => 5,
226 'spam_user_ban_notification' => 1,
227 'min_number_post_to_attach' => 3,
228 'min_number_post_to_link' => 0,
229 'limited_file_ext' => 'pdf|doc|docx|txt|htm|html|rtf|xml|xls|xlsx|zip|rar|tar|gz|bzip|7z',
230 'rc_site_key' => '',
231 'rc_secret_key' => '',
232 'rc_theme' => 'light',
233 'rc_login_form' => 0,
234 'rc_reg_form' => 0,
235 'rc_lostpass_form' => 0,
236 'rc_wpf_login_form' => 1,
237 'rc_wpf_reg_form' => 1,
238 'rc_wpf_lostpass_form' => 1,
239 'rc_topic_editor' => 1,
240 'rc_post_editor' => 1,
241 );
242
243 $this->default->tools_cleanup = array(
244 'user_reg_days_ago' => 7,
245 'auto_cleanup_users' => 0,
246 'usergroup' => array ( 1 => '0', 5 => '0', 2 => '1', 3 => '0' )
247 );
248
249 $this->default->tools_misc = array(
250 'dofollow' => '',
251 'noindex' => ''
252 );
253
254 $this->default->stats = array(
255 'forums' => 0,
256 'topics' => 0,
257 'posts' => 0,
258 'members' => 0,
259 'online_members_count' => 0,
260 'last_post_title' => '',
261 'last_post_url' => '',
262 'newest_member_dname' => '',
263 'newest_member_profile_url' => ''
264 );
265 }
266
267 private function init_options(){
268 $permalink_structure = get_option('permalink_structure');
269
270 $this->use_trailing_slashes = ( '/' == substr($permalink_structure, -1, 1) );
271
272 //OPTIONS
273 $this->use_home_url = get_wpf_option('wpforo_use_home_url', $this->default->use_home_url);
274 $this->excld_urls = get_wpf_option('wpforo_excld_urls', $this->default->excld_urls);
275
276 $this->permastruct = trim( get_wpf_option('wpforo_permastruct', $this->default->permastruct), '/' );
277 $this->permastruct = preg_replace('#^/?index\.php/?#isu', '', $this->permastruct);
278 $this->permastruct = trim($this->permastruct, '/');
279
280 $this->base_permastruct = (!$this->use_home_url ? $this->permastruct : '');
281 $this->base_permastruct = rtrim( ( strpos($permalink_structure, 'index.php') !== FALSE ? '/index.php/' . $this->base_permastruct : '/' . $this->base_permastruct ), '/\\' );
282 $this->url = esc_url( home_url( $this->user_trailingslashit($this->base_permastruct) ) );
283 $this->pageid = get_wpf_option( 'wpforo_pageid');
284
285 $this->general_options = get_wpf_option( 'wpforo_general_options', $this->default->general_options);
286 $this->features = get_wpf_option('wpforo_features', $this->default->features);
287 $this->tools_antispam = get_wpf_option('wpforo_tools_antispam', $this->default->tools_antispam);
288 $this->tools_cleanup = get_wpf_option('wpforo_tools_cleanup', $this->default->tools_cleanup);
289 $this->tools_misc = get_wpf_option('wpforo_tools_misc', $this->default->tools_misc);
290
291 //CONSTANTS
292 define('WPFORO_BASE_PERMASTRUCT', $this->base_permastruct );
293 define('WPFORO_BASE_URL', $this->url );
294 }
295
296 private function setup(){
297 if( wpforo_is_admin() ){
298 register_activation_hook($this->basename, 'do_wpforo_activation');
299 register_deactivation_hook($this->basename, 'do_wpforo_deactivation');
300 }
301 }
302
303 public function user_trailingslashit($url) {
304 $rtrimed_url = '';
305 $url_append_vars = '';
306 if( preg_match('#(^.+?)(/?\?.*$|$)#isu', $url, $match) ){
307 if(isset($match[1]) && $match[1]) $rtrimed_url = rtrim($match[1], '/\\');
308 if(isset($match[2]) && $match[2]) $url_append_vars = trim($match[2], '/\\');
309 if( $rtrimed_url ) {
310 $home_url = rtrim( preg_replace('#/?\?.*$#isu', '', home_url()), '/\\' );
311 if( $rtrimed_url == $home_url ){
312 $url = $rtrimed_url . '/';
313 }else{
314 $url = ( $this->use_trailing_slashes ? $rtrimed_url . '/' : $rtrimed_url );
315 }
316 }
317 }
318 return $url . $url_append_vars;
319 }
320
321 public function statistic( $mode = 'get', $template = 'all' ){
322
323 if( $mode == 'get' ){
324 $user_groupid = ( $this->current_user_groupid ) ? $this->current_user_groupid : 4;
325 if( $cached_stat = get_option('wpforo_stat_' . $user_groupid ) ){
326 $cached_stat['online_members_count'] = $this->member->online_members_count();
327 return $cached_stat;
328 }
329 }
330
331 if( $mode == 'get' || $template == 'all' ) {
332 $stats['forums'] = $this->forum->get_count( array('is_cat' => 0) );
333 $stats['topics'] = $this->topic->get_count();
334 $stats['posts'] = $this->post->get_count();
335 $stats['members'] = $this->member->get_count();
336 $stats['online_members_count'] = $this->member->online_members_count();
337
338 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => 10, 'private' => 0 ));
339 $first = key($posts);
340 if ( isset($posts[$first]) && !empty($posts[$first]) && $this->perm->forum_can('vf', $posts[$first]['forumid']) ) {
341 $stats['last_post_title'] = $posts[$first]['title'];
342 $stats['last_post_url'] = $this->post->get_post_url($posts[$first]['last_post']);
343 }
344
345 $members = $this->member->get_members(array('orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1));
346 if (isset($members[0]) && !empty($members[0])) {
347 $stats['newest_member_dname'] = wpforo_make_dname($members[0]['display_name'], $members[0]['user_nicename']);
348 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
349 }
350 }else{
351 $stats = get_wpf_option('wpforo_stat_' . $this->current_user_groupid, $this->default->stats);
352 switch ($template){
353 case 'forum':
354 $stats['forums'] = $this->forum->get_count( array('is_cat' => 0) );
355 break;
356 case 'topic':
357 $stats['topics'] = $this->topic->get_count();
358 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1));
359 if ( isset($posts[0]) && !empty($posts[0]) && $this->perm->forum_can('vf', $posts[0]['forumid']) ) {
360 $stats['last_post_title'] = $posts[0]['title'];
361 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
362 }
363 break;
364 case 'post':
365 $stats['posts'] = $this->post->get_count();
366 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1));
367 if ( isset($posts[0]) && !empty($posts[0]) && $this->perm->forum_can('vf', $posts[0]['forumid']) ) {
368 $stats['last_post_title'] = $posts[0]['title'];
369 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
370 }
371 break;
372 case 'user':
373 $stats['members'] = $this->member->get_count();
374 $stats['online_members_count'] = $this->member->online_members_count();
375
376 $members = $this->member->get_members(array('orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1));
377 if (isset($members[0]) && !empty($members[0])) {
378 $stats['newest_member_dname'] = wpforo_make_dname($members[0]['display_name'], $members[0]['user_nicename']);
379 $stats['newest_member_profile_url'] = $this->member->get_profile_url($members[0]['ID']);
380 }
381 break;
382 }
383 }
384
385 $stats = array_merge($this->default->stats, $stats);
386 $stats = apply_filters('wpforo_get_statistic_array_filter', $stats);
387 $user_groupid = ( $this->current_user_groupid ) ? $this->current_user_groupid : 4;
388 if( isset($user_groupid) && $user_groupid ){
389 update_option( 'wpforo_stat_' . $this->current_user_groupid, $stats );
390 }
391 return $stats;
392 }
393
394 public function init_current_object($url = ''){
395 $this->current_object = array('template' => '', 'paged' => 1, 'is_404' => false, 'user_is_same_current_user' => false);
396 if(!$url) $url = wpforo_get_request_uri();
397
398 if( !is_wpforo_page($url) ) return;
399
400 $current_url = wpforo_get_url_query_vars_str($url);
401
402 if( $this->use_home_url ) $this->permastruct = '';
403
404 $current_object = array();
405 $current_object['template'] = '';
406 $current_object['is_404'] = false;
407 $current_object['user_is_same_current_user'] = false;
408
409 if(isset($_GET['wpfs'])) $current_object['template'] = 'search';
410 if( isset($_GET['wpforo']) ){
411 switch($_GET['wpforo']){
412 case 'signup':
413 if(!is_user_logged_in()) $current_object['template'] = 'register';
414 break;
415 case 'signin':
416 if(!is_user_logged_in()) $current_object['template'] = 'login';
417 break;
418 case 'lostpassword':
419 if(!is_user_logged_in()) $current_object['template'] = 'lostpassword';
420 break;
421 case 'resetpassword':
422 $current_object['template'] = 'resetpassword';
423 break;
424 case 'logout':
425 wp_logout();
426 wp_redirect( wpforo_home_url( preg_replace('#\?.*$#is', '', wpforo_get_request_uri()) ) );
427 exit();
428 break;
429 }
430 }
431
432 $wpf_url = preg_replace( '#^/?'.preg_quote($this->permastruct).'#isu', '' , $current_url, 1 );
433 $wpf_url = preg_replace('#/?\?.*$#isu', '', $wpf_url);
434 $wpf_url_parse = array_filter( explode('/', trim($wpf_url, '/')) );
435 $wpf_url_parse = array_reverse($wpf_url_parse);
436
437 if(in_array('paged', $wpf_url_parse)){
438 foreach($wpf_url_parse as $key => $value){
439 if( $value == 'paged'){
440 unset($wpf_url_parse[$key]);
441 break;
442 }
443 if(is_numeric($value)) $paged = intval($value);
444
445 unset($wpf_url_parse[$key]);
446 }
447 }
448 if(isset($_GET['wpfpaged']) && intval($_GET['wpfpaged'])) $paged = intval($_GET['wpfpaged']);
449 $current_object['paged'] = (isset($paged) && $paged) ? $paged : 1;
450
451 $wpf_url_parse = array_values($wpf_url_parse);
452
453 if( !isset($current_object['template']) || !$current_object['template'] )
454 $current_object = apply_filters('wpforo_before_init_current_object', $current_object, $wpf_url_parse);
455
456 if( !isset($current_object['template']) || !$current_object['template'] ) {
457 if(in_array('members', $wpf_url_parse) && $wpf_url_parse[0] == 'members'){
458 $current_object['template'] = 'members';
459 }elseif(in_array('recent', $wpf_url_parse) && $wpf_url_parse[0] == 'recent'){
460 $current_object['template'] = 'recent';
461 }elseif(in_array('profile', $wpf_url_parse)){
462 $current_object['template'] = 'profile';
463 foreach($wpf_url_parse as $value){
464 if( $value == 'profile') break;
465 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['user_nicename'] = $value;
466 }
467 }elseif(in_array('account', $wpf_url_parse)){
468 $current_object['template'] = 'account';
469 foreach($wpf_url_parse as $value){
470 if( $value == 'account') break;
471 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['user_nicename'] = $value;
472 }
473 }elseif(in_array('activity', $wpf_url_parse)){
474 $current_object['template'] = 'activity';
475 foreach($wpf_url_parse as $value){
476 if( $value == 'activity') break;
477 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['user_nicename'] = $value;
478 }
479 }elseif(in_array('subscriptions', $wpf_url_parse)){
480 $current_object['template'] = 'subscriptions';
481 foreach($wpf_url_parse as $value){
482 if( $value == 'subscriptions') break;
483 if(is_numeric($value)) $current_object['userid'] = $value; else $current_object['user_nicename'] = $value;
484 }
485 }else{
486 $current_object['template'] = 'forum';
487 if( isset($wpf_url_parse[0]) ){
488 if( isset($wpf_url_parse[1]) ){
489 $current_object['topic_slug'] = $wpf_url_parse[0];
490 $current_object['forum_slug'] = $wpf_url_parse[1];
491 $current_object['template'] = 'post';
492 }else{
493 $current_object['forum_slug'] = $wpf_url_parse[0];
494 $current_object['template'] = 'topic';
495 }
496 }
497 }
498 }
499
500 if( in_array( $current_object['template'], array('profile', 'account', 'activity', 'subscriptions') )
501 && !isset($current_object['user_nicename']) && !isset($current_object['userid']) ){
502 $current_object = wpforo_find_current_user_data( $current_object );
503 }
504
505 if( isset($current_object['userid']) || isset($current_object['user_nicename']) ){
506 $args = array();
507 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
508 if(isset($current_object['user_nicename'])) $args['user_nicename'] = $current_object['user_nicename'];
509 $selected_user = $this->member->get_member($args);
510 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('user_nicename' => $current_object['userid']));
511 if(!empty($selected_user)){
512 $current_object['user'] = $selected_user;
513 $current_object['userid'] = $selected_user['ID'];
514 $current_object['user_nicename'] = $selected_user['user_nicename'];
515 $current_object['user_is_same_current_user'] = !empty($this->current_userid) && $selected_user['ID'] == $this->current_userid;
516
517 switch($current_object['template']){
518 case 'activity':
519 $args = array(
520 'offset' => ($current_object['paged'] - 1) * $this->post->options['posts_per_page'],
521 'row_count' => $this->post->options['posts_per_page'],
522 'userid' => $current_object['userid'],
523 'order' => 'DESC',
524 'check_private' => true
525 );
526 $current_object['items_count'] = 0;
527 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
528 break;
529 case 'subscriptions':
530 $args = array(
531 'offset' => ($current_object['paged'] - 1) * $this->post->options['posts_per_page'],
532 'row_count' => $this->post->options['posts_per_page'],
533 'userid' => $current_object['userid'],
534 'order' => 'DESC'
535 );
536 $current_object['items_count'] = 0;
537 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
538 break;
539 }
540
541 }else{
542 $current_object['is_404'] = true;
543 $current_object['user'] = array();
544 $current_object['userid'] = 0;
545 $current_object['user_nicename'] = '';
546 }
547 }
548
549 if(isset($current_object['forum_slug']) && $current_object['forum_slug']){
550 $forum = $this->forum->get_forum( array('slug' => $current_object['forum_slug']) );
551 if(!empty($forum)){
552 $current_object['forum'] = $forum;
553 $current_object['forumid'] = $forum['forumid'];
554 $current_object['forum_desc'] = $forum['description'];
555 $current_object['forum_meta_key'] = $forum['meta_key'];
556 $current_object['forum_meta_desc'] = $forum['meta_desc'];
557 }else{
558 $current_object['is_404'] = true;
559 $current_object['forum'] = array();
560 $current_object['forumid'] = 0;
561 $current_object['forum_desc'] = '';
562 $current_object['forum_meta_key'] = '';
563 $current_object['forum_meta_desc'] = '';
564 }
565 }
566
567 if(isset($current_object['topic_slug']) && $current_object['topic_slug']){
568 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']));
569 if(!empty($topic)){
570 $current_object['topic'] = $topic;
571 $current_object['topicid'] = $topic['topicid'];
572 }elseif( $this->current_object['status'] == 'unapproved' && !is_user_logged_in() ){
573 wp_redirect( wpforo_login_url() );
574 exit();
575 }else{
576 $current_object['is_404'] = true;
577 $current_object['topic'] = array();
578 $current_object['topicid'] = 0;
579 }
580 }
581
582 $this->current_object = apply_filters('wpforo_after_init_current_object', $current_object, $wpf_url_parse);
583 }
584
585 public function is_installed(){
586 return (bool) get_option('wpforo_version');
587 }
588 }
589
590 /**
591 * Main instance of wpForo.
592 *
593 * Returns the main instance of WPF to prevent the need to use globals.
594 *
595 * @since 1.4.3
596 * @return wpForo
597 */
598 if ( !function_exists('WPF') ){
599 function WPF() {
600 return wpForo::instance();
601 }
602 }
603
604 // Global for backwards compatibility.
605 $GLOBALS['wpforo'] = WPF();
606
607 //ADDONS/////////////////////////////////////////////////////
608 WPF()->addons = array(
609 'embeds' => array('version' => '1.0.4', 'requires' => '1.4.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' => 'https://gvectors.com/product/wpforo-embeds/'),
610 'polls' => array('version' => '1.0.0', 'requires' => '1.4.3', 'class' => 'wpForoPoll', 'title' => 'Polls', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'polls' . '/header.png', 'desc' => __('wpForo Polls is a complete addon to help forum members create, vote and manage polls effectively. Comes with poll specific permissions and settings.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-polls/'),
611 'mycred' => array('version' => '1.0.0', 'requires' => '1.4.3', 'class' => 'myCRED_Hook_wpForo', 'title' => 'MyCRED Integration', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'mycred' . '/header.png', 'desc' => __('Awards myCRED points for forum activity. Integrates myCRED Badges and Ranks. Converts wpForo topic and posts, likes to myCRED points.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-mycred/'),
612 'ucf' => array('version' => '1.0.0', 'requires' => '1.4.0', 'class' => 'WpforoUcf', 'title' => 'User Custom Fields', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'ucf' . '/header.png', 'desc' => __('Advanced user profile builder system. Allows to add new fields and manage profile page. Creates custom Registration, Account, Member Search forms.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-user-custom-fields/'),
613 'attachments' => array('version' => '1.1.2', 'requires' => '1.4.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' => 'https://gvectors.com/product/wpforo-advanced-attachments/'),
614 'pm' => array('version' => '1.0.3', 'requires' => '1.4.0', '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' => 'https://gvectors.com/product/wpforo-private-messages/'),
615 'cross' => array('version' => '1.0.3', 'requires' => '1.4.0', 'class' => 'wpForoCrossPosting', 'title' => '"Forum - Blog" Cross Posting', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'cross' . '/header.png', 'desc' => __('Blog to Forum and Forum to Blog content synchronization. Blog posts with Forum topics and Blog comments with Forum replies.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-cross-posting/'),
616 'ad-manager' => array('version' => '1.0.0', 'requires' => '1.4.0', 'class' => 'wpForoAD', 'title' => 'Ads Manager', 'thumb' => WPFORO_URL . '/wpf-assets/addons/' . 'ad-manager' . '/header.png', 'desc' => __('Ads Manager is a powerful yet simple advertisement management system, that allows you to add adverting banners between forums, topics and posts.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-ad-manager/'),
617 );
618 $wp_version = get_bloginfo('version'); if (version_compare($wp_version, '4.2.0', '>=')) { add_action('wp_ajax_dismiss_wpforo_addon_note', array(WPF()->notice, 'dismissAddonNote')); add_action('admin_notices', array(WPF()->notice, 'addonNote'));}
619 /////////////////////////////////////////////////////////////
620 }