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
|
|||
2 | /** |
||
3 | * Plugin Name: Carbon Fields |
||
4 | * Description: WordPress developer-friendly custom fields for post types, taxonomy terms, users, comments, widgets, options, navigation menus and more. |
||
5 | * Version: 1.0 |
||
6 | * Author: htmlburger |
||
7 | * Author URI: https://htmlburger.com/ |
||
8 | * Plugin URI: http://carbonfields.net/ |
||
9 | * License: GPL2 |
||
10 | * Requires at least: 4.0 |
||
11 | * Tested up to: 4.4.1 |
||
12 | * Text Domain: carbon_fields |
||
13 | * Domain Path: /languages |
||
14 | */ |
||
15 | |||
16 | $dir = dirname( __FILE__ ); |
||
17 | |||
18 | if ( file_exists( $dir . '/vendor/autoload.php' ) ) { |
||
19 | require( $dir . '/vendor/autoload.php' ); |
||
20 | } else { |
||
21 | function carbon_fields_spl_autoload_register( $class ) { |
||
22 | $prefix = 'Carbon_Fields'; |
||
23 | if ( stripos( $class, $prefix ) === false ) { |
||
24 | return; |
||
25 | } |
||
26 | |||
27 | $file_path = dirname( __FILE__ ) . '/core/' . str_ireplace( 'Carbon_Fields\\', '', $class ) . '.php'; |
||
28 | $file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $file_path ); |
||
29 | include_once( $file_path ); |
||
30 | } |
||
31 | |||
32 | spl_autoload_register( 'carbon_fields_spl_autoload_register' ); |
||
33 | } |
||
34 | |||
35 | include_once( dirname( __FILE__ ) . '/carbon-fields.php' ); |
||
36 | include_once( dirname( __FILE__ ) . '/core/functions.php' ); |
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.