is_widget_enabled() ) { return; } // Bundle resolves translations via window.aisenticI18nLoader; without it every translated string throws. $this->enqueue_i18n_loader(); wp_enqueue_script( 'aisentic-frontend-scripts' ); wp_localize_script( 'aisentic-frontend-scripts', 'aisentic', Localize::get_frontend() ); } /** * Render the public chat mount point in the site footer. * * @return void */ public function render_chat_container() { if ( ! $this->is_widget_enabled() ) { return; } echo '
'; } /** * Whether the public chat widget should load. * * True when at least one public chat integration is switched on and its * plugin is active. Without an active integration the agent has no tools, so * the widget would be a non-functional shell. * * @return bool */ private function is_widget_enabled(): bool { return ( new \Aisentic\PublicAgent\Public_Agent_Settings() )->any_enabled(); } /** * Get all scripts * * @return array List register scripts */ public function get_scripts(): array { $scripts = [ 'aisentic-i18n-loader' => [ 'src' => aisentic()->assets_url . '/build/js/i18n-loader.js', 'in_footer' => true, ], 'aisentic-frontend-scripts' => [ 'src' => aisentic()->assets_url . '/build/js/frontend.js', 'deps' => [ 'aisentic-i18n-loader' ], 'in_footer' => true, ], ]; return apply_filters( 'aisentic_frontend_assets', $scripts ); } /** * List of register styles * * @return array */ public function get_styles(): array { $styles = [ 'aisentic-frontend' => [ 'src' => aisentic()->assets_url . '/build/css/frontend.css', ], ]; return apply_filters( 'aisentic_frontend_styles', $styles ); } }