PluginProbe ʕ •ᴥ•ʔ
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel / trunk
WP All Export – Drag & Drop Export to Any Custom CSV, XML & Excel vtrunk
trunk 0.9.0 0.9.1 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.14 1.4.15 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0
wp-all-export / src / App / Service / SnippetParser.php
wp-all-export / src / App / Service Last commit date
Addons 2 years ago License 1 year ago Pro 2 years ago VariationOptions 2 years ago CategoriesService.php 5 years ago ScheduledExport.php 3 weeks ago SnippetParser.php 8 years ago WooCommerceVersion.php 8 years ago
SnippetParser.php
52 lines
1 <?php
2
3 namespace Wpae\App\Service;
4
5 class SnippetParser
6 {
7 const SNIPPET_MATCH_REGEX = '/{([^}^\"^\']*)}/';
8
9 const FUNCTION_MATCH_REGEX = '%(\[[^\]\[]*\])%';
10
11 public function parseSnippets($string)
12 {
13 $snippets = array();
14
15 preg_match_all(self::SNIPPET_MATCH_REGEX, $string, $snippets);
16
17 if(is_array($snippets)) {
18 $snippets = array_filter($snippets[1]);
19 }
20
21 foreach ($snippets as &$snippet) {
22 $snippet = trim($snippet, "{}");
23 }
24 return $snippets;
25 }
26
27 public function parseFunctions($string)
28 {
29 $functions = array();
30 $functionsResponse = array();
31
32 preg_match_all(self::FUNCTION_MATCH_REGEX, $string, $functions);
33
34 if(is_array($functions) && isset($functions[0]) && !empty($functions[0]) && $functions[0]) {
35
36 $functionsResponse[] = $functions[0];
37 }
38
39
40 $functionsResponse = array_filter($functionsResponse);
41 if(isset($functionsResponse[0])) {
42 $functionsResponse = $functionsResponse[0];
43 }
44
45 foreach($functionsResponse as &$function) {
46 $function = trim($function,"[]");
47
48 }
49
50 return $functionsResponse;
51 }
52 }