Last active
August 29, 2015 14:19
-
-
Save GuerrillaCoder/2a439634cb2c2a589a45 to your computer and use it in GitHub Desktop.
Idea for set up structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool thanks. I am going to refactor it.