Skip to content

Commit

Permalink
Add no ui mode. (#25)
Browse files Browse the repository at this point in the history
- No UI and no renderer if constsants defined.
  • Loading branch information
fumikito committed May 29, 2023
2 parents a95d422 + 0c9b35d commit 2825c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Kunoichi/GaCommunicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ protected function init() {
}
// Load local.
$this->locale();
// Load Setting Screen
// Load Setting Screen by default.
Settings::get_instance();
// Script Renderer.
ScriptRenderer::get_instance();
// Script Renderer by default.
if ( ! defined( 'GA_COMMUNICATOR_NO_RENDERER' ) || ! GA_COMMUNICATOR_NO_RENDERER ) {
ScriptRenderer::get_instance();
}
// Register scripts.
add_action( 'init', [ $this, 'register_assets' ] );
// API.
Expand Down
4 changes: 4 additions & 0 deletions src/Kunoichi/GaCommunicator/Screen/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class Settings extends Singleton {
* Constructor
*/
protected function init() {
if ( defined( 'GA_COMMUNICATOR_NO_UI' ) && GA_COMMUNICATOR_NO_UI ) {
// NO UI flag is on. Stop rendering admin screen.
return;
}
add_action( 'admin_init', [ $this, 'register_setting_fields' ] );
if ( $this->should_network_activate() ) {
add_action( 'network_admin_menu', [ $this, 'network_admin_menu' ] );
Expand Down

0 comments on commit 2825c01

Please sign in to comment.