public static function comments_open($open, $post_id) { // if ( $open ) // return $open; if (get_post_type($post_id) != bbp_get_topic_post_type()) { return $open; } $use_comments = (bool) bbpresskr()->forum_option('use_comments', $post_id); if (strpos($_SERVER['SCRIPT_FILENAME'], 'wp-comments-post.php') !== false && !empty($_POST['comment_post_ID']) && !empty($_POST['comment'])) { return $use_comments; } if (bbp_is_single_topic()) { return $use_comments; } return $open; }
static function user_has_cap($allcaps, $caps, $args, $user) { static $doing = false; // bypass if non-bbpress contents and avoid infinite loop if ($doing === true || !did_action('wp') || !is_bbpress()) { return $allcaps; } $bbp_allcaps = bbp_get_caps_for_role(bbp_get_keymaster_role()); $check_caps = array_intersect(array_values($caps), array_keys($bbp_allcaps)); if (!$check_caps && in_array('upload_files', $caps)) { $check_caps = array('upload_files'); } // bypass non bbpress caps if (!$check_caps || in_array('keep_gate', $check_caps)) { return $allcaps; } $doing = true; if (!($forum_id = bbp_get_forum_id())) { $doing = false; return $allcaps; } // Give all modorator capabilities to optional forum moderators per forum $moderators = bbpresskr()->forum_option('moderators', $forum_id); if (in_array($user->ID, $moderators) && ($new_caps = bbp_get_caps_for_role(bbp_get_moderator_role()))) { // remove all bbpress capabilities and append for asigned role only $_allcaps = array_diff_assoc($allcaps, $bbp_allcaps); $allcaps = array_merge($_allcaps, $new_caps); $allcaps['upload_files'] = true; } // In case we use usermeta for forum moderator setting /*$metakey = "forum_role_{$forum_id}"; // Dobule check forum role still exists. Role may excluded by plugin or updates. if ( isset( $user->$metakey ) && ($new_caps = bbp_get_caps_for_role( $user->$metakey )) ) { // remove all bbpress capabilities and append for asigned role only $_allcaps = array_diff_assoc( $allcaps, $bbp_allcaps ); $allcaps = array_merge( $_allcaps, $new_caps ); $allcaps['upload_files'] = true; }*/ $doing = false; return $allcaps; }
function bbp_user_can_comment() { return bbpresskr()->forum_option('use_comments') && bbp_current_user_can_access_create_reply_form() && !bbp_is_topic_closed() && !bbp_is_forum_closed(); }
?> <li class="topic-info-general clearfix"> <div class="path fl"><a href="<?php bbp_forum_permalink(bbp_get_forum_id()); ?> "><?php bbp_forum_title(bbp_get_topic_forum_id(bbp_get_topic_id())); ?> </a></div> <div class="date fr"> <time datetime="<?php echo get_post_time('c', false, bbp_get_topic_id()); ?> "> <?php printf(_x('%1$s at %2$s', '1: date, 2: time'), get_post_time(bbpresskr()->forum_option('date_format'), false, bbp_get_topic_id()), get_post_time(bbpresskr()->forum_option('time_format'), false, bbp_get_topic_id())); ?> </time> </div> <div class="title"><?php bbp_topic_title(); ?> </div> </li> <li class="topic-info-meta clearfix"> <div class="author"> <?php do_action('bbp_theme_before_reply_author_details'); ?> <?php
<?php if (bbp_user_can_comment()) { ?> <div id="topic-<?php bbp_topic_id(); ?> -comments" class="forums bbp-comments"> <?php comments_template(); ?> </div> <?php } elseif (!bbpresskr()->forum_option('use_comments')) { ?> <?php if (bbp_has_replies()) { ?> <?php // bbp_get_template_part( 'pagination', 'replies' ); ?> <?php bbp_get_template_part('loop', 'replies'); ?> <?php
die('Forbidden'); } define('BBPKR_PATH', dirname(__FILE__)); define('BBPKR_INC', BBPKR_PATH . '/inc'); define('BBPKR_LIB', BBPKR_PATH . '/lib'); spl_autoload_register(function ($class) { // project-specific namespace prefix $prefix = 'bbPressKR\\'; // does the class use the namespace prefix? $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { // no, move to the next registered autoloader return; } // get the relative class name $relativeClass = substr($class, $len); $relativeClass = str_replace('_', '-', strtolower($relativeClass)); $fileInc = rtrim(BBPKR_INC, '/') . '/' . str_replace('\\', '/', $relativeClass) . '.php'; $fileLib = rtrim(BBPKR_LIB, '/') . '/' . str_replace('\\', '/', $relativeClass) . '.php'; // if the file exists, require it if (file_exists($fileInc)) { require $fileInc; } elseif (file_exists($fileLib)) { require $fileLib; } }); require BBPKR_INC . '/functions-compat.php'; require BBPKR_INC . '/functions.php'; global $bbpkr; $bbpkr = bbpresskr();
public static function template_container_start() { $type = bbpresskr()->forum_option('skin'); echo '<div class="bbpkr bbpskin-' . $type . '">'; }
static function admin_enqueue_scripts() { return; global $pagenow; if (!in_array($pagenow, array('post.php', 'post-new.php')) || get_post_type() != bbp_get_forum_post_type()) { return; } wp_enqueue_style('bbpkr-admin', bbpresskr()->url . '/assets/css/admin.css', false, bbpresskr()->ver); wp_enqueue_script('bbpkr-admin', bbpresskr()->url . '/assets/js/admin.js', array('jquery-ui-tabs'), bbpresskr()->ver, true); }
static function can_download($attachment) { $attachment = get_post($attachment); if (!$attachment || $attachment->post_type != 'attachment') { return false; } $post = get_post($attachment->post_parent); $post_type = get_post_type($post); $bbp_types = array(bbp_get_topic_post_type(), bbp_get_reply_post_type()); if (in_array($post_type, $bbp_types)) { if (current_user_can('moderate')) { return true; } $forum_id = $post_type == bbp_get_topic_post_type() ? bbp_get_topic_forum_id() : bbp_get_reply_forum_id(); $allowed_roles = (array) get_option('_bbpkr_download_perms', self::$download_perms); if ($use_custom = Permissions::use_custom($forum_id)) { $allowed_roles = Permissions::get_forum_perms($use_custom, 'download'); } $can = in_array(bbpresskr()->get_user_role(), $allowed_roles); } else { // TODO: default user level for download, currently for all $can = self::check_user(self::$wp_download_level); } return $can; }
/** * Get a list of CSS classes for the <table> tag * * @since 3.1.0 * @access protected * * @return array */ protected function get_table_classes() { $skin = bbpresskr()->forum_option('skin'); return array('bbpkr-list-table', "bbptb-{$skin}", 'widefat', 'striped', 'fixed', $this->_args['plural']); }
/** * Builds the absolute URL path to the view. * * @param string $file * @return string */ private function path($file) { if (!preg_match('/\\.[a-z0-9]{1,4}$/i', $file)) { $file .= '.php'; } return bbpresskr()->path . '/views/' . $file; }
public static function bbp_is_forum_private($retval, $forum_id, $check_ancestors) { if ($retval) { return $retval; } return $retval; // only filter public forums $perms = self::get_forum_perms($forum_id, 'read'); $user_id = get_current_user_id(); $user_role = bbpresskr()->get_user_role($user_id); $retval = !in_array($user_role, $perms); return $retval; }
static function callback_attachment_perms($key, $default = array()) { $_user_roles = bbpresskr()->get_user_roles(); $allowed = (array) get_option("_bbpkr_{$key}_perms", $default); $field_name = "_bbpkr_{$key}_perms[]"; ?> <div id="bbp-perms-<?php echo $key; ?> "> <strong class="screen-reader-text"><?php printf(__('Allow %s to:', 'bbpresskr'), $key); ?> </strong> <ul> <?php foreach ($_user_roles as $role => $roledata) { if ($role == 'bbpkr_anonymous' && in_array($key, array('upload'))) { continue; } $field_id = "_bbpkr_{$key}_perms_{$role}"; $title = $roledata['name']; ?> <li> <label for="<?php echo $field_id; ?> "> <input type="checkbox" value="<?php echo $role; ?> " id="<?php echo $field_id; ?> " name="<?php echo $field_name; ?> "<?php checked(in_array($role, $allowed)); ?> /> <?php echo $title; ?> </label> </li> <?php } ?> </ul> </div> <?php }
* @package bbPress * @subpackage Theme */ ?> <?php do_action('bbp_template_before_topics_loop'); ?> <div class="tableinfo"> <?php bbpresskr()->topic_list_table->views(); ?> </div> <?php bbpresskr()->topic_list_table->display(); ?> <div class="tablenav"> <?php bbpresskr()->topic_list_table->search_box('Search', 'post'); ?> </div> <?php do_action('bbp_template_after_topics_loop'); ?>
static function options($forum_id = 0, $admin = false) { $forum_id = bbp_get_forum_id($forum_id); if ($cached = wp_cache_get($forum_id, 'forum_options')) { return $cached; } $forum_options = self::$defaults; if (get_post_meta($forum_id, 'bbpkr_custom_settings', true)) { $forum_options = array_merge($forum_options, (array) get_post_meta($forum_id, 'bbpkr_options', true)); // var_dump( $this->options()['skin'], $options); } elseif (!$admin) { // follow closest parent forum custom settings $forum_parent = (int) get_post_field('post_parent', $forum_id); if ($forum_parent) { while ($forum_parent) { if (get_post_meta($forum_parent, 'bbpkr_custom_settings', true)) { $forum_options = array_merge($forum_options, (array) get_post_meta($forum_parent, 'bbpkr_options', true)); break; } $forum_parent = (int) get_post_field('post_parent', $forum_parent); } } } $return = array_merge(bbpresskr()->options(), (array) $forum_options); wp_cache_set($forum_id, $return, 'forum_options'); return $return; }