Search Results for '+.+default+.+'
-
AuthorSearch Results
-
May 31, 2014 at 1:49 pm #147217
Jerry
ParticipantOkay, here is a very tough and long question. So I have this plugin created by Igor Yavych. I have a book review site and I really need my users to be able to rate the books listed (star rating). Here is my dilemma; this plugin only works for WordPress Posts. It does not work for bbpress posts. I want to change this plugin to function with bbpress. I think I probably have to dig through the bbpress codex, but I am hoping someone can tell me an easier way? There is a lot of code posted below from rating.php (my apologies). I will also post code from settings.php at the bottom. I think perhaps I need to just change some common wordpress variables to bbpress variables?
Of course, what I would actually hope is that someone knows of a star rating plugin that already works for bbpress. I’ve been searching for days and cannot find one.<?php /* Plugin Name: Simple Rating Description: Allows users to rate posts and pages. Version: 1.3.2 Author: Igor Yavych Author URI: https://www.odesk.com/users/~~d196de64099a8aa3 */ require_once ("spr_widgets.php"); require_once ("spr_upgrade.php"); upgrade(); $options=spr_options(); if ($options['activated']==1&&$options['method']=="auto") { add_filter('the_content', 'spr_filter', 15); } function spr_filter($content) { $options=spr_options(); $list=spr_list_cpt_slugs(); global $post, $wpdb, $spr_style; $disable_rating=get_post_meta($post->ID, '_spr_disable', true); //trying to change this to a bbpress plugin instead of a wordpress plugin - bbp_topic_id() or topic_id //$disable_rating=get_post_meta($post->topic_id, '_spr_disable', true); foreach ($list as $list_) { if (is_singular($list_)&&$options['where_to_show'][$list_]&&$disable_rating!='1') { if ($options['position']=='before') { $content=spr_rating().$content; } elseif ($options['position']=='after') { $content .= spr_rating(); } break; } else if ((is_archive()||(is_home()&&$options['loop_on_hp']==1&&in_the_loop()))&&$options['show_in_loops']==1) { if ($post->post_type==$list_&$options['where_to_show'][$list_]&&$disable_rating!='1') { wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); if ($spr_style!=1) { spr_print_additional_styles(); $spr_style=1; } $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post->ID';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } $results='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'; if ($options['position']=='before') { $content=$results.$content; } elseif ($options['position']=='after') { $content .= $results; } break; } } } return $content; } function spr_show_rating() { $options=spr_options(); $list=spr_list_cpt_slugs(); global $post, $wpdb, $spr_added, $spr_added_loop, $spr_style; $disable_rating=get_post_meta($post->ID, '_spr_disable', true); //trying to change this to a bbpress plugin instead of a wordpress plugin //$disable_rating=get_post_meta($post->topic_id, '_spr_disable', true); $result=""; if ($options['method']=="manual"&&$options['activated']==1) { foreach ($list as $list_) { if (is_singular($list_)&&$options['where_to_show'][$list_]&&$disable_rating!='1'&&$spr_added!=1) { $result=spr_rating(); $spr_added=1; break; } if ((is_archive()||($options['loop_on_hp']==1&&is_home()&&in_the_loop()))&&$options['show_in_loops']==1) { if ($post->post_type==$list_&$options['where_to_show'][$list_]&&$disable_rating!='1'&&!isset($spr_added_loop[$post->ID])) { wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); if ($spr_style!=1) { spr_print_additional_styles(); $spr_style=1; } $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post->ID';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } $result='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'; $spr_added_loop[$post->ID]=1; break; } } } return $result; } } function spr_get_entry_rating($post_id, $echo=false) { global $wpdb, $spr_added_loop, $spr_style; $options=spr_options(); if ($options['activated']) { if (is_numeric($post_id)) { wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); if ($spr_style!=1) { spr_print_additional_styles(); $spr_style=1; } if (!isset($spr_added_loop[$post_id])) { $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post_id';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } $result='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'; $spr_added_loop[$post_id]=1; if ($echo) { echo $result; } else { return $result; } } } else { echo "Invalid Post ID was supplied"; } } } function spr_rating() { global $post, $current_user, $wpdb; $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post->ID';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } wp_enqueue_script('spr_script', plugins_url('/resources/spr_script.js', __FILE__), array('jquery'), NULL); wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); $options=spr_options(); spr_print_additional_styles(); if ($votes>0) { $rate=$points/$votes; if ($options['use_aggregated']) { $aggregated='<div class="spr_hidden" itemscope="" itemtype="http://schema.org/Product"><meta itemprop="name" content="'.$post->post_title.'"><div class="spr_hidden" itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating"><meta itemprop="bestRating" content="'.$options['scale'].'"><meta itemprop="ratingValue" content="'.$rate.'"><meta itemprop="ratingCount" content="'.$votes.'"></div></div>'; } else { $aggregated=''; } } else { $rate=0; $votes=0; $aggregated=''; } if (is_user_logged_in()==1) { $query="select * from <code>".$wpdb->prefix."spr_votes</code> where <code>post_id</code>='$post->ID' and <code>user_id</code>='$current_user->ID';"; $voted=$wpdb->get_results($query, ARRAY_N); if (count($voted)>0) { $results='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'.$aggregated; wp_localize_script('spr_script', 'spr_ajax_object', array('ajax_url'=>admin_url('admin-ajax.php'), 'scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'], 'rating_working'=>false, 'post_id'=>$post->ID)); return $results; } else { $results='<div id="spr_container"><div class="spr_visual_container" id="spr_container_'.$post->ID.'">'.spr_show_voting($votes, $points, $options['show_vote_count']).'</div></div>'.$aggregated; wp_localize_script('spr_script', 'spr_ajax_object', array('ajax_url'=>admin_url('admin-ajax.php'), 'scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'], 'rating_working'=>true, 'post_id'=>$post->ID)); return $results; } } else if ($options['allow_guest_vote']&&filter_var(spr_get_ip(), FILTER_VALIDATE_IP)) { $query="select * from <code>".$wpdb->prefix."spr_votes</code> where <code>post_id</code>='$post->ID' and <code>user_id</code>='".spr_get_ip()."';"; $voted=$wpdb->get_results($query, ARRAY_N); if (count($voted)>0) { $results='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'.$aggregated; wp_localize_script('spr_script', 'spr_ajax_object', array('ajax_url'=>admin_url('admin-ajax.php'), 'scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'], 'rating_working'=>false, 'post_id'=>$post->ID)); return $results; } else { $results='<div id="spr_container"><div class="spr_visual_container" id="spr_container_'.$post->ID.'">'.spr_show_voting($votes, $points, $options['show_vote_count']).'</div></div>'.$aggregated; wp_localize_script('spr_script', 'spr_ajax_object', array('ajax_url'=>admin_url('admin-ajax.php'), 'scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'], 'rating_working'=>true, 'post_id'=>$post->ID)); return $results; } } else { wp_localize_script('spr_script', 'spr_ajax_object', array('ajax_url'=>admin_url('admin-ajax.php'), 'scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'], 'rating_working'=>false)); $results='<div id="spr_container"><div class="spr_visual_container">'.spr_show_voted($votes, $points, $options['show_vote_count']).'</div></div>'.$aggregated; return $results; } } function spr_show_voted($votes, $points, $show_vc) { $options=spr_options(); $spr_type=$options['color'].$options['shape']; if ($votes>0) { $rate=$points/$votes; } else { $rate=0; $votes=0; } $html='<div id="spr_shapes">'; for ($i=1; $i<=$options['scale']; $i++) { if ($rate>=($i-0.25)) { $class='spr_'.$spr_type.'_full_voted'; } elseif ($rate<($i-0.25)&&$rate>=($i-0.75)) { $class='spr_'.$spr_type.'_half_voted'; } else { $class='spr_'.$spr_type.'_empty'; } $html .= '<span class="spr_rating_piece '.$class.'"></span> '; } $html.='</div>'; if ($show_vc) { if ($votes==1) { $votesorvote='vote'; } else { $votesorvote='votes'; } $html .= '<span id="spr_votes">'.$votes.' '.$votesorvote.'</span>'; } return $html; } function spr_show_voting($votes, $points, $show_vc) { $options=spr_options(); $spr_type=$options['color'].$options['shape']; if ($votes>0) { $rate=$points/$votes; } else { $rate=0; $votes=0; } $html='<div id="spr_shapes">'; for ($i=1; $i<=$options['scale']; $i++) { if ($rate>=($i-0.25)) { $class='spr_'.$spr_type.'_full_voting'; } elseif ($rate<($i-0.25)&&$rate>=($i-0.75)) { $class='spr_'.$spr_type.'_half_voting'; } else { $class='spr_'.$spr_type.'_empty'; } $html .= '<span id="spr_piece_'.$i.'" class="spr_rating_piece '.$class.'"></span> '; } $html.='</div>'; if ($show_vc) { if ($votes==1) { $votesorvote='vote'; } else { $votesorvote='votes'; } $html .= '<span id="spr_votes">'.$votes.' '.$votesorvote.'</span>'; } return $html; } function spr_rate() { global $current_user, $wpdb; $options=spr_options(); if ($options['activated']==1) { if (isset($_POST['points'])&&isset($_POST['post_id'])) // key parameters are set { $post_id=(int) esc_sql($_POST['post_id']); $points_=(int) esc_sql($_POST['points']); if ($points_>=1&&$points_<=$options['scale']) { if (is_user_logged_in()==1) // user is logged in { $query="select * from <code>".$wpdb->prefix."posts</code> where <code>ID</code>='$post_id';"; $post_exists=$wpdb->get_results($query, ARRAY_N); if (count($post_exists)>0) // post exists { $query="select * from <code>".$wpdb->prefix."spr_votes</code> where <code>post_id</code>='$post_id' and <code>user_id</code>='$current_user->ID';"; $voted=$wpdb->get_results($query, ARRAY_N); if (count($voted)>0) // already voted { $response=json_encode(array('status'=>2)); } else // haven't voted yet { $wpdb->query("INSERT INTO <code>".$wpdb->prefix."spr_votes</code> (<code>post_id</code>, <code>user_id</code>, <code>points</code>) VALUES ('$post_id', '$current_user->ID', '$points_');"); $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post_id';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } if ($votes==0||$points==0) { $wpdb->query("INSERT INTO <code>".$wpdb->prefix."spr_rating</code> (<code>post_id</code>, <code>votes</code>, <code>points</code>) VALUES ('$post_id', '1', '$points_');"); } else { $points=$points+$points_; $votes=$votes+1; $wpdb->query("UPDATE <code>".$wpdb->prefix."spr_rating</code> set <code>votes</code>='$votes', <code>points</code>='$points' where <code>post_id</code>='$post_id';"); } $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post_id';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } $html=spr_show_voted($votes, $points, $options['show_vote_count']); $response=json_encode(array('status'=>1, 'html'=>$html)); } } else { $response=json_encode(array('status'=>3)); // post doesn't exist } } else if ($options['allow_guest_vote']&&filter_var(spr_get_ip(), FILTER_VALIDATE_IP)) { $query="select * from <code>".$wpdb->prefix."posts</code> where <code>ID</code>='$post_id';"; $post_exists=$wpdb->get_results($query, ARRAY_N); if (count($post_exists)>0) // post exists { $query="select * from <code>".$wpdb->prefix."spr_votes</code> where <code>post_id</code>='$post_id' and <code>user_id</code>='".spr_get_ip()."';"; $voted=$wpdb->get_results($query, ARRAY_N); if (count($voted)>0) // already voted { $response=json_encode(array('status'=>2)); } else // haven't voted yet { $wpdb->query("INSERT INTO <code>".$wpdb->prefix."spr_votes</code> (<code>post_id</code>, <code>user_id</code>, <code>points</code>) VALUES ('$post_id', '".spr_get_ip()."', '$points_');"); $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post_id';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } if ($votes==0||$points==0) { $wpdb->query("INSERT INTO <code>".$wpdb->prefix."spr_rating</code> (<code>post_id</code>, <code>votes</code>, <code>points</code>) VALUES ('$post_id', '1', '$points_');"); } else { $points=$points+$points_; $votes=$votes+1; $wpdb->query("UPDATE <code>".$wpdb->prefix."spr_rating</code> set <code>votes</code>='$votes', <code>points</code>='$points' where <code>post_id</code>='$post_id';"); } $query="select <code>votes</code>, <code>points</code> from <code>".$wpdb->prefix."spr_rating</code> where <code>post_id</code>='$post_id';"; $popularity=$wpdb->get_results($query, ARRAY_N); if (count($popularity)>0) { $votes=$popularity[0][0]; $points=$popularity[0][1]; } else { $votes=0; $points=0; } $html=spr_show_voted($votes, $points, $options['show_vote_count']); $response=json_encode(array('status'=>1, 'html'=>$html)); } } else { $response=json_encode(array('status'=>3)); // post doesn't exist } } else { $response=json_encode(array('status'=>4)); // user isn't logged in } } else { $response=json_encode(array('status'=>5)); // key parameters aren't set } } else { $response=json_encode(array('status'=>6)); // key parameters aren't set } } else { $response=json_encode(array('status'=>7)); // rating isn't active } echo $response; if (isset($_POST['action'])) { die(); } } function spr_options() { $list=spr_list_cpt_slugs(); foreach ($list as $list_) { $def_types[$list_]=0; } $default_options=array("shape"=>"s", "color"=>"y", "where_to_show"=>$def_types, "position"=>"before", "show_vote_count"=>"1", "activated"=>"0", "scale"=>"5", "method"=>"auto", "alignment"=>"center", "vote_count_color"=>"", "vc_bold"=>"0", "vc_italic"=>"0", "show_in_loops"=>"0", "loop_on_hp"=>"0", "use_aggregated"=>"1", "allow_guest_vote"=>"0", "show_stats_metabox"=>"1"); $options=get_option('spr_settings', 'undef'); if ($options!='undef') { $options=json_decode($options, true); $diff=array_diff_key($default_options, $options); if (count($diff)>0) { $options=array_merge($options, $diff); } } else { $options=$default_options; } return $options; } function spr_options_page() { require_once (plugin_dir_path(__FILE__).'/settings.php'); } function spr_save_settings() { $current_options=spr_options(); $current_json=json_encode($current_options); if (isset($_POST['spr_shape'])||isset($_POST['spr_color'])||isset($_POST['spr_position'])||isset($_POST['spr_scale'])||isset($_POST['spr_show_vote_count'])||isset($_POST['spr_activated'])||isset($_POST['spr_method'])||isset($_POST['spr_vote_count_color'])||isset($_POST['spr_vc_bold'])||isset($_POST['spr_vc_italic'])||isset($_POST['spr_show_in_loops'])||isset($_POST['spr_loop_on_hp'])||isset($_POST['spr_use_aggregated'])||isset($_POST['spr_allow_guest_vote'])||isset($_POST['spr_show_stats_metabox'])) { //Shape if (isset($_POST['spr_shape'])) { switch ($_POST['spr_shape']) { case 'c' : { $options['shape']='c'; break; } case 'h' : { $options['shape']='h'; break; } case 'b' : { $options['shape']='b'; break; } case 's' : { $options['shape']='s'; break; } default: { $options['shape']=$current_options['shape']; break; } } } //Color if (isset($_POST['spr_color'])) { switch ($_POST['spr_color']) { case 'p' : { $options['color']='p'; break; } case 'b' : { $options['color']='b'; break; } case 'y' : { $options['color']='y'; break; } case 'r' : { $options['color']='r'; break; } case 'g' : { $options['color']='g'; break; } default: { $options['color']=$current_options['color']; break; } } } //Position if (isset($_POST['spr_position'])) { switch ($_POST['spr_position']) { case 'before' : { $options['position']='before'; break; } case 'after' : { $options['position']='after'; break; } default: { $options['position']=$current_options['position']; break; } } } //Alignment if (isset($_POST['spr_alignment'])) { switch ($_POST['spr_alignment']) { case 'center' : { $options['alignment']='center'; break; } case 'left' : { $options['alignment']='left'; break; } case 'right' : { $options['alignment']='right'; break; } default: { $options['alignment']=$current_options['alignment']; break; } } } //Show vote count if (isset($_POST['spr_show_vote_count'])) { $options['show_vote_count']='1'; } else { $options['show_vote_count']='0'; } //Activated if (isset($_POST['spr_activated'])) { $options['activated']='1'; } else { $options['activated']='0'; } //Scale if (isset($_POST['spr_scale'])) { if ($_POST['spr_scale']>=3&&$_POST['spr_scale']<=10) { $options['scale']=$_POST['spr_scale']; } else { $options['scale']=$current_options['scale']; } } //Method if (isset($_POST['spr_method'])) { switch ($_POST['spr_method']) { case 'auto' : { $options['method']='auto'; break; } case 'manual' : { $options['method']='manual'; break; } default: { $options['method']=$current_options['method']; break; } } } // Vote count color if (isset($_POST['spr_vote_count_color'])) { if (preg_match('@^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$@', $_POST['spr_vote_count_color'])) { $options['vote_count_color']=$_POST['spr_vote_count_color']; } else { $_POST['spr_vote_count_color']=""; } } //Bold if (isset($_POST['spr_vc_bold'])) { $options['vc_bold']='1'; } else { $options['vc_bold']='0'; } //Italic if (isset($_POST['spr_vc_italic'])) { $options['vc_italic']='1'; } else { $options['vc_italic']='0'; } if (isset($_POST['spr_show_in_loops'])) { $options['show_in_loops']='1'; } else { $options['show_in_loops']='0'; } //Loop on homepage if (isset($_POST['spr_loop_on_hp'])) { $options['loop_on_hp']='1'; } else { $options['loop_on_hp']='0'; } //Use aggregated if (isset($_POST['spr_use_aggregated'])) { $options['use_aggregated']='1'; } else { $options['use_aggregated']='0'; } //Allow guests to vote if (isset($_POST['spr_allow_guest_vote'])) { $options['allow_guest_vote']='1'; } else { $options['allow_guest_vote']='0'; } //Show statistics metabox if (isset($_POST['spr_show_stats_metabox'])) { $options['show_stats_metabox']='1'; } else { $options['show_stats_metabox']='0'; } //where to show $list=spr_list_cpt_slugs(); foreach ($list as $list_) { $def_types[$list_]=0; if (isset($_POST[$list_])) { $options['where_to_show'][$list_]='1'; } else { $options['where_to_show'][$list_]='0'; } } $default_options=array("shape"=>"s", "color"=>"y", "where_to_show"=>$def_types, "position"=>"before", "show_vote_count"=>"1", "activated"=>"0", "scale"=>"5", "method"=>"auto", "alignment"=>"center", "vote_count_color"=>"", "vc_bold"=>"0", "vc_italic"=>"0", "show_in_loops"=>"0", "loop_on_hp"=>"0", "use_aggregated"=>"1", "allow_guest_vote"=>"0", "show_stats_metabox"=>"1"); $diff=array_diff_key($default_options, $options); if (count($diff)>0) { $options=array_merge($options, $diff); } $options=json_encode($options); if ($current_json!=$options) { update_option('spr_settings', $options); echo "<div class='updated'><p>Settings were updated successfully.</p></div>"; } } } function spr_menu() { add_options_page('Simple Rating', 'Simple Rating', 'manage_options', 'spr_options', 'spr_options_page'); } function spr_activation_func() { global $wpdb; $query="CREATE TABLE IF NOT EXISTS <code>".$wpdb->prefix."spr_votes</code> ( <code>post_id</code> INT(11) NULL DEFAULT NULL, <code>user_id</code> TINYTEXT NULL COLLATE 'utf8_unicode_ci', <code>points</code> INT(11) NULL DEFAULT NULL ) COLLATE='utf8_unicode_ci' ENGINE=MyISAM; "; $wpdb->query($query); $query="CREATE TABLE IF NOT EXISTS <code>".$wpdb->prefix."spr_rating</code> ( <code>post_id</code> INT(11) NOT NULL, <code>votes</code> INT(11) NOT NULL, <code>points</code> INT(11) NOT NULL ) COLLATE='utf8_unicode_ci' ENGINE=MyISAM; "; $wpdb->query($query); $list=spr_list_cpt_slugs(); foreach ($list as $list_) { $def_types[$list_]=0; } $default_options=array("shape"=>"s", "color"=>"y", "where_to_show"=>$def_types, "position"=>"before", "show_vote_count"=>"1", "activated"=>"0", "scale"=>"5", "method"=>"auto", "alignment"=>"center", "vote_count_color"=>"", "vc_bold"=>"0", "vc_italic"=>"0", "show_in_loops"=>"0", "loop_on_hp"=>"0", "use_aggregated"=>"1", "allow_guest_vote"=>"0", "show_stats_metabox"=>"1"); add_option('spr_settings', json_encode($default_options)); add_option('spr_version', '1.3.1'); } function add_spr_checkbox() { global $post; $type=get_post_type($post->ID); $disable_rating=get_post_meta($post->ID, '_spr_disable', true); ?> <div class="misc-pub-section"> <input id="spr_disable_rating" type="checkbox" name="spr_disable_rating" value="<?php echo $disable_rating; ?>" <?php checked($disable_rating, 1, true); ?>> <label for="spr_enable_rating">Disable rating for this entry</label></div> <?php } function spr_new_update_post_handler($data, $postarr) { if (isset($_POST['spr_disable_rating'])) { update_post_meta($postarr['ID'], '_spr_disable', '1'); } else { delete_post_meta($postarr['ID'], '_spr_disable'); } return $data; } function spr_truncate_tables() { global $wpdb; $query="TRUNCATE TABLE <code>".$wpdb->prefix."spr_votes</code> ;"; $wpdb->query($query); $query="TRUNCATE TABLE <code>".$wpdb->prefix."spr_rating</code>;"; $wpdb->query($query); echo "<div class='updated'><p>All votes were cleared.</p></div>"; } function spr_add_settings_link($links) { return array_merge( array( 'settings'=>'<a href="'.admin_url('options-general.php?page=spr_options').'">Settings</a>' ), $links ); } function spr_print_additional_styles() { $options=spr_options(); $style="<style>"; $vc_style="#spr_votes{"; $c_style="#spr_container{"; if (strlen($options['vote_count_color'])>0&&$options['show_vote_count']) { $vc_style.="color:".$options['vote_count_color']." !important;"; } if ($options['vc_bold']&&$options['show_vote_count']) { $vc_style.="font-weight:700 !important;"; } if ($options['vc_italic']&&$options['show_vote_count']) { $vc_style.="font-style:italic !important;"; } $vc_style.="}"; if ($vc_style!="#spr_votes{}") { $style.=$vc_style; } if ($options['alignment']=="right"||$options['alignment']=="left") { $c_style.="text-align:".$options['alignment']." !important;"; } $c_style.="}"; if ($c_style!="#spr_container{}") { $style.=$c_style; } $style.="</style>"; if ($style!="<style></style>") { echo $style; } } function spr_get_post_types_fo() { $options=spr_options(); $post_types=get_post_types(array('public'=>true, '_builtin'=>false), 'objects', 'and'); $result='<table><tr><td class="spr_cb_labels">Posts</td><td><input type="checkbox" name="post" id="post" value="'.$options['where_to_show']['post'].'" '.checked($options['where_to_show']['post'], 1, false).'></td></tr><tr><td class="spr_cb_labels">Pages</td><td><input type="checkbox" name="page" id="page" value="'.$options['where_to_show']['page'].'" '.checked($options['where_to_show']['page'], 1, false).'></td></tr>'; foreach ($post_types as $post_type) { $result.= '<tr><td class="spr_cb_labels">'.$post_type->labels->name.'</td><td><input type="checkbox" name="'.$post_type->rewrite['slug'].'" id="'.$post_type->rewrite['slug'].'" value="'.$options['where_to_show'][$post_type->rewrite['slug']].'" '.checked($options['where_to_show'][$post_type->rewrite['slug']], 1, false).'></td></tr>'; } $result.="</table>"; return $result; } function spr_list_cpt_slugs() { $types=array("post", "page"); $post_types=get_post_types(array('public'=>true, '_builtin'=>false), 'objects', 'and'); foreach ($post_types as $post_type) { $types[]=$post_type->rewrite['slug']; } return $types; } function spr_get_ip() { if (getenv("HTTP_CLIENT_IP")&&strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) { $ip=getenv("HTTP_CLIENT_IP"); } else if (getenv("HTTP_X_FORWARDED_FOR")&&strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) { $ip=getenv("HTTP_X_FORWARDED_FOR"); } else if (getenv("REMOTE_ADDR")&&strcasecmp(getenv("REMOTE_ADDR"), "unknown")) { $ip=getenv("REMOTE_ADDR"); } else if (isset($_SERVER['REMOTE_ADDR'])&&$_SERVER['REMOTE_ADDR']&&strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) { $ip=$_SERVER['REMOTE_ADDR']; } else { $ip="unknown"; } return($ip); } function spr_list_ratings($post) { $options=spr_options(); global $wpdb; wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); $query="select <code>points</code>,<code>user_id</code>, count(points) as <code>amount</code> from <code>".$wpdb->prefix."spr_votes</code> where <code>post_id</code>='".$post->ID."' group by <code>points</code> order by <code>points</code> asc;"; $list=$wpdb->get_results($query, ARRAY_A); $html=""; $result=""; if (count($list)>0) { $totalpoints=0; $totalvoters=0; for ($i=$options['scale']; $i>=1; $i--) { $users=0; $guests=0; $votes=0; $found=false; foreach ($list as $list_) { if ($list_['points']==$i) { $found=true; $totalpoints+=$list_['points']*$list_['amount']; $totalvotes+=$list_['amount']; $votes=$list_['amount']; if (is_numeric($list_['used_id'])) { $users++; } else if ($options['allow_guest_vote']&&filter_var($list_['used_id'], FILTER_VALIDATE_IP)) { $guests++; } } } if ($found) { if ($votes==1) { $votesorvote='vote'; } else { $votesorvote='votes'; } $html.='<div id="spr_visual_container_adm">'.spr_show_voted(1, $i, false).'<span id="spr_votes">'.$votes." ".$votesorvote."</span></div><br/>"; } else { $html.='<div id="spr_visual_container_adm">'.spr_show_voted(1, $i, false)."<span id='spr_votes'>0 votes</span></div><br/>"; } } $result='<div id="spr_visual_container_adm">'.spr_show_voted($totalvotes, $totalpoints, true)."</div><div style='text-align:center;font-size:15px;margin:3px;font-weight:700;'>Statistics by rating:</div>"; } else { $html.="There are no votes for this entry yet."; } echo $result.$html; } function spr_add_custom_box() { $options=spr_options(); if ($options['show_stats_metabox']) { foreach ($options['where_to_show'] as $k=> $v) { if ($v) { $screens[]=$k; } } if (count($screens)>0) { foreach ($screens as $screen) { add_meta_box('spr_rating_stats', __('Rating statistics', 'spr_text_domain'), 'spr_list_ratings', $screen, 'side'); } } } } add_action('add_meta_boxes', 'spr_add_custom_box'); add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'spr_add_settings_link'); add_filter('wp_insert_post_data', 'spr_new_update_post_handler', '99', 2); add_action('post_submitbox_misc_actions', 'add_spr_checkbox'); add_action('admin_menu', 'spr_menu'); add_action('wp_ajax_spr_rate', 'spr_rate'); add_action('wp_ajax_nopriv_spr_rate', 'spr_rate'); register_activation_hook(__FILE__, 'spr_activation_func'); ?>Here is code from settings.php. Here I think I probably have to change wp_enqueue to something else, among other things:
<?php if (isset($_POST['spr_reset_votes'])) { if (current_user_can('activate_plugins')) { spr_truncate_tables(); } } spr_save_settings(); $options=spr_options(); wp_enqueue_style('farbtastic'); wp_enqueue_script('farbtastic'); wp_enqueue_style('spr_style', plugins_url('/resources/spr_style.css', __FILE__)); wp_enqueue_script('spr_admin', plugins_url('/resources/spr_admin.js', __FILE__), array('farbtastic', 'jquery'), NULL); wp_localize_script('spr_admin', 'spr_ajax_object', array('scale'=>$options['scale'], 'spr_type'=>$options['color'].$options['shape'])); ?> <h1>Adjust settings of the Simple Rating</h1> <div style="float:left;"> <form name="form" method="POST" style="margin-top:15px;"> <table> <tr> <td class="spr_adm_label"><label>Show rating</label></td> <td><input type="checkbox" name="spr_activated" id="spr_activated" value="<?php echo $options['activated']; ?>" <?php checked($options['activated'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="Unless you check this box, rating won't show up."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Allow guests to vote</label></td> <td><input type="checkbox" name="spr_allow_guest_vote" id="spr_allow_guest_vote" value="<?php echo $options['allow_guest_vote']; ?>" <?php checked($options['allow_guest_vote'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="If you check this box, guests will be allowed to vote. Guest votes will be tracked by IP instead of UserID"></div></td> </tr> <tr> <td class="spr_adm_label"><label>Insertion method</label></td> <td> <select name="spr_method" id="spr_method" class="spr_admin_input"> <option value="auto" <?php selected($options['method'], 'auto', true); ?>>Automatic</option> <option value="manual" <?php selected($options['method'], 'manual', true); ?>>Manual</option> </select> </td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="Automatic method is recommended if you don't want to touch theme files. It will use filter to insert rating before or after content. If you want to insert rating into a specific part of your template, set method to Manual and insert <?php if(function_exists('spr_show_rating')){echo spr_show_rating();}?> where you need it."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Shape</label></td> <td> <select name="spr_shape" id="spr_shape" class="spr_admin_input"> <option value="s" <?php selected($options['shape'], 's', true); ?>>Stars</option> <option value="c" <?php selected($options['shape'], 'c', true); ?>>Circles</option> <option value="h" <?php selected($options['shape'], 'h', true); ?>>Hearts</option> <option value="b" <?php selected($options['shape'], 'b', true); ?>>Bar</option> </select> </td> </tr> <tr> <td class="spr_adm_label"><label>Color</label></td> <td> <select name="spr_color" id="spr_color" class="spr_admin_input"> <option value="y" <?php selected($options['color'], 'y', true); ?>>Yellow</option> <option value="p" <?php selected($options['color'], 'p', true); ?>>Purple</option> <option value="g" <?php selected($options['color'], 'g', true); ?>>Green</option> <option value="b" <?php selected($options['color'], 'b', true); ?>>Blue</option> <option value="r" <?php selected($options['color'], 'r', true); ?>>Red</option> </select> </td> </tr> <tr> <td class="spr_adm_label"><label>Alignment</label></td> <td> <select name="spr_alignment" id="spr_alignment" class="spr_admin_input"> <option value="center" <?php selected($options['alignment'], 'center', true); ?>>Center</option> <option value="right" <?php selected($options['alignment'], 'right', true); ?>>Right</option> <option value="left" <?php selected($options['alignment'], 'left', true); ?>>Left</option> </select> </td> </tr> <tr> <td class="spr_adm_label"><label>Show vote count</label></td> <td><input type="checkbox" name="spr_show_vote_count" id="spr_show_vote_count" value="<?php echo $options['show_vote_count']; ?>" <?php checked($options['show_vote_count'], 1, true); ?>></td> </tr> <tr> <td class="spr_adm_label"><label>Vote count color</label></td> <td> <input type="text" size="10" maxlength="8" name="spr_vote_count_color" id="spr_vote_count_color" value="<?php echo $options['vote_count_color']; ?>" class="spr_admin_input"> </td> <td><a href="#" id="spr_vote_count_color_box" class="pickcolor" style="padding: 4px 11px; border: 1px solid #dfdfdf; background-color: <?php echo $options['vote_count_color']; ?>;"></a> <div id="psr_color_picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div></td> </tr> <tr> <td class="spr_adm_label"><label>Vote count style</label></td> <td> Bold <input type="checkbox" name="spr_vc_bold" id="spr_vc_bold" value="<?php echo $options['vc_bold']; ?>" <?php checked($options['vc_bold'], 1, true); ?>> Italic <input type="checkbox" name="spr_vc_italic" id="spr_vc_italic" value="<?php echo $options['vc_italic']; ?>" <?php checked($options['vc_italic'], 1, true); ?>> </td> </tr> <tr> <td class="spr_adm_label"><label>Scale</label></td> <td><input type="text" size="10" maxlength="200" name="spr_scale" id="spr_scale" value="<?php echo $options['scale']; ?>" class="spr_admin_input"></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="Scale of rating. Allowed values: 3-10."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Where to add rating</label></td> <td> <?php echo spr_get_post_types_fo(); ?> </td> </tr> <tr> <td class="spr_adm_label"><label>Position</label></td> <td> <select name="spr_position" id="spr_position" class="spr_admin_input"> <option value="before" <?php selected($options['position'], 'before', true); ?>>Before content</option> <option value="after" <?php selected($options['position'], 'after', true); ?>>After content</option> </select> </td> </tr> <tr> <td class="spr_adm_label"><label>Show in loops</label></td> <td><input type="checkbox" name="spr_show_in_loops" id="spr_show_in_loops" value="<?php echo $options['show_in_loops']; ?>" <?php checked($options['show_in_loops'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="Check this box if you want to show rating in the loops. Category page for example. Note: voting is allowed only from a single page."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Show in loop on home page</label></td> <td><input type="checkbox" name="spr_loop_on_hp" id="spr_loop_on_hp" value="<?php echo $options['loop_on_hp']; ?>" <?php checked($options['loop_on_hp'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="If your homepage uses loop and you want to show rating there, check this box."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Use aggregated rating</label></td> <td><input type="checkbox" name="spr_use_aggregated" id="spr_use_aggregated" value="<?php echo $options['use_aggregated']; ?>" <?php checked($options['use_aggregated'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="If you check this box, rating will be shown in search engines' snippets. See Screenshot 4 for example. Note: this plugin can't control rating style in snippets."></div></td> </tr> <tr> <td class="spr_adm_label"><label>Show statistics metabox</label></td> <td><input type="checkbox" name="spr_show_stats_metabox" id="spr_show_stats_metabox" value="<?php echo $options['show_stats_metabox']; ?>" <?php checked($options['show_stats_metabox'], 1, true); ?>></td> <td class="spr_hint_container"><div class="spr_hint tooltip-right" data-tooltip="If you check this box, you will see metabox with rating statistics when editing posts/pages/custom post type entries."></div></td> </tr> </table> <input type="submit" style="margin-top:10px;" class='button button-primary button-large' value="Save settings"> </form> </div> <div id="postbox-container-1" class="postbox-container" style="float: right;display:inline-block;width: 280px;margin-right:20px;"> <div class="postbox "> <h3 class="spr_widget_title"> <span>Live preview</span> </h3> <div class="inside"> <div id="spr_container"><div class="spr_visual_container"><?php echo spr_show_voting(5, 25, $options['show_vote_count']); ?></div></div> </div> </div> <div class="postbox "> <h3 class="spr_widget_title"> <span>Donate</span> </h3> <div class="inside"> <form action="https://www.moneybookers.com/app/payment.pl" method="post"> <input type="hidden" name="pay_to_email" value="igor.yavych@gmail.com"> <input type="hidden" name="status_url" value="mailto:igor.yavych@gmail.com"> <input type="hidden" name="language" value="EN"> <input type="hidden" name="recipient_description" value="Simple Rating"> <input type="text" name="amount" size="5" value="5" /> <select name="currency" style="margin-top:-1px;" id="currency"> <option value="USD" selected="selected">USD</option> <option value="EUR">EUR</option> </select> <input type="hidden" name="confirmation_note" value="Thanks for your support!"> <br/><input class="spr_button button button-primary button-small" type="submit" value="Donate via Skrill"> </form> </div> </div> <div class="postbox "> <h3 class="spr_widget_title"> <span>Reset votes</span> </h3> <div class="inside"> <form method="post" onsubmit="return confirm('Do you really want to reset votes?')"> You can reset votes by pressing button below.<br/> <input type="hidden" name="spr_reset_votes" value="1"> <input class="spr_button button button-primary button-small" type="submit" value="Reset votes"> </form> </div> </div> <div class="postbox "> <h3 class="spr_widget_title"> <span>Feedback</span> </h3> <div class="inside"> Found a bug? Or maybe have a feature request? Head over to <a href="http://wordpress.org/support/plugin/simple-rating">support forum</a> and let me know! </div> </div> </div>May 30, 2014 at 9:42 am #147185Topic: Default reply form behavior.
in forum Troubleshootinginfd
ParticipantIf i push “reply” on any post then default reply form push my post directly under that post. If i don’t push “reply” on any post then default reply form behaves as if I pressed the answer under the first post in the topic. Is it possible to change this behavior? I need this – if i don’t push “reply” then my post appears last in topic as if i pressed the answer to the last post of the topic.
WordPress 3.9.1
bbPress 2.5.3May 30, 2014 at 6:56 am #147180In reply to: Newby a little lost
Robin W
Moderatorok, so we’re back to setting the default template that bbpress uses, but this time to one with a sidebar
May 30, 2014 at 4:24 am #147170In reply to: All topics' freshness updates whenever someone posts
Robin W
Moderatorpossibly a conflict
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, switch to a default theme such as twentytwelve, and see if this fixes.
May 29, 2014 at 2:25 pm #147155In reply to: Only the admin can attach
Robin W
Moderatoryou could try adding the following to your functions file
add_filter( 'd4p_is_bbpress', '__return_true' );or seeing if your theme or other plugins are affecting
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, switch to a default theme such as twentytwelve, and see if this fixes.
May 29, 2014 at 2:19 pm #147154In reply to: Forum styling broken on category view
Robin W
ModeratorCan you just eliminate theem or plugin issues, this should show descriptions (content) on the category pages.
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, switch to a default theme such as twentytwelve, and see if this fixes.
May 29, 2014 at 6:50 am #147115Robin W
Moderatorok, quick and messy way (based on some code I did elsewhere)
create a directory in your theme root called bbpress
wp-content/themes/%your-theme-name%/bbpress
copy
wp-content/plugins/bbpress/templates/default/bbpress
loop-replies.php
and
loop-single-reply.phpinto this directory
bbpress will now use these files instead
in loop-replies change from line 40 to
<li class="bbp-body"> <?php if ( bbp_thread_replies() ) : ?> <?php bbp_list_replies(); ?> <?php else : ?> <?php global $countr ; $countr=0 ; ?> <?php while ( bbp_replies() ) : bbp_the_reply(); ?> <?php $countr ++ ; <?php bbp_get_template_part( 'loop', 'single-reply' ); ?> <?php endwhile; ?>This is basically just putting a count into this, so that we can see that the topic is count 0
then in loop-single-reply change line 45 to read
<?php if ($countr !=0) bbp_reply_author_link( array( ‘sep’ => ‘<br />’, ‘show_role’ => true ) ); ?>
I’ve not tested this, but you should be able to get it to work.
May 29, 2014 at 6:13 am #147109In reply to: Newby a little lost
kowarler
ParticipantNice one – thanks for that. If I set it the template to default, that should work?
I’m having ‘fun’ with my child-theme setup at the moment, so can’t experiment at the mo.
May 29, 2014 at 4:37 am #147103demonboy
ParticipantA slightly different question to the last one about visibility. I’d like to make the one private forum’s TITLE and TOPIC COUNT visibile to everyone. If they try and click on it, they’re taken to a page which tells them it’s members only (that part I’ve got covered).
I thought when I first installed bbpress this was actually the default setting but when I log out I don’t see the forum title. Have I inadvertently changed a setting whilst piddling around with plugins, or did I just imagine it? Is this at all possible?
May 29, 2014 at 3:45 am #147099In reply to: Forum styling broken on category view
Robin W
ModeratorI haven’t taken a detailed look at your problem but you could try adding this to you functions file
//This function adds descriptions to the sub forums function custom_list_forums( $args = '' ) { // Define used variables $output = $sub_forums = $topic_count = $reply_count = $counts = ''; $i = 0; $count = array(); // Parse arguments against default values $r = bbp_parse_args( $args, array( 'before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, ), 'list_forums' ); // Loop through forums and create a list $sub_forums = bbp_forum_get_subforums( $r['forum_id'] ); if ( !empty( $sub_forums ) ) { // Total count (for separator) $total_subs = count( $sub_forums ); foreach ( $sub_forums as $sub_forum ) { $i++; // Separator count // Get forum details $count = array(); $show_sep = $total_subs > $i ? $r['separator'] : ''; $permalink = bbp_get_forum_permalink( $sub_forum->ID ); $title = bbp_get_forum_title( $sub_forum->ID ); $content = bbp_get_forum_content($sub_forum->ID) ; // Show topic count if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) { $count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID ); } // Show reply count if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) { $count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID ); } // Counts to show if ( !empty( $count ) ) { $counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after']; } // Build this sub forums link $output .= $r['before'].$r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'].'<div class="bbp-forum-content">'.$content.'</div>'.$r['after']; } // Output the list return $output ; } } add_filter('bbp_list_forums', 'custom_list_forums' );May 28, 2014 at 3:55 am #147057In reply to: Newby a little lost
peter-hamilton
ParticipantA category can have multiple forums, a forum can not have multiple categories.
Forums can have sub-forums, so the hierarchy goes like this:
Category : transportation
Forum : Trains
Subforum : My favorite trainCategory : transportation
Forum : cars
Subforum : Who Likes Mini’s anyway?You could create a menu in “appearances => menus”
Add your category to the menu, save and use “manage locations” to add your new menu instead of the default menu.That menu link should bring you on a page showing a list of your forums!
If you want to land directly on a forum’s page you add a forum link (instead of category) to your menu and repeat previous steps.
That is how I create my current theme http://www.cultivators-forum.com
good luck
P.H.May 28, 2014 at 3:47 am #147056In reply to: Moving bbPress Edit profile forms
Robin W
Moderatorok, you could just call each by their url
or if you know the username you could call the form from within a page using the ‘insert php’ plugin
https://wordpress.org/plugins/insert-php/
then
[insert_php]
$user_id = whatever you used to get the user-id
$filelocation=”wp-content/plugins/bbpress/templates/default/bbpress/form-user-edit.php”;
include($_server[‘DOCUMENT_ROOT’].$filelocation);
[/insert_php]May 28, 2014 at 1:09 am #147050Topic: Hello from Japan! How to remove the anchor tag…
in forum Troubleshootingyoosuke
ParticipantHello from Japan!
bbpress is great!Well, I’m in trouble.
so I would appreciate if you help me.1.
By default, an anchor tag is given to texts of “freshness“. like…<a>2hours, 1minute ago</a>To remove the anchor tag from freshness texts, which files should I modify ?
Could you please tell me a path to get to the file?2.
By default, a comma is used in display of “freshness”. like..2hours,(←here!) 1minute agoI want to also remove the comma.
In this case, a file to be modified will be the same as the file described above?Thanks for reading,
and I’m looking forward to your reply…WordPress: ver3.9.1
bbPress: ver2.5.3May 27, 2014 at 3:10 am #147009In reply to: Templating Issue
Robin W
Moderatorok, the simplest way would be as follows
In you theme create a directory called bbpress
ie wp-content/your-theme-name/bbpress
The copy the following file into this
wp-content/plugins/bbpress/templates/default/bbpress/loop-single-forum.php
so you end up with a file
wp-content/your-theme-name/bbpress/loop-single-forum.php
bbpress will now sue this file instead of the default one, so then edit this file to change line 68 from
<span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>to
<span class="bbp-topic-freshness-author"><?php //bbp_author_link( array( 'post_id' => bbp_get_forum_last_active_id(), 'size' => 14 ) ); ?></span>If your theme is a child theme, then that will be fine. If it is a main theme, then just keep a note of this change, as you may have to repeat it on a theme update.
May 26, 2014 at 8:10 am #146984Topic: View of latest topic for group forums
in forum Troubleshootingflipdamusic
ParticipantHi,
i have the challenge to show the latest topics for the role members in the topic index view. I’m new to bbpress so i’ve to learn a lot.I’m using buddypress with sidewide and group forums. Each group has one forum.
When I’m using a site and shortcode [bbp-topic-index] only all topics from the sidewide forums are shown. What I’ve learned is that this is a default behavior – i hope i’m not wrong 🙂Now I want to show all latest topics / posts for all members belonging to their group / group forum – optimal on the latest topic page. The users are members (bbpress) and abonnents (WordPress).
How do i accomplish that ?May 24, 2014 at 9:18 am #146941In reply to: New Users Auto Subscribe to One Forum
Nathan
ParticipantHi Christian,
The code I ended up using was not my original idea. I didn’t hook into a new user creation. What this does is inverts the subscribe list. It turns it into an unsubscribe list. So any user should be subscribed to any new forum by default. Let me know if something is not working for you, and I’ll see what I can do!– Nathan
May 23, 2014 at 11:04 am #146903In reply to: WP Symposium converter for bbPress
lagrou
ParticipantSomething odd about those “replies to replies”. I had assumed they would be there by default, but couldn’t see them…
I’ve added some ‘replies to replies’ to my test WPS forum before converting it… In bbPress, in the backend they are not displayed in the list of replies, although I do see ‘hidden’ replies in the count that I cannot access to. In the frontend, the forum topic does not show those replies, nor do the counters. However!! When dumping wp_posts table WHERE post_type = ‘reply’, they are there, so they were converted ok, it’s just that they don’t show. I did set bbPress threated replies 2 levels deep before conversion. Any advice…?
As far as groups forum topics, I would add ‘AND symposium_topics.topic_group = 0 ‘ to the ‘from_expression’ of both the topic ID and Reply ID sections to get rid of those posts. Cleaner until v2.
May 23, 2014 at 10:41 am #146901In reply to: Subscribers unable to write topics & add images
Robin W
ModeratorI think you need to eliminate conflicts for instance maybe the access plugin is conflicting
try
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, switch to a default theme such as twentytwelve, and see if this fixes.
May 23, 2014 at 10:24 am #146900In reply to: Per Forum Permissions by Group
Robin W
ModeratorJust taken a good look at form_reply_move.php and that calls a function that uses the bbp_has_topics with a ‘post__not_in’ parameter. My function uses a ‘post__in’ parameter, and wp-Query can’t handle both in one query, hense why it falls over.
I’m already in trouble with my wife for still typing this, but try copying
wp-content/bbpress/templates/default/bbpress/form_reply_move.php to a folder called bbpress within the root of your theme – ie wp-content/your-theme-name/bbpress/form_reply_move.php
this will create a copy that is used instead of the default
try
changing
line 45
<?php if ( bbp_has_topics( array( 'show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id( bbp_get_reply_id() ), 'post__not_in' => array( bbp_get_reply_topic_id( bbp_get_reply_id() ) ) ) ) ) : ?>to
<?php //if ( bbp_has_topics( array( 'show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id( bbp_get_reply_id() ), 'post__not_in' => array( bbp_get_reply_topic_id( bbp_get_reply_id() ) ) ) ) ) : ?>and line 63
from
<?php endif; ?>
to
<?php //endif; ?>
This just takes that argument out and see how it runs then
If that works, then I can play with what is needed – think I know, but am out of the door….now !!!
May 23, 2014 at 12:59 am #146820In reply to: Give bbPress full editor by default?
Stephen Edgar
KeymasterIt is not a bug, we removed the default behaviour to have both editors enabled by default in 2.3.1, switching between editor types would more often than not change the content of the users topics or replies.
Now that TinyMCE v4 has shipped with WordPress v3.9.x once we have a few more architectural fixes in bbPress we can take another look, it is far from a small bug, quite complex to be honest.
May 23, 2014 at 12:17 am #146812Topic: Give bbPress full editor by default?
in forum Requests & FeedbackMycelus
ParticipantHey guys. So Ive been wondering this for a long time, and I just dont understand. Why is bbPress’ editor so bad? Everything uses lame tags and is very primitive. WordPress already has color and bold and italic and linking and everything integrated, so why doesn’t bbPress add this?
No one can actually tell me that bbPress is meant to be this way? Is there something stopping the devs from just importing the full editor over…?
Very curious…
May 22, 2014 at 11:56 pm #146810demonboy
ParticipantI have added this code to my functions.php file
function mycustom_breadcrumb_options() { // Home - default = true $args['include_home'] = false; // Forum root - default = true $args['include_root'] = true; // Current - default = true $args['include_current'] = false; return $args; } add_filter('bbp_before_get_breadcrumb_parse_args', 'mycustom_breadcrumb_options' );… but that last argument only works for the original post, which returns something like this:
Forums › Assignment Submissions ›
On the replies underneath it includes the current location, something like this:
Forums › Assignment Submissions › Assignment 24: 1st 24 hours in Crown Point, Tobago
You can see this in action here.
How do I remove that last part in the replies?
May 22, 2014 at 4:21 pm #146788In reply to: Unable to Assign Forum to Topic
Robin W
ModeratorIt could be a theme or plugin issue
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Themes
If plugins don’t pinpoint the problem, switch to a default theme such as twentytwelve, and see if this fixes.
May 22, 2014 at 3:16 pm #146784Topic: Adding forum posts to activity stream…
in forum Troubleshootingdugfunny
ParticipantUsing this code I have made it to where only updates and rtmedia posts show up on my activity stream
/** * Activity Stream Default Updates */ function make_swa_show_notice_only( $retval ) { if ( bp_is_page( 'activity' ) ) { $retval['action'] = 'activity_update, rtmedia_update'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );I would like bbpress forum posts to show up on my wall as well. What would i put next to
‘activity_update, rtmedia_update’
in my code to make that happen? Thanks!
May 22, 2014 at 10:36 am #146770demonboy
ParticipantGoing nuts, here. I’m using an Avada child theme and I’m fairly au fait with CSS and getting under the bonnet with PHP (commenting stuff out etc), though I’ve not done much aside from a few CSS changes.
My forum home has the sidebar on the left. The problem is when I click into a forum, (so the URL is http://www.lizcleere.com/forums/forum/assignments/, for example), the sidebar now jumps to the right. Same when I click into a topic.
What isn’t explained very well is the use of the additional slugs. ‘Topic’ is set as the slug ‘topic’, so surely it stands to reason that I create a ‘topic’ page, format it how I want the ‘topic’ section to appear, and save it with the name ‘topic’. I’ve tried that and it doesn’t work.
I’ve also tried disabling the WP Tweaks plugin, removing the inactive widgets, logging out, logging back in, reactivating etc etc. Nothing.
I then took a copy of Avada’s single.php and renamed it forum.php and made it a template. I’ve called that template up on my Forum page and the sidebar appears on the left, as intended. (Actually, it’s the Blog sidebar, even though I’ve set it to BBPress sidebar, but that’s another story.)
Why do ‘forum’ and ‘topic’ not inherit the properties I set on the forums page (i.e. default layout (not 100% width or full page or anything like that), sidebar on left, using the forum template page)? I feel like I’m missing something really obvious…
-
AuthorSearch Results