Completed
Push — master ( 173256...c57c8c )
by
unknown
17:38 queued 07:39
created

carbon-fields.php (7 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 9 and the first side effect is on line 8.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
No space after opening parenthesis of array is bad style
Loading history...
Expected 1 space between "'Version'" and double arrow; 0 found
Loading history...
Expected 1 space between double arrow and "'Version'"; 0 found
Loading history...
Expected 1 space before "=>"; 0 found
Loading history...
Expected 1 space after "=>"; 0 found
Loading history...
No space before closing parenthesis of array is bad style
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