'Years',
'ujic_year' => 'Year',
'ujic_months' => 'Months',
'ujic_month' => 'Month',
'ujic_weeks' => 'Weeks',
'ujic_week' => 'Week',
'ujic_days' => 'Days',
'ujic_day' => 'Day',
'ujic_hours' => 'Hours',
'ujic_hour' => 'Hour',
'ujic_minutes' => 'Minutes',
'ujic_minute' => 'Minute',
'ujic_seconds' => 'Seconds',
'ujic_second' => 'Second',
);
}
/**
* Keep legacy Pro label sources visually aligned with the refreshed admin UI.
*
* @since 2.2
*/
public function ujic_admin_label_text( $translated, $text, $domain ) {
if ( 'ujicountdown' !== $domain || ! is_admin() ) {
return $translated;
}
$label_map = array(
'Select Style' => 'Choose Style',
'Select Style:' => 'Choose Style:',
'Main format:' => 'Primary Units:',
'Main Format:' => 'Primary Units:',
'Secondary format:' => 'Additional Units:',
'Secondary Format:' => 'Additional Units:',
'Ring Progress' => 'Progress Fill',
'Ring Progress:' => 'Progress Fill:',
'Line Color' => 'Ring Colors',
'Line Color:' => 'Ring Colors:',
'Select Line Color:' => 'Ring Colors:',
'Thickness' => 'Ring Thickness',
'Thickness:' => 'Ring Thickness:',
'Timer Size:' => 'Counter Size:',
'Save Timer Style' => 'Save Style',
);
if ( isset( $label_map[ $text ] ) ) {
return $label_map[ $text ];
}
return $translated;
}
/**
* Print template of table counters.
*
* @since 2.0
*/
public function admin_tablelist() {
$this->cform_delete();
if ( $this->saved_db_style() ) {
global $wpdb;
$style_count = absint( $wpdb->get_var( 'SELECT COUNT(*) FROM ' . $this->ujic_tab_name() ) );
$count_label = sprintf(
_n( '%s style', '%s styles', $style_count, 'ujicountdown' ),
number_format_i18n( $style_count )
);
$table_headers = '
' . esc_html( __( 'Create a Counter Style before generating a shortcode.', 'ujicountdown' ) ) . '
';
$cnt .= '';
if ( $this->cform_is_edit() ) {
$form .= '
' . __( 'Style Type:', 'ujicountdown' ) . '
';
$form .= '
';
$form .= '
' . esc_attr( $val ) . '';
} else {
$form .= '
' . __( 'Choose Style:', 'ujicountdown' ) . '
';
$form .= '
';
foreach ( $styles as $style ) {
$sel = ( $style == $this->ujic_request_text( 'style', 'classic' ) ) ? ' ujic-types-sel' : '';
$form .= '
' . esc_attr( $style ) . '';
}
}
$form .= '
';
$form .= '
';
$form .= '
';
return $form;
}
/**
* Print title.
*
* @since 2.0
*/
public function cform_title( $title ) {
$form = '
';
$form .= '
' . esc_html( $title ) . '
';
$form .= '';
return $form;
}
/**
* Print input field.
*
* @since 2.0
*/
public function cform_input( $label, $name, $val, $cls = null ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$form .= '
';
return $form;
}
/**
* Print radio field.
*
* @since 2.0
*/
public function cform_radiobox( $label, $name, $name_val, $types, $val ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$i = 0;
foreach ( $types as $type ) {
$form .= '';
$form .= '';
$i++;
}
$form .= '
';
$form .= '
';
return $form;
}
/**
* Print select field.
*
* @since 2.0
*/
public function cform_select( $label, $name, $types, $val ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$form .= '
';
$form .= '
';
return $form;
}
/**
* MM and SS.
*
* @since 2.1.3
*/
public function cform_select_time( $label, $cls, $hh, $mm ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$form .= ':';
$form .= '';
$form .= '
';
return $form;
}
/**
* Recurring time
*
* @since 2.1.3
*/
public function cform_reccur( $label, $timelabel, $info ) {
$form = '
' . esc_html( $label ) . '
';
$form .= '
';
$form .= '
';
$form .= '
' . esc_html( $info ) . '
';
$form .= '
';
return $form;
}
/**
* Print slider-ui field.
*
* @since 2.0
*/
public function cform_sliderui( $label, $name, $val, $min, $max, $step ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
// values
$val = ( $val == '' ) ? 32 : esc_attr( $val );
// html output
$form .= '
';
$form .= '
';
$form .= '
';
$form .= '
';
$form .= '
';
return $form;
}
/**
* Color picker field.
*
* @since 2.0
*/
public function cform_color( $label, $names, $clabels, $vals, $class = '' ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$i = 0;
foreach ( $names as $name ) {
// values
$default_color = ' data-default-color="' . esc_attr( $vals[ $i ] ) . '" ';
$form .= '
';
$form .= ' ' . esc_html( $clabels[ $i ] ) . ' :';
$form .= '';
$form .= '
';
$i++;
}
$form .= '
';
$form .= '
';
return $form;
}
/**
* Add buttons.
*
* @since 2.0
*/
private function cform_buttons() {
$type = $this->ujic_request_id( 'edit' );
$form = '
';
if ( ! empty( $type ) ) {
$form .= get_submit_button( __( 'Update Style', 'ujicountdown' ), 'primary', 'submit_ujic', true );
$form .= '
' . __( 'Add New Style', 'ujicountdown' ) . '';
} else {
$form .= get_submit_button( __( 'Save Style', 'ujicountdown' ), 'primary', 'submit_ujic', true );
}
$form .= '
';
return $form;
}
/**
* Form Date.
*
* @since 2.0
*/
private function cform_date( $label, $id ) {
$form = '
';
$form .= '
' . esc_html( $label ) . '
';
$form .= '
';
$form .= '
';
return $form;
}
/**
* Form Date.
*
* @since 2.0
*/
private function cform_time( $label ) {
$form = '
';
return $form;
}
/**
* Form Type.
*
* @since 2.0
*/
private function cform_ftype( $cur_style, $id = null ) {
$type = $this->ujic_request_id( 'edit' );
if ( ! empty( $type ) && ! empty( $id ) ) {
$form = '
';
echo $this->custom_metabox( __( 'Timer Settings', 'ujicountdown' ), $cnt, 'ujic-create ujic-settings' );
}
/**
* Save timer settings
*
* @since 2.0
*/
public function save_timerset() {
$settings = $this->ujic_post_values();
if ( ! empty( $settings ) && 'true' === $this->ujic_request_text( 'saveset' ) ) {
$this->ujic_require_manage_options();
// 2.0.7 Fix Cross-Site Request Forgery attacks
$this->ujic_secure( 'ujic_secureset', 'ujic_secureset_form', $settings );
unset( $settings['submit_ujic'] );
update_option( 'ujic_set', $settings );
$this->ujic_message( __( 'Settings saved.', 'ujicountdown' ) );
} elseif ( ! empty( $settings ) ) {
$this->ujic_message( __( 'Some error occured. Please try again.', 'ujicountdown' ) );
}
}
/**
* Get timer settings
*
* @since 2.0
*/
public function get_timerset( $name = null ) {
$vars = get_option( 'ujic_set', array() );
if ( $name ) {
return $vars[ $name ] ?? false;
} else {
return $vars;
}
}
/**
* Secure against Cross-Site Request Forgery
*
* @since 2.0.7
*/
public function ujic_secure( $secure, $secure_filed, $posts ) {
if ( ! isset( $posts[ $secure_filed ] ) || ! wp_verify_nonce( $posts[ $secure_filed ], $secure )
) {
wp_die( __( 'Cheatin’ huh?', 'ujicountdown' ) );
}
}
/**
* Get a sanitized text value from the admin query string.
*
* @since 2.3.5
*/
protected function ujic_request_text( $key, $default = '' ) {
if ( ! isset( $_GET[ $key ] ) ) {
return $default;
}
$value = sanitize_text_field( wp_unslash( $_GET[ $key ] ) );
return '' === $value ? $default : $value;
}
/**
* Get a positive id value from the admin query string.
*
* @since 2.3.5
*/
protected function ujic_request_id( $key ) {
if ( ! isset( $_GET[ $key ] ) ) {
return 0;
}
return absint( wp_unslash( $_GET[ $key ] ) );
}
/**
* Get sanitized admin form data.
*
* @since 2.3.5
*/
protected function ujic_post_values() {
if ( empty( $_POST ) ) {
return array();
}
return $this->sanitize_array( wp_unslash( $_POST ) );
}
/**
* Require settings capability before data changes.
*
* @since 2.3.5
*/
protected function ujic_require_manage_options() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'Sorry, you are not allowed to manage Uji Countdown.', 'ujicountdown' ) );
}
}
/**
* Sanitize values in array
*
* @since 2.3
*/
public function sanitize_array( $input ) {
// Initialize the new array that will hold the sanitize values
$new_input = array();
// Loop through the input and sanitize each of the values
foreach ( (array) $input as $key => $val ) {
$clean_key = sanitize_key( $key );
if ( is_array( $val ) ) {
$new_input[ $clean_key ] = $this->sanitize_array( $val );
continue;
}
$new_input[ $clean_key ] = sanitize_text_field( $val );
}
return $new_input;
}
}