), ), 'redirect' => false, 'has_errors' => false, 'notification' => array( 'type' => 'success', 'text' => '' . $this->get_title() . ' ' . __( 'Successfully connected', 'hustle' ), ), ); } } $options = array( array( 'type' => 'wrapper', 'class' => $api_key_validated ? '' : 'sui-form-field-error', 'elements' => array( 'label' => array( 'type' => 'label', 'for' => 'api_key', 'value' => __( 'API Key', 'hustle' ), ), 'api_key' => array( 'type' => 'text', 'name' => 'api_key', 'value' => $current_data['api_key'], 'placeholder' => __( 'Enter Key', 'hustle' ), 'id' => 'api_key', 'icon' => 'key', ), 'error' => array( 'type' => 'error', 'class' => $api_key_validated ? 'sui-hidden' : '', 'value' => __( 'Please enter a valid MailerLite API key', 'hustle' ), ), ), ), array( 'type' => 'wrapper', 'style' => 'margin-bottom: 0;', 'elements' => array( 'label' => array( 'type' => 'label', 'for' => 'instance-name-input', 'value' => __( 'Identifier', 'hustle' ), ), 'name' => array( 'type' => 'text', 'name' => 'name', 'value' => $current_data['name'], 'placeholder' => __( 'E.g. Business Account', 'hustle' ), 'id' => 'instance-name-input', ), 'message' => array( 'type' => 'description', 'value' => __( 'Helps to distinguish your integrations if you have connected to the multiple accounts of this integration.', 'hustle' ), ), ), ), ); if ( $has_errors ) { $error_notice = array( 'type' => 'notice', 'icon' => 'info', 'class' => 'sui-notice-error', 'value' => esc_html( $error_message ), ); array_unshift( $options, $error_notice ); } $step_html = Hustle_Provider_Utils::get_integration_modal_title_markup( __( 'Configure MailerLite', 'hustle' ), sprintf( /* translators: 1. opening 'a' tag to MailerLite API page, 2. closing 'a' tag */ __( 'Log in to %1$sMailerLite Integrations%2$s page to get your API Key.', 'hustle' ), '', '' ) ); $step_html .= Hustle_Provider_Utils::get_html_for_options( $options ); $is_edit = $this->settings_are_completed( $global_multi_id ); if ( $is_edit ) { $buttons = array( 'disconnect' => array( 'markup' => Hustle_Provider_Utils::get_provider_button_markup( __( 'Disconnect', 'hustle' ), 'sui-button-ghost', 'disconnect', true ), ), 'save' => array( 'markup' => Hustle_Provider_Utils::get_provider_button_markup( __( 'Save', 'hustle' ), '', 'connect', true ), ), ); } else { $buttons = array( 'connect' => array( 'markup' => Hustle_Provider_Utils::get_provider_button_markup( __( 'Connect', 'hustle' ), 'sui-button-right', 'connect', true ), ), ); } $response = array( 'html' => $step_html, 'buttons' => $buttons, 'has_errors' => $has_errors, ); return $response; } /** * Validate the provided API key. * * @since 4.0 * * @param string $api_key Api key. * @return bool */ private function validate_api_key( $api_key ) { if ( empty( trim( $api_key ) ) ) { return false; } // Check API Key by validating it on get_info request. try { // Check if API key is valid. $api = self::api( $api_key ); // Check if API key is valid. $_lists = null; if ( $api ) { $_lists = $api->list_groups(); } if ( ! is_array( $_lists ) || is_wp_error( $_lists ) || isset( $_lists['error'] ) ) { Hustle_Provider_Utils::maybe_log( __METHOD__, __( 'Invalid MailerLite API key.', 'hustle' ) ); return false; } } catch ( Exception $e ) { Hustle_Provider_Utils::maybe_log( __METHOD__, $e->getMessage() ); return false; } return true; } /** * Check if an email exists * * @param int $group_id - the group id. * @param string $email - the email. * @param object $api - the API class. * * @return bool */ public function email_exists( $group_id, $email, $api ) { $member_groups = $api->get_subscriber( $email ); if ( is_wp_error( $member_groups ) ) { return false; } else { if ( ! isset( $member_groups['error'] ) ) { foreach ( $member_groups as $member_group => $group ) { if ( $group['id'] === (int) $group_id ) { return true; } } } else { return false; } } return false; } /** * Get 3.0 provider mappings * * @return type */ public function get_30_provider_mappings() { return array( 'api_key' => 'api_key', ); } /** * Add custom fields * * @param array $fields Fields. * @param object $api Api. * @return type */ public static function add_custom_fields( $fields, $api ) { $existing_fields = $api->get_custom_field(); $existing_field_keys = wp_list_pluck( $existing_fields, 'key' ); foreach ( $fields as $field ) { if ( $existing_field_keys && ! in_array( $field['name'], $existing_field_keys, true ) ) { $api->add_custom_field( array( 'title' => $field['name'], 'type' => strtoupper( $field['type'] ), ) ); } } return array( 'success' => true, 'field' => $fields, ); } } endif; Communauté – Meducol

Communauté

Équipe Meducol

4 Abonnés 56 Vidéos

Amin Zgarni

0 Abonnés 0 Vidéos

Marie Lambert

0 Abonnés 0 Vidéos

williamamaws

0 Abonnés 0 Vidéos

اسلام عبد الله

0 Abonnés 0 Vidéos

bizbizbelluci

0 Abonnés 0 Vidéos

Rezeda Ismagilova

0 Abonnés 0 Vidéos

Naomi Nakatani

0 Abonnés 0 Vidéos

lamri mohamed

0 Abonnés 0 Vidéos

ouarda zega

0 Abonnés 0 Vidéos
1 2 3 177

Mot de passe perdu ? Merci de saisir ton adresse email. Tu recevras un e-mail avec un lien pour définir un nouveau mot de passe.

Ton clé de lien de réinitialisation du mot de passe est manquante.
Ton lien de réinitialisation du mot de passe est manquant.

Mot de passe perdu ? Merci de saisir ton adresse email. Tu recevras un e-mail avec un lien pour définir un nouveau mot de passe.