PluginProbe
Gutenberg / 8.3.0
Gutenberg v8.3.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / utils.php

utils.php in Gutenberg 8.3.0, at lib/utils.php

28 lines 796 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * General utilities.
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * This function allows to easily access a part from a php array.
10 * It is equivalent to want lodash get provides for JavaScript and is useful to have something similar
11 * in php so functions that do the same thing on the client and sever can have identical code.
12 *
13 * @param array $array An array from where we want to retrieve some information from.
14 * @param array $path An array containing the path we want to retrieve.
15 *
16 * @return array Containing a set of css rules.
17 */
18 function gutenberg_experimental_get( $array, $path ) {
19 $path_length = count( $path );
20 for ( $i = 0; $i < $path_length; ++$i ) {
21 if ( empty( $array[ $path[ $i ] ] ) ) {
22 return null;
23 }
24 $array = $array[ $path[ $i ] ];
25 }
26 return $array;
27 }
28