__( 'Connection', 'convohub' ), 'widget' => __( 'Widget', 'convohub' ), 'leads' => __( 'Leads', 'convohub' ), 'logs' => __( 'Logs', 'convohub' ), 'help' => __( 'Help', 'convohub' ), ); } /** * The active tab. Reading it needs no nonce: it only chooses what to display. * * @return string */ private function current_tab() { $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'connection'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended return array_key_exists( $tab, $this->tabs() ) ? $tab : 'connection'; } /** * Loads admin assets on the ConvoHub screen only. * * @param string $hook_suffix Current admin page. */ public function enqueue_assets( $hook_suffix ) { if ( 'toplevel_page_' . self::PAGE_SLUG !== $hook_suffix ) { return; } $scripts = array( 'connection' => 'admin', 'widget' => 'admin-widget', 'leads' => 'admin-leads', 'logs' => 'admin-logs', 'help' => 'admin-help', ); $script = $scripts[ $this->current_tab() ]; wp_enqueue_style( 'convohub-admin' ); wp_enqueue_script( 'convohub-admin-ui' ); wp_enqueue_script( 'convohub-admin', CONVOHUB_URL . 'assets/' . $script . '.js', array( 'convohub-admin-ui', 'wp-api-fetch', 'wp-i18n' ), CONVOHUB_VERSION, true ); wp_set_script_translations( 'convohub-admin', 'convohub' ); if ( 'leads' === $this->current_tab() ) { wp_enqueue_script( 'convohub-admin-fields', CONVOHUB_URL . 'assets/admin-fields.js', array( 'wp-i18n' ), CONVOHUB_VERSION, true ); wp_set_script_translations( 'convohub-admin-fields', 'convohub' ); } } /** * Renders the settings page. */ public function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $current = $this->current_tab(); $settings = ConvoHub_Settings::get(); $connected = ConvoHub_Settings::is_connected(); ?>


render_notices(); if ( 'widget' === $current ) { $this->render_widget_tab(); } elseif ( 'leads' === $current ) { $this->render_leads_tab(); } elseif ( 'logs' === $current ) { $this->render_logs_tab(); } elseif ( 'help' === $current ) { ConvoHub_Help::render( $settings ); } else { $this->render_connection_tab(); } ?>
Settings > Integrations > WordPress and paste it here.', 'convohub' ) ); } $identity_status = array( 'done' => array( 'ok', __( 'On', 'convohub' ) ), 'optional' => array( '', __( 'Off', 'convohub' ) ), 'todo' => array( 'warn', __( 'Needs attention', 'convohub' ) ), ); ConvoHub_Admin_UI::panel_open(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-checklist', 'title' => __( 'Setup', 'convohub' ), 'description' => $summary['done'] === $summary['total'] ? __( 'Everything is set up.', 'convohub' ) /* translators: 1: steps done, 2: total steps. */ : sprintf( __( '%1$d of %2$d steps done.', 'convohub' ), $summary['done'], $summary['total'] ), 'wide' => true, ) ); ConvoHub_Admin_UI::checklist( $steps, array( 'leads' ) ); ConvoHub_Admin_UI::section_close(); if ( $connected ) { $this->render_connection_details( $settings, $method ); } if ( $show_form ) { ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-connect', 'title' => $connected ? __( 'Replace the access token', 'convohub' ) : __( 'Connect', 'convohub' ), 'description' => $connected ? __( 'A connection key replaces the token and keeps the inbox and webhook settings of the same account.', 'convohub' ) : __( 'Connect this site to your ConvoHub account with a one-time key.', 'convohub' ), ) ); ?>
  1. Integrations > WordPress and generate a key.', 'convohub' ); ?>
'convohub-key', 'label' => __( 'Connection key', 'convohub' ), 'hint' => __( 'Used once to connect. It is not saved.', 'convohub' ), 'error' => $form_error, ); ConvoHub_Admin_UI::row_open( $key_args ); ?>
>
'cvh-inbox', 'title' => __( 'Chat widget inbox', 'convohub' ), 'description' => __( 'The website inbox behind the chat on your site.', 'convohub' ), ) ); ConvoHub_Admin_UI::status( 'done' === $by_id['inbox']['state'] ? 'ok' : '', 'done' === $by_id['inbox']['state'] ? __( 'Chosen', 'convohub' ) : __( 'Not chosen', 'convohub' ) ); echo '

' . esc_html__( 'Choose it on the Widget tab', 'convohub' ) . '

'; ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-identity', 'title' => __( 'Identity validation', 'convohub' ), 'help' => 'identity-validation', 'description' => __( 'Optional. Lets ConvoHub trust who logged-in customers are.', 'convohub' ), ) ); ConvoHub_Admin_UI::status( $identity_status[ $by_id['identity']['state'] ][0], $identity_status[ $by_id['identity']['state'] ][1] ); echo '

' . esc_html__( 'Change it on the Widget tab', 'convohub' ) . '

'; ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-webhook', 'title' => __( 'Webhook', 'convohub' ), 'help' => 'webhook-overview', 'description' => __( 'Tells this site about new messages and conversation changes. Events are signed and processed once.', 'convohub' ), ) ); ?>
render_disconnect(); }//end if ConvoHub_Admin_UI::panel_close(); } /** * What this site is connected to, with the connection test. * * @param array $settings Plugin settings. * @param string $method key or token. */ private function render_connection_details( array $settings, $method ) { $name = '' !== $settings['account_name'] ? $settings['account_name'] /* translators: %d: ConvoHub account number. */ : sprintf( __( 'Account #%d', 'convohub' ), (int) $settings['account_id'] ); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-connection', 'title' => __( 'Connection', 'convohub' ), 'description' => __( 'The ConvoHub account this site uses. To use another, disconnect and connect with its key.', 'convohub' ), ) ); echo '
'; echo '
' . esc_html__( 'Account', 'convohub' ) . '
' . esc_html( $name ) . '
'; if ( 'key' === $method ) { if ( '' !== $settings['connected_as'] ) { echo '
' . esc_html__( 'Connected as', 'convohub' ) . '
' . esc_html( $settings['connected_as'] ) . '
'; } echo '
' . esc_html__( 'Connected on', 'convohub' ) . '
' . esc_html( wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), (int) $settings['connected_at'] ) ) . '
'; } else { echo '
' . esc_html__( 'Connected with', 'convohub' ) . '
' . esc_html__( 'Access token (legacy)', 'convohub' ) . '
'; } if ( 'key' === $method ) { echo '
' . esc_html__( 'Key used', 'convohub' ) . '
' . esc_html( $settings['key_prefix'] ) . '…
'; } echo '
'; ?>
'cvh-disconnect', 'title' => __( 'Disconnect', 'convohub' ), 'description' => __( 'Stop using this ConvoHub account on this site.', 'convohub' ), ) ); ?>

$default, '1' => __( 'Yes', 'convohub' ), '0' => __( 'No', 'convohub' ), ); ConvoHub_Admin_UI::panel_open(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-inbox', 'title' => __( 'Website inbox', 'convohub' ), 'help' => 'allowed-domains', 'description' => __( 'The inbox that powers the chat widget.', 'convohub' ), ) ); ?>
'cvh-display', 'title' => __( 'Display', 'convohub' ), 'description' => __( 'Whether the chat shows, and on which pages.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_switch( array( 'id' => 'convohub-widget-enabled', 'name' => $field . '[widget_enabled]', 'text' => __( 'Show the chat widget on this site', 'convohub' ), 'checked' => $settings['widget_enabled'], 'disabled' => $no_inbox, 'hint' => $no_inbox ? __( 'Choose a website inbox first.', 'convohub' ) : '', ) ); ConvoHub_Admin_UI::field_radios( array( 'id' => 'convohub-visibility', 'name' => $field . '[visibility]', 'label' => __( 'Show on', 'convohub' ), 'value' => $settings['visibility'], 'options' => array( 'all' => __( 'All pages', 'convohub' ), 'include' => __( 'Only the pages listed below', 'convohub' ), 'exclude' => __( 'All pages except the ones listed below', 'convohub' ), // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- a setting value, not a query argument. ), ) ); ConvoHub_Admin_UI::field_textarea( array( 'id' => 'convohub-url-patterns', 'name' => $field . '[url_patterns]', 'label' => __( 'Page paths', 'convohub' ), 'value' => $settings['url_patterns'], 'rows' => 4, 'mono' => true, 'placeholder' => "/pricing\n/shop/*", 'hint' => __( 'One path per line. Use * to match anything, for example /shop/*.', 'convohub' ), ) ); ConvoHub_Admin_UI::row_open( array( 'id' => 'convohub-hide', 'label' => __( 'Hide for', 'convohub' ), 'group' => true, ) ); echo '
'; ConvoHub_Admin_UI::check_control( array( 'id' => 'convohub-hide-logged-in', 'name' => $field . '[hide_logged_in]', 'text' => __( 'Logged-in users', 'convohub' ), 'checked' => $settings['hide_logged_in'], ) ); ConvoHub_Admin_UI::check_control( array( 'id' => 'convohub-hide-checkout', 'name' => $field . '[hide_checkout]', 'text' => __( 'The WooCommerce checkout page', 'convohub' ), 'checked' => $settings['hide_checkout'], ) ); echo '
'; ConvoHub_Admin_UI::row_close( array( 'id' => 'convohub-hide' ) ); ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-identity', 'title' => __( 'Identity validation', 'convohub' ), 'help' => 'identity-validation', 'description' => __( 'Signs logged-in customers so ConvoHub can trust who they are.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_switch( array( 'id' => 'convohub-identity-enabled', 'name' => $field . '[identity_enabled]', 'text' => __( 'Recognize logged-in customers in the chat', 'convohub' ), 'checked' => $settings['identity_enabled'], 'disabled' => $no_secret, 'hint' => $no_secret ? __( 'Needs the inbox identity secret, which only ConvoHub administrators can see. Connect with a key made by a ConvoHub administrator, then choose the inbox again.', 'convohub' ) : __( 'Also shows their conversation history on any device.', 'convohub' ), ) ); ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-appearance', 'title' => __( 'Appearance', 'convohub' ), 'description' => __( 'Colors and welcome text are set on the inbox in ConvoHub.', 'convohub' ), ) ); echo '
'; ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-position', 'name' => $field . '[position]', 'label' => __( 'Position', 'convohub' ), 'value' => $settings['position'], 'options' => array( '' => $default, 'right' => __( 'Right', 'convohub' ), 'left' => __( 'Left', 'convohub' ), ), ) ); ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-widget-type', 'name' => $field . '[widget_type]', 'label' => __( 'Launcher', 'convohub' ), 'value' => $settings['widget_type'], 'options' => array( '' => $default, 'standard' => __( 'Standard bubble', 'convohub' ), 'expanded_bubble' => __( 'Expanded bubble with a label', 'convohub' ), ), ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-launcher-title', 'name' => $field . '[launcher_title]', 'label' => __( 'Launcher label', 'convohub' ), 'value' => $settings['launcher_title'], ) ); ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-widget-style', 'name' => $field . '[widget_style]', 'label' => __( 'Style', 'convohub' ), 'value' => $settings['widget_style'], 'options' => array( '' => $default, 'standard' => __( 'Standard', 'convohub' ), 'flat' => __( 'Flat', 'convohub' ), ), ) ); ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-dark-mode', 'name' => $field . '[dark_mode]', 'label' => __( 'Color scheme', 'convohub' ), 'value' => $settings['dark_mode'], 'options' => array( '' => $default, 'light' => __( 'Light', 'convohub' ), 'auto' => __( 'Follow the visitor\'s device', 'convohub' ), 'dark' => __( 'Dark', 'convohub' ), ), ) ); echo '
'; ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-visitor', 'title' => __( 'Visitor options', 'convohub' ), 'description' => __( '"ConvoHub default" keeps the setting of the inbox.', 'convohub' ), ) ); echo '
'; foreach ( array( 'use_browser_language' => array( 'convohub-use-browser-language', __( 'Use the visitor\'s browser language', 'convohub' ) ), 'enable_file_upload' => array( 'convohub-enable-file-upload', __( 'Allow file uploads', 'convohub' ) ), 'enable_emoji_picker' => array( 'convohub-enable-emoji-picker', __( 'Show the emoji picker', 'convohub' ) ), 'enable_end_conversation' => array( 'convohub-enable-end-conversation', __( 'Let visitors end the conversation', 'convohub' ) ), ) as $key => $option ) { ConvoHub_Admin_UI::field_select( array( 'id' => $option[0], 'name' => $field . '[' . $key . ']', 'label' => $option[1], 'value' => $settings[ $key ], 'options' => $tristate, ) ); } echo '
'; ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::panel_close(); ConvoHub_Admin_UI::save_bar(); ?>
Customize, or Styles in the Site Editor) if you still need it, then dismiss this notice.', 'convohub' ) ); ConvoHub_Admin_UI::code_block( 'convohub-retired-css', $retired ); printf( '
%3$s
', esc_url( admin_url( 'admin-post.php' ) ), esc_attr( ConvoHub_Settings::DISMISS_ACTION ), wp_nonce_field( ConvoHub_Settings::DISMISS_ACTION, '_wpnonce', true, false ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Core escapes it. esc_html__( 'Dismiss', 'convohub' ) ); } ConvoHub_Admin_UI::panel_open(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-leads-inbox', 'title' => __( 'Destination', 'convohub' ), 'description' => __( 'Each submission creates a contact and a conversation in an API inbox.', 'convohub' ), ) ); ?>
'cvh-add-form', 'title' => __( 'Add the form to a page', 'convohub' ), 'description' => __( 'Use the "ConvoHub Lead Form" block, or paste this shortcode.', 'convohub' ), ) ); ConvoHub_Admin_UI::code_block( 'convohub-shortcode', '[convohub_form heading="Contact us" button="Send"]' ); ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::panel_close(); ?>
'cvh-form-options', 'title' => __( 'Form', 'convohub' ), 'description' => __( 'Phone numbers, consent and the message after sending.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-default-country', 'name' => $field . '[leads_default_country]', 'label' => __( 'Default country code', 'convohub' ), 'help' => 'default-country-code', 'value' => $settings['leads_default_country'], 'size' => 'short', 'inputmode' => 'numeric', 'placeholder' => '91', 'hint' => __( 'Added to phone numbers typed without a +, for example 91 for India.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_switch( array( 'id' => 'convohub-require-consent', 'name' => $field . '[leads_require_consent]', 'text' => __( 'Require a consent checkbox', 'convohub' ), 'checked' => $settings['leads_require_consent'], ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-consent-text', 'name' => $field . '[leads_consent_text]', 'label' => __( 'Consent text', 'convohub' ), 'value' => $settings['leads_consent_text'], 'placeholder' => __( 'I agree to be contacted about my enquiry.', 'convohub' ), 'hint' => __( 'Empty uses the text in the placeholder.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-success-message', 'name' => $field . '[leads_success_message]', 'label' => __( 'Thank-you message', 'convohub' ), 'value' => $settings['leads_success_message'], 'placeholder' => __( 'Thanks! We will get back to you soon.', 'convohub' ), ) ); ConvoHub_Admin_UI::section_close(); ConvoHub_Admin_UI::section_open( array( 'id' => 'cvh-form-fields', 'title' => __( 'Fields', 'convohub' ), 'description' => __( 'Show, rename, reorder or add fields. A lead needs an email address or a phone number.', 'convohub' ), 'stack' => true, 'wide' => true, ) ); ?>

'cvh-appearance', 'title' => __( 'Appearance', 'convohub' ), 'help' => 'form-appearance', 'description' => __( 'What you do not set follows your theme. Only loaded on pages that show the form.', 'convohub' ), ) ); $style = $settings['leads_style']; ConvoHub_Admin_UI::field_switch( array( 'id' => 'convohub-style-use-accent', 'name' => $field . '[leads_style][use_accent]', 'text' => __( 'Use my own button colour', 'convohub' ), 'checked' => '' !== $style['accent'], ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-style-accent', 'name' => $field . '[leads_style][accent]', 'label' => __( 'Button colour', 'convohub' ), 'type' => 'color', 'value' => '' !== $style['accent'] ? $style['accent'] : '#0065ff', 'hint' => __( 'The button text turns black or white to stay readable.', 'convohub' ), ) ); ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-style-radius', 'name' => $field . '[leads_style][radius]', 'label' => __( 'Corners', 'convohub' ), 'value' => $style['radius'], 'options' => array( '' => __( 'Follow the theme', 'convohub' ), 'none' => __( 'Square', 'convohub' ), 'small' => __( 'Slightly rounded', 'convohub' ), 'medium' => __( 'Rounded', 'convohub' ), 'large' => __( 'Very rounded', 'convohub' ), ), ) ); ConvoHub_Admin_UI::field_select( array( 'id' => 'convohub-style-spacing', 'name' => $field . '[leads_style][spacing]', 'label' => __( 'Space between fields', 'convohub' ), 'value' => $style['spacing'], 'options' => array( '' => __( 'Follow the theme', 'convohub' ), 'compact' => __( 'Compact', 'convohub' ), 'normal' => __( 'Normal', 'convohub' ), 'roomy' => __( 'Roomy', 'convohub' ), ), ) ); ConvoHub_Admin_UI::field_input( array( 'id' => 'convohub-style-max-width', 'name' => $field . '[leads_style][max_width]', 'label' => __( 'Maximum width in pixels', 'convohub' ), 'type' => 'number', 'value' => $style['max_width'] > 0 ? (string) $style['max_width'] : '', 'hint' => sprintf( /* translators: 1: smallest width, 2: largest width. */ __( 'Leave empty for the full width of the page. From %1$d to %2$d.', 'convohub' ), ConvoHub_Lead_Style::MIN_WIDTH, ConvoHub_Lead_Style::MAX_WIDTH ), ) ); ?>

Customize, or Styles in the Site Editor). The Help tab lists the class names of the form.', 'convohub' ); ?>