| 1 |
<?php |
| 2 |
/** |
| 3 |
* Get all saved styles |
| 4 |
* |
| 5 |
* @since 2.1.3 |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Clean variables using sanitize_text_field. Arrays are cleaned recursively. |
| 15 |
*/ |
| 16 |
function ujic_clean( $var ) { |
| 17 |
if ( is_array( $var ) ) { |
| 18 |
return array_map( 'ujic_clean', $var ); |
| 19 |
} else { |
| 20 |
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Escape JSON for use on HTML or attribute text nodes. |
| 26 |
*/ |
| 27 |
function ujic_esc_json( $json, $html = false ) { |
| 28 |
return _wp_specialchars( |
| 29 |
$json, |
| 30 |
$html ? ENT_NOQUOTES : ENT_QUOTES, // Escape quotes in attribute nodes only. |
| 31 |
'UTF-8', // json_encode() outputs UTF-8 (really just ASCII), not the blog's charset. |
| 32 |
true // Double escape entities: `&` -> `&amp;`. |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Check whether the premium extension is loaded at runtime. |
| 38 |
*/ |
| 39 |
function ujic_is_pro_active() { |
| 40 |
return ( defined( 'UJIC_NAMEPRO' ) && 'Uji Countdown Pro' === UJIC_NAMEPRO ) |
| 41 |
|| defined( 'UJICOUNTDOWNPRO' ) |
| 42 |
|| class_exists( 'Uji_Countdown_Pro' ); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Return the plugin display name for the active free/pro combination. |
| 47 |
*/ |
| 48 |
function ujic_plugin_name() { |
| 49 |
if ( ujic_is_pro_active() && defined( 'UJIC_NAMEPRO' ) ) { |
| 50 |
return UJIC_NAMEPRO; |
| 51 |
} |
| 52 |
|
| 53 |
return defined( 'UJIC_NAME' ) ? UJIC_NAME : 'Uji Countdown'; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Return the plugin display version for the active free/pro combination. |
| 58 |
*/ |
| 59 |
function ujic_plugin_version() { |
| 60 |
if ( ujic_is_pro_active() && defined( 'UJIC_VERSPRO' ) ) { |
| 61 |
return UJIC_VERSPRO; |
| 62 |
} |
| 63 |
|
| 64 |
return defined( 'UJIC_VERS' ) ? UJIC_VERS : ''; |
| 65 |
} |
| 66 |
|
| 67 |
function ujic_styles_get( $first = '') { |
| 68 |
global $wpdb; |
| 69 |
$ujic_styles = $wpdb->get_results( "SELECT style, title, link FROM " . $wpdb->prefix . "uji_counter ORDER BY `time` DESC" ); |
| 70 |
$ujic_sel = array(); |
| 71 |
|
| 72 |
if ( !empty($ujic_styles) ) { |
| 73 |
foreach ( $ujic_styles as $ujic ) { |
| 74 |
$ujic_sel[$ujic->link] = $ujic->title; |
| 75 |
} |
| 76 |
|
| 77 |
if($first){ |
| 78 |
$selop = array( '' => $first ); |
| 79 |
$ujic_sel = array_merge($selop, $ujic_sel); |
| 80 |
} |
| 81 |
return $ujic_sel; |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
function ujic_datetime_get($nr) { |
| 87 |
$ujic_sel = array(); |
| 88 |
for ( $i = 0; $i <= $nr; $i++ ) { |
| 89 |
$ujic_sel[$i]['text'] = $num[sprintf("%02s", $i)] = sprintf("%02s", $i); |
| 90 |
$ujic_sel[$i]['value'] = $i; |
| 91 |
} |
| 92 |
|
| 93 |
return $ujic_sel; |
| 94 |
} |
| 95 |
|
| 96 |
function ujic_reclab_get() { |
| 97 |
$tlab = array('second'=> __( 'Second(s)', 'ujicountdown' ), |
| 98 |
'minute'=> __( 'Minute(s)', 'ujicountdown' ), |
| 99 |
'hour'=> __('Hour(s)', 'ujicountdown' ), |
| 100 |
'day'=> __( 'Day(s)', 'ujicountdown' ), |
| 101 |
'week'=> __( 'Week(s)', 'ujicountdown' ), |
| 102 |
'month'=> __( 'Month(s)', 'ujicountdown' )); |
| 103 |
$i=0; |
| 104 |
foreach ( $tlab as $v => $n ) { |
| 105 |
$ujic_sel[$i]['text'] = $n; |
| 106 |
$ujic_sel[$i]['value'] = $v; |
| 107 |
$i++; |
| 108 |
} |
| 109 |
|
| 110 |
return $ujic_sel; |
| 111 |
} |
| 112 |
|
| 113 |
?> |
| 114 |
|