'tempo_widget_post_meta',
'description' => __( 'This widget can be used only for single post templates', 'sarmys' )
));
}
/**
* Widget Preview
*/
function widget( $args, $instance )
{
global $post;
// extract args
extract( $args , EXTR_SKIP );
$instance = wp_parse_args( (array)$instance, array(
'title' => __( 'Post Meta Details', 'sarmys' )
));
if( !is_single() ){
return;
}
echo $before_widget;
if( !empty( $instance[ 'title' ] ) ) {
echo $before_title;
echo apply_filters( 'widget_title', esc_attr( $instance[ 'title' ] ), $instance, $this -> id_base );
echo $after_title;
}
// date settings
$y = esc_attr( get_post_time( 'Y', false, $post ) );
$m = esc_attr( get_post_time( 'm', false, $post ) );
$d = esc_attr( get_post_time( 'd', false, $post ) );
$name = esc_attr( get_the_author_meta( 'display_name' , $post -> post_author ) );
$time = esc_attr( get_post_time( 'Y-m-d', false, $post ) );
$wp_time = get_post_time( esc_attr( get_option( 'date_format' ) ), false , $post, true );
echo '
';
echo '
';
// edit link
edit_post_link( '' . __( 'Edit', 'sarmys' ) , '- ', '
' );
// date link
echo '- ';
echo '';
echo '
';
// author link
echo '- ' . esc_html( $name ) . '
';
// comments link
if( $post -> comment_status == 'open' ) {
$nr = get_comments_number( $post -> ID );
echo '- ';
echo '';
echo '';
echo sprintf( _nx( '%s Comment', '%s Comments', absint( $nr ), '...', 'sarmys' ), number_format_i18n( absint( $nr ) ) );
echo '
';
}
// jetpack nr view details
if( function_exists( 'stats_get_csv' ) ) {
$args = array(
'days' => -1,
'post_id' => $post -> ID,
);
$result = stats_get_csv( 'postviews' , $args );
$views = $result[ 0 ][ 'views' ];
echo '- ' . sprintf( _n( '%s view', '%s views', absint( $views ), 'sarmys' ), number_format_i18n( absint( $views ) ) ) . '
';
}
echo '
';
echo '
';
echo $after_widget;
}
/**
* Widget Update
*/
function update( $new_instance, $old_instance )
{
$instance = $old_instance;
$instance[ 'title' ] = sanitize_text_field( $new_instance[ 'title' ] );
return $instance;
}
/**
* Widget Form ( admin side )
*/
function form( $instance )
{
$instance = wp_parse_args( (array) $instance, array(
'title' => null
));
echo '';
echo '';
echo '
';
}
}
}
?>