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

1,181 lines 55.8 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
7 * Author URI: https://gvectors.com/
8 * Version: 1.9.8
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.9.8');
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 $wp_upload_dir = wp_upload_dir();
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 define('WPFORO_UPLOAD_DIR', $wp_upload_dir['basedir'] . "/wpforo" );
27 define('WPFORO_CACHE_DIR', $wp_upload_dir['basedir'] . "/wpforo/cache" );
28
29 final class wpForo{
30 private static $_instance = NULL;
31
32 public $file;
33 public $basename;
34 public $error;
35 public $locale;
36
37 public $tables;
38 public $blog_prefix;
39 public $prefix = "wpforo_";
40 private $_tables = array( 'accesses', 'activity', 'forums', 'languages', 'likes', 'phrases', 'postmeta', 'posts', 'post_revisions', 'profiles',
41 'subscribes', 'topics', 'tags', 'usergroups', 'views', 'visits', 'votes', 'logs' );
42 public $upload_dir_folders = array();
43
44 public $db;
45 public $use_mysql8;
46 public $addons = array();
47 public $current_url;
48 public $GET;
49 public $current_object;
50 public $menu = array();
51 public $data = array();
52 public $default;
53
54 public $wp_current_user = array();
55 public $current_user = array();
56 public $current_usermeta = array();
57 public $current_user_groupid = 4;
58 public $current_user_groupids = array(4);
59 public $current_user_secondary_groupids = '';
60 public $current_userid = 0;
61 public $current_username = '';
62 public $current_user_email = '';
63 public $current_user_display_name = '';
64 public $current_user_status = '';
65 public $current_user_accesses = array();
66 public $session_token = '';
67
68 public $use_trailing_slashes;
69 public $use_home_url;
70 public $excld_urls;
71 public $base_permastruct;
72 public $permastruct;
73 public $url;
74 public $pageid;
75
76 public $general_options;
77 public $features;
78 public $tools_antispam;
79 public $tools_cleanup;
80 public $tools_misc;
81 public $tools_legal;
82
83 public $sql_cache;
84 public $ram_cache;
85 public $action;
86 public $cache;
87 public $phrase;
88 public $forum;
89 public $topic;
90 public $postmeta;
91 public $post;
92 public $usergroup;
93 public $member;
94 public $perm;
95 public $sbscrb;
96 public $tpl;
97 public $notice;
98 public $api;
99 public $log;
100 public $feed;
101 public $form;
102 public $moderation;
103 public $activity;
104 public $revision;
105 public $seo;
106 public $add;
107 public $dissmissed;
108
109 public $member_tpls;
110
111 public static function instance(){
112 if ( is_null(self::$_instance) ) self::$_instance = new self();
113 return self::$_instance;
114 }
115
116 private function use_mysql8() {
117 global $wpdb;
118 if( preg_match( '#([\d.]+)-MariaDB#iu', $wpdb->get_var( "SELECT VERSION()" ), $match ) ){
119 return version_compare( $match[1], '10.2.6', '>=' );
120 }
121 return version_compare( $wpdb->db_version(), '8.0.0', '>=' );
122 }
123
124 private function __construct(){
125 global $wpdb;
126 $this->db = $wpdb;
127 $this->use_mysql8 = $this->use_mysql8();
128 $this->file = __FILE__;
129 $this->error = NULL;
130 $this->locale = 'en_US';
131 $this->basename = plugin_basename($this->file);
132
133 $this->init_db_tables();
134 $this->includes();
135 $this->init_defaults();
136 $this->reset_current_object();
137 $this->init_options();
138 $this->setup();
139 $this->init_hooks();
140
141 $this->sql_cache =
142 $this->ram_cache = new wpForoRamCache();
143 $this->action = new wpForoAction();
144 $this->cache = new wpForoCache();
145 $this->phrase = new wpForoPhrase();
146 $this->forum = new wpForoForum();
147 $this->topic = new wpForoTopic();
148 $this->postmeta = new wpForoPostMeta();
149 $this->post = new wpForoPost();
150 $this->usergroup = new wpForoUsergroup();
151 $this->member = new wpForoMember();
152 $this->perm = new wpForoPermissions();
153 $this->sbscrb = new wpForoSubscribe();
154 $this->tpl = new wpForoTemplate();
155 $this->notice = new wpForoNotices();
156 $this->api = new wpForoAPI();
157 $this->log = new wpForoLogs();
158 $this->feed = new wpForoFeed();
159 $this->form = new wpForoForm();
160 $this->moderation = new wpForoModeration();
161 $this->activity = new wpForoActivity();
162 $this->revision = new wpForoRevision();
163 $this->seo = new wpForoSEO();
164 $this->add = new stdClass(); // Integrations
165 }
166
167 private function init_hooks(){
168 add_action('plugins_loaded', array($this, 'plugins_loaded'));
169 if( is_admin() ){
170 add_action('admin_init', array($this, 'admin_init'));
171 add_action('admin_init', array($this, 'init'), 99);
172 }else{
173 add_action('init', array($this, 'init_hook'), 99);
174 add_action('wp', array($this, 'init'), 99);
175 }
176 add_action('switch_blog', array($this, 'after_switch_blog'), 10, 2);
177 }
178
179 public function after_switch_blog($new_blog_id, $prev_blog_id){
180 if( intval($new_blog_id) !== intval($prev_blog_id) ){
181 $this->init_db_tables();
182 }
183 }
184
185 public function init_db_tables($blog_id = 0){
186 $this->db->query("SET SESSION group_concat_max_len = 1000000");
187 $blog_id = apply_filters('wpforo_current_blog_id', $blog_id);
188 $this->tables = new stdClass;
189 if(!$blog_id) $blog_id = $this->db->blogid;
190 $this->blog_prefix = $this->db->get_blog_prefix( $blog_id );
191 $this->_tables = apply_filters('wpforo_init_db_tables', $this->_tables);
192 foreach ( $this->_tables as $table )
193 $this->tables->$table = $this->fix_table_name($table);
194 }
195
196 /**
197 * @param string $basename
198 *
199 * @return string
200 */
201 public function fix_table_name($basename){
202 return $this->blog_prefix . $this->prefix . $basename;
203 }
204
205 private function includes(){
206 require_once( WPFORO_DIR . '/wpf-includes/wpf-hooks.php' );
207 require_once( WPFORO_DIR . '/wpf-includes/functions.php' );
208 require_once( WPFORO_DIR . '/wpf-includes/functions-integration.php' );
209 require_once( WPFORO_DIR . '/wpf-includes/functions-template.php' );
210 require_once( WPFORO_DIR . '/wpf-includes/functions-installation.php' );
211
212 if( wpforo_is_admin() ) require_once( WPFORO_DIR .'/wpf-admin/admin.php' );
213
214 require_once( WPFORO_DIR . '/wpf-includes/class-ramcache.php' );
215 require_once( WPFORO_DIR . '/wpf-includes/class-actions.php' );
216 require_once( WPFORO_DIR . '/wpf-includes/class-cache.php' );
217 require_once( WPFORO_DIR . '/wpf-includes/class-forums.php' );
218 require_once( WPFORO_DIR . '/wpf-includes/class-topics.php' );
219 require_once( WPFORO_DIR . '/wpf-includes/class-postmeta.php' );
220 require_once( WPFORO_DIR . '/wpf-includes/class-posts.php' );
221 require_once( WPFORO_DIR . '/wpf-includes/class-usergroups.php' );
222 require_once( WPFORO_DIR . '/wpf-includes/class-members.php' );
223 require_once( WPFORO_DIR . '/wpf-includes/class-permissions.php' );
224 require_once( WPFORO_DIR . '/wpf-includes/class-phrases.php');
225 require_once( WPFORO_DIR . '/wpf-includes/class-subscribes.php' );
226 require_once( WPFORO_DIR . '/wpf-includes/class-template.php' );
227 require_once( WPFORO_DIR . '/wpf-includes/class-notices.php' );
228 require_once( WPFORO_DIR . '/wpf-includes/class-logs.php' );
229 require_once( WPFORO_DIR . '/wpf-includes/class-api.php' );
230 require_once( WPFORO_DIR . '/wpf-includes/class-feed.php' );
231 require_once( WPFORO_DIR . '/wpf-includes/class-forms.php' );
232 require_once( WPFORO_DIR . '/wpf-includes/class-moderation.php' );
233 require_once( WPFORO_DIR . '/wpf-includes/class-activity.php' );
234 require_once( WPFORO_DIR . '/wpf-includes/class-revisions.php' );
235 require_once( WPFORO_DIR . '/wpf-includes/class-seo.php' );
236 }
237
238 public function plugins_loaded(){
239 if ( wpforo_feature( 'disable_new_user_admin_notification' ) ) {
240 remove_action( 'after_password_reset', 'wp_password_change_notification' );
241
242 remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
243 add_action( 'register_new_user', 'wpforo_send_new_user_notifications');
244
245 remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications' );
246 add_action( 'edit_user_created_user', 'wpforo_send_new_user_notifications', 10, 2);
247
248 remove_action( 'network_site_new_created_user', 'wp_send_new_user_notifications' );
249 add_action( 'network_site_new_created_user', 'wpforo_send_new_user_notifications');
250
251 remove_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' );
252 add_action( 'network_site_new_created_user', 'wpforo_send_new_user_notifications');
253
254 remove_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' );
255 add_action( 'network_user_new_created_user', 'wpforo_send_new_user_notifications');
256 }
257 }
258
259 public function admin_init(){
260 if( wpforo_is_admin() ){
261
262 $this->check_database();
263
264 if( strpos( wpforo_get_request_uri(), 'user-new.php' ) === false ){
265 $sql = "SELECT `groupid` FROM ". $this->tables->profiles ." WHERE `userid` = " . wpforo_bigintval($this->current_userid);
266 if( !$current_groupid = $this->db->get_var($sql) ){
267 $this->member->synchronize_user($this->current_userid);
268 }
269 }
270
271 if( !$this->forum->manage() && wpforo_current_user_is('admin') ){
272 $this->member->set_usergroup($this->current_userid, 1);
273 }
274 }
275 }
276
277 public function check_database(){
278
279 //Make sure all users profiles are created
280 if( !wpforo_feature('user-synch') && get_option('wpforo_version') ){
281 $users = $this->db->get_var("SELECT COUNT(*) FROM `".$this->db->users."`");
282 $profiles = $this->db->get_var("SELECT COUNT(*) FROM `" . $this->tables->profiles."`");
283 $delta = $users - $profiles;
284 if( $users > 100 && $delta > 2 ){ add_action( 'admin_notices', 'wpforo_profile_notice', 10 ); }
285 }
286 //Make sure tables structures are correct for current version
287 $wpforo_version_db = get_option('wpforo_version_db');
288 if( !$wpforo_version_db || version_compare( $wpforo_version_db, WPFORO_VERSION, '<') ){
289 if( 'tables' != wpfval($_GET, 'view') ){
290 $db_note = false;
291 $problems = wpforo_database_check();
292 if( !empty($problems) ) {
293 foreach( $problems as $table_name => $problem ){
294 if( wpfval($problem, 'fields') ) $db_note = true;
295 if( wpfval($problem, 'exists') ) $db_note = true;
296 }
297 if( $db_note ) {
298 add_action( 'admin_notices', 'wpforo_database_notice', 10 );
299 }
300 } else {
301 update_option('wpforo_version_db', WPFORO_VERSION );
302 }
303 }
304 }
305 }
306
307 public function init(){
308 $this->locale = get_locale();
309
310 do_action( 'wpforo_before_init' );
311
312 $this->phrase->init();
313
314 $this->perm->init();
315 $this->perm->init_current_user_accesses();
316
317 $this->init_current_url();
318 $this->init_current_object();
319
320 $this->moderation->init();
321 $this->tpl->init();
322 //reCAPTCHA on wpForo pages
323 $this->api->hooks();
324
325 do_action( 'wpforo_after_init' );
326 }
327
328 public function init_hook(){
329 //reCAPTCHA on wp-login.php page
330 $this->api->init_wp_recaptcha();
331 }
332
333 public function shortcode_atts_to_url($atts){
334 $url = wpforo_home_url();
335
336 $args = shortcode_atts( array(
337 'item' => 'forum',
338 'id' => 0,
339 'slug' => '',
340 ), (array) $atts );
341
342 if( $args['item'] === 'profile' && !$args['id'] ) $args['id'] = $this->current_userid;
343
344 if( $args['item'] === 'add-topic' ){
345 $forum = $this->forum->get_forum( ( $args['slug'] ?: $args['id'] ) );
346 $forumid = (int) wpfval($forum, 'is_cat') ? 0 : (int) wpfval($forum, 'forumid');
347 $url = wpforo_home_url( wpforo_get_template_slug('add-topic') . '/' . (int) $forumid );
348 }elseif( $args['item'] === 'recent' ){
349 $url = wpforo_get_template_slug('recent') . '/';
350 if( trim($args['slug']) ) $url .= '?view=' . wpforo_get_template_slug($args['slug']);
351 $url = wpforo_home_url($url);
352 }elseif( $args['id'] || $args['slug'] ){
353 $getid = ( $args['slug'] ? $args['slug'] : $args['id'] );
354 if( $args['item'] === 'topic' ){
355 $url = $this->topic->get_topic_url($getid);
356 }elseif( $args['item'] === 'profile' ){
357 $url = $this->member->get_profile_url($getid);
358 }else{
359 $url = $this->forum->get_forum_url($getid);
360 }
361 }elseif( $args['item'] === 'signin' ){
362 $url = wpforo_home_url('?foro=signin');
363 }elseif( $args['item'] === 'signup' ){
364 $url = wpforo_home_url('?foro=signup');
365 }elseif( $args['item'] === 'lostpassword' ){
366 $url = wpforo_home_url('?foro=lostpassword');
367 }
368
369 return $url;
370 }
371
372 public function init_current_url($atts = array()){
373 $url = wpforo_get_request_uri();
374 if( $atts || is_wpforo_shortcode_page($url) ){
375 if( $atts || ($atts = get_wpforo_shortcode_atts('', $url)) ){
376 $url = $this->shortcode_atts_to_url($atts);
377 }else{
378 $url = wpforo_home_url();
379 }
380 }elseif( is_wpforo_url($url) && preg_match('#/'.preg_quote(wpforo_get_template_slug('postid')).'/(\d+)/?$#isu', strtok($url, '?'), $matches) ){
381 $post_url = $this->post->get_post_url($matches[1]);
382 if( $post_url !== wpforo_home_url() ) $url = $post_url;
383 }
384
385 $url = wpforo_fix_url($url);
386 $url = preg_replace('#\#[^/?&]*$#isu', '', $url);
387 parse_str( parse_url($url, PHP_URL_QUERY), $get );
388 $get = array_merge( (array) $get, (array) $_GET );
389 $get = wp_unslash($get);
390
391 $this->current_url = apply_filters('wpforo_init_current_url', $url);
392 $this->GET = apply_filters('wpforo_init_current_url_GET', $get);
393 }
394
395 private function init_defaults() {
396 date_default_timezone_set( 'UTC' );
397 ini_set( 'date.timezone', 'UTC' );
398
399 $this->default = new stdClass;
400
401 $this->default->use_home_url = 0;
402 $this->default->excld_urls = '';
403 $this->default->permastruct = 'community';
404
405 $this->default->current_object = array(
406 'template' => '',
407 'qvars' => array(),
408 'args' => array(),
409 'layout' => 1,
410 'og_text' => '',
411 'paged' => 1,
412 'items_count' => 0,
413 'items_per_page' => 15,
414 'is_404' => false,
415 'user_is_same_current_user' => false,
416 'orderby' => null,
417 'members' => array(),
418 'categories' => array(),
419 'topics' => array(),
420 'posts' => array(),
421 'user' => array(),
422 'userid' => 0,
423 'user_nicename' => '',
424 'forum' => array(),
425 'forumid' => 0,
426 'forum_slug' => '',
427 'forum_desc' => '',
428 'forum_meta_key' => '',
429 'forum_meta_desc' => '',
430 'topic' => array(),
431 'topicid' => 0,
432 'topic_slug' => '',
433 'tags' => array(),
434 'load_tinymce' => false
435 );
436
437 $blogname = get_option( 'blogname', '' );
438 $this->default->general_options = array(
439 'title' => $blogname . ' ' . __( 'Forum', 'wpforo' ),
440 'description' => $blogname . ' ' . __( 'Discussion Board', 'wpforo' ),
441 'lang' => 1
442 );
443
444 $this->default->features = array(
445 'user-admin-bar' => 0,
446 'page-title' => 1,
447 'top-bar' => 1,
448 'top-bar-search' => 1,
449 'breadcrumb' => 1,
450 'footer-stat' => 1,
451 'notifications' => 1,
452 'notifications-live' => 0,
453 'notifications-bar' => 1,
454 'mention-nicknames' => 1,
455 'content-do_shortcode' => 0,
456 'view-logging' => 1,
457 'track-logging' => 1,
458 'goto-unread' => 1,
459 'goto-unread-button' => 0,
460 'profile' => 1,
461 'user-register' => 1,
462 'user-register-email-confirm' => 1,
463 'disable_new_user_admin_notification' => 1,
464 'register-url' => 0,
465 'login-url' => 0,
466 'resetpass-url' => 1,
467 //In most cases incompatible with security and antispam plugins
468 'replace-avatar' => 1,
469 'avatars' => 1,
470 'custom-avatars' => 1,
471 'signature' => 1,
472 'rating' => 1,
473 'rating_title' => 1,
474 'member_cashe' => 1,
475 'object_cashe' => 1,
476 'option_cache' => 1,
477 'html_cashe' => 0,
478 'memory_cashe' => 1,
479 'seo-title' => 1,
480 'seo-meta' => 1,
481 'seo-profile' => 1,
482 'rss-feed' => 1,
483 'font-awesome' => 1,
484 'bp_activity' => 1,
485 'bp_notification' => 1,
486 'bp_forum_tab' => 1,
487 'um_forum_tab' => 1,
488 'um_notification' => 1,
489 'user-synch' => 0,
490 'role-synch' => 1,
491 'output-buffer' => 1,
492 'wp-date-format' => 0,
493 'subscribe_conf' => 1,
494 'subscribe_checkbox_on_post_editor' => 1,
495 'subscribe_checkbox_default_status' => 0,
496 'attach-media-lib' => 1,
497 'admin-cp' => 1,
498 'debug-mode' => 0,
499 'copyright' => 1
500 );
501
502 $this->default->tools_antispam = array(
503 'spam_filter' => 1,
504 'spam_filter_level_topic' => mt_rand( 30, 60 ),
505 'spam_filter_level_post' => mt_rand( 30, 60 ),
506 'spam_user_ban' => 0,
507 'new_user_max_posts' => 3,
508 'unapprove_post_if_user_is_new' => 0,
509 'spam_user_ban_notification' => 1,
510 'min_number_post_to_attach' => 0,
511 'min_number_post_to_link' => 0,
512 'spam_file_scanner' => 1,
513 'limited_file_ext' => 'pdf|doc|docx|txt|htm|html|rtf|xml|xls|xlsx|zip|rar|tar|gz|bzip|7z',
514 'exclude_file_ext' => 'pdf|doc|docx|txt',
515 'rc_site_key' => '',
516 'rc_secret_key' => '',
517 'rc_theme' => 'light',
518 'rc_login_form' => 0,
519 'rc_reg_form' => 0,
520 'rc_lostpass_form' => 0,
521 'rc_wpf_login_form' => 1,
522 'rc_wpf_reg_form' => 1,
523 'rc_wpf_lostpass_form' => 1,
524 'rc_topic_editor' => 1,
525 'rc_post_editor' => 1,
526 'html' => 'embed(src width height name pluginspage type wmode allowFullScreen allowScriptAccess flashVars),'
527 );
528
529 $this->default->tools_cleanup = array(
530 'user_reg_days_ago' => 7,
531 'auto_cleanup_users' => 0,
532 'usergroup' => array( 1 => '0', 5 => '0', 2 => '1', 3 => '0' )
533 );
534
535 $this->default->tools_misc = array(
536 'dofollow' => '',
537 'noindex' => '',
538 'admin_note' => '',
539 'admin_note_groups' => array( 1, 2, 3, 4, 5 ),
540 'admin_note_pages' => array( 'forum' )
541 );
542
543 $this->default->tools_legal = array(
544 'rules_checkbox' => 0,
545 'rules_text' => null,
546 'page_terms' => '',
547 'page_privacy' => '',
548 'forum_privacy_text' => null,
549 'checkbox_terms_privacy' => 0,
550 'checkbox_email_password' => 1,
551 'checkbox_forum_privacy' => 0,
552 'checkbox_fb_login' => 1,
553 'contact_page_url' => null,
554 'cookies' => 1
555 );
556
557 $this->default->stats = array(
558 'forums' => 0,
559 'topics' => 0,
560 'posts' => 0,
561 'members' => 0,
562 'online_members_count' => 0,
563 'last_post_title' => '',
564 'last_post_url' => '',
565 'newest_member' => array(),
566 'newest_member_dname' => '',
567 'newest_member_profile_url' => ''
568 );
569
570 $this->default->dissmissed = array(
571 'recaptcha_backend_note' => 0,
572 'recaptcha_note' => 0,
573 'addons_css_update' => 0
574 );
575 }
576
577 private function reset_current_object(){
578 $this->current_object = $this->default->current_object;
579 }
580
581 private function init_options(){
582 $permalink_structure = get_option('permalink_structure');
583
584 $this->use_trailing_slashes = ( '/' == substr($permalink_structure, -1, 1) );
585
586 //OPTIONS
587 $this->use_home_url = get_wpf_option('wpforo_use_home_url', $this->default->use_home_url);
588 $this->excld_urls = get_wpf_option('wpforo_excld_urls', $this->default->excld_urls);
589
590 $this->permastruct = trim( get_wpf_option('wpforo_permastruct', $this->default->permastruct), '/' );
591 $this->permastruct = preg_replace('#^/?index\.php/?#isu', '', $this->permastruct);
592 $this->permastruct = trim($this->permastruct, '/');
593
594 $this->base_permastruct = (!$this->use_home_url ? $this->permastruct : '');
595 $this->base_permastruct = rtrim( ( strpos($permalink_structure, 'index.php') !== FALSE ? '/index.php/' . $this->base_permastruct : '/' . $this->base_permastruct ), '/\\' );
596 $this->url = esc_url( home_url( $this->user_trailingslashit($this->base_permastruct) ) );
597 $this->pageid = get_wpf_option( 'wpforo_pageid', 0);
598
599 $this->general_options = get_wpf_option( 'wpforo_general_options', $this->default->general_options);
600 $this->features = get_wpf_option('wpforo_features', $this->default->features);
601 $fp = intval($this->features['profile']);
602 if( ($fp === 3 && !class_exists('BP_Component')) || ($fp === 4 && !function_exists('UM')) ){
603 $this->features['profile'] = 1;
604 update_option('wpforo_features', array_map( 'intval', $this->features));
605 wpforo_clean_cache('option');
606 }
607 $this->tools_antispam = get_wpf_option('wpforo_tools_antispam', $this->default->tools_antispam);
608 $this->tools_cleanup = get_wpf_option('wpforo_tools_cleanup', $this->default->tools_cleanup);
609 $this->tools_misc = get_wpf_option('wpforo_tools_misc', $this->default->tools_misc);
610 $this->tools_legal = get_wpf_option('wpforo_tools_legal', $this->default->tools_legal);
611
612 $this->dissmissed = get_wpf_option('wpforo_dissmissed', $this->default->dissmissed);
613 }
614
615 private function setup(){
616 register_activation_hook($this->basename, 'do_wpforo_activation');
617 register_deactivation_hook($this->basename, 'do_wpforo_deactivation');
618 }
619
620 public function user_trailingslashit($url) {
621 $rtrimed_url = '';
622 $url_append_vars = '';
623 if( preg_match('#^(.+?)(/?[?&].*)?$#isu', $url, $match) ){
624 if( wpfval($match, 1) ) $rtrimed_url = rtrim($match[1], '/\\');
625 if( wpfval($match, 2) ) $url_append_vars = '?' . trim($match[2], '?&/\\');
626 if( $rtrimed_url ) {
627 $home_url = rtrim( preg_replace('#/?\?.*$#isu', '', home_url()), '/\\' );
628 if( $rtrimed_url == $home_url ){
629 $url = $rtrimed_url . '/';
630 }else{
631 $url = ( $this->use_trailing_slashes ? $rtrimed_url . '/' : $rtrimed_url );
632 }
633 }
634 }
635 return $url . $url_append_vars;
636 }
637
638 public function strip_url_paged_var($url){
639 $patterns = array(
640 '#/'. preg_quote( wpforo_get_template_slug('paged') ) .'/?\d*/?#isu',
641 '#[\&\?]wpfpaged=\d*#isu'
642 );
643 $url = preg_replace($patterns, '', $url);
644 $url = $this->user_trailingslashit($url);
645 return $url;
646 }
647
648 public function statistic( $mode = 'get', $template = 'all' ){
649 $key = 'wpforo_stat_' . $this->current_user_groupid;
650 if( $mode === 'get' ){
651 if( $cached_stat = get_option($key) ){
652 $cached_stat['online_members_count'] = $this->member->online_members_count();
653 if( wpfval($cached_stat, 'forums') && wpfval($cached_stat, 'topics') && wpfval($cached_stat, 'posts') ){
654 $cached_stat = wpforo_array_args_cast_and_merge($cached_stat, $this->default->stats);
655 return $cached_stat;
656 }
657 }
658 }
659
660 if( $mode === 'get' || $template === 'all' ) {
661 $stats['forums'] = $this->forum->get_count( array('is_cat' => 0) );
662 $stats['topics'] = $this->topic->get_count();
663 $stats['posts'] = $this->post->get_count();
664 $member_status = array( 'p.`status`' => apply_filters('wpforo_display_members_status', array('active')));
665 $stats['members'] = $this->member->get_count( $member_status );
666 $stats['online_members_count'] = $this->member->online_members_count();
667 $row_count = apply_filters('wpforo_get_statistic_row_count', 20);
668
669 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => $row_count, 'private' => 0, 'status' => 0, 'permgroup' => 4 ));
670 $first = key($posts);
671 if ( isset($posts[$first]) && !empty($posts[$first]) && $this->perm->forum_can('vf', $posts[$first]['forumid']) ) {
672 $stats['last_post_title'] = $posts[$first]['title'];
673 $stats['last_post_url'] = $this->post->get_post_url($posts[$first]['last_post']);
674 }
675
676 $members = $this->member->get_members(array('orderby' => 'userid', 'status' => array('active'), 'order' => 'DESC', 'row_count' => 1, 'groupids' => $this->usergroup->get_visible_usergroup_ids()));
677 if (isset($members[0]) && !empty($members[0])) {
678 $members[0]['profile_url'] = $this->member->profile_url($members[0]);
679 $stats['newest_member'] = $members[0];
680 $stats['newest_member_dname'] = wpforo_user_dname($members[0]);
681 $stats['newest_member_profile_url'] = $members[0]['profile_url'];
682 }
683 }else{
684 $stats = get_wpf_option($key, $this->default->stats);
685 switch ($template){
686 case 'forum':
687 $stats['forums'] = $this->forum->get_count( array('is_cat' => 0) );
688 break;
689 case 'topic':
690 $stats['topics'] = $this->topic->get_count();
691 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1));
692 if ( isset($posts[0]) && !empty($posts[0]) && $this->perm->forum_can('vf', $posts[0]['forumid']) ) {
693 $stats['last_post_title'] = $posts[0]['title'];
694 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
695 }
696 break;
697 case 'post':
698 $stats['posts'] = $this->post->get_count();
699 $posts = $this->topic->get_topics(array('orderby' => 'modified', 'order' => 'DESC', 'row_count' => 1));
700 if ( isset($posts[0]) && !empty($posts[0]) && $this->perm->forum_can('vf', $posts[0]['forumid']) ) {
701 $stats['last_post_title'] = $posts[0]['title'];
702 $stats['last_post_url'] = $this->post->get_post_url($posts[0]['last_post']);
703 }
704 break;
705 case 'user':
706 $member_status = array( 'p.`status`' => apply_filters('wpforo_display_members_status', array('active')));
707 $stats['members'] = $this->member->get_count( $member_status );
708 $stats['online_members_count'] = $this->member->online_members_count();
709
710 $members = $this->member->get_members(array('orderby' => 'userid', 'order' => 'DESC', 'row_count' => 1, 'groupids' => $this->usergroup->get_visible_usergroup_ids()));
711 if (isset($members[0]) && !empty($members[0])) {
712 $members[0]['profile_url'] = WPF()->member->profile_url($members[0]);
713 $stats['newest_member'] = $members[0];
714 $stats['newest_member_dname'] = wpforo_user_dname($members[0]);
715 $stats['newest_member_profile_url'] = $members[0]['profile_url'];
716 }
717 break;
718 }
719 }
720
721 $stats = apply_filters('wpforo_get_statistic_array_filter', $stats);
722 $stats = wpforo_array_args_cast_and_merge($stats, $this->default->stats);
723 update_option( $key, $stats );
724 return $stats;
725 }
726
727 public function init_current_template(){
728
729 }
730
731 public function init_current_object(){
732 $this->reset_current_object();
733 $this->current_object['items_per_page'] = $this->post->get_option_items_per_page();
734 $url = $this->current_url;
735 $get = $this->GET;
736
737 if( !is_wpforo_page($url) ) return;
738
739 $current_url = wpforo_get_url_query_vars_str($url);
740
741 if( $this->use_home_url ) $this->permastruct = '';
742
743 $current_object = array();
744 if( wpfkey($get, 'wpfs') || wpfval($get, 'foro') === 'search' ) $this->current_object['template'] = 'search';
745 if( wpfval($get, 'wpforo') || wpfval($get, 'foro') ){
746 $request = ( wpfval($get, 'wpforo') ) ? wpfval($get, 'wpforo') : wpfval($get, 'foro');
747 switch( $request ){
748 case 'signup':
749 if(!is_user_logged_in()) {
750 $this->data['template'] = $this->current_object['template'] = 'register';
751 $this->data['value']['user_login'] = sanitize_user((string) wpfval($_POST, 'wpfreg', 'user_login'));
752 $this->data['value']['user_email'] = sanitize_email((string) wpfval($_POST, 'wpfreg', 'user_email'));
753 $this->data['varname'] = 'wpfreg';
754 }
755 break;
756 case 'signin':
757 if(!is_user_logged_in()) $this->current_object['template'] = 'login';
758 break;
759 case 'lostpassword':
760 if(!is_user_logged_in()) $this->current_object['template'] = 'lostpassword';
761 break;
762 case 'resetpassword':
763 $this->current_object['template'] = 'resetpassword';
764 break;
765 case 'page':
766 $this->current_object['template'] = 'page';
767 break;
768 case 'logout':
769 wp_logout();
770 wp_safe_redirect( wpforo_home_url( preg_replace('#\?.*$#is', '', wpforo_get_request_uri()) ) );
771 exit();
772 break;
773 }
774 }
775
776 $wpf_url = preg_replace( '#^/?'.preg_quote($this->permastruct).'#isu', '' , $current_url, 1 );
777 $wpf_url = preg_replace('#/?\?.*$#isu', '', $wpf_url);
778 $wpf_url_parse = array_filter( explode('/', trim($wpf_url, '/')) );
779 $wpf_url_parse = array_reverse($wpf_url_parse);
780
781 if(in_array(wpforo_get_template_slug('paged'), $wpf_url_parse)){
782 foreach($wpf_url_parse as $key => $value){
783 if( $value === wpforo_get_template_slug('paged')){
784 unset($wpf_url_parse[$key]);
785 break;
786 }
787 if(is_numeric($value)) $paged = intval($value);
788
789 unset($wpf_url_parse[$key]);
790 }
791 }
792 if( $_paged = intval( wpfval($get, 'wpfpaged') ) ) $paged = $_paged;
793 $current_object['paged'] = (isset($paged) && $paged > 0) ? $paged : 1;
794 $current_object['orderby'] = wpfval($get, 'orderby');
795
796 $wpf_url_parse = array_values($wpf_url_parse);
797
798 if( !$this->current_object['template'] ){
799 $current_object = apply_filters('wpforo_before_init_current_object', $current_object, $wpf_url_parse);
800 if( wpfkey($current_object, 'template') ) $this->current_object['template'] = (string) wpfval( $current_object, 'template' );
801 }
802
803 if( !$this->current_object['template'] ){
804 if( $templates = $this->tpl->get_templates_list() ){
805 $__slug = end($wpf_url_parse);
806 foreach ( $templates as $template ){
807 if( $__slug === wpforo_get_template_slug($template) ){
808 $this->current_object['template'] = $template;
809 $current_object['qvars'] = $wpf_url_parse;
810 array_pop($current_object['qvars']);
811 $current_object['qvars'] = array_reverse($current_object['qvars']);
812 break;
813 }
814 }
815 }
816 }
817
818 if( !$this->current_object['template'] ){
819 $this->current_object['template'] = 'forum';
820 $this->data['varname'] = 'topic';
821 if( isset($wpf_url_parse[0]) ){
822 if( isset($wpf_url_parse[1]) ){
823 $current_object['topic_slug'] = $wpf_url_parse[0];
824 $current_object['forum_slug'] = $wpf_url_parse[1];
825 $this->current_object['template'] = 'post';
826 $this->data['varname'] = 'post';
827 }else{
828 $current_object['forum_slug'] = $wpf_url_parse[0];
829 $this->current_object['template'] = 'topic';
830 $this->data['varname'] = 'topic';
831 }
832 }
833 }
834
835 $current_object = apply_filters('wpforo_after_init_current_template', $current_object, $wpf_url_parse, $get);
836 if( wpfkey($current_object, 'template') ) $this->current_object['template'] = (string) wpfval( $current_object, 'template' );
837
838 if( $this->current_object['template'] ){
839 if( !wpfval($current_object, 'userid') && !wpfval($current_object, 'user_nicename') && wpforo_is_member_template($this->current_object['template']) ){
840 if( $qvar0 = wpfval($current_object['qvars'], 0) ){
841 if( $this->member->options['url_structure'] === 'id' ) {
842 $current_object['userid'] = $qvar0;
843 }else {
844 $current_object['user_nicename'] = $qvar0;
845 }
846 }else{
847 if($this->current_userid){
848 $current_object['userid'] = $this->current_userid;
849 }else{
850 wp_safe_redirect( wpforo_login_url() );
851 exit();
852 }
853 }
854 }elseif($this->current_object['template'] === 'search'){
855 $args = array(
856 'needle' => sanitize_text_field( wpfval($get, 'wpfs') ),
857 'type' => sanitize_text_field( wpfval($get, 'wpfin') ),
858 'date_period' => intval( wpfval($get, 'wpfd') ),
859 'forumids' => (array) wpfval($get, 'wpff'),
860 'offset' => ($current_object['paged'] - 1) * $this->current_object['items_per_page'],
861 'row_count' => $this->current_object['items_per_page'],
862 'orderby' => 'relevancy',
863 'order' => 'desc',
864 'postids' => array()
865 );
866 if( !empty($get['wpfob']) ){
867 $args['orderby'] = sanitize_text_field( $get['wpfob'] );
868 }elseif( in_array(wpfval( $args, 'type' ), array('tag','user-posts','user-topics'), true) ) {
869 $args['orderby'] = 'date';
870 }
871 $wpfo = strtolower(wpfval($get, 'wpfo'));
872 if( in_array($wpfo, array('asc','desc'), true) ) $args['order'] = $wpfo;
873 $sdata = array_filter( (array) wpfval($get, 'data') );
874 $args['postids'] = WPF()->postmeta->search($sdata);
875 $current_object['args'] = $args;
876 if( $sdata && !$args['postids'] ){
877 $current_object['items_count'] = 0;
878 $current_object['posts'] = array();
879 }else{
880 $current_object['posts'] = WPF()->post->search($args, $current_object['items_count']);
881 }
882 }elseif($this->current_object['template'] === 'recent'){
883 $current_object['items_per_page'] = $this->post->options['topics_per_page'];
884 }elseif($this->current_object['template'] === 'tags'){
885 $current_object['items_per_page'] = $this->post->options['tags_per_page'];
886 $args = array(
887 'offset' => ($current_object['paged'] - 1) * $current_object['items_per_page'],
888 'row_count' => $current_object['items_per_page']
889 );
890 $current_object['tags'] = $this->topic->get_tags($args, $current_object['items_count']);
891 }elseif($this->current_object['template'] === 'members'){
892 $current_object['items_per_page'] = $this->member->options['members_per_page'];
893
894 $this->data['template'] = 'members';
895 $this->data['value'] = $get;
896 $this->data['varname'] = '';
897
898 if( !empty($get['_wpfms']) ){
899 $users_include = array();
900 $search_fields_names = $this->member->get_search_fields_names(false);
901
902 $wpfms = (isset($get['wpfms'])) ? sanitize_text_field($get['wpfms']) : '';
903 if($wpfms){
904 $users_include = $this->member->search($wpfms, $search_fields_names);
905 }else{
906 if( $filters = array_filter($get, function($v){return !( is_null($v) || $v === false || $v === '' );}) ){
907 $filters = array_merge( array_filter((array) wpfval($get, 'data'), function($v){return !( is_null($v) || $v === false || $v === '' );}), $filters );
908 unset($filters['data']);
909 $args = array();
910 foreach ($filters as $filter_key => $filter){
911 if( in_array($filter_key, (array) $search_fields_names) ){
912 $args[$filter_key] = $filter;
913 }
914 }
915 $users_include = $this->member->filter($args);
916 }
917 }
918
919 $users_include = apply_filters('wpforo_member_search_users_include', $users_include);
920 }
921 $member_status = apply_filters('wpforo_display_members_status', array('active'));
922 $args = array(
923 'offset' => ($current_object['paged'] - 1) * $current_object['items_per_page'],
924 'row_count' => $current_object['items_per_page'],
925 'orderby' => 'posts',
926 'order' => 'DESC',
927 'status' => $member_status,
928 'groupids' => $this->usergroup->get_visible_usergroup_ids()
929 );
930 if(!empty($users_include)) $args['include'] = $users_include;
931 $current_object['members'] = $this->member->get_members($args, $current_object['items_count']);
932 if(isset($users_include) && empty($users_include)){ $current_object['members'] = array(); $current_object['items_count'] = 0; }
933 }elseif($this->current_object['template'] === 'add-topic'){
934 if( $qvar0 = (int) wpfval($current_object['qvars'], 0) ){
935 $forum = (array) $this->forum->get_forum($qvar0);
936 if( !$forum || (int) wpfval($forum, 'is_cat') ){
937 wp_safe_redirect( wpforo_home_url( wpforo_get_template_slug('add-topic') ), 301 );
938 exit();
939 }
940 }
941 }
942 }
943
944 if( wpfval($current_object, 'userid') || wpfval($current_object, 'user_nicename') ){
945 $args = array();
946 if(isset($current_object['userid'])) $args['userid'] = $current_object['userid'];
947 if(isset($current_object['user_nicename'])) $args['user_nicename'] = $current_object['user_nicename'];
948 $selected_user = $this->member->get_member($args);
949 if(isset($current_object['userid']) && empty($selected_user)) $selected_user = $this->member->get_member(array('user_nicename' => $current_object['userid']));
950 if(!empty($selected_user)){
951 $current_object['user'] = $selected_user;
952 $current_object['userid'] = $selected_user['ID'];
953 $current_object['user_nicename'] = $selected_user['user_nicename'];
954 $current_object['user_is_same_current_user'] = !empty($this->current_userid) && $selected_user['ID'] == $this->current_userid;
955
956 if( $this->tpl->can_view_template($this->current_object['template'], $current_object['user']) ){
957 switch($this->current_object['template']){
958 case 'activity':
959 $args = array(
960 'offset' => ($current_object['paged'] - 1) * $this->current_object['items_per_page'],
961 'row_count' => $this->current_object['items_per_page'],
962 'userid' => $current_object['userid'],
963 'orderby' => '`created` DESC, `postid` DESC',
964 'check_private' => true
965 );
966 $current_object['items_count'] = 0;
967 $current_object['activities'] = $this->post->get_posts( $args, $current_object['items_count']);
968 break;
969 case 'subscriptions':
970 $args = array(
971 'offset' => ($current_object['paged'] - 1) * $this->current_object['items_per_page'],
972 'row_count' => $this->current_object['items_per_page'],
973 'userid' => $current_object['userid'],
974 'order' => 'DESC'
975 );
976 $current_object['items_count'] = 0;
977 $current_object['subscribes'] = $this->sbscrb->get_subscribes( $args, $current_object['items_count']);
978 break;
979 case 'account':
980 $this->data['template'] = 'account';
981 $this->data['varname'] = 'member';
982 $this->data['value'] = array_merge($current_object['user'], (array) wpfval($_POST, 'member'));
983 break;
984 default:
985 $this->data['template'] = 'profile';
986 $this->data['value'] = $current_object['user'];
987 break;
988 }
989 }else{
990 if( !$this->current_userid ){
991 wp_safe_redirect( wpforo_login_url() );
992 exit();
993 }
994 $current_object['is_404'] = true;
995 }
996
997 }else{
998 $current_object['is_404'] = true;
999 }
1000 }
1001
1002 if( wpfval($current_object, 'topic_slug') ){
1003 $topic = $this->topic->get_topic(array('slug' => $current_object['topic_slug']), false);
1004 if(!empty($topic)){
1005
1006 $topic_forumid = intval( wpfval($topic, 'forumid') );
1007 $is_owner = wpforo_is_owner($topic['userid'], $topic['email']);
1008
1009 if( $topic_forumid && (
1010 !WPF()->perm->forum_can('vf', $topic_forumid) ||
1011 ( !$is_owner && !WPF()->perm->forum_can('vt', $topic_forumid) ) ||
1012 ( wpfval($topic, 'private') && !$is_owner && !WPF()->perm->forum_can('vp', $topic_forumid) ) ||
1013 ( wpfval($topic, 'status') && !$is_owner && !WPF()->perm->forum_can('au', $topic_forumid) )
1014 ) ){
1015 if( !$this->current_userid ){
1016 wp_safe_redirect( wpforo_login_url() );
1017 exit();
1018 }
1019 $current_object['is_404'] = true;
1020 }else{
1021 $current_object['topic'] = $topic;
1022 $current_object['topicid'] = $topic['topicid'];
1023 $current_object['og_text'] = (string) wpfval($topic, 'title');
1024 }
1025
1026 }else{
1027 $current_object['is_404'] = true;
1028 }
1029 }
1030
1031 if( wpfval($current_object, 'forum_slug') ){
1032 $args = ( empty($topic) ? array('slug' => $current_object['forum_slug']) : $topic['forumid'] );
1033 if( $forum = $this->forum->get_forum( $args ) ){
1034 if( !empty($topic) && strtolower($current_object['forum_slug']) !== strtolower($forum['slug']) ){
1035 wp_safe_redirect( $this->topic->get_topic_url($topic, $forum), 301 );
1036 exit();
1037 }
1038 if( $forum['is_cat'] ) $this->current_object['template'] = 'forum';
1039 $current_object['forum'] = $forum;
1040 $current_object['forumid'] = $forum['forumid'];
1041 $current_object['forum_desc'] = $forum['description'];
1042 $current_object['forum_meta_key'] = $forum['meta_key'];
1043 $current_object['forum_meta_desc'] = $forum['meta_desc'];
1044 $current_object['og_text'] = $forum['title'];
1045 $current_object['layout'] = $this->forum->get_layout( $forum );
1046
1047 if( $this->current_object['template'] === 'topic' ){
1048 $current_object['items_per_page'] = $this->post->options['topics_per_page'];
1049 $args = array(
1050 'offset' => ($current_object['paged'] - 1) * $current_object['items_per_page'],
1051 'row_count' => $current_object['items_per_page'],
1052 'forumid' => $current_object['forumid'],
1053 'orderby' => 'type, modified',
1054 'order' => 'DESC'
1055 );
1056 $args = apply_filters('wpforo_topic_list_args', $args);
1057 $current_object['topics'] = $this->topic->get_topics( $args, $current_object['items_count'] );
1058 }
1059 }else{
1060 $current_object['is_404'] = true;
1061 }
1062 }
1063
1064 if( in_array($this->current_object['template'], array('forum', 'topic')) ){
1065 if( !empty($forum) ){
1066 $current_object['categories'] = array( $forum );
1067 }else{
1068 $current_object['categories'] = $this->forum->get_forums( array( "type" => 'category' ) );
1069 }
1070 }
1071
1072 if ( $this->current_object['template'] === 'post' && ! empty( $forum ) && ! empty( $topic ) ) {
1073 $current_object['items_per_page'] = $this->post->get_option_items_per_page($current_object['layout']);
1074
1075 $args = array(
1076 'forumid' => $forum['forumid'],
1077 'topicid' => $topic['topicid'],
1078 'offset' => ( $current_object['paged'] - 1 ) * $current_object['items_per_page'],
1079 'row_count' => $current_object['items_per_page']
1080 );
1081 if( $current_object['layout'] == 4 ){
1082 $args['parentid'] = 0;
1083 }elseif( $current_object['layout'] == 3 ){
1084 $args['parentid'] = 0;
1085 switch ( $current_object['orderby'] ) {
1086 case 'oldest':
1087 $args['orderby'] = '`is_first_post` DESC, `is_answer` DESC, `created` ASC, `postid` ASC';
1088 break;
1089 case 'newest':
1090 $args['orderby'] = '`is_first_post` DESC, `is_answer` DESC, `modified` DESC, `postid` DESC';
1091 break;
1092 default:
1093 $args['orderby'] = '`is_first_post` DESC, `is_answer` DESC, `votes` DESC, `created` ASC, `postid` ASC';
1094 break;
1095 }
1096 }
1097 if( $this->post->get_option_union_first_post($current_object['layout']) ) $args['union_first_post'] = true;
1098 $args = apply_filters('wpforo_post_list_args', $args);
1099 $current_object['posts'] = $this->post->get_posts( $args, $current_object['items_count']);
1100 }
1101
1102 $this->current_object = wpforo_parse_args($current_object, $this->current_object);
1103
1104 $this->current_object = apply_filters('wpforo_after_init_current_object', $this->current_object, $wpf_url_parse);
1105
1106 if( $this->current_object['template'] ){
1107 /**
1108 * redirect not logged-in users to login page when that user no access to this page
1109 */
1110 if( !$this->current_userid && $this->current_object['forumid'] && (
1111 (in_array($this->current_object['template'], array('forum', 'topic')) && !$this->perm->forum_can('vf', $this->current_object['forumid']))
1112 || ($this->current_object['template'] === 'post' && !$this->perm->forum_can('vt', $this->current_object['forumid']))
1113 )
1114 ){
1115 wp_safe_redirect( wpforo_login_url() );
1116 exit();
1117 }
1118
1119 /**
1120 * redirect to the first page when paged var is greater items_count
1121 */
1122 if( $this->current_object['items_count']
1123 && $this->current_object['paged'] > 1
1124 && (($this->current_object['paged'] - 1) * $this->current_object['items_per_page']) >= $this->current_object['items_count']
1125 ){
1126 wp_safe_redirect( $this->strip_url_paged_var( $this->current_url ), 301 );
1127 exit();
1128 }
1129 }else{
1130 $this->current_object['is_404'] = true;
1131 }
1132 }
1133
1134 public function is_installed(){
1135 return WPFORO_VERSION === get_option('wpforo_version');
1136 }
1137
1138 public function can_use_this_slug($slug){
1139 $return = !in_array($slug, $this->tpl->slugs, true) && !in_array($slug, array_keys($this->tpl->slugs), true);
1140 return apply_filters('wpforo_can_use_this_slug', $return, $slug);
1141 }
1142 }
1143
1144 /**
1145 * Main instance of wpForo.
1146 *
1147 * Returns the main instance of WPF to prevent the need to use globals.
1148 *
1149 * @since 1.4.3
1150 * @return wpForo
1151 */
1152 if ( !function_exists('WPF') ){
1153 function WPF() {
1154 return wpForo::instance();
1155 }
1156 }
1157
1158 // Global for backwards compatibility.
1159 $GLOBALS['wpforo'] = WPF();
1160
1161 //ADDONS/////////////////////////////////////////////////////
1162 WPF()->addons = array(
1163 'prefix' => array('version' => '1.0.0', 'requires' => '1.9.4', 'class' => 'wpForoTopicPrefix', 'title' => 'Topic Prefix & Tag Manager', 'thumb' => WPFORO_URL . '/wpf-assets/addons/prefix/header.png', 'desc' => __('Allows you to create topic prefixes and prefix groups to categorize topics. Also, it allows you to add, edit, delete topic tags and convert them to prefixes.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-topic-prefix/'),
1164 'tenor' => array('version' => '1.0.0', 'requires' => '1.9.8', 'class' => 'wpForoTenor', 'title' => 'Tenor GIFs Integration', 'thumb' => WPFORO_URL . '/wpf-assets/addons/tenor/header.png', 'desc' => __('Adds Tenor [GIF] button and opens popup where you can search for gifs and insert them in topic, post and private message content.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-tenor/'),
1165 'giphy' => array('version' => '1.0.0', 'requires' => '1.9.8', 'class' => 'wpForoGiphy', 'title' => 'GIPHY Integration', 'thumb' => WPFORO_URL . '/wpf-assets/addons/giphy/header.png', 'desc' => __('Adds GIPHY [GIF] button and opens popup where you can search for gifs and insert them in topic, post and private message content.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-giphy/'),
1166 'attachments' => array('version' => '2.0.4', 'requires' => '1.8.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/'),
1167 'embeds' => array('version' => '2.0.7', 'requires' => '1.8.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/'),
1168 'ucf' => array('version' => '2.0.2', 'requires' => '1.8.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/'),
1169 'pm' => array('version' => '1.3.3', 'requires' => '1.8.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/'),
1170 'tcf' => array('version' => '1.0.0', 'requires' => '1.8.0', 'class' => 'wpForoTcf', 'title' => 'Topic Custom Fields', 'thumb' => WPFORO_URL . '/wpf-assets/addons/tcf/header.png', 'desc' => __('Allows to create topic custom fields and manage topic form layout with a form builder. Adds topic search options by custom fields', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-topic-custom-fields/'),
1171 'syntax' => array('version' => '1.0.0', 'requires' => '1.9.0', 'class' => 'wpForoSyntaxHighlighter', 'title' => 'Syntax Highlighter', 'thumb' => WPFORO_URL . '/wpf-assets/addons/syntax/header.png', 'desc' => __('Syntax highlighting for forum posts, automatic language detection and multi-language code highlighting.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-syntax-highlighter/'),
1172 'mycred' => array('version' => '1.1.2', 'requires' => '1.8.0', '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/'),
1173 'cross' => array('version' => '2.1.5', 'requires' => '1.8.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/'),
1174 'ad-manager' => array('version' => '1.1.3', 'requires' => '1.8.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/'),
1175 'polls' => array('version' => '1.0.6', 'requires' => '1.8.0', '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/'),
1176 'emoticons' => array('version' => '1.0.5', 'requires' => '1.8.0', 'class' => 'wpForoSmiles', 'title' => 'wpForo Emoticons', 'thumb' => WPFORO_URL . '/wpf-assets/addons/wpforo-emoticons/header.png', 'desc' => __('Adds awesome Sticker and Emoticons packs to editor. Allows to create new custom emoticons packs.', 'wpforo'), 'url' => 'https://gvectors.com/product/wpforo-emoticons/'),
1177 );
1178 $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'));}
1179 /////////////////////////////////////////////////////////////
1180 }
1181