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:
<?php
namespace VSP\Modules;
defined( 'ABSPATH' ) || exit;
use VSP\Base;
class System_Tools extends Base {
private $slug = null;
protected function defaults() {
return array(
'system_tools' => true,
'menu' => true,
'logging' => true,
);
}
public function __construct( $options = array() ) {
$this->set_args( $options );
$this->add_action( $this->plugin()->slug( 'hook' ) . '/settings/fields', 'options', 999 );
}
public function output_logs_info() {
$instance = $this->_instance( '\VSP\Modules\System_Logs' );
$instance->render();
}
public function options( $builder ) {
if ( false === $this->option( 'system_tools' ) ) {
$this->system_logs_menu( $builder, true );
} else {
$menu = $this->menu_data( $this->option( 'menu' ), array(
'title' => esc_html__( 'System Tools', 'vsp-framework' ),
'icon' => 'fa fa-gear',
'name' => 'system-tools',
) );
$this->slug = $menu['name'];
$builder->container( $menu['name'], $menu['title'], $menu['icon'] );
$this->system_logs_menu( $builder, false );
}
}
private function menu_data( $given_data, $default = array() ) {
if ( is_bool( $given_data ) ) {
return $default;
} elseif ( is_string( $given_data ) ) {
$default['title'] = $given_data;
$default['name'] = sanitize_title( $given_data );
} elseif ( is_array( $given_data ) ) {
$default = array_merge( $default, $given_data );
}
return $default;
}
protected function system_logs_menu( $args = array(), $is_page = true ) {
if ( false !== $this->option( 'logging' ) ) {
$m = $this->menu_data( $this->option( 'logging' ), array(
'title' => esc_html__( 'System Logs', 'vsp-framework' ),
'icon' => 'fa fa-file',
'name' => 'system-logs',
) );
$box = ( true === $is_page ) ? $args : $args->container( $this->slug );
if ( wpo_is_container( $box ) || wpo_is( $box ) ) {
$box->container( $m['name'], $m['title'], $m['icon'] )->callback( array( $this, 'output_logs_info' ) );
}
}
return $args;
}
}