-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrt-transcoder-progressbar.php
86 lines (79 loc) · 1.39 KB
/
rt-transcoder-progressbar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Handle progress calculation and display of progress bar.
*
* @since 1.0.0
*
* @package Transcoder
* @subpackage Transcoder/Admin
*/
/**
* Handle progress calculation and display of progress bar.
*
* @since 1.0.0
*
* @package Transcoder
* @subpackage Transcoder/Admin
*/
class RT_Progress {
/**
* Constructor
*
* @since 1.0.0
*
* @access public
* @return void
*/
public function __construct() {
}
/**
* Show progress_ui.
*
* @access public
*
* @since 1.0.0
*
* @param float $progress Progress value.
* @param bool $echo If true then echo the output else return.
*
* @return string $progress_ui Output of progress bar.
*/
public function progress_ui( $progress, $echo = true ) {
$progress_ui = '
<div id="rttprogressbar">
<div style="width:' . esc_attr( $progress ) . '%"></div>
</div>
';
if ( $echo ) {
echo wp_kses(
$progress_ui,
array(
'div' => array(
'id' => array(),
'style' => array(),
),
)
);
} else {
return $progress_ui;
}
}
/**
* Calculate progress %.
*
* @access public
*
* @since 1.0.0
*
* @param float $progress Progress value.
* @param float $total Total value.
*
* @return float
*/
public function progress( $progress, $total ) {
if ( $total < 1 ) {
return 100;
}
return ( $progress / $total ) * 100;
}
}