-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Make global styles shape consistent with local styles shape. (#…
…22744) Co-authored-by: Andrés <[email protected]> (+1 squashed commit)
- Loading branch information
1 parent
c149be2
commit e8d7e84
Showing
4 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* General utilities. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* This function allows to easily access a part from a php array. | ||
* It is equivalent to want lodash get provides for JavaScript and is useful to have something similar | ||
* in php so functions that do the same thing on the client and sever can have identical code. | ||
* | ||
* @param array $array An array from where we want to retrieve some information from. | ||
* @param array $path An array containing the path we want to retrieve. | ||
* | ||
* @return array Containing a set of css rules. | ||
*/ | ||
function gutenberg_experimental_get( $array, $path ) { | ||
$path_length = count( $path ); | ||
for ( $i = 0; $i < $path_length; ++$i ) { | ||
if ( empty( $array[ $path[ $i ] ] ) ) { | ||
return null; | ||
} | ||
$array = $array[ $path[ $i ] ]; | ||
} | ||
return $array; | ||
} |