Allow float values for opacity, remove empty check if float value is 0

This commit is contained in:
Jay Wood
2016-09-30 14:55:15 -04:00
parent f7b8ad1fe9
commit a97c276343
3 changed files with 7 additions and 8 deletions

View File

@ -289,14 +289,13 @@ class ContentWarning_v2 {
* @return null * @return null
*/ */
public function register_frontend_data() { public function register_frontend_data() {
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
// Jquery Cookie // Jquery Cookie
wp_register_script( 'jquery_cookie', plugins_url( "js/jquery_cookie{$min}.js", dirname( __FILE__ ) ), array( 'jquery' ), '1.4.1', true ); wp_register_script( 'jquery_cookie', $this->url( "js/jquery_cookie{$this->min}.js" ), array( 'jquery' ), '1.4.1', true );
// Main data // Main data
wp_register_script( 'cwv3_js', plugins_url( "js/cwv3{$min}.js", dirname( __FILE__ ) ), array( 'jquery_cookie' ), '3.6.0', true ); wp_register_script( 'cwv3_js', $this->url( "js/cwv3{$this->min}.js" ), array( 'jquery_cookie' ), '3.6.0', true );
wp_register_style( 'cwv3_css', plugins_url( "css/cwv3{$min}.css", dirname( __FILE__ ) ), '', '1.0' ); wp_register_style( 'cwv3_css', $this->url( "css/cwv3{$this->min}.css" ), '', '1.0' );
} }
/** /**

View File

@ -22,7 +22,9 @@ function cwv3_get_css() {
$image = get_option( 'cwv3_bg_image', '' ); $image = get_option( 'cwv3_bg_image', '' );
$color = get_option( 'cwv3_bg_color', '' ); $color = get_option( 'cwv3_bg_color', '' );
$custom_css = get_option( 'cwv3_css', '' ); $custom_css = get_option( 'cwv3_css', '' );
$opacity = get_option( 'cwv3_bg_opacity', '' ); $opacity = get_option( 'cwv3_bg_opacity', '1' );
error_log( print_r( $opacity, 1 ) );
$bg_image_css = ! empty( $image ) ? 'background: url( '. esc_url( $image ) . ' ) no-repeat top center;' : ''; $bg_image_css = ! empty( $image ) ? 'background: url( '. esc_url( $image ) . ' ) no-repeat top center;' : '';
$bg_color_css = ! empty( $color ) ? 'background-color: ' . $color . ';' : ''; $bg_color_css = ! empty( $color ) ? 'background-color: ' . $color . ';' : '';
@ -33,11 +35,9 @@ function cwv3_get_css() {
<style type="text/css"> <style type="text/css">
.cwv3.dialog-overlay{ .cwv3.dialog-overlay{
<?php echo $bg_image_css . $bg_color_css; ?> <?php echo $bg_image_css . $bg_color_css; ?>
<?php if ( ! empty( $opacity ) ) : ?>
opacity: <?php echo floatval( $opacity ); ?>; opacity: <?php echo floatval( $opacity ); ?>;
-moz-opacity: <?php echo floatval( $opacity ); ?>; -moz-opacity: <?php echo floatval( $opacity ); ?>;
-webkit-opacity: <?php echo floatval( $opacity ); ?>; -webkit-opacity: <?php echo floatval( $opacity ); ?>;
<?php endif; ?>
} }
<?php echo $custom_css; ?> <?php echo $custom_css; ?>

View File

@ -125,7 +125,7 @@ class CWV2_Settings {
} }
} }
?><input type="number" name="<?php echo $field_id; ?>" value="<?php echo intval( $option_value ); ?>" id="<?php echo $field_id; ?>" <?php echo $attributes; ?>/><?php ?><input type="number" name="<?php echo $field_id; ?>" value="<?php echo $option_value; ?>" id="<?php echo $field_id; ?>" <?php echo $attributes; ?>/><?php
if ( ! empty( $description ) ) { if ( ! empty( $description ) ) {
?><p class="description"><?php echo $description; ?></p><?php ?><p class="description"><?php echo $description; ?></p><?php