forked from htmlburger/carbon-fields
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarbon-fields.php
42 lines (33 loc) · 1.08 KB
/
carbon-fields.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
<?php
namespace Carbon_Fields;
use Carbon_Fields\Helper\Helper;
# Define root directory
if ( ! defined( __NAMESPACE__ . '\DIR' ) ) {
define( __NAMESPACE__ . '\DIR', __DIR__ );
}
# Define root URL
if ( ! defined( __NAMESPACE__ . '\URL' ) ) {
$url = \trailingslashit( DIR );
$count = 0;
# Sanitize directory separator on Windows
$url = str_replace( '\\' ,'/', $url );
# If installed as a plugin
$wp_plugin_dir = str_replace( '\\' ,'/', WP_PLUGIN_DIR );
$url = str_replace( $wp_plugin_dir, \plugins_url(), $url, $count );
if ( $count < 1 ) {
# If anywhere in wp-content
$wp_content_dir = str_replace( '\\' ,'/', WP_CONTENT_DIR );
$url = str_replace( $wp_content_dir, \content_url(), $url, $count );
}
if ( $count < 1 ) {
# If anywhere else within the WordPress installation
$wp_dir = str_replace( '\\' ,'/', ABSPATH );
$url = str_replace( $wp_dir, \site_url( '/' ), $url );
}
define( __NAMESPACE__ . '\URL', \untrailingslashit( $url ) );
}
# Initialize helper
global $carbon_fields_helper;
if ( ! isset( $carbon_fields_helper ) ) {
$carbon_fields_helper = new Helper();
}