Skip to content

Instantly share code, notes, and snippets.

@KratosGemini
Created August 8, 2024 10:50
Show Gist options
  • Save KratosGemini/b7bffce185e705ce88c7fb3bbc2779b3 to your computer and use it in GitHub Desktop.
Save KratosGemini/b7bffce185e705ce88c7fb3bbc2779b3 to your computer and use it in GitHub Desktop.
Splitting WordPress custom code into multiple files
<?php
/**
* General theme loading and functions
*
* @package [THEME NAME]
*/
declare(strict_types=1);
namespace [SPECIFIC PREFIX]\Theme;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
http_response_code( 403 );
exit;
}
require_once 'includes/dom/functions.php';
<?php
/**
* DOM code loading and general functions
*
* @package [THEME NAME]
*/
declare(strict_types=1);
namespace [SPECIFIC PREFIX]\Theme\DOM;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
http_response_code( 403 );
exit;
}
require_once 'styles-and-scripts.php';
<?php
/**
* Code for enqueuing or dequeuing styles and scripts
*
* @package [THEME NAME]
*/
declare(strict_types=1);
namespace [SPECIFIC PREFIX]\Theme\DOM;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
http_response_code( 403 );
exit;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment