Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seothemes/core-constants
Dynamically defines constants for use throughout child themes
https://github.com/seothemes/core-constants
Last synced: 7 days ago
JSON representation
Dynamically defines constants for use throughout child themes
- Host: GitHub
- URL: https://github.com/seothemes/core-constants
- Owner: seothemes
- Created: 2018-08-01T10:09:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-01T10:23:19.000Z (over 6 years ago)
- Last Synced: 2024-04-22T03:15:15.423Z (7 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Constants
Dynamically defines constants for use throughout child themes.
## Installation
This component should be installed using Composer, with the command `composer require seothemes/core-constants`.
## Usage
Within your config file (typically found at `config/defaults.php`), use the `Constants::DEFINE` class constant as an array key to add a list of constants to define.
For example:
```php
use SEOThemes\Core\Constants;$constants = [
Constants::DEFINE => [
'CHILD_THEME_NAME' => wp_get_theme()->get( 'Name' ),
'CHILD_THEME_URL' => wp_get_theme()->get( 'ThemeURI' ),
'CHILD_THEME_VERSION' => wp_get_theme()->get( 'Version' ),
'CHILD_THEME_HANDLE' => wp_get_theme()->get( 'TextDomain' ),
'CHILD_THEME_AUTHOR' => wp_get_theme()->get( 'Author' ),
'CHILD_THEME_DIR' => get_stylesheet_directory(),
'CHILD_THEME_URI' => get_stylesheet_directory_uri(),
],
];return [
Constants::class => $constants,
];
```## Load the component
Components should be loaded in your theme `functions.php` file, using the `Theme::setup` static method. Code should run on the `after_setup_theme` hook (or `genesis_setup` if you use Genesis Framework).
```php
add_action( 'after_setup_theme', function() {
$config = include_once __DIR__ . '/config/defaults.php';
D2\Core\Theme::setup( $config );
} );
```