wip prof check page now handle the success message on paiement

This commit is contained in:
asus
2024-03-07 21:34:48 +01:00
parent 5e28bf3059
commit f870f77a2c
9 changed files with 80 additions and 54 deletions

View File

@@ -92,8 +92,6 @@ add_filter('df_notification_body', 'filter_email_fb_CIPF', 10, 2); // the admini
* or event that a different user has already logged in
*/
function filter_email_wp_CIPF($args) {
error_log("in filter_email_wp_CIPF");
// pattern : anything surrounded by '$$', ex : $$value$$
$pattern = '/\$\$(.*?)\$\$/';

View File

@@ -25,7 +25,6 @@ if (!defined('ABSPATH')) {
* Default false.
*/
function wp_image_editor( $post_id, $msg = false ) {
error_log("------1");
$nonce = wp_create_nonce( "image_editor-$post_id" );
$meta = wp_get_attachment_metadata( $post_id );
@@ -39,7 +38,6 @@ error_log("------1");
die( __( 'Image data does not exist. Please re-upload the image.' ) );
}
error_log("------2");
$sizer = $big > 600 ? 600 / $big : 1;
@@ -67,7 +65,6 @@ error_log("------2");
*/
$edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
error_log("------3");
?>
<div class="imgedit-wrap wp-clearfix">
@@ -291,7 +288,6 @@ error_log("------3");
<?php
if ( $edit_thumbnails_separately && $thumb && $sub_sizes ) {
$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
error_log("------4");
?>
@@ -346,7 +342,6 @@ error_log("------4");
<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e( "There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor." ); ?></div>
</div>
<?php
error_log("------5");
}
@@ -361,7 +356,6 @@ error_log("------5");
* @return bool True on success, false on failure.
*/
function wp_stream_image( $image, $mime_type, $attachment_id ) {
error_log("------1");
if ( $image instanceof WP_Image_Editor ) {
@@ -443,7 +437,6 @@ error_log("------1");
* }
*/
function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
error_log("------1");
if ( $image instanceof WP_Image_Editor ) {
@@ -534,7 +527,6 @@ error_log("------1");
* @return float|int Image preview ratio.
*/
function _image_get_preview_ratio( $w, $h ) {
error_log("------1");
$max = max( $w, $h );
return $max > 600 ? ( 600 / $max ) : 1;
@@ -553,7 +545,6 @@ error_log("------1");
* @return resource|GdImage|false GD image resource or GdImage instance, false otherwise.
*/
function _rotate_image_resource( $img, $angle ) {
error_log("------1");
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' );
@@ -583,7 +574,6 @@ error_log("------1");
* @return resource|GdImage (maybe) flipped image resource or GdImage instance.
*/
function _flip_image_resource( $img, $horz, $vert ) {
error_log("------1");
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' );
@@ -620,7 +610,6 @@ error_log("------1");
* @return resource|GdImage (maybe) cropped image resource or GdImage instance.
*/
function _crop_image_resource( $img, $x, $y, $w, $h ) {
error_log("------1");
$dst = wp_imagecreatetruecolor( $w, $h );
@@ -644,7 +633,6 @@ error_log("------1");
* @return WP_Image_Editor WP_Image_Editor instance with changes applied.
*/
function image_edit_apply_changes( $image, $changes ) {
error_log("------1");
if ( is_gd_image( $image ) ) {
/* translators: 1: $image, 2: WP_Image_Editor */
@@ -781,7 +769,6 @@ error_log("------1");
* @return bool True on success, false on failure.
*/
function stream_preview_image( $post_id ) {
error_log("------1");
$post = get_post( $post_id );
@@ -823,7 +810,6 @@ error_log("------1");
* @return stdClass Image restoration message object.
*/
function wp_restore_image( $post_id ) {
error_log("------1");
$meta = wp_get_attachment_metadata( $post_id );
$file = get_attached_file( $post_id );
@@ -919,7 +905,6 @@ error_log("------1");
* @return stdClass
*/
function wp_save_image( $post_id ) {
error_log("------1");
$_wp_additional_image_sizes = wp_get_additional_image_sizes();

View File

@@ -21,31 +21,6 @@ include_once(PLGNTLS_class::get_path() . '/php/paypal/routes.php');
/*
function check_paypal_request()
{
error_log("----");
if (is_page('test_paypal_payment'))
error_log("on test_paypal_payment");
else if (is_page('test_paypal_ok'))
error_log("on test_paypal_ok");
else if (is_page('test_paypal_infos'))
error_log("on test_paypal_infos");
else
return;
error_log("_GET");
error_log(json_encode($_GET));
error_log("_POST");
error_log(json_encode($_POST));
// error_log("_COOKIE");
// error_log(json_encode($_COOKIE));
}
add_action('template_redirect', 'check_paypal_request');
*/
?>

View File

@@ -26,7 +26,6 @@ function handle_orders_capture_request_FIPF($request) {
return new WP_REST_Response($json_response, $http_status_code);
}
catch (Exception $e) {
error_log('Failed to capture order: ' . $e->getMessage());
return new WP_REST_Response(array('error' => 'Failed to capture order.'), 500);
}
}

View File

@@ -48,10 +48,22 @@ function update_user_payment_FIPF($message, $step) {
// add a schedule event to delete this order_id
schedule_delete_orderid_FIPF($user_id, $order_id);
/*
* create a meta field to check states of payements on prof author page :
* - 'started' -> payement started | at order creation (if seen on author page, it means failure)
* - 'success' -> success payement | at order success (on author page, it means success, then empty it)
* - '' -> no message to output | on author page (after set to empty on author page)
*
*/
delete_user_meta($user_id, 'fipf_payement_status');
add_user_meta($user_id, 'fipf_payement_status', 'started');
// if transaction is COMPLETED, then delete order_id and update user
if ($status === 'COMPLETED') {
// find the user containing the order_id and delete this order_id
$user_id_to_update = delete_order_id_on_success_FIPF($user_id, $order_id);
// change payement status to success
update_user_meta($user_id_to_update, 'fipf_payement_status', 'success');
// proceed to validate payment for user
validate_payment_for_user_FIPF($user_id_to_update, $order_id);
}
@@ -132,14 +144,14 @@ function validate_payment_for_user_FIPF($user_id, $order_id) {
* update date limit validity to add 1 year
*
*/
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));;
$date_plus_one_year = $current_date_limit->add(date_interval_create_from_date_string('+'.$card_duration));
update_field($acf_card_expiration, $date_plus_one_year->format($acf_date_format), $acf_id);
/*
* change user profil to active
*
*/
update_field($prof_is_activ, 'Active', $acf_id)
update_field($prof_is_activ, 'Actif', $acf_id);
}
@@ -169,7 +181,6 @@ function schedule_delete_orderid_FIPF($user_id, $order_id)
*/
function delete_order_id_later_FIPF($user_id, $order_id)
{
error_log("delete order_id[$order_id] from user_id[$user_id]");
delete_user_meta($user_id, 'fipf_order_id', $order_id);
}
add_action('orderid_deletion_event_FIPF', 'delete_order_id_later_FIPF', 5, 2);

View File

@@ -50,6 +50,54 @@ function handle_prof_is_activ_CIPF($author_id) {
}
/*
* check meta field 'fipf_payement_status'
* if field value is 'success'
* - hide block 'failure'
* - and update field to '', so it will not show next time
* if field value is 'started'
* - hide bloc success
* (we assume it means the order didn't go well)
* (it does not really makes sens, but ok for the moment)
* if field value is ''
* - hide both 'success' and 'failure' blocs
*
* .fipf_prof_paiement_message -> on row, added display none in page css
* #fipf_prof_paiement_reussi -> on row
* #fipf_prof_paiement_echoue -> on row
*
*/
function show_prof_paiement_messages_CIPF($user_id) {
/*
* if prof is inactive, do nothing more
*
*/
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
$acf_id = 'user_' . $user_id;
$is_activ = get_field($acf_prof_is_activ, $acf_id);
if (is_null($is_activ) || empty($is_activ))
return;
if ($is_activ === 'Inactif')
return;
$fipf_prof_payement = new PLGNTLS_class();
$payement_status2 = get_user_meta($user_id, 'fipf_payement_status');
$payement_status = get_user_meta($user_id, 'fipf_payement_status', true);
if ($payement_status === 'success') {
$fipf_prof_payement->add_to_front(array(
array( 'css' => '#fipf_prof_paiement_reussi {display: block;}' )
));
}
else if ($payement_status === 'started') {
$fipf_prof_payement->add_to_front(array(
array( 'css' => '#fipf_prof_paiement_echoue {display: block;}' )
));
}
update_user_meta($user_id, 'fipf_payement_status', '');
}
/*
* series of check to do before printing a prof author page
@@ -64,6 +112,9 @@ function check_prof_page_CIPF() {
$author_id = get_queried_object_id();
handle_prof_is_activ_CIPF($author_id);
show_prof_paiement_messages_CIPF($author_id);
}
add_action('template_redirect', 'check_prof_page_CIPF', 11);

View File

@@ -14,9 +14,6 @@ if (!defined('ABSPATH')) {
*/
function add_partenaires_PLGNTLS($customer_data){
$current_url = $_SERVER['HTTP_REFERER']; // not reliable to use referer, TODO: find another solution
error_log("---");
error_log("uri:");
error_log($_SERVER['REQUEST_URI']);
$path_brut = parse_url($current_url, PHP_URL_PATH);
$path = trim($path_brut, '/');
if ($path === 'creation-du-compte-partenaire')

View File

@@ -304,16 +304,26 @@ class PLGNTLS_class
}
private function add_inline_script($src) {
$handle = $src->depends;
if ($handle === null)
if ($handle === null || empty($handle))
$handle = $this->_first_script;
wp_add_inline_script($src->depends, $src->src, 'before');
if ($handle === null || empty($handle)) {
global $wp_scripts;
$script_queue = $wp_scripts->queue;
$handle = array_pop($script_queue);
}
wp_add_inline_script($handle, $src->src, 'before');
}
private function add_inline_style($src) {
error_log("inside add_inline_style");
$handle = $src->depends;
if ($handle === null)
if ($handle === null || empty($handle))
$handle = $this->_first_style;
wp_add_inline_style($src->depends, $src->src);
if ($handle === null || empty($handle)) {
global $wp_styles;
$style_queue = $wp_styles->queue;
$handle = array_pop($style_queue);
}
wp_add_inline_style($handle, $src->src);
}

Submodule private updated: f8fbd0231d...0243fd7e20