Skip to content

Instantly share code, notes, and snippets.

@GuerrillaCoder
Last active August 29, 2015 14:19
Show Gist options
  • Save GuerrillaCoder/2a439634cb2c2a589a45 to your computer and use it in GitHub Desktop.
Save GuerrillaCoder/2a439634cb2c2a589a45 to your computer and use it in GitHub Desktop.
Idea for set up structure
<?php
namespace themename\setup;
//todo: abstract actual values to another object and pass it to this contructor
class MainThemeSetupMaster
{
private $cssSetup;
private $jsSetup;
public function __construct()
{
$this->cssSetup = new CssSetup();
$this->jsSetup = new ScriptSetup();
}
public function initScripts()
{
$this->cssSetup->init();
$this->jsSetup->init();
}
}
class CssSetup
{
public function init()
{
// call privates
add_action( 'wp_enqueue_scripts',
function ()
{
$this->_theme_styles();
});
add_action( 'wp_enqueue_scripts',
function ()
{
$this->_vendor_styles();
});
}
private function _theme_styles()
{
// queue theme styles
}
private function _vendor_styles()
{
// queue vendor styles
}
}
class ScriptSetup
{
public function init()
{
// call privates
add_action( 'wp_enqueue_scripts',
function ()
{
$this->_theme_scripts();
});
add_action( 'wp_enqueue_scripts',
function ()
{
$this->_vendor_scripts();
});
}
private function _theme_scripts()
{
// queue theme scripts
}
private function _vendor_scripts()
{
// queue vendor scripts
}
}
@GuerrillaCoder
Copy link
Author

Cool thanks. I am going to refactor it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment