'amaaaze-profile-widget',
'description' => esc_html__('Custom amaaaze Profile Widget', 'amaaaze')
);
parent::__construct( 'amaaaze-profile', esc_html__('amaaaze Profile', 'amaaaze') , $widget_ops );
}
//back-end display of widget
public function form( $instance ){
echo '
' . esc_html__( 'No options for this widget!', 'amaaaze') . ' ' .esc_html__( 'You can control the fields of this Widget from', 'amaaaze') .'' . esc_html__('This page', 'amaaaze') . '
';
}
//front-end display of widget
public function widget( $args, $instance ){
$picture = esc_attr( get_option( 'profile_picture' ) );
$firstName = esc_attr( get_option( 'first_name' ) );
$lastName = esc_attr( get_option( 'last_name' ) );
$fullName = $firstName . ' ' .$lastName;
$description = esc_attr( get_option( 'user_description' ) );
$twitter_icon = esc_attr( get_option( 'twitter_handler' ) );
$facebook_icon = esc_attr( get_option( 'facebook_handler' ) );
$gplus_icon = esc_attr( get_option( 'gplus_handler' ) );
echo $args['before_widget'];
?>
' ){
return;
}
else{
$links = str_replace('(', '', $links);
$links = str_replace(')', ' ', $links);
}
return $links;
}
add_filter( 'wp_list_categories', 'amaaaze_list_categories_output_change' );
function amaaaze_archive_postcount_filter ($links) {
if (strpos($links, '', $links);
$links = str_replace(')', ' ', $links);
}
return $links;
}
add_filter('get_archives_link', 'amaaaze_archive_postcount_filter');
/*
Save Posts views
*/
function amaaaze_save_post_views( $postID ){
$metaKey = 'amaaaze_post_views';
$views = get_post_meta( $postID, $metaKey, true );
$count = ( empty($views) ? 0 : $views );
$count++;
update_post_meta( $postID, $metaKey, $count );
}
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
/*
Popular posts widget
*/
class amaaaze_Popular_Posts_Widget extends WP_Widget{
public function __construct(){
$widget_ops = array(
'classname' => 'amaaaze-popular-posts-widget',
'description' => esc_html__('Popular Posts Widget','amaaaze')
);
parent::__construct( 'amaaaze_popular_posts', esc_html__('amaaaze Popular Posts','amaaaze'), $widget_ops );
}
//back-end display of widget
public function form( $instance ){
$title = ( !empty( $instance['title'] ) ? $instance['title'] : esc_html__('Popular Posts','amaaaze') );
$tot = ( !empty( $instance['tot'] ) ? absint( $instance['tot'] ) : 4 );
$output = '';
$output .= ''. esc_html__('Title:','amaaaze') .' ';
$output .= ' get_field_id('tot') ) .'">'. esc_html__('Number of Posts:','amaaaze') .'';
$output .= ' 'post',
'posts_per_page' => $tot,
'meta_key' => 'amaaaze_post_views',
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
$posts_query = new WP_Query( $posts_args );
echo $args['before_widget'];
if( !empty( $instance['title'] ) ):
echo $args['before_title']. apply_filters('widget_title', $instance['title']) . $args['after_title'];
endif;
if( $posts_query->have_posts() ) :
while( $posts_query->have_posts() ): $posts_query->the_post();
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
$posted_on = ''. get_the_date() .' ';
echo '
';
echo '
';
echo '
';
echo '
' .get_the_author_posts_link() .' ' ;
echo '' . $posted_on .' ' ;
echo '
';
echo '
';
the_post_thumbnail();
echo '
';
echo '
';
endwhile;
endif;
echo $args['after_widget'];
}
}
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
$posted_on = ''. get_the_date() .' ';
function amaaaze_register_popular_posts_widget_init() {
register_widget( 'amaaaze_Popular_Posts_Widget' );
}
add_action( 'widgets_init', 'amaaaze_register_popular_posts_widget_init');