-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.php
47 lines (43 loc) · 1.12 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Kindling Image Forwarding - Helpers
* @package Kindling_Image_Forwarding
*/
/**
* Checks if image forwarding is enabled
*
* @return boolean
*/
function kindling_image_forwarding_enabled()
{
return (bool) apply_filters(
'kindling_image_forwarding_enabled',
config('kindling-image-forwarding.enabled')
);
}
/**
* Replaces the forward URL if needed.
*
* @param string $uri
* @return string
*/
function kindling_image_forwarding_replace_forward_uri($uri)
{
if (!kindling_image_forwarding_enabled()) {
return $uri;
}
// Let's check if the file exists before altering it.
// You may want to upload files while testing even
// though the primary access is from the forwarding site.
if (file_exists(str_replace(network_home_url('/'), ABSPATH, $uri))) {
return $uri;
}
return str_replace(
network_home_url(),
apply_filters(
'kindling_image_forwarding_get_forward_url',
config('kindling-image-forwarding.url') ? config('kindling-image-forwarding.url') : network_home_url()
),
$uri
);
}