Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using the theme's information to populate the constants instead of duplicating it.
<?php
/**
* Theme initialization
*
* @package KnowTheCode\Developers
* @since 1.0.0
* @author hellofromTonya
* @link https://knowthecode.io
* @license GNU General Public License 2.0+
*/
namespace KnowTheCode\Developers;
/**
* Initialize the theme's constants.
*
* @since 1.0.0
*
* @return void
*/
function init_constants() {
$child_theme = wp_get_theme();
define( 'CHILD_THEME_NAME', $child_theme->get( 'Name' ) );
define( 'CHILD_THEME_URL', $child_theme->get( 'ThemeURI' ) );
define( 'CHILD_THEME_VERSION', $child_theme->get( 'Version' ) );
define( 'CHILD_TEXT_DOMAIN', $child_theme->get( 'TextDomain' ) );
}
init_constants();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment