PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
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 4 weeks ago dates.php 4 weeks ago general.php 4 weeks ago index.php 4 weeks ago screen.php 4 weeks ago strings.php 4 weeks ago
strings.php
73 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /*
8 * Foo Functions - Strings
9 * A bunch of common and useful functions related to strings
10 *
11 * Author: Brad Vincent
12 * Author URI: http://fooplugins.com
13 * License: GPL2
14 */
15
16 if ( !function_exists( 'foo_convert_to_key' ) ) {
17 function foo_convert_to_key($input) {
18 return str_replace( " ", "_", strtolower( $input ) );
19 }
20 }
21
22 if ( !function_exists( 'foo_title_case' ) ) {
23 function foo_title_case($input) {
24 return ucwords( str_replace( array("-", "_"), " ", $input ) );
25 }
26 }
27
28 if ( !function_exists( 'foo_contains' ) ) {
29 /*
30 * returns true if a needle can be found in a haystack
31 */
32 function foo_contains($haystack, $needle) {
33 if ( empty($haystack) || empty($needle) ) {
34 return false;
35 }
36
37 $pos = strpos( strtolower( $haystack ), strtolower( $needle ) );
38
39 if ( $pos === false ) {
40 return false;
41 } else {
42 return true;
43 }
44 }
45 }
46
47 if ( !function_exists( 'foo_starts_with' ) ) {
48 /**
49 * starts_with
50 * Tests if a text starts with an given string.
51 *
52 * @param string
53 * @param string
54 *
55 * @return bool
56 */
57 function foo_starts_with($haystack, $needle) {
58 return strpos( $haystack, $needle ) === 0;
59 }
60 }
61
62 if ( !function_exists( 'foo_ends_with' ) ) {
63 function foo_ends_with($haystack, $needle, $case = true) {
64 $expectedPosition = strlen( $haystack ) - strlen( $needle );
65
66 if ( $case ) {
67 return strrpos( $haystack, $needle, 0 ) === $expectedPosition;
68 }
69
70 return strripos( $haystack, $needle, 0 ) === $expectedPosition;
71 }
72 }
73