Skip to content

Commit

Permalink
Merge branch 'release/4.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
sapayth committed Feb 13, 2024
2 parents 64cde54 + 509108d commit a94e190
Show file tree
Hide file tree
Showing 63 changed files with 7,503 additions and 9,088 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.gitignore export-ignore
.jshintrc export-ignore
.php_cs.dist export-ignore
.php_cs export-ignore
.github export-ignore
Gruntfile.js export-ignore
docs.md export-ignore
package-lock.json export-ignore
Expand Down
8 changes: 4 additions & 4 deletions Lib/Appsero/Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct($client, $name = null, $file = null)
/**
* Don't show the notice
*
* @return \self
* @return self
*/
public function hide_notice()
{
Expand All @@ -77,7 +77,7 @@ public function hide_notice()
/**
* Add plugin data if needed
*
* @return \self
* @return self
*/
public function add_plugin_data()
{
Expand All @@ -91,7 +91,7 @@ public function add_plugin_data()
*
* @param array $data
*
* @return \self
* @return self
*/
public function add_extra($data = [])
{
Expand All @@ -105,7 +105,7 @@ public function add_extra($data = [])
*
* @param string $text
*
* @return \self
* @return self
*/
public function notice($text = '')
{
Expand Down
78 changes: 47 additions & 31 deletions Lib/Gateway/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function prepare_to_send( $data ) {
$billing_amount = empty( $data['price'] ) ? 0 : $data['price'];

if ( isset( $_POST['coupon_id'] ) && ! empty( $_POST['coupon_id'] ) ) {
$billing_amount = WPUF_Coupons::init()->discount( $billing_amount, $_POST['coupon_id'], $data['item_number'] );
$billing_amount = wpuf_pro()->coupon->discount( $billing_amount, $_POST['coupon_id'], $data['item_number'] );

$coupon_id = $_POST['coupon_id'];
} else {
Expand Down Expand Up @@ -342,16 +342,30 @@ public function paypal_success() {
$insert_payment = false;

if ( isset( $_GET['action'] ) && $_GET['action'] == 'wpuf_paypal_success' ) {
WP_User_Frontend::log( 'paypal-payment-info', print_r( $_POST, true ) );
\WP_User_Frontend::log( 'paypal-payment-info', print_r( $_POST, true ) );

$post_id = 0;
$pack_id = 0;

$postdata = $_POST;
$type = $postdata['custom'];
$custom = json_decode( stripcslashes( $postdata['custom'] ) );
$type = isset( $postdata['custom'] ) ? $postdata['custom'] : '';
$custom = json_decode( stripcslashes( $type ) );
$item_number = ! empty( $postdata['item_number'] ) ? $postdata['item_number'] : 0;
$amount = $postdata['mc_gross'];

if ( property_exists( $custom, 'type' ) ) {
switch ( $custom->type ) {
case 'post':
$post_id = $item_number;
break;

case 'pack':
$pack_id = $item_number;
break;
}
}

$amount = isset( $postdata['mc_gross'] ) ? $postdata['mc_gross'] : 0;
$is_recurring = false;
$post_id = $custom->type === 'post' ? $item_number : 0;
$pack_id = $custom->type === 'pack' ? $item_number : 0;
$transaction_id = isset( $postdata['txn_id'] ) ? sanitize_text_field( $postdata['txn_id'] ) : '';

$coupon_id = isset( $custom->coupon_id ) ? $custom->coupon_id : false;
Expand All @@ -361,7 +375,7 @@ public function paypal_success() {
}

if ( isset( $postdata['txn_type'] ) && ( $postdata['txn_type'] == 'subscr_signup' ) ) {
WP_User_Frontend::log( 'paypal-recurring', 'got subscriber with email ' . $postdata['payer_email'] );
\WP_User_Frontend::log( 'paypal-recurring', 'got subscriber with email ' . $postdata['payer_email'] );

return;
}
Expand All @@ -385,14 +399,14 @@ public function paypal_success() {
$is_recurring = true;
$status = 'subscr_payment';

WP_User_Frontend::log( 'paypal-recurring', 'got subscr_payment, should insert of pack_id: ' . $pack_id );
\WP_User_Frontend::log( 'paypal-recurring', 'got subscr_payment, should insert of pack_id: ' . $pack_id );
} else {
$this->subscription_cancel( $custom->user_id );

WP_User_Frontend::log( 'paypal-recurring', 'got subscr_payment. billing validation failed, cancel subscription. user_id: ' . $custom->user_id );
\WP_User_Frontend::log( 'paypal-recurring', 'got subscr_payment. billing validation failed, cancel subscription. user_id: ' . $custom->user_id );
}
} elseif ( isset( $postdata['txn_type'] ) && ( $postdata['txn_type'] == 'web_accept' ) && ( strtolower( $postdata['payment_status'] ) == 'completed' ) ) {
WP_User_Frontend::log( 'paypal', 'got web_accept. type: ' . $custom->type . '. item_number: ' . $item_number );
\WP_User_Frontend::log( 'paypal', 'got web_accept. type: ' . $custom->type . '. item_number: ' . $item_number );

//verify payment
$status = 'web_accept';
Expand Down Expand Up @@ -434,25 +448,25 @@ public function paypal_success() {
} // payment type

$data = [
'user_id' => (int) $custom->user_id,
'status' => strtolower( $postdata['payment_status'] ),
'subtotal' => $postdata['mc_gross'],
'tax' => (float) $custom->tax,
'cost' => (float) $custom->subtotal,
'post_id' => isset( $post_id ) ? $post_id : '',
'pack_id' => isset( $pack_id ) ? $pack_id : '',
'payer_first_name' => $postdata['first_name'],
'payer_last_name' => $postdata['last_name'],
'payer_email' => $postdata['payer_email'],
'user_id' => property_exists( $custom, 'user_id' ) ? ( int) $custom->user_id : 0,
'status' => ! empty( $postdata['payment_status'] ) ? strtolower( $postdata['payment_status'] ) : '',
'subtotal' => ! empty( $postdata['mc_gross'] ) ? $postdata['mc_gross'] : '',
'tax' => property_exists( $custom, 'tax' ) ? (float) $custom->tax : 0,
'cost' => property_exists( $custom, 'subtotal' ) ? (float) $custom->subtotal : 0,
'post_id' => isset( $post_id ) ? $post_id : 0,
'pack_id' => isset( $pack_id ) ? $pack_id : 0,
'payer_first_name' => ! empty( $postdata['first_name'] ) ? $postdata['first_name'] : '',
'payer_last_name' => ! empty( $postdata['last_name'] ) ? $postdata['last_name'] : '',
'payer_email' => ! empty( $postdata['payer_email'] ) ? $postdata['payer_email'] : '',
'payment_type' => 'Paypal',
'payer_address' => isset( $postdata['residence_country'] ) ? $postdata['residence_country'] : null,
'transaction_id' => $transaction_id,
'created' => current_time( 'mysql' ),
];

WP_User_Frontend::log( 'payment', 'inserting payment to database. ' . print_r( $data, true ) );
\WP_User_Frontend::log( 'payment', 'inserting payment to database. ' . print_r( $data, true ) );

_Payment::insert_payment( $data, $transaction_id, $is_recurring );
\WeDevs\Wpuf\Frontend\Payment::insert_payment( $data, $transaction_id, $is_recurring );

if ( $coupon_id ) {
$pre_usage = get_post_meta( $coupon_id, '_coupon_used', true );
Expand All @@ -468,8 +482,10 @@ public function paypal_success() {
update_user_meta( $custom->user_id, '_wpuf_subscription_pack', $umeta );
}

delete_user_meta( $custom->user_id, '_wpuf_user_active' );
delete_user_meta( $custom->user_id, '_wpuf_activation_key' );
if ( is_object( $custom ) && $custom->user_id ) {
delete_user_meta( $custom->user_id, '_wpuf_user_active' );
delete_user_meta( $custom->user_id, '_wpuf_activation_key' );
}
}
}

Expand All @@ -493,7 +509,7 @@ public function handle_cancel_subscription( $data ) {
* @return bool
*/
public function validateIpn() {
WP_User_Frontend::log( 'paypal', 'Checking if PayPal IPN response is valid' );
\WP_User_Frontend::log( 'paypal', 'Checking if PayPal IPN response is valid' );

$this->set_mode();

Expand All @@ -518,20 +534,20 @@ public function validateIpn() {
}
$response = wp_safe_remote_post( $this->gateway_url, $params );

WP_User_Frontend::log( 'paypal', 'IPN Request: ' . print_r( $params, true ) );
WP_User_Frontend::log( 'paypal', 'IPN Response: ' . print_r( $response, true ) );
\WP_User_Frontend::log( 'paypal', 'IPN Request: ' . print_r( $params, true ) );
\WP_User_Frontend::log( 'paypal', 'IPN Response: ' . print_r( $response, true ) );

// check to see if the request was valid
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
WP_User_Frontend::log( 'paypal', 'Received valid response from PayPal' );
\WP_User_Frontend::log( 'paypal', 'Received valid response from PayPal' );

return true;
}

WP_User_Frontend::log( 'paypal', 'Received invalid response from PayPal' );
\WP_User_Frontend::log( 'paypal', 'Received invalid response from PayPal' );

if ( is_wp_error( $response ) ) {
WP_User_Frontend::log( 'paypal', 'Error response: ' . $response->get_error_message() );
\WP_User_Frontend::log( 'paypal', 'Error response: ' . $response->get_error_message() );
}

return false;
Expand Down
5 changes: 3 additions & 2 deletions Lib/invisible_recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*
*/

#[AllowDynamicProperties]
class Invisible_Recaptcha{

private static $_signupUrl = "https://www.google.com/recaptcha/admin";

public function __construct( $site_key, $secret_key ){

if ( $secret_key == null || $secret_key == "" ) {
die("To use reCAPTCHA you must get an API key from <a href='"
. self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
Expand All @@ -32,7 +33,7 @@ public function __construct( $site_key, $secret_key ){
);
}


public function verifyResponse($recaptcha){

$remoteIp = $this->getIPAddress();
Expand Down
8 changes: 5 additions & 3 deletions admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
/**
* WPUF settings
*/

#[AllowDynamicProperties]
class WPUF_Admin_Settings {

/**
* Settings API
*
* @var \WeDevs_Settings_API
* @var WeDevs_Settings_API
*/
private $settings_api;

/**
* Static instance of this class
*
* @var \self
* @var self
*/
private static $_instance;

/**
* Public instance of this class
*
* @var \self
* @var self
*/
public $subscribers_list_table_obj;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

<div v-if="'logged_in' === selected" class="condiotional-logic-container">

<?php $roles = get_editable_roles(); ?>
<?php use WeDevs\Wpuf\Admin\Subscription;

$roles = get_editable_roles(); ?>

<ul>
<?php
Expand All @@ -36,7 +38,7 @@
<?php

if ( class_exists( 'WPUF_Subscription' ) ) {
$subscriptions = (new \WeDevs\Wpuf\Admin\Subscription())->get_subscriptions();
$subscriptions = wpuf()->subscription->get_subscriptions();

if ( $subscriptions ) {
foreach ( $subscriptions as $pack ) {
Expand Down
26 changes: 26 additions & 0 deletions admin/html/whats-new.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
<?php
$changelog = [
[
'version' => 'Version 4.0.6',
'released' => '2024-02-13',
'changes' => [
[
'title' => __( 'Update deprecated uses for PHP versions and latest WordPress', 'wp-user-frontend' ),
'type' => 'Enhance',
],
[
'title' => __( 'Eye icon inside password field', 'wp-user-frontend' ),
'type' => 'Enhance',
],
[
'title' => __( 'Error after PayPal payment', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Reset password not working', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Subscription posting restriction not working', 'wp-user-frontend' ),
'type' => 'Fix',
],
],
],
[
'version' => 'Version 4.0.5',
'released' => '2024-01-31',
Expand Down
6 changes: 6 additions & 0 deletions assets/css/frontend-forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -1833,3 +1833,9 @@ body .wpuf-attachment-upload-filelist + .moxie-shim {
.iti--allow-dropdown input[type="text"] {
padding-left: 52px !important;
}
img.wpuf-eye {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%) translateX(-6%);
}
3 changes: 3 additions & 0 deletions assets/images/eye-close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions assets/js-templates/form-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ class="option-chooser-radio"

<div v-if="'logged_in' === selected" class="condiotional-logic-container">

<?php $roles = get_editable_roles(); ?>
<?php use WeDevs\Wpuf\Admin\Subscription;

$roles = get_editable_roles(); ?>

<ul>
<?php
Expand All @@ -396,7 +398,7 @@ class="option-chooser-radio"
<?php

if ( class_exists( 'WPUF_Subscription' ) ) {
$subscriptions = (new \WeDevs\Wpuf\Admin\Subscription())->get_subscriptions();
$subscriptions = wpuf()->subscription->get_subscriptions();

if ( $subscriptions ) {
foreach ( $subscriptions as $pack ) {
Expand Down
19 changes: 17 additions & 2 deletions assets/js/frontend-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@

if ( typeof res.type !== 'undefined' && res.type === 'login' ) {

if ( confirm(res.error) ) {
if ( confirm(res.data.error) ) {
window.location = res.redirect_to;
} else {
submitButton.removeAttr('disabled');
Expand All @@ -482,7 +482,7 @@
}

Swal.fire({
html: res.error,
html: res.data.error,
icon: 'warning',
showCancelButton: false,
confirmButtonColor: '#d54e21',
Expand Down Expand Up @@ -1492,4 +1492,19 @@
// Set name attribute for google map search field
$(".wpuf-form-add #wpuf-map-add-location").attr("name", "find_address");
});

$(function($) {
// eye icon for password field
$(document).on('click', '.wpuf-eye', function () {
const input = $( this ).siblings( 'input' );

if ( input.attr("type") === "password" ) {
input.attr( "type", "text" );
$( this ).attr( "src", wpuf_frontend.asset_url + '/images/eye-close.svg' );
} else {
input.attr( "type", "password" );
$( this ).attr( "src", wpuf_frontend.asset_url + '/images/eye.svg' );
}
});
});
})(jQuery, window);
2 changes: 1 addition & 1 deletion assets/js/frontend-form.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/less/frontend-forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -2121,3 +2121,10 @@ ul.wpuf-form{
.iti--allow-dropdown input[type="text"] {
padding-left: 52px !important;
}

img.wpuf-eye {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%) translateX(-6%);
}
Loading

0 comments on commit a94e190

Please sign in to comment.