PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / foopluginbase / functions / strings.php
foogallery / includes / foopluginbase / functions Last commit date
arrays.php 2 months ago dates.php 2 months ago general.php 2 months ago index.php 2 months ago screen.php 2 months ago strings.php 2 months ago
strings.php
67 lines
1 <?php
2 /*
3 * Foo Functions - Strings
4 * A bunch of common and useful functions related to strings
5 *
6 * Author: Brad Vincent
7 * Author URI: http://fooplugins.com
8 * License: GPL2
9 */
10
11 if ( !function_exists( 'foo_convert_to_key' ) ) {
12 function foo_convert_to_key($input) {
13 return str_replace( " ", "_", strtolower( $input ) );
14 }
15 }
16
17 if ( !function_exists( 'foo_title_case' ) ) {
18 function foo_title_case($input) {
19 return ucwords( str_replace( array("-", "_"), " ", $input ) );
20 }
21 }
22
23 if ( !function_exists( 'foo_contains' ) ) {
24 /*
25 * returns true if a needle can be found in a haystack
26 */
27 function foo_contains($haystack, $needle) {
28 if ( empty($haystack) || empty($needle) ) {
29 return false;
30 }
31
32 $pos = strpos( strtolower( $haystack ), strtolower( $needle ) );
33
34 if ( $pos === false ) {
35 return false;
36 } else {
37 return true;
38 }
39 }
40 }
41
42 if ( !function_exists( 'foo_starts_with' ) ) {
43 /**
44 * starts_with
45 * Tests if a text starts with an given string.
46 *
47 * @param string
48 * @param string
49 *
50 * @return bool
51 */
52 function foo_starts_with($haystack, $needle) {
53 return strpos( $haystack, $needle ) === 0;
54 }
55 }
56
57 if ( !function_exists( 'foo_ends_with' ) ) {
58 function foo_ends_with($haystack, $needle, $case = true) {
59 $expectedPosition = strlen( $haystack ) - strlen( $needle );
60
61 if ( $case ) {
62 return strrpos( $haystack, $needle, 0 ) === $expectedPosition;
63 }
64
65 return strripos( $haystack, $needle, 0 ) === $expectedPosition;
66 }
67 }