'digits’ => 6,
'format’ => ”,
'tenths’ => true,
'digit_height’ => 40,
'digit_width’ => 30,
'digit_padding’ => 0,
'digit_style’ => ”,
'alignment’ => 'center’,
'bustedness’ => 2,
'flat’ => false,
'speed’ => 80,
'start’ => 0,
'end’ => 0,
'direction’ => 'up’,
'timestamp’ => false,
'interval’ => 1,
'tick_multiplier’ => 1,
'active’ => true
), $atts );

$element_id = 'jellyfish-counter-shortcode-’ . esc_attr( $a[’id’] );

if ( $a[’timestamp’] ) {
$init_timestamp = strtotime( $a[’timestamp’], current_time( 'timestamp’ ) );
if ( $init_timestamp ) {
if ( $a[’direction’] == 'down’ ) {
$a[’start’] -= round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $a[’interval’] );
if ( $a[’start’] <= $a[’end’] ) { $a[’start’] = $a[’end’]; } } else { $a[’start’] += round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $a[’interval’] ); if ( $a[’start’] >= $a[’end’] ) {
$a[’start’] = $a[’end’];
}
}
}
} else {
$current_value = $a[’start’];
}
wp_enqueue_script( 'jellyfish_cw_odometer’ );
wp_enqueue_script( 'jellyfish_cw_loader’ );

$counter_html = ’

’;
return $counter_html;
}

// Counter Widget class
class Jellyfish_Counter_Widget extends WP_Widget {

function __construct() {
parent::__construct(
'counter_widget’, 'Counter Widget’, array( 'description’ => 'Show an odometer style counter’ )
);
}

// options form
function form( $instance ) {
// Retrieve previous values from instance or set default values if new
$disable_title = $instance[’disable_title’];
$disable_depth = $instance[’disable_depth’];
$disable_tenths = $instance[’disable_tenths’];
$persist = ( $instance[’persist’] == 'true’ || $instance[’persist’] == 'on’ ) ? 'on’ : null;
$init_timestamp = $instance[’init_timestamp’];

$start_value = ( is_numeric( $instance[’start_value’] ) ? $instance[’start_value’] : 0 );
$end_value = ( is_numeric( $instance[’end_value’] ) ? $instance[’end_value’] : 100 );
$animate_speed = ( is_numeric( $instance[’animate_speed’] ) ? $instance[’animate_speed’] : 50 );
$direction = ( !empty( $instance[’direction’] ) ? $instance[’direction’] : 'up’ );
$interval = ( is_numeric( $instance[’persist_interval’] ) ? $instance[’persist_interval’] : 1 );
$number_of_digits = ( is_numeric( $instance[’number_of_digits’] ) ? $instance[’number_of_digits’] : 5 );
$digit_height = ( is_numeric( $instance[’digit_height’] ) ? $instance[’digit_height’] : 40 );
$digit_width = ( is_numeric( $instance[’digit_width’] ) ? $instance[’digit_width’] : 30 );
$digit_padding = ( is_numeric( $instance[’digit_padding’] ) ? $instance[’digit_padding’] : 0 );
$digit_bustedness = ( is_numeric( $instance[’digit_bustedness’] ) ? $instance[’digit_bustedness’] : 2 );

$alignment = ( !empty( $instance[’alignment’] ) ? $instance[’alignment’] : 'center’ );
$digit_style = ( !empty( $instance[’digit_style’] ) ? $instance[’digit_style’] : 'font-family: Courier New, Courier, monospace; font-weight: 900;’ );
$widget_title = ( !empty( $instance[’widget_title’] ) ? $instance[’widget_title’] : 'Counter’ );
$before_text = $instance[’before_text’];
$after_text = $instance[’after_text’];
$format = $instance[’format’];

// get the current count of an active continuous counter
// set to end value if it’s already finished
if ( ( $persist == 'on’ ) && !empty( $init_timestamp ) ) {
if ( $direction == 'down’ ) {
$start_value -= round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $interval );
if ( $start_value < $end_value ) { $start_value = $end_value; } } elseif ( $direction == 'up’ ) { $start_value += round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $interval ); if ( $start_value > $end_value ) {
$start_value = $end_value;
}
}
}

?>




.



 


id=”
name=”
/>







id=”
name=”
/>






id=”
name=”” />




 


id=”
name=”” />

Amount of digit misalignment



wp_enqueue_script( 'jellyfish_cw_odometer’ );
wp_enqueue_script( 'jellyfish_cw_loader’ );
}
// Extract members of args array as individual variables
extract( $args );

$interval = ( isset( $instance[’persist_interval’] ) ?
$instance[’persist_interval’] : 1 );

$init_timestamp = ( isset( $instance[’init_timestamp’] ) ?
$instance[’init_timestamp’] : current_time( 'timestamp’ ) );

$disable_title = isset( $instance[’disable_title’] ) ? 'true’ : 'false’;
$disable_tenths = isset( $instance[’disable_tenths’] ) ? 'true’ : 'false’;
$tenths = $disable_tenths == 'true’ ? 'false’ : 'true’ ;
$disable_depth = isset( $instance[’disable_depth’] ) ? 'true’ : 'false’;
$persist = isset( $instance[’persist’] ) ? 'true’ : 'false’;
$direction = ( !empty( $instance[’direction’] ) ? $instance[’direction’] : 'up’ );

$format = $instance[’format’];
$number_of_digits = ( is_numeric( $instance[’number_of_digits’] ) ? $instance[’number_of_digits’] : 5 );
$start_value = ( is_numeric( $instance[’start_value’] ) ? $instance[’start_value’] : 0 );
$end_value = ( is_numeric( $instance[’end_value’] ) ? $instance[’end_value’] : 100 );

$animate_speed = $instance[’animate_speed’];
$wait_time = max( 0, ( 100 – $animate_speed ) );

$digit_height = ( is_numeric( $instance[’digit_height’] ) ? $instance[’digit_height’] : 40 );
$digit_width = ( is_numeric( $instance[’digit_width’] ) ? $instance[’digit_width’] : 30 );
$digit_padding = ( is_numeric( $instance[’digit_padding’] ) ? $instance[’digit_padding’] : 0 );
$digit_bustedness = ( is_numeric( $instance[’digit_bustedness’] ) ? $instance[’digit_bustedness’] : 2 );
$alignment = ( !empty( $instance[’alignment’] ) ? $instance[’alignment’] : 'center’ );
$digit_style = ( !empty( $instance[’digit_style’] ) ? $instance[’digit_style’] : 'font-family: Courier New, Courier, monospace; font-weight: 900;’ );
$widget_title = ( !empty( $instance[’widget_title’] ) ? $instance[’widget_title’] : 'Counter’ );
$before_text = esc_attr( $instance[’before_text’] );
$after_text = esc_attr( $instance[’after_text’] );

if ( $persist == 'true’ ) {
// calculate how may 'counts’ have passed since initializing the counter
// widget and update the start_value appropriately. If we have already
// passed the end_value then we don’t want to continue counting.
if ( $direction == 'down’ ) {
$start_value -= round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $interval );
if ( $start_value < $end_value ) { $start_value = $end_value; } } elseif ( $direction == 'up’ ) { $start_value += round( ( current_time( 'timestamp’ ) – $init_timestamp ) / $interval ); if ( $start_value > $end_value ) {
$start_value = $end_value;
}
}
$animate_speed = 100;
$tenths = 'false’;
} else {
$interval = 1;
}

if ( $direction == 'static’ ) {
$end_value = $start_value;
}

// Begin widget output
echo $before_widget;
if ( $disable_title == 'false’ ) {
echo $before_title;
echo apply_filters( 'widget_title’, $widget_title );
echo $after_title;
}
if ( $before_text ) {
echo ’

’;
echo apply_filters( 'widget_content’, $before_text );
echo ’

’;
}
echo ’

’;
if ( $after_text ) {
echo ’

’;
echo apply_filters( 'widget_content’, $after_text );
echo ’

’;
}
// finish off widget
echo $after_widget;
}
}

?>