1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143:
<?php
namespace VSP;
defined( 'ABSPATH' ) || exit;
use Varunsridharan\PHP\Autoloader;
use Varunsridharan\WordPress\Localizer;
abstract class Framework_Modules extends Framework_Admin {
private $logging = null;
private $autoloader = null;
protected function _init_system_tools() {
if ( false !== $this->option( 'system_tools' ) ) {
$this->_instance( '\VSP\Modules\System_Tools', $this->option( 'system_tools' ) );
}
}
protected function _addon_init() {
if ( false !== $this->option( 'addons' ) ) {
$this->do_deprecated_action( 'addons_init_before', null, '0.9', 'addons/init/before' );
$this->do_action( 'addons/init/before' );
$this->_instance( '\VSP\Modules\Addons', $this->option( 'addons' ) );
$this->do_deprecated_action( 'addons_init', null, '0.9', 'addons/init' );
$this->do_action( 'addons/init' );
}
}
protected function _settings_init() {
if ( false !== $this->option( 'settings_page' ) ) {
$this->settings_init_before();
$this->do_deprecated_action( 'settings_init_before', null, '0.9', 'settings/init/before' );
$this->do_action( 'settings/init/before' );
$args = $this->option( 'settings_page' );
if ( is_array( $args ) ) {
$args['option_name'] = ( isset( $args['option_name'] ) ) ? $args['option_name'] : $this->slug( 'db' );
$this->_instance( '\VSP\Modules\WPOnion', $this->option( 'settings_page' ) );
$this->settings_init();
$this->do_deprecated_action( 'settings_init', null, '0.9', 'settings/init' );
$this->do_action( 'settings/init' );
}
}
}
public function _logging_init() {
if ( false !== $this->option( 'logging' ) ) {
$this->do_deprecated_action( 'logging_init_before', null, '0.9', 'logger/init/before' );
$this->do_action( 'logger/init/before' );
$this->logging = vsp_get_logger( $this->slug() );
$this->do_deprecated_action( 'loggin_init', null, '0.9', 'logger/init' );
$this->do_action( 'logger/init' );
}
}
protected function _autoloader_init() {
if ( false !== $this->option( 'autoloader' ) ) {
$args = $this->parse_args( $this->option( 'autoloader' ), array(
'namespace' => false,
'base_path' => $this->plugin_path(),
'options' => array(),
) );
$this->autoloader = new Autoloader( $args['namespace'], $args['base_path'], $args['options'] );
}
}
public function localizer() {
if ( false !== $this->option( 'localizer' ) ) {
return Localizer::instance( $this->option( 'localizer' ) );
}
return false;
}
public function logger() {
return $this->logging;
}
public function autoloader() {
return $this->autoloader;
}
}