Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created July 14, 2016 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellofromtonya/96e6cfa31e43040c2a37640eac4191ca to your computer and use it in GitHub Desktop.
Save hellofromtonya/96e6cfa31e43040c2a37640eac4191ca to your computer and use it in GitHub Desktop.
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