added message payments in admin menu

This commit is contained in:
asus
2024-03-27 17:18:14 +01:00
parent a0018c903b
commit dd0d4dfbeb
13 changed files with 229 additions and 34 deletions

View File

@@ -16,7 +16,6 @@ function add_plugin_content_CIPF() {
/*
* paypal
*
$option_paypal = PLGNTLS_class::OPTION_PAYPAL;
*/
$admin_post_paypal = PLGNTLS_class::ADMIN_POST_PAYPAL;
$nonce_paypal = PLGNTLS_class::ADMIN_MENU_NONCE_PAYPAL;
@@ -25,12 +24,19 @@ function add_plugin_content_CIPF() {
/*
* registration email
*
$option_email = PLGNTLS_class::OPTION_EMAIL;
*/
$admin_post_email_registration = PLGNTLS_class::ADMIN_POST_EMAIL_REGISTRATION;
$nonce_email = PLGNTLS_class::ADMIN_MENU_NONCE_EMAIL_REGISTRATION;
$email_registration = get_email_registration_option_CIPF();
/*
* registration email
*
*/
$admin_post_payment_messages = PLGNTLS_class::ADMIN_POST_PAYMENT_MESSAGES;
$nonce_payment_messages = PLGNTLS_class::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
$payment_messages = get_payment_messages_option_CIPF();
ob_start();
include(PLGNTLS_class::root_path() . '/html/menu/cipf_menu.html');
$html = ob_get_clean();

View File

@@ -0,0 +1,81 @@
<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* use this hook 'admin_post_{$action}' to receive a form post
* https://developer.wordpress.org/reference/hooks/admin_post_action/
*
* add the url to the action atrtibute of form, and the value of the action in an hidden input
* <form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
* <input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
*
*/
function change_payment_messages_CIPF() {
PLGNTLS_class::debug_infos();
$nonce_payment_messages = PLGNTLS_class::ADMIN_MENU_NONCE_PAYMENT_MESSAGES;
if (!isset($_POST[$nonce_payment_messages['_name']])) {
redirect_menu_referer_CIPF($_POST);
exit;
}
if (!wp_verify_nonce($_POST[$nonce_payment_messages['_name']], $nonce_payment_messages['_action'])) {
redirect_menu_referer_CIPF($_POST);
exit;
}
// do actions here
update_payment_messages_option_CIPF($_POST);
redirect_menu_referer_CIPF($_POST);
}
add_action('admin_post_'.PLGNTLS_class::ADMIN_POST_PAYMENT_MESSAGES, 'change_payment_messages_CIPF');
function update_payment_messages_option_CIPF($post) {
PLGNTLS_class::debug_infos();
error_log("post: " . json_encode($post));
/*
* success
* failure
*
*/
$success = '';
$failure = '';
if (!isset($post['message_success'])) {
return;
}
if (!isset($post['message_failure'])) {
return;
}
$success = $post['message_success'];
$failure = $post['message_failure'];
/*
* update the option with new values
*
*/
set_payment_messages_option_CIPF($success, $failure);
}
?>