Skip to content

Commit e02e82a

Browse files
committed
🎨 Apply coding standards
1 parent 8ee5ae6 commit e02e82a

File tree

2 files changed

+78
-132
lines changed

2 files changed

+78
-132
lines changed

block-control.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<?php
22
namespace epiphyt\Block_Control;
3-
use function array_pop;
4-
use function defined;
5-
use function explode;
6-
use function file_exists;
7-
use function spl_autoload_register;
8-
use function str_replace;
9-
use function strtolower;
10-
use function wp_doing_ajax;
113

124
/*
135
Plugin Name: Block Control
@@ -36,30 +28,26 @@
3628
You should have received a copy of the GNU General Public License
3729
along with Block Control. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
3830
*/
39-
40-
// exit if ABSPATH is not defined
41-
defined( 'ABSPATH' ) || exit;
42-
43-
if ( wp_doing_ajax() ) return;
31+
\defined( 'ABSPATH' ) || exit;
4432

4533
/**
4634
* Autoload all necessary classes.
4735
*
48-
* @param string $class The class name of the auto-loaded class
36+
* @param string $class_name The class name of the auto-loaded class
4937
*/
50-
spl_autoload_register( function( $class ) {
51-
$namespace = strtolower( __NAMESPACE__ . '\\' );
52-
$path = explode( '\\', $class );
53-
$filename = str_replace( '_', '-', strtolower( array_pop( $path ) ) );
54-
$class = str_replace(
38+
\spl_autoload_register( static function( $class_name ) {
39+
$namespace = \strtolower( __NAMESPACE__ . '\\' );
40+
$path = \explode( '\\', $class_name );
41+
$filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) );
42+
$class_name = \str_replace(
5543
[ $namespace, '\\', '_' ],
5644
[ '', '/', '-' ],
57-
strtolower( $class )
45+
\strtolower( $class_name )
5846
);
59-
$class = str_replace( $filename, 'class-' . $filename, $class );
60-
$maybe_file = __DIR__ . '/inc/' . $class . '.php';
47+
$class_name = \str_replace( $filename, 'class-' . $filename, $class_name );
48+
$maybe_file = __DIR__ . '/inc/' . $class_name . '.php';
6149

62-
if ( file_exists( $maybe_file ) ) {
50+
if ( \file_exists( $maybe_file ) ) {
6351
require_once $maybe_file;
6452
}
6553
} );

0 commit comments

Comments
 (0)