init_defaults(); $this->init_base_templates(); add_action( 'wpforo_core_inited', function() { $this->init_member_templates(); $this->init_templates(); }, 999 ); $this->init_current_theme( wpforo_setting( 'general', 'current_theme' ) ); add_action( 'wpforo_after_init', function() { $this->init_hooks(); $this->init_nav_menu(); } ); } private function init_hooks() { if( is_wpforo_page() ) { add_filter( "mce_external_plugins", [ $this, 'add_mce_external_plugins' ], 15 ); add_filter( "tiny_mce_plugins", [ $this, 'filter_tinymce_plugins' ], 15 ); add_filter( "wp_mce_translation", [ $this, 'add_tinymce_translations' ] ); add_filter( "wpforo_editor_settings", [ $this, 'editor_settings_required_params' ], 999 ); add_action( 'wpforo_topic_form_extra_fields_after', [ $this, 'add_default_attach_input' ] ); add_action( 'wpforo_reply_form_extra_fields_after', [ $this, 'add_default_attach_input' ], 10, 1 ); add_action( 'wpforo_portable_form_extra_fields_after', [ $this, 'add_default_attach_input' ] ); add_filter( 'is_wpforo_attach_page_templates', function( $templates ) { $templates[] = 'add-topic'; return $templates; } ); add_filter( 'wpforo_emoticons_loading_template', function( $templates ) { $templates[] = 'add-topic'; return $templates; } ); add_action( 'wp_footer', [ $this, 'add_footer_html' ], 999999 ); add_action( 'wpforo_profile_head_right', function( $user ) { echo $this->change_cover_button( $user ); } ); //ajax actions hooks add_action( 'wp_ajax_wpforo_active_tab_content_ajax', [ $this, 'ajx_active_tab_content' ] ); } add_filter( 'wpforo_content_after', [ $this, 'do_spoilers' ] ); add_filter( 'wpforo_content_after', [ $this, 'apply_quotes' ] ); add_action( 'wpforo_register_form_end', function() { echo ''; } ); add_action( 'wpforo_login_form_end', function() { wp_nonce_field( 'login', '_wpfnonce', false ); echo ''; } ); add_action( 'wpforo_profile_account_bottom', function() { echo ''; } ); } private function init_defaults() { $this->default = new stdClass; $this->default->editor_settings = [ 'media_buttons' => false, 'textarea_name' => '', 'textarea_rows' => 15, 'tabindex' => '', 'editor_height' => 130, 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'plugins' => 'hr,lists,textcolor,paste,wpautoresize,fullscreen,wordpress', 'external_plugins' => [ 'wpforo_pre_button' => WPFORO_URL . '/assets/js/tinymce-pre.js', 'wpforo_link_button' => WPFORO_URL . '/assets/js/tinymce-link.js', 'wpforo_spoiler_button' => WPFORO_URL . '/assets/js/tinymce-spoiler.js', 'wpforo_source_code_button' => WPFORO_URL . '/assets/js/tinymce-code.js', 'emoticons' => WPFORO_URL . '/assets/js/tinymce-emoji.js', 'wpfaeditimage' => WPFORO_URL . '/assets/js/tinymce-figure-align.js', ], 'tinymce' => [ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,wpf_spoil,undo,redo,pastetext,source_code,emoticons,fullscreen', 'toolbar2' => '', 'toolbar3' => '', 'toolbar4' => '', 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;} pre{border-left: 3px solid #ccc; outline: none !important; background: #fafcff;padding: 10px;font-size: 14px;margin: 20px 0 0 10px;display: block;width: 100%;} img.emoji{width: 20px;}', 'object_resizing' => false, 'autoresize_on_init' => true, 'wp_autoresize_on' => true, 'wp_keep_scroll_position' => true, 'indent' => true, 'add_unload_trigger' => false, 'wpautop' => false, 'setup' => 'wpforo_tinymce_setup', 'content_css' => '', 'extended_valid_elements' => 'i[class|style],span[class|style]', 'custom_elements' => '', ], 'quicktags' => false, 'default_editor' => 'tinymce', ]; $this->default->template = [ 'type' => 'html', 'key' => '', 'slug' => '', 'menu_shortcode' => '', 'callback_for_can_view_menu' => null, 'ico' => '', 'title' => '', 'callback_for_page' => null, 'callback_for_get_url' => null, 'value' => '', 'status' => 1, 'is_default' => 0, 'callback_for_can' => null, 'can' => '', 'callback_for_can_view_member_menu' => null, 'add_in_member_menu' => 1, 'add_in_member_buttons' => 0, ]; $this->default->base_templates = [ 'members' => [ 'type' => 'callback', 'key' => 'members', 'slug' => 'participants', 'title' => 'Members', 'callback_for_get_url' => function() { return wpforo_members_url(); }, 'is_default' => 1, 'can' => 'vmem', 'callback_for_page' => function() { require wpftpl( 'members.php' ); }, ], 'register' => [ 'type' => 'callback', 'key' => 'register', 'slug' => 'sign-up', 'title' => 'Register', 'callback_for_get_url' => function() { return wpforo_register_url(); }, 'callback_for_can_view_menu' => function() { return ( ! wpforo_is_bot() && ! WPF()->current_userid && ( wpforo_setting( 'authorization', 'user_register' ) || wpforo_setting( 'authorization', 'register_url' ) ) ); }, 'is_default' => 1, 'callback_for_page' => function() { require wpftpl( 'register.php' ); }, ], 'login' => [ 'type' => 'callback', 'key' => 'login', 'slug' => 'sign-in', 'title' => 'Login', 'callback_for_get_url' => function() { return wpforo_login_url(); }, 'callback_for_can_view_menu' => function() { return ! wpforo_is_bot() && ! WPF()->current_userid; }, 'is_default' => 1, 'callback_for_page' => function() { require wpftpl( 'login.php' ); }, 'callback_for_can' => function() { return ! wpforo_is_bot() && ! WPF()->current_userid; }, ], 'lostpassword' => [ 'type' => 'callback', 'key' => 'lostpassword', 'slug' => 'change-password', 'title' => 'Lost your password', 'callback_for_get_url' => function() { return wpforo_lostpassword_url(); }, 'callback_for_can_view_menu' => function() { return ! wpforo_is_bot() && ! WPF()->current_userid; }, 'is_default' => 1, 'callback_for_page' => function() { if( wpfval( WPF()->GET, 'wpfaction' ) === 'resetpassword_form' ) { echo do_shortcode( '[wpforo-resetpassword]' ); } else { echo do_shortcode( '[wpforo-lostpassword]' ); } }, ], 'logout' => [ 'type' => 'callback', 'key' => 'logout', 'slug' => 'sign-out', 'title' => 'Logout', 'callback_for_get_url' => function() { return wpforo_logout_url(); }, 'callback_for_can_view_menu' => function() { return ! wpforo_is_bot() && WPF()->current_userid; }, 'is_default' => 1, 'callback_for_can' => function() { return ! wpforo_is_bot() && WPF()->current_userid; }, ], 'member' => [ 'type' => 'callback', 'key' => 'member', 'slug' => 'participant', 'ico' => '', 'title' => 'Profile', 'is_default' => 1, 'can' => 'vprf', 'callback_for_page' => function() { require wpftpl( 'profile.php' ); }, ], 'cantlogin' => [ 'type' => 'callback', 'key' => 'cantlogin', 'slug' => 'login-message', 'title' => 'Can\'t Login', 'is_default' => 1, 'callback_for_can' => function() { return (bool) WPF()->ram_cache->get( 'USER_LOGIN_REFERER' ); }, 'callback_for_page' => function() { echo $this->cantlogin_page(); }, 'callback_for_can_view_menu' => '__return_false', 'add_in_member_menu' => 0, 'add_in_member_buttons' => 0, ], ]; $this->default->member_templates = [ 'profile' => [ 'type' => 'callback', 'key' => 'profile', 'menu_shortcode' => 'wpforo-profile-home', 'ico' => '', 'title' => 'Profile', 'is_default' => 1, 'can' => 'vprf', 'add_in_member_menu' => 1, 'add_in_member_buttons' => 1, 'callback_for_page' => function() { require wpftpl( 'profile-home.php' ); }, ], 'account' => [ 'type' => 'callback', 'key' => 'account', 'menu_shortcode' => 'wpforo-profile-account', 'ico' => '', 'title' => 'Account', 'is_default' => 1, 'can' => 'em', 'add_in_member_menu' => 0, 'add_in_member_buttons' => 1, 'callback_for_page' => function() { if( WPF()->perm->user_can_edit_account() ) { require wpftpl( 'profile-account.php' ); } else { printf( '

%1$s

', wpforo_phrase( 'You should have minimum number of approved posts to be able edit your profile information', false ) ); } }, ], 'activity' => [ 'type' => 'callback', 'key' => 'activity', 'menu_shortcode' => 'wpforo-profile-activity', 'ico' => '', 'title' => 'Activity', 'is_default' => 1, 'can' => 'vpra', 'add_in_member_menu' => 1, 'add_in_member_buttons' => 1, 'callback_for_page' => function() { require wpftpl( 'profile-activity.php' ); }, ], 'favored' => [ 'type' => 'callback', 'key' => 'favored', 'menu_shortcode' => 'wpforo-profile-favored', 'ico' => '', 'title' => 'Favored', 'is_default' => 1, 'can' => 'l', 'add_in_member_menu' => 1, 'add_in_member_buttons' => 1, 'callback_for_page' => function() { require wpftpl( 'profile-favored.php' ); }, ], ]; $this->default->templates = [ 'add-topic' => [ 'type' => 'callback', 'key' => 'add-topic', 'title' => 'Add New Topic', 'is_default' => 1, 'callback_for_page' => function() { echo '
'; printf( '

%1$s

', wpforo_phrase( 'Add New Topic', false ) ); $forumid = (int) wpfval( WPF()->current_object['qvars'], 0 ); $this->portable_topic_form( $forumid ); echo '
'; }, 'can' => 'vt_add_topic', ], 'recent' => [ 'type' => 'callback', 'key' => 'recent', 'title' => 'Recent Posts', 'is_default' => 1, 'callback_for_page' => function() { require wpftpl( 'recent.php' ); }, ], 'tags' => [ 'type' => 'callback', 'key' => 'tags', 'title' => 'Tags', 'is_default' => 1, 'callback_for_page' => function() { require wpftpl( 'tags.php' ); }, ], 'recent-activity' => [ 'type' => 'callback', 'key' => 'recent-activity', 'menu_shortcode' => 'recent-activity', 'title' => 'What\'s New', 'is_default' => 1, 'callback_for_page' => function() { require wpftpl( 'activity.php' ); }, ], ]; } /** * initialize base templates */ private function init_base_templates() { $this->base_templates = $this->default->base_templates; $this->base_templates = (array) apply_filters( 'wpforo_init_base_templates', $this->base_templates ); do_action( 'wpforo_after_init_base_templates', $this->base_templates ); } /** * initialize templates */ private function init_member_templates() { $this->member_templates = $this->default->member_templates; $this->member_templates = (array) apply_filters( 'wpforo_init_member_templates', $this->member_templates ); do_action( 'wpforo_after_init_member_templates', $this->member_templates ); } /** * initialize templates */ private function init_templates() { $this->templates = $this->default->templates; $this->templates = (array) apply_filters( 'wpforo_init_templates', $this->templates ); do_action( 'wpforo_after_init_templates', $this->templates ); } /** * initialize templates paths */ private function init_paths() { if( ! $this->paths && function_exists( 'wpftpl' ) ) { $this->paths = [ '404' => wpftpl( '404.php' ), 'search' => wpftpl( 'search.php' ), 'forum' => wpftpl( 'forum.php' ), 'topic' => wpftpl( 'topic.php' ), 'post' => wpftpl( 'post.php' ), ]; $this->paths = apply_filters( 'wpforo_init_template_paths', $this->paths ); } } /** * @param array|string $template * * @return array */ private function fix_template( $template ) { if( is_string( $template ) ) { $t = $this->default->template; $t['key'] = $template; $t['menu_shortcode'] = $template; $t['title'] = ucfirst( (string) $template ); return $t; } else { $template = wpforo_settype( $template, 'array' ); if( is_array( $template ) ) { $template = array_merge( $this->default->template, $template ); if( ! $template['ico'] = trim( (string) $template['ico'] ) ) { $template['ico'] = ''; } return $template; } } return $this->default->template; } /** * @param array $template * * @return bool */ private function is_template( &$template ) { $key = wpfval( $template, 'key' ); if( wpfval( $template, 'type' ) && $key && is_string( $key ) ) { $template = $this->fix_template( $template ); return true; } return false; } /** * @param array|string $template * @param array $member * @param bool $default * * @return bool */ public function can_view_template( $template, $member = [], $default = false ) { if( $template = $this->get_template( $template ) ) { if( (int) $template['status'] ) { if( ! is_callable( $template['callback_for_can'] ) ) { if( $template['can'] ) { $userid = wpforo_bigintval( wpfval( $member, 'userid' ) ); if( $userid && $userid === WPF()->current_userid && wpforo_is_member_template( $template ) ) { return true; } else { return (bool) WPF()->usergroup->can( $template['can'] ); } } else { return true; } } else { return (bool) call_user_func( $template['callback_for_can'], $template, $member, $default ); } } } return $default; } /** * @param array|string $template * * @return string */ public function get_key( $template = null ) { if( ! $template ) $template = WPF()->current_object['template']; return is_string( $template ) ? $template : (string) wpfval( $template, 'key' ); } /** * @param array|string $template * * @return string */ private function get_menu_shortcode( $template ) { $menu_shortcode = ''; if( $template = $this->get_template( $template ) ) { $menu_shortcode = sanitize_title( trim( (string) $template['menu_shortcode'], '%/' ) ); if( ! $menu_shortcode ) $menu_shortcode = $template['key']; if( strpos( (string) $menu_shortcode, 'wpforo-' ) !== 0 ) $menu_shortcode = 'wpforo-' . $menu_shortcode; } return $menu_shortcode; } /** * @param array|string $template * @param array $args * @param string $default * * @return string */ private function get_url( $template, $args = [], $default = '' ) { $return = $default ?: '#'; if( $template = $this->get_template( $template ) ) { if( is_callable( $template['callback_for_get_url'] ) ) { $return = call_user_func( $template['callback_for_get_url'], $template, $args, $default ); } elseif( wpfval( $args, 'userid' ) && wpfval( $args, 'user_nicename' ) && wpforo_is_member_template( $template ) ) { $return = WPF()->member->get_profile_url( $args, $template['key'] ); } elseif( ! $default && $slug = wpforo_settings_get_slug( $template['key'] ) ) { $return = wpforo_home_url( $slug ); } } return $return; } /** * @param array|string $template * * @return string */ public function get_template_path( $template ) { $this->init_paths(); $path = (string) wpfval( $this->paths, $this->get_key( $template ) ); return apply_filters( 'wpforo_get_template_path', $path, $template ); } /** * @param bool $only_enableds * @param bool $only_defaults * @param array $__templates * * @return array */ public function get_templates( $only_enableds = true, $only_defaults = false, $__templates = [] ) { $templates = []; if( ! $__templates ) $__templates = array_merge( (array) $this->base_templates, (array) $this->member_templates, (array) $this->templates ); foreach( $__templates as $key => $template ) { if( $this->is_template( $template ) && ( ! $only_enableds || $template['status'] ) && ( ! $only_defaults || $template['is_default'] ) ) { $templates[ $key ] = $template; } } return $templates; } /** * @param bool $only_enableds * @param bool $only_defaults * * @return array */ public function get_member_templates( $only_enableds = true, $only_defaults = false ) { return $this->get_templates( $only_enableds, $only_defaults, $this->member_templates ); } /** * @param bool $only_enableds * @param bool $only_defaults * * @return array */ public function get_templates_list( $only_enableds = true, $only_defaults = false ) { return array_keys( $this->get_templates( $only_enableds, $only_defaults ) ); } /** * @param bool $only_enableds * @param bool $only_defaults * * @return array */ public function get_member_templates_list( $only_enableds = true, $only_defaults = false ) { return array_keys( $this->get_member_templates( $only_enableds, $only_defaults ) ); } /** * @param array|string $template * * @return array */ public function get_template( $template = null ) { $return = []; if( ! $template ) $template = WPF()->current_object['template']; if( is_string( $template ) ) { $templates = $this->get_templates(); if( $t = (array) wpfval( $templates, $template ) ) { $return = $t; } else { $return = $this->fix_template( $template ); } } elseif( is_array( $template ) ) { $return = $this->fix_template( $template ); } return ( $this->is_template( $return ) ? $return : [] ); } /** * show given template * * @param array|string $template */ public function show_template( $template = null ) { if( $template = $this->get_template( $template ) ) { if( $template['type'] === 'callback' && is_callable( $template['callback_for_page'] ) ) { ?>
show_msg( wpforo_phrase( 'Your template is not found', false ) ); } } public function member_menu() { if( $templates = $this->get_member_templates() ) { foreach( $templates as $key => $template ) { if( is_callable( $template['callback_for_can_view_member_menu'] ) ) { $can_view = call_user_func( $template['callback_for_can_view_member_menu'] ); } else { $can_view = (bool) $template['add_in_member_menu']; } if( $can_view && $this->can_view_template( $template, WPF()->current_object['user'] ) ) { printf( '%3$s %4$s', WPF()->current_object['template'] === $key ? 'wpforo-active' : '', esc_url( $this->get_url( $template, WPF()->current_object['user'], WPF()->member->get_profile_url( WPF()->current_object['user'], $key ) ) ), $template['ico'], wpforo_phrase( $template['title'], false ) ); } } } } public function member_buttons( $member, $called_from = '' ) { if( wpforo_bigintval( wpfval( $member, 'userid' ) ) && WPF()->usergroup->can( 'vprf' ) ) { if( $templates = $this->get_member_templates() ) { foreach( $templates as $template ) { if( $template['add_in_member_buttons'] && $this->can_view_template( $template, $member ) ) { printf( '%4$s', wpforo_phrase( $template['title'], false ), esc_url( $this->get_url( $template, $member, WPF()->member->get_profile_url( $member, $template['key'] ) ) ), ( ( $button_attrs = wpfval( $template, 'button_attrs' ) ) ? implode( ' ', array_map( function( $attr, $attrval ) use ( $called_from ) { return sprintf( '%1$s="%2$s"', $attr, ( is_callable( $attrval ) ? call_user_func( $attrval, $called_from ) : $attrval ) ); }, array_keys( $button_attrs ), $button_attrs ) ) : '' ), $template['ico'] ); } } } do_action( 'wpforo_member_info_buttons', $member ); } } public function get_member_actions_html( $user ) { $html = ''; foreach( WPF()->member->get_actions( $user ) as $key => $action ) { $data = []; if( $action['data'] ) foreach( $action['data'] as $k => $v ) $data[] = "data-$k=\"$v\""; $_html = sprintf( '%5$s', $key, $action['label'], implode( ' ', $data ), ( $action['confirm_msg'] ? 'onclick="return wpforo_confirm(\'' . $action['confirm_msg'] . '\', event)"' : '' ), $action['ico'] ); $url = ( is_callable( $action['callback_for_get_url'] ) ? call_user_func( $action['callback_for_get_url'] ) : '' ); $html .= ( $url ? sprintf( '%2$s', $url, $_html ) : $_html ); } return $html ? sprintf( '
%1$s
', $html ) : ''; } public function member_template( $template = null ) { if( $template = $this->get_template( $template ) ) { if( $this->can_view_template( $template, WPF()->current_object['user'] ) ) { $this->show_template( $template ); } else { $this->show_msg( wpforo_phrase( 'You do not have permission to view this page', false ) ); } } else { $this->show_msg( wpforo_phrase( 'Your template has not found', false ) ); } } public function show_msg( $msg ) { ?>
get_template( $template ) ) { if( $this->can_view_template( $template, WPF()->current_user ) ) { if( ! is_callable( $template['callback_for_can_view_menu'] ) ) { if( wpforo_is_member_template( $template ) ) { $can_view = (bool) WPF()->current_userid; } else { $can_view = true; } } else { $can_view = (bool) call_user_func( $template['callback_for_can_view_menu'], $template, $default ); } } } return $can_view; } function init_nav_menu() { $actives = []; $is_active = in_array( WPF()->current_object['template'], [ 'forum', 'topic', 'post' ] ); $this->menu['wpforo-home'] = [ 'href' => wpforo_home_url(), 'label' => wpforo_phrase( 'forums', false ), 'is_active' => $is_active && ! in_array( true, $actives ), ]; $actives['wpforo-home'] = $is_active; $is_active = WPF()->current_object['template'] === 'recent' && wpfval( WPF()->GET, 'view' ) === 'prefix'; $this->menu['wpforo-unread'] = [ 'href' => wpforo_home_url( wpforo_settings_get_slug( 'recent' ) . '?view=unread' ), 'label' => wpforo_phrase( 'Unread Posts', false ), 'is_active' => $is_active && ! in_array( true, $actives ), ]; $actives['wpforo-unread'] = $is_active; if( $templates = $this->get_templates() ) { $cot_is_member_template = wpforo_is_member_template(); foreach( $templates as $key => $template ) { if( $this->can_view_nav_menu( $template ) ) { $is_active = ( $key === WPF()->current_object['template'] && ( ! $cot_is_member_template || WPF( )->current_object['user_is_same_current_user'] ) ) || ( $key === 'profile' && $cot_is_member_template && WPF( )->current_object['user_is_same_current_user'] ); $default_url = wpforo_is_member_template( $template ) ? WPF()->member->get_profile_url( WPF()->current_user, $key ) : ''; $shortcode = $this->get_menu_shortcode( $template ); $this->menu[ $shortcode ] = [ 'href' => $this->get_url( $template, WPF()->current_user, $default_url ), 'label' => wpforo_phrase( $template['title'], false ), 'is_active' => $is_active && ! in_array( true, $actives ), ]; if( $key !== 'profile' ) $actives[ $shortcode ] = $is_active; } } } $this->menu = apply_filters( 'wpforo_menu_array_filter', $this->menu ); } function has_menu() { return has_nav_menu( 'wpforo-menu' ); } function nav_menu() { $location = wpforo_prefix_slug( 'menu' ); if( has_nav_menu( $location ) ) { $defaults = [ 'theme_location' => $location, 'menu' => '', 'container' => '', 'container_class' => '', 'container_id' => '', 'menu_class' => 'wpf-menu', 'menu_id' => 'wpf-menu', 'echo' => false, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '', 'depth' => 0, 'walker' => '', ]; $menu = wp_nav_menu( $defaults ); // Remove whitespace between menu items to prevent gaps with inline-block display $menu = preg_replace( '/>\s+<', $menu ); echo $menu; } } private function init_current_theme( $theme ) { if( ! $this->theme_exists( $theme ) ) $theme = '2026'; $this->theme = $theme; $this->theme_info = $this->find_theme( $this->theme ); $this->template_dir = wpforo_fix_dir_sep( WPFORO_THEME_DIR . '/' . $this->theme ); $this->template_url = WPFORO_THEME_URL . '/' . $this->theme; } function add_mce_external_plugins() { $plugin_array = []; $plugin_array['wpforo_pre_button'] = WPFORO_URL . '/assets/js/tinymce-pre.js'; $plugin_array['wpforo_link_button'] = WPFORO_URL . '/assets/js/tinymce-link.js'; $plugin_array['wpforo_spoiler_button'] = WPFORO_URL . '/assets/js/tinymce-spoiler.js'; $plugin_array['wpforo_source_code_button'] = WPFORO_URL . '/assets/js/tinymce-code.js'; $plugin_array['emoticons'] = WPFORO_URL . '/assets/js/tinymce-emoji.js'; // Centralized figure alignment plugin (applies to attachments, GIPHY, Tenor) $plugin_array['wpfaeditimage'] = WPFORO_URL . '/assets/js/tinymce-figure-align.js'; return $plugin_array; } function filter_tinymce_plugins() { return [ 'hr', 'lists', 'textcolor', 'paste', 'wpautoresize', 'fullscreen', 'wordpress' ]; } function add_tinymce_translations( $mce_translation ) { $mce_translation['Insert link'] = __( 'Insert link' ); $mce_translation['Link Text'] = __( 'Link Text' ); $mce_translation['Open link in a new tab'] = __( 'Open link in a new tab' ); $mce_translation['Insert Spoiler'] = __( 'Insert Spoiler', 'wpforo' ); $mce_translation['Spoiler'] = __( 'Spoiler', 'wpforo' ); return $mce_translation; } public function add_default_attach_input( $forumid = null ) { if( WPF()->perm->can_attach( $forumid ) ) { ?>

perm->forum_can( 'ct', $forumid ) ) { $this->portable_topic_form( null, $forumid ); } } public function portable_topic_form( $forumid = null, $parent_forumid = null ) { WPF()->current_object['load_tinymce'] = true; $uniqid = uniqid(); ?>
topic_form( $forumid ); ?>
current_object['forum']; if( is_scalar( $forum ) ) $forum = WPF()->forum->get_forum( (int) $forum ); if( ! $forum ) return; $forumid = intval( $forum['forumid'] ); $layout = WPF()->forum->get_layout( $forum ); $uniqid = uniqid(); WPF()->form->current['varname'] = 'thread'; ?>
post->get_topic_fields( $forum, $values, ! WPF()->current_userid ) ) ?>
perm->forum_can( 's', $forumid ) ) : ?>         |      perm->forum_can( 'p', $forumid ) || WPF()->perm->forum_can( 'op', $forumid ) ) : ?>      
perm->forum_can( 'tag', $forumid ) ) : ?>

current_object['topic']; if( is_scalar( $topic ) ) $topic = wpforo_topic( $topic ); $forum = WPF()->forum->get_forum( wpfval( $topic, 'forumid' ) ); if( wpfval( $topic, 'closed' ) ) return; $layout = $topic['layout'] = WPF()->forum->get_layout( $forum ); WPF()->form->current['varname'] = 'post'; $style = ( $layout === 3 && ! wpforo_setting( 'posting', 'qa_display_answer_editor' ) ) ? 'style="display: none;"' : ''; $parentid = ( $layout === 3 && ! WPF()->topic->can_answer( $topic['topicid'] ) ) ? wpforo_bigintval( wpfval( $topic, 'first_postid' ) ) : 0; $v = $values; if( ! trim( (string) wpfval( $v, 'title' ) ) ) $v['title'] = $topic['title']; ?>
>

post->get_post_fields( $forum, $topic, $v, ! WPF()->current_userid ) ); ?>
post_form(); } else { $this->post_form_simple(); } } } public function post_form_simple() { if( wpfval( WPF()->current_object, 'topic', 'closed' ) ) return; $textareaid = uniqid( 'wpf_post_body_' ); $topicid = wpforo_bigintval( wpfval( WPF()->current_object, 'topicid' ) ); $topic = WPF()->current_object['topic']; $forum = WPF()->current_object['forum']; $layout = WPF()->forum->get_layout(); $bodyminlength = ( $layout == 3 ? wpforo_setting( 'posting', 'comment_body_min_length' ) : wpforo_setting( 'posting', 'post_body_min_length' ) ); $bodymaxlength = ( $layout == 3 ? wpforo_setting( 'posting', 'comment_body_max_length' ) : wpforo_setting( 'posting', 'post_body_max_length' ) ); $submit_ico = ( $layout == 3 ? '' : '' ); $submit_value = ( $layout == 3 ? wpforo_phrase( 'Add a comment', false ) : wpforo_phrase( 'Reply', false ) ); $uniqid = uniqid(); ?> current_object, 'topic', 'closed' ) ) return; $textareaid = uniqid( 'wpf_post_body_' ); $topicid = wpforo_bigintval( wpfval( WPF()->current_object, 'topicid' ) ); $topic = WPF()->current_object['topic']; $forum = WPF()->current_object['forum']; $layout = WPF()->forum->get_layout(); $bodyminlength = ( $layout == 3 ? wpforo_setting( 'posting', 'comment_body_min_length' ) : wpforo_setting( 'posting', 'post_body_min_length' ) ); $bodymaxlength = ( $layout == 3 ? wpforo_setting( 'posting', 'comment_body_max_length' ) : wpforo_setting( 'posting', 'post_body_max_length' ) ); $submit_ico = ( $layout == 3 ? '' : '' ); $submit_value = ( $layout == 3 ? wpforo_phrase( 'Add a comment', false ) : wpforo_phrase( 'Reply', false ) ); $uniqid = uniqid(); ?> '', 'id' => '', 'class' => '', 'icon' => '', 'active' => false ]; ?>
 

post->get_posts( [ 'topicid' => WPF()->current_object['topicid'] ] ) ) return; if( count( $posts ) < 2 ) return; ?>

post->get_posts( [ 'topicid' => WPF()->current_object['topicid'] ] ) ) return; if( count( $posts ) < 2 ) return; ?>

current_object['topicid'] ) ) return; if( ! $topicid ) $topicid = WPF()->current_object['topicid']; ?>

post->get_search_fields( (array) wpfval( $_GET, 'data' ) ); ?>
 :
 :
>
 :
 :

 :

board, 'get_current' ] ) ? WPF()->board->get_current( 'boardid' ) : 0 ); ?>
current_object['paged']; if( is_null( $items_count ) ) $items_count = WPF()->current_object['items_count']; if( is_null( $items_per_page ) ) $items_per_page = WPF()->current_object['items_per_page']; if( $items_count <= $items_per_page ) return; $pages_count = ceil( $items_count / $items_per_page ); $current_url = ( WPF()->current_url ? WPF()->current_url : wpforo_get_request_uri() ); $sanitized_current_url = trim( WPF()->strip_url_paged_var( $current_url ), '/' ); $permalink = apply_filters( 'wpforo_pagenavi_permalink', $permalink, $paged, $items_count, $items_per_page, $class ); $sanitized_current_url = apply_filters( 'wpforo_pagenavi_current_url', $sanitized_current_url, $paged, $items_count, $items_per_page, $class ); if( $permalink ) { $rtrimed_url = ''; $url_append_vars = ''; if( preg_match( '#^(.+?)(/?[?&].*)?$#isu', $sanitized_current_url, $match ) ) { if( wpfval( $match, 1 ) ) $rtrimed_url = rtrim( $match[1], '/\\' ); if( wpfval( $match, 2 ) ) $url_append_vars = '?' . trim( $match[2], '?&/\\' ); } $url = str_replace( '%', '%%', $rtrimed_url . '/' . wpforo_settings_get_slug( 'paged' ) ) . '/%1$d/' . str_replace( '%', '%%', $url_append_vars ); } else { $url = str_replace( '%', '%%', $sanitized_current_url ) . '&wpfpaged=%1$d'; } $url = apply_filters( 'wpforo_pagenavi_url', $url, $paged, $items_count, $items_per_page, $permalink, $class ); ?>
/ 0 ): $prev_url = ( ( $paged - 1 ) == 1 ? $sanitized_current_url : sprintf( $url, $paged - 1 ) ); ?>
current_userid && wpforo_is_owner( $userid ) ); $mention = (string) ( ! $is_owner && wpforo_setting( 'profiles', 'mention_nicknames' ) ? wpforo_member( $post, 'user_nicename' ) : '' ); } else { $userid = 0; $is_owner = 0; $mention = ''; } $is_sticky = ( isset( $topic['type'] ) ) ? $topic['type'] : 0; $is_closed = ( isset( $topic['closed'] ) ) ? $topic['closed'] : 0; $is_private = ( isset( $topic['private'] ) ) ? $topic['private'] : 0; $is_solved = ( isset( $topic['solved'] ) ) ? $topic['solved'] : 0; $is_approve = ( isset( $post['status'] ) ) ? $post['status'] : 0; foreach( $buttons as $button ) { switch( $button ) { case 'reply': if( $is_closed || $is_approve || ( $is_topic && ! wpforo_setting( 'topics', 'layout_threaded_first_post_reply' ) ) ) break; if( WPF()->perm->forum_can( 'cr', $forumid ) || ( wpforo_is_owner( wpforo_bigintval( wpfval( $topic, 'userid' ) ), (string) wpfval( $topic, 'email' ) ) && WPF()->perm->forum_can( 'ocr', $forumid ) ) ) { $layout = WPF()->forum->get_layout( $forumid ); $layout_class = 'wpforo_layout_' . $layout; $button_html[] = '' . wpforo_phrase( 'Reply', false ) . ''; } else { $button_html[] = ( $login ) ? '' : '' . wpforo_phrase( 'Reply', false ) . ''; } break; case 'answer': if( $is_closed || $is_approve ) break; if( WPF()->perm->forum_can( 'cr', $forumid ) || ( wpforo_is_owner( wpforo_bigintval( wpfval( $topic, 'userid' ) ), (string) wpfval( $topic, 'email' ) ) && WPF()->perm->forum_can( 'ocr', $forumid ) ) ) { if( WPF()->topic->can_answer( $topicid ) ) { $button_html[] = '' . wpforo_phrase( 'Answer', false ) . ''; } } else { $button_html[] = ( $login ) ? '' : '' . wpforo_phrase( 'Answer', false ) . ''; } break; case 'comment': if( $is_closed || $is_approve || ( $is_topic && ! wpforo_setting( 'topics', 'layout_qa_first_post_reply' ) ) ) break; $title = wpforo_phrase( 'Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false ); if( WPF()->perm->forum_can( 'cr', $forumid ) || ( wpforo_is_owner( wpforo_bigintval( wpfval( $topic, 'userid' ) ), (string) wpfval( $topic, 'email' ) ) && WPF()->perm->forum_can( 'ocr', $forumid ) ) ) { $button_html[] = '' . wpforo_phrase( 'Add a comment', false ) . ''; } else { $button_html[] = ( $login ) ? '' : '' . wpforo_phrase( 'Add a comment', false ) . ''; } break; case 'comment_raw': if( $is_closed || $is_approve || ( $is_topic && ! wpforo_setting( 'topics', 'layout_qa_first_post_reply' ) ) ) break; $title = wpforo_phrase( 'Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.', false ); if( WPF()->perm->forum_can( 'cr', $forumid ) || ( wpforo_is_owner( wpforo_bigintval( wpfval( $topic, 'userid' ) ), (string) wpfval( $topic, 'email' ) ) && WPF()->perm->forum_can( 'ocr', $forumid ) ) ) { $button_html[] = '' . wpforo_phrase( 'Add a comment', false, 'lower' ) . ''; } else { $button_html[] = ( $login ) ? '' : '' . wpforo_phrase( 'Add a comment', false, 'lower' ) . ''; } break; case 'quote': if( $is_closed || $is_approve ) break; if( WPF()->perm->forum_can( 'cr', $forumid ) || ( wpforo_is_owner( wpforo_bigintval( wpfval( $topic, 'userid' ) ), (string) wpfval( $topic, 'email' ) ) && WPF()->perm->forum_can( 'ocr', $forumid ) ) ) { $button_html[] = '' . wpforo_phrase( 'Quote', false ) . ''; } else { $button_html[] = ( $login ) ? '' : '' . wpforo_phrase( 'Quote', false ) . ''; } break; case 'report': if( WPF()->perm->can_report( $forumid ) ) { $button_html[] = '' . wpforo_phrase( 'Report', false ) . ''; } break; case 'sticky': $sticky_status = ( $is_sticky ? 'wpforo-unsticky' : 'wpforo-sticky' ); if( WPF()->perm->forum_can( 's', $forumid ) ) { $button_html[] = '' . wpforo_phrase( str_replace( 'wpforo-', '', $sticky_status ), false ) . ''; } break; case 'private': if( $login ) { if( WPF()->perm->forum_can( 'p', $forumid ) || ( WPF()->current_userid == $post['userid'] && WPF()->perm->forum_can( 'op', $forumid ) ) ) { $private_status = ( $is_private ? 'wpforo-public' : 'wpforo-private' ); $private_icon = ( $private_status == 'wpforo-public' ) ? 'eye' : 'eye-slash'; $button_html[] = '' . wpforo_phrase( str_replace( 'wpforo-', '', $private_status ), false ) . ''; } } break; case 'solved': $solved_status = ( $is_solved ? 'wpforo-unsolved' : 'wpforo-solved' ); if( WPF()->perm->forum_can( 'sv', $forumid ) || ( WPF()->current_userid == $post['userid'] && WPF()->perm->forum_can( 'osv', $forumid ) ) ) { $button_html[] = '' . wpforo_phrase( str_replace( 'wpforo-', '', $solved_status ), false ) . ''; } break; case 'approved': if( WPF()->perm->forum_can( 'au', $forumid ) && $login ) { $approve_status = ( ! $is_approve ? 'wpforo-unapprove' : 'wpforo-approve' ); $approve_icon = ( $approve_status == 'wpforo-unapprove' ) ? 'fa-exclamation-circle' : 'fa-check'; $button_html[] = '' . wpforo_phrase( str_replace( 'wpforo-', '', $approve_status ), false ) . ''; } break; case 'close': if( WPF()->perm->forum_can( 'cot', $forumid ) && $login ) { $open_status = ( $is_closed ? 'wpforo-open' : 'wpforo-close' ); $open_icon = ( $open_status == 'wpforo-open' ) ? 'unlock' : 'lock'; $button_html[] = '' . wpforo_phrase( str_replace( 'wpforo-', '', $open_status ), false ) . ''; } break; case 'tools': if( WPF()->perm->forum_can( 'mt', $forumid ) && $login ) { $button_html[] = '' . wpforo_phrase( 'Tools', false ) . ''; } break; case 'edit': if( $is_closed ) break; $diff = time() - strtotime( $post['created'] . ' GMT' ); $_durr = $is_topic ? wpforo_setting( 'posting', 'edit_own_topic_durr' ) : wpforo_setting( 'posting', 'edit_own_post_durr' ); if( ! $login && isset( $post['email'] ) && wpforo_is_owner( $post['userid'], $post['email'] ) && WPF()->perm->forum_can( ( $is_topic ? 'eot' : 'eor' ), $forumid ) && $diff < $_durr ) { $a = ( $is_topic ) ? 'wpfedittopicpid' : ''; $b = $postid; $button_html[] = '' . wpforo_phrase( 'Edit', false ) . ''; } elseif( $login ) { if( WPF()->perm->forum_can( ( $is_topic ? 'et' : 'er' ), $forumid ) || ( WPF()->current_userid == $post['userid'] && WPF()->perm->forum_can( ( $is_topic ? 'eot' : 'eor' ), $forumid ) && ( $_durr === 0 || $diff < $_durr ) ) ) { $a = ( $is_topic ) ? 'wpfedittopicpid' : ''; $b = $postid; $button_html[] = '' . wpforo_phrase( 'Edit', false ) . ''; } } break; case 'delete': if( $login ) { /*if( WPF()->member->current_user_is_new() && $post['status'] ){ New registered user's unapproved topic/post | No Delete button. }else{*/ $diff = time() - strtotime( $post['created'] . ' GMT' ); $_durr = $is_topic ? wpforo_setting( 'posting', 'delete_own_topic_durr' ) : wpforo_setting( 'posting', 'delete_own_post_durr' ); if( WPF()->perm->forum_can( ( $is_topic ? 'dt' : 'dr' ), $forumid ) || ( WPF()->current_userid == $post['userid'] && WPF()->perm->forum_can( ( $is_topic ? 'dot' : 'dor' ), $forumid ) && ( $_durr === 0 || $diff < $_durr ) ) ) { $a = ( $is_topic ) ? 'wpftopicdelete' : 'wpfreplydelete'; $b = ( $is_topic ) ? $topicid : $postid; $button_html[] = '' . wpforo_phrase( 'Delete', false ) . ''; } //} } break; case 'link': $full_url = esc_url( (string) wpforo_post( $postid, 'full_url' ) ); $short_url = esc_url( (string) wpforo_post( $postid, 'short_url' ) ); $title = esc_attr( wpforo_phrase( 'Post link', false ) ); $button_html[] = sprintf( '', $title, $full_url, $short_url ); break; case 'topic-id': if( $topicid && $is_topic ) { $button_html[] = '[#' . intval( $topicid ) . ']'; } break; case 'positivevote': if( WPF()->perm->forum_can( 'v', $forumid ) && $login ) { $button_html[] = ''; } else { $button_html[] = ''; } break; case 'negativevote': if( WPF()->perm->forum_can( 'v', $forumid ) && $login ) { $button_html[] = ''; } else { $button_html[] = ''; } break; case 'isanswer': if( ! $is_topic ) { $has_is_answer_post = WPF()->topic->has_is_answer_post( $post['topicid'] ); $is_answer = (bool) WPF()->post->is_answered( $postid ); $class = ( $is_answer ) ? '' : '-not'; if( ! $has_is_answer_post || $is_answer ) { if( $login ) { $button_html[] = '
'; } else { $button_html[] = '
'; } } } break; case 'custom-top': $button_html = apply_filters( 'wpforo_template_buttons_top', $button_html, $button, $forum, $topic, $post ); break; case 'custom-bottom': $button_html = apply_filters( 'wpforo_template_buttons_bottom', $button_html, $button, $forum, $topic, $post ); break; default: $bh = apply_filters( 'wpforo_template_buttons', '', $button, $forum, $topic, $post ); if( $bh ) $button_html[] = $bh; break; } //switch } //foreach $before = ''; $after = ''; $html = $before . implode( '', $button_html ) . $after; if( $echo ) echo $html; return $html; } /** * display QA Layout Votes count for loop current post * * @param array $post loop current post array * * @return void */ public function vote_count( $post ) { $votes = ( ! empty( $post['votes'] ) ? $post['votes'] : 0 ); printf( '%d', $votes ); } function breadcrumb( $current_object = null ) { if( ! $current_object ) $current_object = WPF()->current_object; $lenght = apply_filters( 'wpforo_breadcrumb_text_length', 19 ); ?>
 
 
 
 
 
 
 
 
 
 
 
forum->get_parents( $current_object['forumid'], $relative_ids ); foreach( $relative_ids as $key => $rel_forumid ) : ?>
 
forum->get_parents( $current_object['forumid'], $relative_ids ); foreach( $relative_ids as $key => $rel_forumid ) : ?>
  get_template( $current_object['template'] ) ) ) : ?>
 
 
 
topic->is_private( $item['topicid'] ) ) { $icon['class'] = 'fas fa-eye-slash'; $icon['color'] = 'wpfcl-1'; $icon['title'] = wpforo_phrase( 'Private', false ); if( $echo ) { $status = true; echo ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } else { return ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } } if( $item['type'] == 1 ) { $icon['class'] = 'fas fa-thumbtack'; $icon['color'] = 'wpfcl-10'; $icon['title'] = wpforo_phrase( 'Sticky', false ); if( $echo ) { $status = true; echo ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } else { return ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } } if( wpforo_topic( $item['topicid'], 'solved' ) ) { $icon['class'] = 'fas fa-check-circle'; $icon['color'] = 'wpfcl-8'; $icon['title'] = wpforo_phrase( 'Solved', false ); if( $echo ) { $status = true; echo ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } else { return ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } } } if( $item['closed'] ) { $icon['class'] = 'fas fa-lock'; $icon['color'] = 'wpfcl-1'; $icon['title'] = wpforo_phrase( 'Closed', false ); if( $echo ) { $status = true; echo ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } else { return ( $data == 'icon' ) ? implode( ' ', $icon ) : $icon['title']; } } if( ! $status ) { if( $type == 'forum' ) { $icon['class'] = 'fas fa-comments'; $icon['color'] = 'wpfcl-2'; } elseif( $type == 'topic' ) { $icon = $this->icon_status( $item['posts'] ); } if( $echo ) { echo ( $data == 'icon' ) ? implode( ' ', $icon ) : ( wpfval( $icon, 'title' ) ? $icon['title'] : '' ); } else { return ( $data == 'icon' ) ? implode( ' ', $icon ) : ( wpfval( $icon, 'title' ) ? $icon['title'] : '' ); } } } return ''; } function icon_status( $item ) { $icon = []; if( wpfval( $item, 'type' ) ) { $icon['sticky']['class'] = 'fas fa-thumbtack'; $icon['sticky']['color'] = 'wpfcl-10'; $icon['sticky']['title'] = wpforo_phrase( 'Sticky', false ); } if( wpfval( $item, 'topicid' ) && wpforo_topic( $item['topicid'], 'solved' ) ) { $icon['is_answer']['class'] = 'fas fa-check-circle'; $icon['is_answer']['color'] = 'wpfcl-8'; $icon['is_answer']['title'] = wpforo_phrase( 'Solved', false ); } if( wpfval( $item, 'closed' ) ) { $icon['closed']['class'] = 'fas fa-lock'; $icon['closed']['color'] = 'wpfcl-1'; $icon['closed']['title'] = wpforo_phrase( 'Closed', false ); } if( wpfval( $item, 'status' ) ) { $icon['status']['class'] = 'fas fa-exclamation-circle'; $icon['status']['color'] = 'wpfcl-5'; $icon['status']['title'] = wpforo_phrase( 'Unapproved', false ); } if( wpfval( $item, 'private' ) ) { $icon['private']['class'] = 'fas fa-eye-slash'; $icon['private']['color'] = 'wpfcl-1'; $icon['private']['title'] = wpforo_phrase( 'Private', false ); } return $icon; } function icon_base( $post_count ) { $icon = []; $min_posts_for_active_topic = (int) apply_filters( 'wpforo_active_topic_min_posts', 5 ); $min_posts_for_hot_topic = (int) apply_filters( 'wpforo_hot_topic_min_posts', 20 ); if( $post_count < 2 ) { $icon['class'] = 'far fa-file'; $icon['color'] = 'wpfcl-2'; $icon['title'] = wpforo_phrase( 'Not Replied', false ); } elseif( $post_count <= $min_posts_for_active_topic ) { $icon['class'] = 'far fa-file-alt'; $icon['color'] = 'wpfcl-2'; $icon['title'] = wpforo_phrase( 'Replied', false ); } elseif( $post_count <= $min_posts_for_hot_topic ) { $icon['class'] = 'fas fa-file-alt'; $icon['color'] = 'wpfcl-2'; $icon['title'] = wpforo_phrase( 'Active', false ); } else { $icon['class'] = 'fa-solid fa-fire-flame-curved'; $icon['color'] = 'wpfcl-5'; $icon['title'] = wpforo_phrase( 'Hot', false ); } return $icon; } public function member_social_buttons( $member ) { $socnets = []; if( empty( $member ) ) return; $social_access = (bool) WPF()->usergroup->can( 'vmsn' ); if( $social_access ) { if( isset( $member['facebook'] ) && $member['facebook'] ) { $socnets['facebook']['set'] = $member['facebook']; $member['facebook'] = ( strpos( (string) $member['facebook'], 'facebook.com' ) === false ) ? 'https://www.facebook.com/' . trim( (string) $member['facebook'], '/' ) : $member['facebook']; $socnets['facebook']['value'] = $member['facebook']; $socnets['facebook']['protocol'] = 'https://'; $socnets['facebook']['title'] = wpforo_phrase( 'Facebook', false ); } if( isset( $member['twitter'] ) && $member['twitter'] ) { $socnets['twitter']['set'] = $member['twitter']; $member['twitter'] = ( strpos( (string) $member['twitter'], 'x.com' ) === false ) ? 'https://x.com/' . trim( (string) $member['twitter'], '/' ) : $member['twitter']; $socnets['twitter']['value'] = $member['twitter']; $socnets['twitter']['protocol'] = 'https://'; $socnets['twitter']['title'] = wpforo_phrase( 'X.com', false ); } if( isset( $member['skype'] ) && $member['skype'] ) { $socnets['skype']['set'] = $member['skype']; $socnets['skype']['value'] = $member['skype']; $socnets['skype']['protocol'] = 'skype:'; $socnets['skype']['title'] = wpforo_phrase( 'Skype', false ); } ?>
$socnet ): ?> <?php echo esc_attr( $title ) ?>
theme_info['layouts']; if( $identifier_type === 'id' ) { return ( isset( $layouts[ $identifier ] ) && ! empty( $layouts[ $identifier ] ) ); } elseif( $identifier_type === 'name' ) { foreach( $layouts as $layout ) { if( ! isset( $layout['name'] ) && $layout['name'] === $identifier ) { return true; } } } return false; } /** * * Finds and returns all layouts information in array from theme's /layouts/ folder * * @param string $theme Theme id ( folder name ) e.g. 'classic' * * @return array * **@since 1.0.0 * */ function find_layouts( $theme = '' ) { if( ! $theme ) $theme = $this->theme; $layout_data = []; $layouts = $this->find_themes( '/' . $theme . '/layouts', 'php', 'layout' ); if( ! empty( $layouts ) ) { foreach( $layouts as $layout ) { $lid = trim( basename( dirname( (string) $layout['file']['value'] ) ), '/' ); $layout_data[ $lid ]['id'] = intval( $lid ); $layout_data[ $lid ]['name'] = esc_html( $layout['name']['value'] ); $layout_data[ $lid ]['version'] = $layout['version']['value']; $layout_data[ $lid ]['description'] = $layout['description']['value']; $layout_data[ $lid ]['author'] = $layout['author']['value']; $layout_data[ $lid ]['url'] = $layout['layout_url']['value']; $layout_data[ $lid ]['file'] = $layout['file']['value']; } } return $layout_data; } function show_layout_selectbox( $layoutid = 0 ) { $layouts = $this->find_layouts(); if( ! empty( $layouts ) ) { foreach( $layouts as $layout ) : ?> $color ) { if( $color ) { $search[] = '__WPFCOLOR_' . $colorid . '__'; $replace[] = $color; } } } $css_matrix = ( $theme ? WPFORO_THEME_DIR . '/' . $theme : $this->template_dir ) . '/styles/matrix.css'; if( file_exists( $css_matrix ) ) $css = wpforo_get_file_content( $css_matrix ); $dynamic_css = apply_filters( 'wpforo_dynamic_css_filter', '' ); $dynamic_css = wpforo_add_wrapper( $dynamic_css ); $css .= "\r\n" . $dynamic_css; $css = apply_filters( 'wpforo_dynamic_css', $css ); $css = str_replace( $search, $replace, $css ); return trim( (string) $css ); } /** * * Finds and returns styles array from theme's /styles/colors.php file * * @param string $theme Theme id ( folder name ) e.g. 'classic' * * @return array * **@since 1.0.0 * */ function find_styles( $theme ) { $colors = []; $color_file = WPFORO_THEME_DIR . '/' . $theme . '/styles/colors.php'; if( file_exists( $color_file ) ) { include( $color_file ); } return $colors; } /** * * Scans certain theme directory and returns all information in array ( theme header, layouts, styles ). * * @param string $theme_file Theme folder name or main css file base path ( 'classic' OR classic/style.css' ) * * @return array * **@since 1.0.0 * */ function find_theme( $theme_file ) { $theme = []; $theme_file = trim( trim( (string) $theme_file, '/' ) ); if( preg_match( '|\.\w{2,4}$|i', (string) $theme_file ) ) { $theme_folder = trim( basename( dirname( (string) $theme_file ) ), '/' ); } else { $theme_folder = $theme_file; $theme_file = $theme_file . '/style.css'; } if( ! is_readable( WPFORO_THEME_DIR . '/' . $theme_file ) ) { $theme['error'] = __( 'Theme file not readable', 'wpforo' ) . ' (' . $theme_file . ')'; } else { $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . '/' . $theme_file ); $theme['id'] = $theme_folder; $theme['name'] = $theme_data['name']['value']; $theme['version'] = $theme_data['version']['value']; $theme['description'] = $theme_data['description']['value']; $theme['author'] = $theme_data['author']['value']; $theme['url'] = $theme_data['theme_url']['value']; $theme['file'] = $theme_file; $theme['folder'] = $theme_folder; $theme['layouts'] = $this->find_layouts( $theme_folder ); $styles = $this->find_styles( $theme_folder ); if( ! empty( $styles ) ) { reset( $styles ); $theme['style'] = key( $styles ); $theme['styles'] = $styles; } } return $theme; } /** * * Scans wpForo themes (wpf-themes) folder, reads main files' headers and returns information about all themes in array. * This function can also be used to scan and get information about layouts in each theme /layouts/ folder. * * @param string $base_dir Absolute path to scan directory (e.g. /home/public_html/wp-content/plugins/wpforo/themes/) * @param string $ext File extension which may contain header information * @param string $mode 'theme' or 'layout' * * @return array * **@since 1.0.0 * */ function find_themes( $base_dir = '', $ext = 'css', $mode = 'theme' ) { $themes = []; $themes_dir = @opendir( WPFORO_THEME_DIR . $base_dir ); $theme_files = []; if( $themes_dir ) { while( ( $file = readdir( $themes_dir ) ) !== false ) { if( substr( (string) $file, 0, 1 ) == '.' ) continue; if( is_dir( WPFORO_THEME_DIR . $base_dir . '/' . $file ) ) { $themes_subdir = @opendir( WPFORO_THEME_DIR . $base_dir . '/' . $file ); if( $themes_subdir ) { while( ( $subfile = readdir( $themes_subdir ) ) !== false ) { if( substr( (string) $subfile, 0, 1 ) == '.' ) continue; if( substr( (string) $subfile, - 4 ) == '.' . $ext ) $theme_files[] = "$file/$subfile"; } closedir( $themes_subdir ); } } else { if( substr( (string) $file, - 4 ) == '.' . $ext ) $theme_files[] = $file; } } closedir( $themes_dir ); } if( empty( $theme_files ) ) return $themes; foreach( $theme_files as $theme_file ) { if( ! is_readable( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ) ) continue; if( $mode === 'theme' ) { $theme_data = $this->find_theme_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ); } elseif( $mode === 'layout' ) { $theme_data = $this->find_layout_headers( WPFORO_THEME_DIR . $base_dir . '/' . $theme_file ); } if( empty( $theme_data['name']['value'] ) ) continue; $themes[ wpforo_clear_basename( $theme_file ) ] = $theme_data; } return $themes; } /** * * Reads theme main file's header variables and returns information in array. * * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/themes/style.css) * * @return array * **@since 1.0.0 * */ function find_theme_headers( $file ) { $theme_headers = []; $headers = [ 'name' => 'Theme Name', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'theme_url' => 'Theme URI', ]; $fp = fopen( $file, 'r' ); $data = fread( $fp, 8192 ); fclose( $fp ); $data = str_replace( "\r", "\n", $data ); foreach( $headers as $header_key => $header_name ) { $theme_headers[ $header_key ]['name'] = $header_name; if( preg_match( '|^[\s\t/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', (string) $data, $match ) && $match[1] ) { $theme_headers[ $header_key ]['value'] = trim( preg_replace( "/\s*(?:\*\/|\?>).*/", '', $match[1] ) ); } else { $theme_headers[ $header_key ]['value'] = ''; } } $theme_headers['file']['name'] = 'file'; $theme_headers['file']['value'] = $file; return $theme_headers; } /** * * Reads layout main file's header variables and returns information in array. * * @param string $file Absolute path to file (e.g. /home/public_html/wp-content/plugins/wpforo/themes/layouts/1/forum.php) * * @return array * **@since 1.0.0 * */ function find_layout_headers( $file ) { $theme_headers = []; $headers = [ 'name' => 'layout', 'version' => 'version', 'description' => 'description', 'author' => 'author', 'layout_url' => 'url', ]; $fp = fopen( $file, 'r' ); $data = fread( $fp, 8192 ); fclose( $fp ); $data = str_replace( "\r", "\n", $data ); foreach( $headers as $header_key => $header_name ) { $theme_headers[ $header_key ]['name'] = $header_name; if( preg_match( '|^[\s\t/*#@]*' . preg_quote( $header_name, '|' ) . ':(.*)$|mi', (string) $data, $match ) && $match[1] ) { $theme_headers[ $header_key ]['value'] = trim( preg_replace( "/\s*(?:\*\/|\?>).*/", '', $match[1] ) ); } else { $theme_headers[ $header_key ]['value'] = ''; } } $theme_headers['file']['name'] = 'file'; $theme_headers['file']['value'] = trim( str_replace( WPFORO_THEME_DIR, '', (string) $file ), '/' ); return $theme_headers; } public function theme_exists( $theme ) { $_theme = $this->find_theme( $theme ); return ! wpfkey( $_theme, 'error' ); } public function copyright() { if( wpforo_setting( 'components', 'copyright' ) ): ?>

  wpForo version

topic_merge_form(); exit(); case 'reply_move_form': $this->reply_move_form(); exit(); case 'topic_split_form': $this->topic_split_form(); exit(); case 'topic_move_form': $this->topic_move_form(); exit(); } } echo 0; exit(); } public function add_footer_html() { $this->dialog(); if( WPF()->current_object['template'] === 'post' ) $this->report_form(); $this->notifications_bar(); } public function posts_ordering_dropdown( $orderby = null, $topicid = null ) { if( is_null( $topicid ) ) $topicid = wpforo_bigintval( wpfval( WPF()->current_object, 'topicid' ) ); if( $topicid && $topic_url = wpforo_topic( $topicid, 'url' ) ) { if( is_null( $orderby ) ) $orderby = WPF()->current_object['orderby']; ?> registered, 'wpforo-font-awesome' ) ) && ( $fa_rtl = wpfval( $wp_styles->registered, 'wpforo-font-awesome-rtl' ) ) ) { $content_css = $fa->src . ( is_rtl() ? ',' . $fa_rtl->src : '' ); } else { $content_css = ''; } $settings = [ 'topic' => [ 'media_buttons' => false, 'textarea_name' => 'topic[body]', 'textarea_rows' => get_option( 'default_post_edit_rows', 20 ),// rows = "..." 'tabindex' => '', 'editor_height' => 180, 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => [ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,wpf_spoil,undo,redo,pastetext,source_code,emoticons,fullscreen', 'toolbar2' => '', 'toolbar3' => '', 'toolbar4' => '', 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;} pre{border-left: 3px solid #ccc; outline: none !important; background: #fafcff;padding: 10px;font-size: 14px;margin: 20px 0 0 10px;display: block;width: 100%;} img.emoji{width: 20px;}', 'object_resizing' => false, 'autoresize_on_init' => true, 'wp_autoresize_on' => true, 'wp_keep_scroll_position' => true, 'indent' => true, 'add_unload_trigger' => false, 'wpautop' => false, 'setup' => 'wpforo_tinymce_setup', 'content_css' => $content_css, 'extended_valid_elements' => 'i[class|style],span[class|style]', 'custom_elements' => '', ], 'quicktags' => false, 'default_editor' => 'tinymce', ], 'post' => [ 'media_buttons' => false, 'textarea_name' => 'post[body]', 'textarea_rows' => get_option( 'default_post_edit_rows', 5 ), 'editor_class' => 'wpeditor', 'teeny' => false, 'dfw' => false, 'editor_height' => 150, 'tinymce' => [ 'toolbar1' => 'fontsizeselect,bold,italic,underline,strikethrough,forecolor,bullist,numlist,hr,alignleft,aligncenter,alignright,alignjustify,link,unlink,blockquote,pre,wpf_spoil,undo,redo,pastetext,source_code,emoticons,fullscreen', 'toolbar2' => '', 'toolbar3' => '', 'toolbar4' => '', 'content_style' => 'blockquote{border: #cccccc 1px dotted; background: #F7F7F7; padding:10px;font-size:12px; font-style:italic; margin: 20px 10px;} pre{border-left: 3px solid #ccc; outline: none !important; background: #fafcff;padding: 10px;font-size: 14px;margin: 20px 0 0 10px;display: block;width: 100%;} img.emoji{width: 20px;}', 'object_resizing' => false, 'autoresize_on_init' => true, 'wp_autoresize_on' => true, 'wp_keep_scroll_position' => true, 'indent' => true, 'add_unload_trigger' => false, 'wpautop' => false, 'setup' => 'wpforo_tinymce_setup', 'content_css' => $content_css, 'extended_valid_elements' => 'i[class|style],span[class|style]', 'custom_elements' => '', ], 'quicktags' => false, 'default_editor' => 'tinymce', ], ]; return apply_filters( 'wpforo_editor_settings', array_merge( $this->default->editor_settings, $settings[ $editor ] ), $editor ); } public function editor_settings_required_params( $settings ) { if( ! wpfkey( $settings, 'tinymce' ) ) $settings['tinymce'] = []; $settings['tinymce']['setup'] = 'wpforo_tinymce_setup'; if( is_rtl() ) { $settings['tinymce']['rtl_ui'] = true; $settings['plugins'] .= ',directionality'; $settings['tinymce']['toolbar1'] .= ',ltr'; $settings['tinymce']['directionality'] = 'rtl'; $settings['plugins'] = trim( (string) $settings['plugins'], ',' ); $settings['tinymce']['toolbar1'] = trim( (string) $settings['tinymce']['toolbar1'], ',' ); } // Ensure
tags allowed and alignment styles present $settings['tinymce']['extended_valid_elements'] = trim( (string) wpfval( $settings['tinymce'], 'extended_valid_elements' ) . ',figure[class|contenteditable|style|data*]', ',' ); $settings['tinymce']['content_style'] .= 'figure.alignleft { float: left; }'; $settings['tinymce']['content_style'] .= 'figure.aligncenter { clear: both; display: block; }'; $settings['tinymce']['content_style'] .= 'figure.aligncenter a, figure.aligncenter img { display: block; margin-left: auto; margin-right: auto; }'; $settings['tinymce']['content_style'] .= 'figure.alignright { float: right; }'; return $settings; } public function add_topic_button( $forumid = null ) { $phrase = ( WPF()->forum->get_layout( $forumid ) === 3 ? wpforo_phrase( 'Ask a Question', false ) : wpforo_phrase( 'Add Topic', false ) ); if( WPF()->current_object['template'] === 'forum' ) : if( wpforo_forum_list_need_add_topic_button( $forumid ) ) : if( WPF()->perm->forum_can( 'ct', $forumid ) ) : WPF()->current_object['load_tinymce'] = true; ?>
current_user_groupid === 4 ) : ?>
perm->forum_can( 'ct', $forumid ) ): ?> current_user_groupid === 4 ) : ?> '; $this->spinner(); if( apply_filters( 'wpforo_message_bubble', true ) ) $this->msg_box(); echo ''; } private function msg_box() { ?>
]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*\"([^\"]+)\")?[\r\n\t\s\0]*](?:[\r\n\t\s\0]*)#iu', '
' . wpforo_phrase( 'Spoiler', false ) . '
$2
', (string) $text, - 1, $count1 ); $text = preg_replace( '#\[[\r\n\t\s\0]*spoiler(?:[\r\n\t\s\0]*title[\r\n\t\s\0]*=[\r\n\t\s\0]*\"([^\"]+)\")?[\r\n\t\s\0]*]#iu', '
' . wpforo_phrase( 'Spoiler', false ) . '
$1
', (string) $text, - 1, $count2 ); $text = preg_replace( '#(?:<(p|a|span|blockquote|b|i|pre|font|del|strike|strong|em|div|u|center|marquee|table|tr|td|th|tt|sup|sub|s|ul|ol|li|small|code|h\d)(?:[\r\n\t\s\0]+[^<>]*?)?>[\r\n\t\s\0]*)\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*](?:[\r\n\t\s\0]*)#iu', '
', (string) $text, $count1 ); return preg_replace( '#\[[\r\n\t\s\0]*/[\r\n\t\s\0]*spoiler[\r\n\t\s\0]*]#iu', '
', (string) $text, $count2 ); } public function apply_quotes( $text ) { $text = preg_replace_callback( '#\[quote(\s[^\[\]]+|\s?)?]#iu', function( $m ) { $userid = 0; $postid = 0; $mention = ''; $posted_by = ''; if( preg_match( '#data-userid=[\'"](\d+)[\'"]#iu', $m[1], $u ) ) $userid = wpforo_bigintval( $u[1] ); if( preg_match( '#data-postid=[\'"](\d+)[\'"]#iu', $m[1], $p ) ) $postid = wpforo_bigintval( $p[1] ); if( $userid ) { $profiles_mention_nicknames = wpforo_setting( 'profiles', 'mention_nicknames' ); $posted_by = $mention = trim( (string) ( $profiles_mention_nicknames ? wpforo_member( $userid, 'user_nicename' ) : wpforo_member( $userid, 'display_name' ) ) ); if( $profiles_mention_nicknames ) $posted_by = '@' . $posted_by; } return sprintf( '
%4$s %5$s
', $userid, $postid, $mention, ( $posted_by ? sprintf( '
%1$s: %2$s
', wpforo_phrase( 'Posted by', false ), $posted_by ) : '' ), ( $postid ? sprintf( '
', WPF()->post->get_url( $postid ), wpforo_phrase( 'go to original post', false ) ) : '' ) ); }, (string) $text ); return preg_replace( '#\[/quote]#iu', '
', (string) $text ); } public function please_login() { if( ! wpforo_is_bot() ) { $html = sprintf( '
%1$s %2$s
', wpforo_get_login_or_register_notice_text(), wpforo_phrase( 'to reply to this topic.', false, 'lower' ) ); echo apply_filters( 'wpforo_login_message_in_topic', $html ); } } public function profile_board_panel( $user = [], $template = '', $active_boardid = null ) { if( ! is_wpforo_multiboard() ) return ''; if( is_numeric( $user ) ) $user = WPF()->member->get_member( $user ); if( ! $user ) $user = WPF()->current_object['user']; if( ! $template ) $template = WPF()->current_object['template']; if( is_null( $active_boardid ) ) $active_boardid = ( wpfkey( WPF()->GET, 'boardid' ) ? (int) WPF()->GET['boardid'] : WPF()->board->get_current( 'boardid' ) ); $links = ''; $base_profile_url = remove_query_arg( 'boardid', WPF()->member->get_profile_url( $user, $template ) ); foreach( WPF()->board->get_boards( [ 'status' => true ] ) as $board ) { if( $template === 'subscriptions' && ! wpforo_is_module_enabled( 'subscriptions', $board ) ) continue; $links .= sprintf( '%4$s', ( $active_boardid === $board['boardid'] ? 'wpf-active' : '' ), add_query_arg( 'boardid', $board['boardid'], $base_profile_url ), $board['title'], wpforo_text( $board['title'], 10, false ) ); } return sprintf( '
%1$s
%2$s
', wpforo_phrase( 'Board', false ), $links ); } public function profile_activity_panel( $user = [], $boardid = null, $active_filter = '' ) { if( is_numeric( $user ) ) $user = WPF()->member->get_member( $user ); if( ! $user ) $user = WPF()->current_object['user']; if( is_null( $boardid ) ) $boardid = wpfkey( WPF()->GET, 'boardid' ) ? (int) WPF()->GET['boardid'] : WPF()->board->get_current( 'boardid' ); if( ! $active_filter ) $active_filter = (string) wpfval( WPF()->GET, 'filter' ); WPF()->change_board( $boardid ); $filters = [ '' => wpforo_phrase( 'All', false ), 'topics' => wpforo_phrase( 'Topics', false ), 'replies' => wpforo_phrase( 'Replies', false ), ]; $links = ''; foreach( $filters as $filter => $label ) { $links .= sprintf( '%3$s', ( $active_filter === $filter ? 'wpf-active' : '' ), WPF()->member->get_activity_url( $filter, $boardid, $user ), $label ); } $topics = WPF()->topic->get_count( [ 'userid' => $user['userid'], 'status' => 0, 'private' => '0' ] ); $posts = WPF()->post->get_count( [ 'userid' => $user['userid'], 'status' => 0, 'private' => '0' ] ); return sprintf( '
%1$s / %2$s
%3$s
', wpforo_phrase( 'Topics', false ) . ': ' . $topics, wpforo_phrase( 'Replies', false ) . ': ' . ( $posts - $topics ), $links ); } public function profile_favored_panel( $user = [], $boardid = null, $active_filter = '' ) { if( is_numeric( $user ) ) $user = WPF()->member->get_member( $user ); if( ! $user ) $user = WPF()->current_object['user']; if( is_null( $boardid ) ) $boardid = wpfkey( WPF()->GET, 'boardid' ) ? (int) WPF()->GET['boardid'] : WPF()->board->get_current( 'boardid' ); if( ! $active_filter ) $active_filter = (string) wpfval( WPF()->current_object, 'filter' ); $filters = [ 'bookmarks' => wpforo_phrase( 'Bookmarks', false ), 'likes' => wpforo_phrase( 'Likes', false ), 'dislikes' => wpforo_phrase( 'Dislikes', false ), ]; $links = ''; foreach( $filters as $filter => $label ) { $links .= sprintf( '%3$s', ( $active_filter === $filter ? 'wpf-active' : '' ), WPF()->member->get_favored_url( $filter, $boardid, $user ), $label ); } return sprintf( '
%1$s
%2$s
', wpforo_phrase( 'Total Posts', false ) . ': ' . WPF()->current_object['items_count'], $links ); } private function cantlogin_page() { $contact_form_phrase = ( wpforo_setting( 'authorization', 'manually_approval_contact_form' ) ) ? wpforo_phrase( 'Please use the contact form below if you want to contact the website administrator.', false ) : ''; $html = sprintf( '
%1$s %2$s
', wpforo_phrase( 'You have been automatically signed out from the website. Your account is awaiting approval.', false ), $contact_form_phrase ); if( wpforo_setting( 'authorization', 'manually_approval_contact_form' ) ) { $html .= sprintf( '
', wpforo_login_url(), WPF()->ram_cache->get( 'USER_LOGIN_REFERER' ), wpforo_phrase( 'Your message to the website administrator...', false ), wpforo_phrase( 'Send', false ) ); } return '
' . apply_filters( 'wpforo_logout_message', $html ) . '
'; } public function change_cover_button( $user ) { if( WPF()->usergroup->can( 'upc' ) && WPF()->perm->user_can_edit_account( $user ) ) { return sprintf( '
', wpforo_phrase( 'Change Cover Image', false ), wpforo_phrase( 'Upload New Cover', false ), wpforo_phrase( 'Reset to Default', false ) ); } return ''; } }