htmlburger /
carbon-fields
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | namespace Carbon_Fields; |
||
| 3 | |||
| 4 | use Carbon_Fields\Helper\Helper; |
||
| 5 | |||
| 6 | # Define version constant |
||
| 7 | if ( ! defined( __NAMESPACE__ . '\VERSION' ) ) { |
||
| 8 | $plugin_data = get_file_data( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'carbon-fields-plugin.php', array('Version'=>'Version') ); |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 9 | define( __NAMESPACE__ . '\VERSION', $plugin_data['Version'] ); |
||
| 10 | } |
||
| 11 | |||
| 12 | # Define root directory |
||
| 13 | if ( ! defined( __NAMESPACE__ . '\DIR' ) ) { |
||
| 14 | define( __NAMESPACE__ . '\DIR', __DIR__ ); |
||
| 15 | } |
||
| 16 | |||
| 17 | # Define root URL |
||
| 18 | if ( ! defined( __NAMESPACE__ . '\URL' ) ) { |
||
| 19 | $url = \trailingslashit( DIR ); |
||
| 20 | $count = 0; |
||
| 21 | |||
| 22 | # Sanitize directory separator on Windows |
||
| 23 | $url = str_replace( '\\' ,'/', $url ); |
||
| 24 | |||
| 25 | # If installed as a plugin |
||
| 26 | $wp_plugin_dir = str_replace( '\\' ,'/', WP_PLUGIN_DIR ); |
||
| 27 | $url = str_replace( $wp_plugin_dir, \plugins_url(), $url, $count ); |
||
| 28 | |||
| 29 | if ( $count < 1 ) { |
||
| 30 | # If anywhere in wp-content |
||
| 31 | $wp_content_dir = str_replace( '\\' ,'/', WP_CONTENT_DIR ); |
||
| 32 | $url = str_replace( $wp_content_dir, \content_url(), $url, $count ); |
||
| 33 | } |
||
| 34 | |||
| 35 | if ( $count < 1 ) { |
||
| 36 | # If anywhere else within the WordPress installation |
||
| 37 | $wp_dir = str_replace( '\\' ,'/', ABSPATH ); |
||
| 38 | $url = str_replace( $wp_dir, \site_url( '/' ), $url ); |
||
| 39 | } |
||
| 40 | |||
| 41 | define( __NAMESPACE__ . '\URL', \untrailingslashit( $url ) ); |
||
| 42 | } |
||
| 43 | |||
| 44 | # Initialize helper |
||
| 45 | global $carbon_fields_helper; |
||
| 46 | if ( ! isset( $carbon_fields_helper ) ) { |
||
| 47 | $carbon_fields_helper = new Helper(); |
||
| 48 | } |
||
| 49 |