added message payments in admin menu
This commit is contained in:
@@ -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();
|
||||
|
||||
81
plugins/cipf_plugin/php/admin_menu/post_payment_messages.php
Normal file
81
plugins/cipf_plugin/php/admin_menu/post_payment_messages.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -58,7 +58,10 @@ add_filter('wp_new_user_notification_email', 'filter_regitration_email_CIPF', 21
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* OPTIONS
|
||||
*
|
||||
*/
|
||||
|
||||
function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
@@ -73,14 +76,10 @@ function set_email_registration_CIPF($email, $is_email_prof, $is_email_partner)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function get_email_registration_option_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_email = PLGNTLS_class::OPTION_EMAIL;
|
||||
|
||||
delete_option($option_email['_name']);
|
||||
$email_option_serialized = get_option($option_email['_name']);
|
||||
if (false === $email_option_serialized) {
|
||||
add_option($option_email['_name'], serialize($option_email['_default']), '', 'no');
|
||||
|
||||
@@ -10,6 +10,7 @@ if (!defined('ABSPATH')) {
|
||||
|
||||
|
||||
|
||||
|
||||
function set_paypal_options_CIPF($is_sandbox, $client_id, $client_secret) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_paypal = PLGNTLS_class::OPTION_PAYPAL;
|
||||
@@ -72,4 +73,46 @@ function get_paypal_api_base_url_CIPF() {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* OPTIONS MESSAGES PAIMENT
|
||||
*
|
||||
*/
|
||||
|
||||
function set_payment_messages_option_CIPF($success, $failure) {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_payment = PLGNTLS_class::OPTION_PAYMENT;
|
||||
|
||||
$option_data = array();
|
||||
$option_data['success'] = $success;
|
||||
$option_data['failure'] = $failure;
|
||||
|
||||
update_option($option_payment['_name'], serialize($option_data), '', 'no');
|
||||
}
|
||||
|
||||
function get_payment_messages_option_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$option_payment = PLGNTLS_class::OPTION_PAYMENT;
|
||||
|
||||
$payment_option_serialized = get_option($option_payment['_name']);
|
||||
if (false === $payment_option_serialized) {
|
||||
add_option($option_payment['_name'], serialize($option_payment['_default']), '', 'no');
|
||||
$payment_option_serialized = get_option($option_payment['_name']);
|
||||
}
|
||||
|
||||
return unserialize($payment_option_serialized);
|
||||
}
|
||||
|
||||
function get_payment_message_success_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$payment_option = get_payment_messages_option_CIPF();
|
||||
return $payment_option['success'];
|
||||
}
|
||||
|
||||
function get_payment_message_failure_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$payment_option = get_payment_messages_option_CIPF();
|
||||
return $payment_option['failure'];
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -13,6 +13,9 @@ if (!defined('ABSPATH')) {
|
||||
// diff routes and endpoints : https://stackoverflow.com/q/56075017/9497573
|
||||
function routes_endpoints_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
if (is_admin()) {
|
||||
return;
|
||||
}
|
||||
$base_rest_route = PLGNTLS_class::URL_BASE_REST_ROUTE;
|
||||
register_rest_route($base_rest_route, '/orders', array(
|
||||
'methods' => 'POST',
|
||||
|
||||
@@ -20,8 +20,8 @@ function paypal_shortcode_content_CIPF() {
|
||||
$slug_paypal_redirection_success = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_SUCCESS;
|
||||
$slug_paypal_redirection_failure = PLGNTLS_class::SLUG_PAYPAL_REDIRECTION_FAILURE;
|
||||
$paypal_client_id = get_paypal_client_id_CIPF();
|
||||
$paypal_message_success = PLGNTLS_class::PAYPAL_MESSAGE_SUCCESS;
|
||||
$paypal_message_failure = PLGNTLS_class::PAYPAL_MESSAGE_FAILURE;
|
||||
$paypal_message_success = get_payment_message_success_CIPF();
|
||||
$paypal_message_failure = get_payment_message_failure_CIPF();
|
||||
|
||||
// if (!can_pay_now_CIPF())
|
||||
// return no_payment_CIPF();
|
||||
|
||||
Reference in New Issue
Block a user