Comments link goes to Home Page and Favorites to 404
-
I built a custom widget with an activity stream so my client can set a group ID to display a “featured group” in the sidebar. The group avatar displays as well as the activity stream. All of the activity links work correctly, except for comments and favorites.
Comments goes to the home page and favorites returns a 404.
Favorites: http://www.prolifeplanet.com/activity/favorite/114/?_wpnonce=6d82795544
Here is my widget code:
`
add_action( ‘widgets_init’, ‘featured_bpgroup_widget’ );/**
* Register our widget
*/
function featured_bpgroup_widget() {
register_widget( ‘tfd_Featured_BPGroup’ );
}/**
* Add widget style
*/add_action(‘wp_enqueue_scripts’, ‘bpfg_styles’);
function bpfg_styles() {
wp_enqueue_style(‘bpfg-style’, plugin_dir_url(__FILE__) . ‘bpfg-style.css’);
}/*** Widget class ***/
class tfd_Featured_BPGroup extends WP_Widget {/**
* Widget setup.
*/
function tfd_Featured_BPGroup() {
/* Widget settings. */
$widget_ops = array( ‘classname’ => ‘bp_fgroup’, ‘description’ => __(‘A widget to display a featured buddy press group.’, ‘fgroup’) );/* Widget control settings. */
$control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘featured-bpgroup’ );/* Create the widget. */
$this->WP_Widget( ‘featured-bpgroup’, __(‘Featured BP Group’, ‘fgroup’), $widget_ops, $control_ops );
}/**
* How to display the widget on the screen.
*/
function widget( $args, $instance ) {
extract( $args );/* Our variables from the widget settings. */
$title = apply_filters(‘widget_title’, $instance );
$description = $instance;
if ( !$groupid = (int) $groupid )$groupid = 4;/* Before widget (defined by themes). */
echo $before_widget;/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;/* Display Group Avatar */
$avatar = bp_core_fetch_avatar( array( ‘item_id’ => $groupid, ‘object’ => ‘group’, ‘type’ => ‘full’, ‘avatar_dir’ => ‘group-avatars’, ‘alt’ => $alt, /* ‘css_id’ => $id, */’class’ => $class/* , ‘width’ => ‘150px’, ‘height’ => ‘150px’ */ ) );printf( ‘
‘ . __(‘%1$s’, ‘fgroup’) . ‘
‘, $avatar );
/* Display User-Defined Group Description */
if ( $description )
printf( ‘‘ . __(‘%1$s’, ‘fgroup’) . ‘
‘, $description );
/* Display Group Activity */
if ( bp_has_activities (array ( ‘primary_id’ => $groupid, ‘max’ => ‘5’) ) ) : while ( bp_activities() ) : bp_the_activity();
locate_template( array( ‘activity/entry.php’ ), true, false );
endwhile; endif;
wp_reset_query();
/* After widget (defined by themes). */
echo $after_widget;
}/*** Update the widget settings. ***/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;/*** Strip tags ***/
$instance = strip_tags( $new_instance );
$instance = (int) $new_instance;
$instance = strip_tags( $new_instance );return $instance;
}/*** Display widget setting controls on the widget panel. ***/
function form( $instance ) {/* Default widget settings. */
$defaults = array( ‘title’ => __(‘Featured Group’, ‘fgroup’));
$defaults = array( ‘groupid’ => __(‘4’, ‘fgroup’));
$instance = wp_parse_args( (array) $instance, $defaults ); ?><label for="get_field_id( ‘title’ ); ?>”>
<input id="get_field_id( ‘title’ ); ?>” name=”get_field_name( ‘title’ ); ?>” value=”” style=”width:100%;” />
Default: Featured Group<label for="get_field_id( ‘groupid’ ); ?>”>
<input id="get_field_id( ‘groupid’ ); ?>” name=”get_field_name( ‘groupid’ ); ?>” value=”” style=”width:100%;” />
Find the ID in the Network Admin Dashboard under “Buddypress/Group Management”.<label for="get_field_id( ‘description’ ); ?>”>
<input id="get_field_id( ‘description’ ); ?>” name=”get_field_name( ‘description’ ); ?>” value=”” style=”width:100%;” />
Optional: Enter a description or leave blank.<?php
}
}`Any idea what’s going on? The favorites and comments work fine from the other pages, just not from my widget.
- The topic ‘Comments link goes to Home Page and Favorites to 404’ is closed to new replies.