Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 65051

Add Widget Support

$
0
0

Replies: 0

I just add widget support for this plugin:
`
add_action( ‘widgets_init’, ‘bp_profile_views_wdgt’ );

function bp_profile_views_wdgt() {
register_widget( ‘bp_profile_views’ );
}

class bp_profile_views extends WP_Widget
{

public function __construct()
{
$widget_details = array(
‘classname’ => ‘bp_profile_views’,
‘description’ => ‘BP user profile view count widget.’
);

parent::__construct( ‘bp_profile_views’, ‘BP Profile View Count’, $widget_details );

}

public function form( $instance ) {
// Backend Form
}

public function update( $new_instance, $old_instance ) {
return $new_instance;
}

public function widget( $args, $instance ) {
global $bv_views_log_model;

$displayed_user_id = bp_displayed_user_id();

$where = array(
‘member_id’ => $displayed_user_id,
);

$views = $bv_views_log_model->get( $where );

if( !empty( $views ) ) {
$views_count = count( $views );
?><span
class=”bv-view-count”><?php echo sprintf( _n( ‘%s Profile View’, ‘%s Profile Views’, $views_count, ‘buddy-views’ ), $views_count ); ?></span><?php

}
}

}’


Viewing all articles
Browse latest Browse all 65051

Trending Articles