created xtxpatch git repo
This commit is contained in:
50
html/admin_menu.html
Normal file
50
html/admin_menu.html
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<style>
|
||||||
|
h1 {
|
||||||
|
margin-left: 15px;
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
margin: 15px;
|
||||||
|
border: 1px solid black;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
form > div {
|
||||||
|
margin: 20px 0px;
|
||||||
|
}
|
||||||
|
.define_paypal_credentials_cipf input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
form .vertical_wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
form textarea {
|
||||||
|
resize: vertical;
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>email a la creation de compte</h1>
|
||||||
|
<?php echo Plgntls_xtx::open_form_option($option_register_email_name); ?>
|
||||||
|
<div class="define_email_registration vertical_wrapper">
|
||||||
|
<label for="define_email_registration_cipf">email : </label>
|
||||||
|
<textarea id="define_email_registration_cipf" name="email"><?php echo $option_register_email_value['email']; ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
-->
|
||||||
|
<div class="send_email">
|
||||||
|
<input type="checkbox" id="send_email_prof_cipf" name="is_email_prof" <?php if ($option_register_email_value['is_email_prof'] === true) {echo 'checked';} ?> />
|
||||||
|
<label for="send_email_prof_cipf">envoyer un email à l'inscription des profs ?</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="send_email">
|
||||||
|
<input type="checkbox" id="send_email_partner_cipf" name="is_email_partner" <?php if ($option_register_email_value['is_email_partner'] === true) {echo 'checked';} ?> />
|
||||||
|
<label for="send_email_partner_cipf">envoyer un email à l'inscription des partenaires ?</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" value="send"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
1369
php/classes/plgntls_class.php
Normal file
1369
php/classes/plgntls_class.php
Normal file
File diff suppressed because it is too large
Load Diff
36
php/classes/xtxpatch_class.php
Normal file
36
php/classes/xtxpatch_class.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
namespace XTXPATCH;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* it means someone outside wp is accessing the file, in this case kill it.
|
||||||
|
*/
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
die('You can not access this file!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Xtxpatch {
|
||||||
|
const ROLE_PROF = 'professeur__professeure';
|
||||||
|
const ROLE_PARTNER = 'partenaire';
|
||||||
|
|
||||||
|
const OPTION_REGISTER_EMAIL = [
|
||||||
|
'_name'=>'define_email_at_register_xtxpatch',
|
||||||
|
'_callback'=>__NAMESPACE__.'\define_register_email',
|
||||||
|
'_default'=>[
|
||||||
|
'email'=>
|
||||||
|
'Bonjour,
|
||||||
|
Vous venez de créer un compte sur le site carteprof.org avec l’identifiant : $$user_login$$
|
||||||
|
La FIPF',
|
||||||
|
'is_email_prof'=>true,
|
||||||
|
'is_email_partner'=>true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
137
php/menu/admin_menu.php
Normal file
137
php/menu/admin_menu.php
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
namespace XTXPATCH;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* it means someone outside wp is accessing the file, in this case kill it.
|
||||||
|
*/
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
die('You can not access this file!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* creates the plugin menu
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function add_plugin_menu() {
|
||||||
|
\Plgntls_xtx::add_menu(__NAMESPACE__.'\menu_content');
|
||||||
|
}
|
||||||
|
add_action('admin_menu', __NAMESPACE__.'\add_plugin_menu');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the construction of the admin menu page
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function menu_content() {
|
||||||
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
||||||
|
|
||||||
|
$option_register_email_name = $option_register_email['_name'];
|
||||||
|
$option_register_email_value = \Plgntls_xtx::get_option_safe($option_register_email);
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
include(\Plgntls_xtx::root_path() . 'html/admin_menu.html');
|
||||||
|
echo ob_get_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function define_register_email($request, $option_name, $option_value, $option_default) {
|
||||||
|
/*
|
||||||
|
* email
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$email = '';
|
||||||
|
if (isset($request['email'])) {
|
||||||
|
$email = $request['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* is email ?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$is_email_prof = false;
|
||||||
|
if (isset($request['is_email_prof']) && $request['is_email_prof'] === 'on') {
|
||||||
|
$is_email_prof = true;
|
||||||
|
}
|
||||||
|
$is_email_partner = false;
|
||||||
|
if (isset($request['is_email_partner']) && $request['is_email_partner'] === 'on') {
|
||||||
|
$is_email_partner = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* update the option with new values
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$option_data = array(
|
||||||
|
'email' => $email,
|
||||||
|
'is_email_prof' => $is_email_prof,
|
||||||
|
'is_email_partner' => $is_email_partner,
|
||||||
|
);
|
||||||
|
\Plgntls_xtx::update_option_safe($option_name, $option_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* use this filter to check if the role should allow registration email
|
||||||
|
* ../../../wordpress_docker/volumes/wp_volume/wp-includes/pluggable.php
|
||||||
|
* 2210 : $send_notification_to_user = apply_filters( 'wp_send_new_user_notification_to_user', true, $user );
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function send_registration_email($send, $user) {
|
||||||
|
$role_partner = Xtxpatch::ROLE_PARTNER;
|
||||||
|
$role_prof = Xtxpatch::ROLE_PROF;
|
||||||
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
||||||
|
|
||||||
|
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
|
||||||
|
|
||||||
|
if (user_can($user, $role_prof)) {
|
||||||
|
$send = $email_option['is_email_prof'];
|
||||||
|
}
|
||||||
|
else if (user_can($user, $role_partner)) {
|
||||||
|
$send = $email_option['is_email_partner'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $send;
|
||||||
|
}
|
||||||
|
add_filter( 'wp_send_new_user_notification_to_user', __NAMESPACE__.'\send_registration_email', 10, 2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* use this filter to modify the message of the notification email
|
||||||
|
* you can use the specials custer expansions as $$<field>$$
|
||||||
|
* ../../../wordpress_docker/volumes/wp_volume/wp-content/plugins/easy-login-woocommerce/includes/class-xoo-el-form-handler.php
|
||||||
|
* 24 : add_filter( 'wp_new_user_notification_email', array( __CLASS__, 'newuser_notification_email' ), 20, 3 );
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function filter_regitration_email($wp_new_user_notification_email, $user, $blogname) {
|
||||||
|
$option_register_email = Xtxpatch::OPTION_REGISTER_EMAIL;
|
||||||
|
|
||||||
|
$email_option = \Plgntls_xtx::get_option_safe($option_register_email['_name']);
|
||||||
|
$wp_new_user_notification_email['message'] = $email_option['email'];
|
||||||
|
return $wp_new_user_notification_email;
|
||||||
|
}
|
||||||
|
add_filter('wp_new_user_notification_email', __NAMESPACE__.'\filter_regitration_email', 21, 3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
29
xtxpatch.php
Normal file
29
xtxpatch.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: hggg_xtxpatch
|
||||||
|
Plugin URI:
|
||||||
|
Description: some patchs for the xootix login/registration plugin
|
||||||
|
Author: hugogogo
|
||||||
|
Version: 0.1.2.1
|
||||||
|
Author URI:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* it means someone outside wp is accessing the file, in this case kill it.
|
||||||
|
*/
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
die('You can not access this file!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include_once(plugin_dir_path(__FILE__) . '/php/classes/plgntls_class.php');
|
||||||
|
|
||||||
|
include_once(Plgntls_xtx::root_path() . 'php/classes/xtxpatch_class.php');
|
||||||
|
|
||||||
|
include_once(Plgntls_xtx::root_path() . 'php/menu/admin_menu.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user