forked from BracketSpace/Notification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.php
49 lines (36 loc) · 1.13 KB
/
load.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
48
49
<?php
/**
* This file should be used only for loading Notification plugin in other plugin or theme
*
* Just include this file to get it work, it will figure out if it's loaded from theme or from plugin
*/
/**
* Directory
*/
if ( ! defined( 'NOTIFICATION_DIR' ) ) {
define( 'NOTIFICATION_DIR', trailingslashit( dirname( __FILE__ ) ) );
}
/**
* URL
*/
$theme_url = parse_url( get_stylesheet_directory_uri() );
$theme_pos = strpos( NOTIFICATION_DIR, $theme_url['path'] );
// Notification loaded from theme
if ( $theme_pos !== false ) {
$plugin_relative_dir = str_replace( $theme_url['path'], '', substr( NOTIFICATION_DIR, $theme_pos ) );
$url = $theme_url['scheme'] . '://' . $theme_url['host'] . $theme_url['path'] . $plugin_relative_dir;
if ( ! defined( 'NOTIFICATION_URL' ) ) {
define( 'NOTIFICATION_URL', $url );
}
} else { // Notification loaded from plugin
$plugin_url = trailingslashit( plugins_url( '', __FILE__ ) );
if ( ! defined( 'NOTIFICATION_URL' ) ) {
define( 'NOTIFICATION_URL', $plugin_url );
}
}
/**
* Load
*/
if ( defined( 'NOTIFICATION_URL' ) ) {
require_once( NOTIFICATION_DIR . 'notification.php' );
}