PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
faustwp / includes / utilities / functions.php

functions.php in Faust.js 1.0.2, at includes/utilities/functions.php

35 lines 906 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Various utility functions used through the Faust plugin.
4 *
5 * @package FaustWP
6 */
7
8 namespace WPE\FaustWP\Utilities;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Converts string to camelCase. Added to ensure that fields are compliant with the GraphQL spec.
16 *
17 * @param string $str The string to be converted to camelCase.
18 * @param array $preserved_chars The characters to preserve.
19 *
20 * @credit http://www.mendoweb.be/blog/php-convert-string-to-camelcase-string/
21 *
22 * @return string camelCase'd string
23 */
24 function camelcase( $str, $preserved_chars = array() ) {
25 /* Convert non-alpha and non-numeric characters to spaces. */
26 $str = preg_replace( '/[^a-z0-9' . implode( '', $preserved_chars ) . ']+/i', ' ', $str );
27 $str = trim( $str );
28
29 /* Uppercase the first character of each word. */
30 $str = ucwords( $str );
31 $str = str_replace( ' ', '', $str );
32
33 return lcfirst( $str );
34 }
35