PluginProbe
WP Ultimate Post Grid / 2.6.0
WP Ultimate Post Grid v2.6.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / vendor / vafpress / classes / util / text.php

text.php in WP Ultimate Post Grid 2.6.0, at vendor/vafpress/classes/util/text.php

94 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class VP_Util_Text
4 {
5
6 public static function parse_md($text)
7 {
8 if(!function_exists('Markdown'))
9 {
10 $path = VP_FileSystem::instance()->resolve_path('includes', 'markdown/parser');
11 require $path;
12 // require VP_INCLUDE_DIR . '/markdown/parser.php';
13 }
14 return Markdown($text);
15 }
16
17 public static function make_opt($optArray)
18 {
19 $optString = "";
20 foreach ($optArray as $key => $value)
21 {
22 $optString .= "(" . $key . ":" . $value . ")";
23 }
24 return $optString;
25 }
26
27 public static function print_if_exists($value, $format)
28 {
29 if (!empty($value))
30 {
31 if (is_array($value))
32 {
33 $value = implode($value, ', ');
34 }
35 call_user_func('printf', $format, $value);
36 }
37 }
38
39 public static function return_if_exists($value, $format)
40 {
41 $result = '';
42 if (!empty($value))
43 {
44 if (is_array($value))
45 {
46 $value = implode($value, ', ');
47 }
48 $result = call_user_func('sprintf', $format, $value);
49 }
50 return $result;
51 }
52
53 public static function out($string, $default)
54 {
55 if( empty($string) )
56 echo $default;
57 else
58 echo $string;
59 }
60
61 public static function prefix(&$item, $key, $prefix)
62 {
63 $item = $prefix . $item;
64 }
65
66 public static function prefix_array($array, $prefix)
67 {
68 array_walk( $array, 'VP_Util_Text::prefix', $prefix);
69 return $array;
70 }
71
72 public static function starts_with($haystack, $needle)
73 {
74 return !strncmp($haystack, $needle, strlen($needle));
75 }
76
77 public static function ends_with($haystack, $needle)
78 {
79 $length = strlen($needle);
80 if ($length == 0)
81 {
82 return true;
83 }
84 return (substr($haystack, -$length) === $needle);
85 }
86
87 public static function flanked_by($haystack, $left, $right = '')
88 {
89 if( $right == '' )
90 $right = $left;
91 return (self::starts_with($haystack, $left) and self::ends_with($haystack, $right));
92 }
93
94 }