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