PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Media / Url.php

Url.php in Depicter — Popup & Slider Builder 1.9.2, at app/src/Media/Url.php

54 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Media;
3
4 /**
5 * Media File Class
6 *
7 * @package Depicter\Media
8 */
9 class Url
10 {
11
12 /**
13 * check if url is valid
14 * @param $url
15 *
16 * @return bool
17 */
18 public function isUrl( $url ) {
19 return (bool) filter_var( $url, FILTER_VALIDATE_URL );
20 }
21
22 /**
23 * convert url to path
24 * @param $url
25 *
26 * @return false|string
27 */
28 public function toUri( $url ) {
29 $siteUrl = rtrim( get_site_url(), "/") . "/";
30 $relativePath = str_replace( $siteUrl, '', $url );
31 if ( file_exists( ABSPATH . $relativePath ) ) {
32 return ABSPATH . $relativePath;
33 }
34 return false;
35 }
36
37 /**
38 * check if url is external or not
39 * @param $url
40 *
41 * @return bool
42 */
43 public function isExternal( $url ) {
44 $siteUrl = parse_url( get_site_url() );
45 $siteHost = !empty( $siteUrl['path'] ) ? $siteUrl['host'] . $siteUrl['path'] : $siteUrl['host'];
46
47 $urlHost = parse_url( $url, PHP_URL_HOST );
48 // check for multisite that links are like subdirectory not subdomain
49 $urlHost = !empty( $siteUrl['path'] ) && strpos( $url, $urlHost . $siteUrl['path'] ) ? $urlHost . $siteUrl['path'] : $urlHost;
50
51 return $siteHost != $urlHost && !strpos( $siteHost, $urlHost) && !strpos( $urlHost, $siteHost );
52 }
53 }
54