loadVars(); $this->enqueueScripts(); parent::render(); } /** * Load template variables. */ protected function loadVars(): void { $secure = new SecureOptions(); $business = $secure->get_selected_business(); if ( empty( $business['waba_id'] ) ) { $this->vars['error'] = __( 'No WhatsApp Business Account was selected. Go to Settings > WhatsApp Cloud to setup your WhatsApp Business Account.', 'afroit-messaging-workflows' ); } else { $this->vars['error'] = ''; } $this->vars['languages'] = MetaMessaging::getLanguageOptions(); $this->vars['categories'] = MetaMessaging::getCategoryOptions(); $this->vars['button_types'] = MetaMessaging::getButtonTypeOptions(); } /** * Localize message-template script (enqueued earlier on admin_enqueue_scripts by AdminScripts). */ public function enqueueScripts(): void { wp_localize_script( AdminScripts::use_raw_assets() ? AdminScripts::HANDLE_MESSAGE_TEMPLATE_JS : AdminScripts::HANDLE_ADMIN_JS, 'AfroitMessagingWorkflowAutomations', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'afromewo_create_template' ), 'buttonTypes' => MetaMessaging::getButtonTypeOptions(), 'i18n' => array( 'saving' => __( 'Saving…', 'afroit-messaging-workflows' ), 'saved' => __( 'Template created successfully.', 'afroit-messaging-workflows' ), 'error' => __( 'An error occurred. Please try again.', 'afroit-messaging-workflows' ), 'required' => __( 'This field is required.', 'afroit-messaging-workflows' ), 'create' => __( 'Create Template', 'afroit-messaging-workflows' ), 'nameInvalid' => __( 'Template name must contain only lowercase letters, numbers, and underscores.', 'afroit-messaging-workflows' ), ), ) ); } protected function getViewPath() { return AFROMEWO_PLUGIN_DIR . 'includes/Admin/Automation/Views/new-template.php'; } }