Conditions | 6 |
Paths | 7 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 42 |
Changes | 0 |
1 | <?php |
||
9 | function yikes_maybe_activate_blocks() { |
||
10 | include ABSPATH . WPINC . '/version.php'; |
||
11 | if ( version_compare( PHP_VERSION, '5.6.0', '>=' ) && ( function_exists( 'gutenberg_init' ) || isset( $wp_version ) && version_compare( $wp_version, '5.0', '>=' ) ) ) { |
||
12 | |||
13 | // Wrap the init of block functionality into a Try/Catch until everything is stable. |
||
14 | try { |
||
15 | require_once YIKES_MC_PATH . 'blocks/blocks.php'; |
||
16 | require_once YIKES_MC_PATH . 'blocks/api/api.php'; |
||
17 | require_once YIKES_MC_PATH . 'blocks/easy-forms-block/easy-forms-block.php'; |
||
18 | $yikes_easy_form_block = new YIKES_Easy_Form_Block(); |
||
19 | $yikes_easy_form_blocks_api = new YIKES_Easy_Forms_Blocks_API(); |
||
20 | } catch ( Exception $e ) { |
||
21 | $error_logging = new Yikes_Inc_Easy_Mailchimp_Error_Logging(); |
||
22 | $error_logging->maybe_write_to_log( $e->getMessage(), |
||
23 | __( 'Error initializing the Easy Forms\' Gutenberg block functions.', 'yikes-inc-easy-mailchimp-extender' ), |
||
24 | 'blocks.php' |
||
25 | ); |
||
26 | } |
||
27 | } |
||
28 | } |
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.