-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
115 lines (100 loc) · 2.58 KB
/
functions.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Load and return WP Aparat options
*
* @return false|mixed
*/
function get_wp_aparat_options() {
return get_option('wpaparat_options');
}
/**
* Get WP Aparat option : Open in new tab
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_open_new_tab($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_newtab"] ?? true;
}
/**
* Get WP Aparat option : Image width
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_image_width($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_width"] ?? 139;
}
/**
* Get WP Aparat option : Image height
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_image_height($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_height"] ?? 78;
}
/**
* Get WP Aparat option : Figure width
* DEPRECATED
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_figure_width($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_figurewidth"] ?? 35;
}
/**
* Get WP Aparat option : Figure size
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_figure_size($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_figure_size"] ?? 'one-third';
}
/**
* Get WP Aparat option : Custom picture
*
* @param string $option
* @return bool|mixed
*/
function get_wp_aparat_option_custom_picture($option = '') {
if ( empty($option) )
$option = get_wp_aparat_options();
return $option["wpaparat_field_custom_picture"] ?? '';
}
/**
* Convert number duration into human-readable text
*
* @param int $duration
* @return string
*/
function wp_aparat_human_duration( $duration = 0 ) {
if ( $duration < 60 ) {
return "00:" . str_pad($duration, 2, "0", STR_PAD_LEFT);
}
else {
$minutes = intval( $duration / 60 );
$duration = $duration % 60;
if ( $minutes < 60 ) {
return str_pad($minutes, 2, "0", STR_PAD_LEFT) . ":" . str_pad($duration, 2, "0", STR_PAD_LEFT);
}
else {
$hours = intval( $minutes / 60 );
$minutes = $minutes % 60;
echo $hours . ":" . str_pad($minutes, 2, "0", STR_PAD_LEFT) . ":" . str_pad($duration, 2, "0", STR_PAD_LEFT);
}
}
return '';
}