-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add github actions. - Update dependencies. - New module : change email. - Fix behavior when empty avatar.
- Loading branch information
Showing
22 changed files
with
248 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: PHP Lint | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
phplint: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: PHP Lint | ||
uses: michaelw90/PHP-Lint@2.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.mo.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php /* Silence */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
---------------------------------------------------------- */ | ||
|
||
/* Form action | ||
-------------------------- */ | ||
|
||
function wpu_extranet_change_email__action() { | ||
if (empty($_POST)) { | ||
return ''; | ||
} | ||
if (!is_user_logged_in()) { | ||
return ''; | ||
} | ||
if (!isset($_POST['current_email'], $_POST['new_email'], $_POST['confirm_new_email'])) { | ||
return ''; | ||
} | ||
|
||
if (!isset($_POST['wpuextranet_changeemail']) || !wp_verify_nonce($_POST['wpuextranet_changeemail'], 'wpuextranet_changeemail_action')) { | ||
return ''; | ||
} | ||
|
||
$current_email = trim($_POST['current_email']); | ||
$new_email = trim($_POST['new_email']); | ||
$confirm_new_email = trim($_POST['confirm_new_email']); | ||
|
||
$user_id = get_current_user_id(); | ||
$current_user = get_user_by('id', $user_id); | ||
if (!$current_user) { | ||
return; | ||
} | ||
|
||
/* Check errors */ | ||
$errors = array(); | ||
|
||
/* Empty fields */ | ||
if (empty($current_email) || empty($new_email) || empty($confirm_new_email)) { | ||
$errors[] = __('All fields are required.', 'wpu_extranet'); | ||
} | ||
|
||
/* Invalid email */ | ||
if (!is_email($current_email) || !is_email($new_email) || !is_email($confirm_new_email)) { | ||
$errors[] = __('Invalid email.', 'wpu_extranet'); | ||
} | ||
|
||
/* Invalid current email */ | ||
if($current_email == $new_email){ | ||
$errors[] = __('New email is the same as the current email.', 'wpu_extranet'); | ||
} | ||
|
||
/* New emails do not match */ | ||
if ($new_email != $confirm_new_email) { | ||
$errors[] = __('Emails do not match.', 'wpu_extranet'); | ||
} | ||
|
||
/* E-mail is already in use */ | ||
if (email_exists($new_email)) { | ||
$errors[] = __('Email is already in use.', 'wpu_extranet'); | ||
} | ||
|
||
$errors = apply_filters('wpu_extranet_change_email__action_errors', $errors, $current_email, $new_email, $confirm_new_email); | ||
|
||
$html_return = ''; | ||
if (empty($errors)) { | ||
// Change email | ||
wp_update_user(array( | ||
'ID' => $user_id, | ||
'user_email' => $new_email | ||
)); | ||
$html_return = '<p class="extranet-message extranet-message--success form-email-success">' . __('Email successfully updated!', 'wpu_extranet') . '</p>'; | ||
} else { | ||
$html_return = '<p class="extranet-message extranet-message--error form-email-error">' . implode('<br />', $errors) . '</p>'; | ||
} | ||
|
||
return $html_return; | ||
} | ||
|
||
/* HTML Form | ||
-------------------------- */ | ||
|
||
|
||
function wpu_extranet_change_email__form($args = array()) { | ||
if (!is_array($args)) { | ||
$args = array(); | ||
} | ||
if (!isset($args['before_fields'])) { | ||
$args['before_fields'] = ''; | ||
} | ||
$html = ''; | ||
|
||
$userdata = get_userdata(get_current_user_id()); | ||
|
||
$settings = wpu_extranet_get_skin_settings(); | ||
|
||
$html .= '<div class="' . $settings['form_wrapper_classname'] . ' form-changeemail-wrapper">'; | ||
$html .= '<h3>' . __('Change email', 'wpu_extranet') . '</h3>'; | ||
$html .= '<form name="changeemailform" id="changeemailform" action="' . get_permalink() . '#changeemailform" method="post">'; | ||
$html .= $args['before_fields']; | ||
$html .= '<ul class="' . $settings['form_items_classname'] . '">'; | ||
$html .= wpu_extranet__display_field('current_email', array( | ||
'type' => 'email', | ||
'attributes' => 'readonly minlength="6" autocomplete="off" required="required"', | ||
'label' => __('Your current email', 'wpu_extranet'), | ||
'value' => $userdata->user_email | ||
)); | ||
$html .= wpu_extranet__display_field('new_email', array( | ||
'type' => 'email', | ||
'attributes' => 'minlength="6" autocomplete="off" required="required"', | ||
'label' => __('New email', 'wpu_extranet') | ||
)); | ||
$html .= wpu_extranet__display_field('confirm_new_email', array( | ||
'type' => 'email', | ||
'attributes' => 'minlength="6" autocomplete="off" required="required"', | ||
'label' => __('Confirm new email', 'wpu_extranet') | ||
)); | ||
$html .= '<li class="' . $settings['form_box_submit_classname'] . '">'; | ||
$html .= wp_nonce_field('wpuextranet_changeemail_action', 'wpuextranet_changeemail', true, false); | ||
$html .= '<button class="' . $settings['form_submit_button_classname'] . '" type="submit"><span>' . __('Change email', 'wpu_extranet') . '</span></button>'; | ||
$html .= '</li>'; | ||
$html .= '</ul>'; | ||
$html .= '</form>'; | ||
$html .= '</div>'; | ||
|
||
return $html; | ||
} | ||
|
||
/* ---------------------------------------------------------- | ||
Example code | ||
---------------------------------------------------------- */ | ||
|
||
/* | ||
$html_return_email = wpu_extranet_change_email__action(); | ||
get_header(); | ||
echo '<h1>' . get_the_title() . '</h1>'; | ||
echo wpu_extranet_change_email__form(array( | ||
'before_fields' => $html_return_email | ||
)); | ||
get_footer(); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
Password | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
Lost password | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
Honeypot | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
Pages settings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
defined('ABSPATH') || die; | ||
|
||
/* ---------------------------------------------------------- | ||
User fields | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php /* Silence */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php /* Silence */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return ['domain'=>NULL,'plural-forms'=>NULL,'messages'=>['All fields are required.'=>'Tous les champs sont requis.','Invalid email.'=>'E-mail invalide.','New email is the same as the current email.'=>'Le nouvel e-mail est le même que l’e-mail actuel.','Emails do not match.'=>'Les e-mails ne sont pas identiques.','Email is already in use.'=>'L’e-mail est déjà utilisé.','Email successfully updated!'=>'L’e-mail a été mis à jour avec succès !','Change email'=>'Changer d\'adresse e-mail','Your current email'=>'Votre adresse e-mail actuelle','New email'=>'Nouvel e-mail','Confirm new email'=>'Confirmez votre nouvel e-mail','Current password is incorrect.'=>'Le mot de passe actuel est incorrect.','Passwords do not match.'=>'Les mots de passe ne correspondent pas.','Password is too short, minimum of 6 characters.'=>'Le mot de passe est trop court, minimum de 6 caractères.','Password successfully changed!'=>'Mot de passe changé avec succès !','Error:'=>'Erreur :','Change password'=>'Changer le mot de passe','Enter your current password'=>'Veuillez saisir votre mot de passe actuel','New password'=>'Nouveau mot de passe','Confirm new password'=>'Confirmer le nouveau mot de passe','Profile successfully updated!'=>'Profil mis à jour avec succès!','Infos'=>'Infos','The current avatar is generated by %s.'=>'L’avatar actuel est généré par %s.','Delete this avatar'=>'Supprimer cet avatar','Avatar'=>'Avatar','Username'=>'Nom d\'utilisateur','Email'=>'E-mail','Edit my infos'=>'Modifier mes infos','Check your email for the confirmation link.'=>'Vérifiez vos courriels pour y trouver le lien de confirmation.','Your account could not be found.'=>'Votre compte est introuvable.','Reset password failed.'=>'Échec de la réinitialisation du mot de passe.','Username or Email Address'=>'Identifiant ou adresse email','Get New Password'=>'Obtenir un nouveau mot de passe','Registration confirmation will be emailed to you.'=>'La confirmation d’inscription vous sera envoyée par courriel.','This username already exists.'=>'Ce nom d’utilisateur existe déjà.','This email is already registered.'=>'Cet e-mail est déjà enregistré.','This username contains invalid characters.'=>'Ce nom d’utilisateur contient des caractères non valides.','Registration failed.'=>'Échec de l’inscription.','Password'=>'Mot de passe','Register'=>'S\'inscrire','Log out'=>'Se déconnecter','First name'=>'Prénom','Last name'=>'Nom'],'language'=>'fr_FR','x-generator'=>'Poedit 3.4.4']; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.