Skip to content

Commit

Permalink
🎨 Apply coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
MatzeKitt committed Dec 7, 2024
1 parent 8ee5ae6 commit e02e82a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 132 deletions.
34 changes: 11 additions & 23 deletions block-control.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php
namespace epiphyt\Block_Control;
use function array_pop;
use function defined;
use function explode;
use function file_exists;
use function spl_autoload_register;
use function str_replace;
use function strtolower;
use function wp_doing_ajax;

/*
Plugin Name: Block Control
Expand Down Expand Up @@ -36,30 +28,26 @@
You should have received a copy of the GNU General Public License
along with Block Control. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
*/

// exit if ABSPATH is not defined
defined( 'ABSPATH' ) || exit;

if ( wp_doing_ajax() ) return;
\defined( 'ABSPATH' ) || exit;

/**
* Autoload all necessary classes.
*
* @param string $class The class name of the auto-loaded class
* @param string $class_name The class name of the auto-loaded class
*/
spl_autoload_register( function( $class ) {
$namespace = strtolower( __NAMESPACE__ . '\\' );
$path = explode( '\\', $class );
$filename = str_replace( '_', '-', strtolower( array_pop( $path ) ) );
$class = str_replace(
\spl_autoload_register( static function( $class_name ) {
$namespace = \strtolower( __NAMESPACE__ . '\\' );
$path = \explode( '\\', $class_name );
$filename = \str_replace( '_', '-', \strtolower( \array_pop( $path ) ) );
$class_name = \str_replace(
[ $namespace, '\\', '_' ],
[ '', '/', '-' ],
strtolower( $class )
\strtolower( $class_name )
);
$class = str_replace( $filename, 'class-' . $filename, $class );
$maybe_file = __DIR__ . '/inc/' . $class . '.php';
$class_name = \str_replace( $filename, 'class-' . $filename, $class_name );
$maybe_file = __DIR__ . '/inc/' . $class_name . '.php';

if ( file_exists( $maybe_file ) ) {
if ( \file_exists( $maybe_file ) ) {
require_once $maybe_file;
}
} );
Expand Down
Loading

0 comments on commit e02e82a

Please sign in to comment.