Skip to content

Commit 03d2d16

Browse files
authored
Merge pull request #88 from INN/46-back-compat
improve backwards-compatibility support after VIP compatibility changes
2 parents 08f1245 + 5aa2108 commit 03d2d16

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

dfw-options.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,25 @@ function dfw_breakpoints_input() {
143143
while ( $i < 5 ) {
144144
$identifier = ( isset( $breakpoints[ $i ]['identifier'] ) )? $breakpoints[ $i ]['identifier'] : '';
145145
$min_width = ( isset( $breakpoints[ $i ]['min-width'] ) )? $breakpoints[ $i ]['min-width'] : '';
146-
$max_width = ( isset( $breakpoints[ $i ]['max-width'] ) )? $breakpoints[ $i ]['max-width'] : ''; ?>
146+
$max_width = ( isset( $breakpoints[ $i ]['max-width'] ) )? $breakpoints[ $i ]['max-width'] : '';
147+
148+
// fallbacks for post-https://github.com/INN/doubleclick-for-wp/pull/46 compatibility.
149+
if ( empty( $min_width ) && isset( $breakpoints[ $i ][ 'minWidth' ] ) ) {
150+
$min_width = ( isset( $breakpoints[ $i ]['minWidth'] ) )? $breakpoints[ $i ]['minWidth'] : '';
151+
}
152+
if ( empty( $max_width ) && isset( $breakpoints[ $i ][ 'maxWidth' ] ) ) {
153+
$max_width = ( isset( $breakpoints[ $i ]['maxWidth'] ) )? $breakpoints[ $i ]['maxWidth'] : '';
154+
}
155+
156+
// fallbacks, continued.
157+
if ( empty( $min_width ) && isset( $breakpoints[ $i ][ 'min-width' ] ) ) {
158+
$min_width = ( isset( $breakpoints[ $i ]['min-width'] ) )? $breakpoints[ $i ]['min-width'] : '';
159+
}
160+
if ( empty( $max_width ) && isset( $breakpoints[ $i ][ 'max-width' ] ) ) {
161+
$max_width = ( isset( $breakpoints[ $i ]['max-width'] ) )? $breakpoints[ $i ]['max-width'] : '';
162+
}
163+
164+
?>
147165
<input value="<?php echo esc_attr( $identifier ); ?>"
148166
placeholder="Name"
149167
name="dfw_breakpoints[]"

docs/Developer-API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ __$identifier__
4444

4545
__$args__
4646

47-
`Array` An array of properties about the breakpoint. Currently the only keys supported are minWidth and maxWidth.
47+
`Array` An array of properties about the breakpoint. Currently the only keys supported are min_width and max_width.
4848

4949
* * *
5050

inc/class-doubleclickbreakpoint.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ class DoubleClickBreakpoint {
3636
public $option;
3737

3838
public function __construct( $identifier, $args = null ) {
39+
// specify all the options because there has been come confusion, historically
3940
if ( isset( $args['min_width'] ) ) {
4041
$this->min_width = $args['min_width'];
42+
} else if ( isset( $args['minWidth'] ) ) {
43+
$this->min_width = $args['minWidth'];
44+
} else if ( isset( $args['min-width'] ) ) {
45+
$this->max_width = $args['min-width'];
4146
}
4247

4348
if ( isset( $args['max_width'] ) ) {
4449
$this->max_width = $args['max_width'];
50+
} else if ( isset( $args['maxWidth'] ) ) {
51+
$this->max_width = $args['maxWidth'];
52+
} else if ( isset( $args['max-width'] ) ) {
53+
$this->max_width = $args['max-width'];
4554
}
4655

4756
if ( isset( $args['_option'] ) && $args['_option'] ) {
4857
$this->option = true;
4958
}
5059

51-
52-
// Same, but with different spelling
53-
if ( isset( $args['max-width'] ) ) {
54-
$this->max_width = $args['max-width'];
55-
}
56-
if ( isset( $args['min-width'] ) ) {
57-
$this->min_width = $args['min-width'];
58-
}
59-
6060
$this->identifier = $identifier;
6161
}
6262

0 commit comments

Comments
 (0)