admin = $admin; } /** * Enqueue styles and scripts for NoorSMTP admin screens. * * @param string $hook Current admin page hook. * @return void */ public function enqueue( $hook ) { $is_noorsmtp = false !== strpos( (string) $hook, 'noorsmtp' ); if ( ! $is_noorsmtp ) { return; } // Enqueue shared color tokens first. wp_enqueue_style( 'noorsmtp-colors', NOORSMTP_URL . 'assets/admin/css/nw-colors.css', array(), noorsmtp_asset_version( 'assets/admin/css/nw-colors.css' ) ); // Enqueue main admin app stylesheet. wp_enqueue_style( 'noorsmtp-admin', NOORSMTP_URL . 'assets/admin/css/admin.css', array( 'noorsmtp-colors', 'dashicons' ), noorsmtp_asset_version( 'assets/admin/css/admin.css' ) ); // Enqueue JavaScript app controller. wp_enqueue_script( 'noorsmtp-admin', NOORSMTP_URL . 'assets/admin/js/admin.js', array( 'jquery', 'wp-i18n' ), noorsmtp_asset_version( 'assets/admin/js/admin.js' ), true ); wp_localize_script( 'noorsmtp-admin', 'noorsmtpApp', $this->app_config() ); // Backward compatibility for scripts looking for NoorSmtpAdmin. wp_localize_script( 'noorsmtp-admin', 'NoorSmtpAdmin', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'noorsmtp_admin' ), 'i18n' => $this->i18n_strings(), ) ); } /** * Application configuration handed to admin.js. * * @return array */ private function app_config() { $settings = $this->admin->get_settings(); return array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'action' => 'noorsmtp_admin_action', 'nonce' => wp_create_nonce( 'noorsmtp_admin' ), 'baseUrl' => noorsmtp_admin_url( 'noorsmtp' ), 'screen' => $this->admin->current_screen_id(), 'isPro' => noorsmtp_is_pro(), 'licensed' => noorsmtp_license_active(), 'activeMailer' => isset( $settings['mailer'] ) ? $settings['mailer'] : '', 'i18n' => $this->i18n_strings(), ); } /** * Internationalized UI strings. * * @return array */ private function i18n_strings() { return array( 'loading' => __( 'Loading…', 'noorsmtp' ), 'saving' => __( 'Saving…', 'noorsmtp' ), 'saved' => __( 'Settings saved.', 'noorsmtp' ), 'saveFailed' => __( 'Could not save settings. Please try again.', 'noorsmtp' ), 'sending' => __( 'Sending…', 'noorsmtp' ), 'testSent' => __( 'Test email sent successfully!', 'noorsmtp' ), 'testFailed' => __( 'Test email failed to send. Please check your settings and error logs.', 'noorsmtp' ), 'logsFailed' => __( 'Could not load email logs.', 'noorsmtp' ), 'confirm' => __( 'Are you sure?', 'noorsmtp' ), 'confirmClear' => __( 'Are you sure you want to clear all email logs? This cannot be undone.', 'noorsmtp' ), 'confirmUninstallCleanup'=> __( 'Are you sure you want to enable this? When enabled, all saved settings, mailer credentials, and email logs will be permanently deleted when the plugin is deleted.', 'noorsmtp' ), 'cleared' => __( 'Email logs cleared.', 'noorsmtp' ), 'clearFailed' => __( 'Could not clear email logs.', 'noorsmtp' ), 'copied' => __( 'Copied to clipboard!', 'noorsmtp' ), 'copyFailed' => __( 'Could not copy to clipboard.', 'noorsmtp' ), 'details' => __( 'Log Details', 'noorsmtp' ), 'close' => __( 'Close', 'noorsmtp' ), 'noLogs' => __( 'No emails logged yet.', 'noorsmtp' ), 'connected' => __( 'Connected', 'noorsmtp' ), 'connectionVerified' => __( 'Connection Verified!', 'noorsmtp' ), ); } }