Skip to content

Commit

Permalink
OptionTree 2.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
AlxMedia committed May 5, 2015
1 parent 90d0e3a commit 81bd5dc
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 149 deletions.
31 changes: 16 additions & 15 deletions option-tree/includes/ot-functions-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
}

// Unset keys with empty values.
if ( empty( $value ) ) {
if ( empty( $value ) && strlen( $value ) == 0 ) {
unset( $input[$key] );
}

Expand Down Expand Up @@ -543,7 +543,7 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {

// Unset keys with empty values.
foreach( $input as $key => $value ) {
if ( empty( $value ) ) {
if ( empty( $value ) && strlen( $value ) == 0 ) {
unset( $input[$key] );
}
}
Expand Down Expand Up @@ -589,7 +589,7 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
$errors[] = $key;
}
if ( empty( $value ) ) {
if ( empty( $value ) && strlen( $value ) == 0 ) {
unset( $input[$key] );
}
}
Expand Down Expand Up @@ -647,7 +647,7 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
$input[0] = sanitize_text_field( $input[0] );

// No value; set to empty
if ( empty( $input[0] ) && empty( $input[1] ) ) {
if ( empty( $input[0] ) && strlen( $input[0] ) == 0 && empty( $input[1] ) ) {
$input = '';
}

Expand All @@ -658,7 +658,7 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) {
if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) {
$errors[] = $key;
}
if ( empty( $value ) ) {
if ( empty( $value ) && strlen( $value ) == 0 ) {
unset( $input[$key] );
}
}
Expand Down Expand Up @@ -3507,18 +3507,19 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa

// Measurement
if ( $option_type == 'measurement' ) {

$unit = ! empty( $value[1] ) ? $value[1] : 'px';

// Set $value with measurement properties
if ( isset( $value[0] ) && isset( $value[1] ) )
$value = $value[0].$value[1];
if ( isset( $value[0] ) && strlen( $value[0] ) > 0 )
$value = $value[0].$unit;

// Border
} else if ( $option_type == 'border' ) {
$border = array();

$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';

if ( ! empty( $value['width'] ) )
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
$border[] = $value['width'].$unit;

if ( ! empty( $value['style'] ) )
Expand All @@ -3542,10 +3543,10 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa

$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';

if ( ! empty( $value['width'] ) )
if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 )
$dimension[] = $value['width'].$unit;

if ( ! empty( $value['height'] ) )
if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 )
$dimension[] = $value['height'].$unit;

// Set $value with dimension properties or empty string
Expand All @@ -3557,16 +3558,16 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa

$unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px';

if ( ! empty( $value['top'] ) )
if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 )
$spacing[] = $value['top'].$unit;

if ( ! empty( $value['right'] ) )
if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 )
$spacing[] = $value['right'].$unit;

if ( ! empty( $value['bottom'] ) )
if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 )
$spacing[] = $value['bottom'].$unit;

if ( ! empty( $value['left'] ) )
if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 )
$spacing[] = $value['left'].$unit;

// Set $value with spacing properties or empty string
Expand Down
29 changes: 27 additions & 2 deletions option-tree/includes/ot-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,25 @@ function ot_wpml_filter( $options, $option_id ) {
function ot_load_dynamic_css() {

/* don't load in the admin */
if ( is_admin() )
if ( is_admin() ) {
return;
}

/**
* Filter whether or not to enqueue a `dynamic.css` file at the theme level.
*
* By filtering this to `false` OptionTree will not attempt to enqueue any CSS files.
*
* Example: add_filter( 'ot_load_dynamic_css', '__return_false' );
*
* @since 2.5.5
*
* @param bool $load_dynamic_css Default is `true`.
* @return bool
*/
if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) {
return;
}

/* grab a copy of the paths */
$ot_css_file_paths = get_option( 'ot_css_file_paths', array() );
Expand All @@ -238,8 +255,16 @@ function ot_load_dynamic_css() {
if ( '' != $path && file_exists( $path ) ) {

$parts = explode( '/wp-content', $path );

if ( isset( $parts[1] ) ) {

$sub_parts = explode( '/', $parts[1] );

if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) {
if ( $sub_parts[1] == 'themes' && $sub_parts[2] != get_template() ) {
continue;
}
}

$css = set_url_scheme( WP_CONTENT_URL ) . $parts[1];

Expand Down
Binary file modified option-tree/languages/option-tree-et.mo
Binary file not shown.
Loading

0 comments on commit 81bd5dc

Please sign in to comment.