PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.4.9
Backup Migration v1.4.9
2.1.6 2.1.5.2 trunk 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.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / analyst / src / helpers.php
backup-backup / analyst / src Last commit date
Account 11 months ago Cache 11 months ago Contracts 11 months ago Core 11 months ago Http 11 months ago Notices 11 months ago Analyst.php 11 months ago ApiRequestor.php 11 months ago ApiResponse.php 11 months ago Collector.php 11 months ago Mutator.php 11 months ago helpers.php 11 months ago
helpers.php
74 lines
1 <?php
2
3 if (! function_exists('analyst_assets_path')) {
4 /**
5 * Generates path to file in assets folder
6 *
7 * @param $file
8 * @return string
9 */
10 function analyst_assets_path($file)
11 {
12 $path = sprintf('%s/assets/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
13
14 return wp_normalize_path($path);
15 }
16 }
17
18
19 if (! function_exists('analyst_assets_url')) {
20 /**
21 * Generates url to file in assets folder
22 *
23 * @param $file
24 * @return string
25 */
26 function analyst_assets_url($file)
27 {
28 $absolutePath = analyst_assets_path($file);
29
30 // We can always rely on WP_PLUGIN_DIR, because that's where
31 // wordpress install it's plugin's. So we remove last segment
32 // of that path to get the content dir AKA directly where
33 // plugins are installed and make the magic...
34 $contentDir = is_link(WP_PLUGIN_DIR) ?
35 dirname(wp_normalize_path(readlink(WP_PLUGIN_DIR))) :
36 dirname(wp_normalize_path(WP_PLUGIN_DIR));
37
38 $relativePath = str_replace( $contentDir, '', $absolutePath);
39
40 return content_url(wp_normalize_path($relativePath));
41 }
42 }
43
44 if (! function_exists('analyst_templates_path')) {
45 /**
46 * Generates path to file in templates folder
47 *
48 * @param $file
49 * @return string
50 */
51 function analyst_templates_path($file)
52 {
53 $path = sprintf('%s/templates/%s', realpath(__DIR__ . '/..'), trim($file, '/'));
54
55 return wp_normalize_path($path);
56 }
57 }
58
59 if (! function_exists('analyst_require_template')) {
60 /**
61 * Require certain template with data
62 *
63 * @param $file
64 * @param array $data
65 */
66 function analyst_require_template($file, $data = [])
67 {
68 // Extract data to current scope table
69 extract($data);
70
71 require analyst_templates_path($file);
72 }
73 }
74