Skip to content

Commit 61b642c

Browse files
committed
Ad polyfill file for wp_parse_args
1 parent ab90f29 commit 61b642c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

tests/bootstrap.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@
1010
* Now we include any plugin files that we need to be able to run the tests. This
1111
* should be files that define the functions and classes you're going to test.
1212
*/
13+
require_once __DIR__ . '/polyfills.php';
1314
require_once __DIR__ . '/../functions.php';
14-
15-
function test_escape( $value ) {
16-
return 'esc_' . $value;
17-
}

tests/polyfills.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
function test_escape( $value ) {
4+
return 'esc_' . $value;
5+
}
6+
7+
function wp_parse_args( $args, $defaults = array() ) {
8+
if ( is_object( $args ) ) {
9+
$parsed_args = get_object_vars( $args );
10+
} elseif ( is_array( $args ) ) {
11+
$parsed_args =& $args;
12+
} else {
13+
parse_str( $args, $parsed_args );
14+
}
15+
16+
if ( is_array( $defaults ) && $defaults ) {
17+
return array_merge( $defaults, $parsed_args );
18+
}
19+
}

0 commit comments

Comments
 (0)