PluginProbe
wpForo Forum / 1.4.6
wpForo Forum v1.4.6
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.6, at wpforo.php

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