register_modules(); $this->register_settings(); } /** * Registers all modules. * * @return void */ protected function register_modules(): void { NotificationManager::get()->register( 'adpresso-modules-root', __( 'Modules', 'adpresso' ), [ 'location' => 'admin_bar', 'context' => null, ] ); if ( class_exists( ModuleManager::class ) ) { $modules = ModuleManager::get_registered(); foreach ( $modules as $id => $module ) { $is_active = ModuleManager::is_active( $id, $module['setting'] ?? '' ); $status_text = $is_active ? ' [Active]' : ' [Inactive]'; NotificationManager::get()->register( 'adpresso-module-' . $id, esc_html( $module['label'] ) . $status_text, [ 'location' => 'admin_bar', 'context' => 'adpresso-modules-root', 'type' => $is_active ? 'success' : 'error', 'link' => admin_url( 'admin.php?page=adpresso-settings&tab=modules' ), ] ); } } } /** * Registers key settings. * * @return void */ protected function register_settings(): void { NotificationManager::get()->register( 'adpresso-settings-root', __( 'Settings', 'adpresso' ), [ 'location' => 'admin_bar', 'context' => null, ] ); $key_settings = [ 'target_blank' => __( 'Open in New Tab', 'adpresso' ), 'linkbase' => __( 'Link Masking', 'adpresso' ), ]; foreach ( $key_settings as $key => $label ) { $value = Settings::get_setting( $key ); $is_enabled = ! empty( $value ) && $value !== '0'; $status_text = $is_enabled ? ' [Enabled]' : ' [Disabled]'; NotificationManager::get()->register( 'adpresso-setting-' . $key, esc_html( $label ) . $status_text, [ 'location' => 'admin_bar', 'context' => 'adpresso-settings-root', 'type' => $is_enabled ? 'success' : 'info', 'link' => admin_url( 'admin.php?page=adpresso-settings' ), ] ); } $debug_mode = (int) Settings::get_setting( 'debug_mode', 1 ); NotificationManager::get()->register( 'adpresso-setting-debug_mode', __( 'Debug Mode', 'adpresso' ) . sprintf( ' [Level %d]', $debug_mode ), [ 'location' => 'admin_bar', 'context' => 'adpresso-settings-root', 'type' => $debug_mode > 0 ? 'success' : 'info', 'link' => admin_url( 'admin.php?page=adpresso-settings' ), ] ); } }