Last active
August 29, 2015 14:25
-
-
Save GaryJones/4be773657881860336f3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 GMJ\Foobar; | |
class Config extends \ArrayObject {} |
This file contains hidden or 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 GMJ\Foobar; | |
class Plugin { | |
function run() { | |
$shortcode_config = new Config( include DT_EIA_DIR . 'config/shortcode.php', \ArrayObject::ARRAY_AS_PROPS ); | |
$shortcodeui_config = new Config( include DT_EIA_DIR . 'config/shortcodeui.php', \ArrayObject::ARRAY_AS_PROPS ); | |
$dependencies_config = new Config( include DT_EIA_DIR . 'config/dependencies.php', \ArrayObject::ARRAY_AS_PROPS ); | |
$dependencies = new Dependencies( $dependencies_config ); | |
$shortcode = new Shortcode( $shortcode_config, new Shortcode_Atts_Parser, $dependencies ); | |
$shortcodeui = new ShortcodeUI( $shortcodeui_config, $shortcode_config->shortcode_tag ); | |
add_action( 'init', [ $shortcode, 'register' ] ); | |
add_action( 'init', [ $shortcodeui, 'register' ] ); | |
add_action( 'wp_enqueue_scripts', [ $dependencies, 'register' ] ); | |
add_action( 'admin_enqueue_scripts', [ $dependencies, 'register' ] ); | |
add_action( 'shortcode_ui_before_do_shortcode', array( $dependencies, 'admin_output' ) ); | |
} | |
} |
This file contains hidden or 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 GMJ\Foobar; | |
class Shortcode { | |
protected $config; | |
function __construct( Config $config ) { // minimal example | |
$this->config = $config; | |
} | |
function tag() { | |
return $this->config->shortcode_tag; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Gary,
In DT\EIA\Plugin, add
use GMJ\Foobar
to bring the class Config into scope.