Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into fix/conflict_wit…
Browse files Browse the repository at this point in the history
…h_wc_stripe_gateway
  • Loading branch information
sapayth committed Apr 3, 2024
2 parents b3247ce + e381ba0 commit 00cd955
Showing 8 changed files with 111 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/js/frontend-form.js
Original file line number Diff line number Diff line change
@@ -662,7 +662,7 @@
}

if ( hasRepeat === 'yes' ) {
var repeatItem = $('[data-type="confirm_password"]').eq(0);
var repeatItem = $(item).closest('.wpuf-form').find('[data-type="confirm_password"]').eq(0);

if ( repeatItem.val() !== val ) {
errors.push({
2 changes: 1 addition & 1 deletion assets/js/frontend-form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/Admin/Forms/Field_Manager.php
Original file line number Diff line number Diff line change
@@ -268,7 +268,7 @@ public function check_field_visibility( &$form_field ) {
}
}
if ( $visibility_selected == 'subscribed_users' && is_user_logged_in() ) {
$user_pack = Subscription::init()->get_user_pack( get_current_user_id() );
$user_pack = ( new Subscription() )->get_user_pack( get_current_user_id() );
if ( empty( $visibility_choices ) && ! empty( $user_pack ) ) {
$show_field = true;
} else if ( ! empty( $user_pack ) && ! empty( $visibility_choices ) ) {
46 changes: 46 additions & 0 deletions includes/Fields/Field_Contract.php
Original file line number Diff line number Diff line change
@@ -905,4 +905,50 @@ public function check_content_restriction_func( $content_limit, $rich_text, $fie
</script>
<?php
}

/**
* Enqueue file upload scripts
*
* @since WPUF_SINCE
*
* @return void
*/
public function enqueue_file_upload_scripts() {
wp_enqueue_style( 'wpuf-sweetalert2' );

wp_enqueue_script( 'wpuf-sweetalert2' );
wp_enqueue_script( 'wpuf-upload' );

wp_localize_script(
'wpuf-upload', 'wpuf_upload', [
'confirmMsg' => __( 'Are you sure?', 'wp-user-frontend' ),
'delete_it' => __( 'Yes, delete it', 'wp-user-frontend' ),
'cancel_it' => __( 'No, cancel it', 'wp-user-frontend' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpuf_nonce' ),
'plupload' => [
'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce(
'wpuf-upload-nonce'
),
'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
'filters' => [
[
'title' => __( 'Allowed Files', 'wp-user-frontend' ),
'extensions' => '*',
],
],
'multipart' => true,
'urlstream_upload' => true,
'warning' => __( 'Maximum number of files reached!', 'wp-user-frontend' ),
'size_error' => __(
'The file you have uploaded exceeds the file size limit. Please try again.',
'wp-user-frontend'
),
'type_error' => __(
'You have uploaded an incorrect file type. Please try again.', 'wp-user-frontend'
),
],
]
);
}
}
2 changes: 2 additions & 0 deletions includes/Fields/Form_Field_Featured_Image.php
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ public function __construct() {
* @return void
*/
public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) {
$this->enqueue_file_upload_scripts();

$has_featured_image = false;

$unique_id = sprintf( '%s-%d', $field_settings['name'], $form_id );
2 changes: 2 additions & 0 deletions includes/Fields/Form_Field_Image.php
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ public function __construct() {
* @return void
*/
public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) {
$this->enqueue_file_upload_scripts();

$has_images = false;

if ( isset( $post_id ) && $post_id !== 0 ) {
63 changes: 56 additions & 7 deletions includes/Free/Simple_Login.php
Original file line number Diff line number Diff line change
@@ -473,15 +473,64 @@ public function process_login() {
return;
}

if ( isset( $_POST['g-recaptcha-response'] ) ) {
if ( empty( $_POST['g-recaptcha-response'] ) ) {
$this->login_errors[] = __( 'Empty reCaptcha Field', 'wp-user-frontend' );
return;
if ( empty( $_POST['g-recaptcha-response'] ) ) {
$this->login_errors[] = __( 'Empty reCaptcha Field', 'wp-user-frontend' );
return;
} else {
$no_captcha = 1;
$invisible_captcha = 0;
Render_Form::init()->validate_re_captcha( $no_captcha, $invisible_captcha );
}

$log = isset( $_POST['log'] ) ? esc_attr( wp_unslash( $_POST['log'] ) ) : '';
$pwd = isset( $_POST['pwd'] ) ? trim( $_POST['pwd'] ) : '';
// $g_recaptcha_response = isset( $_POST['g-recaptcha-response'] ) ? sanitize_text_field( wp_unslash( $_POST['g-recaptcha-response'] ) ) : '';

$validation_error = new WP_Error();
$validation_error = apply_filters( 'wpuf_process_login_errors', $validation_error, $log, $pwd );

if ( $validation_error->get_error_code() ) {
$this->login_errors[] = $validation_error->get_error_message();

return;
}

if ( empty( $log ) ) {
$this->login_errors[] = __( 'Username is required.', 'wp-user-frontend' );

return;
}

if ( empty( $pwd ) ) {
$this->login_errors[] = __( 'Password is required.', 'wp-user-frontend' );

return;
}

if ( is_email( $log ) && apply_filters( 'wpuf_get_username_from_email', true ) ) {
$user = get_user_by( 'email', $log );

if ( isset( $user->user_login ) ) {
$creds['user_login'] = $user->user_login;
} else {
$no_captcha = 1;
$invisible_captcha = 0;
Render_Form::init()->validate_re_captcha( $no_captcha, $invisible_captcha );
$this->login_errors[] = '<strong>' . __( 'Error', 'wp-user-frontend' ) . ':</strong> ' . __( 'A user could not be found with this email address.', 'wp-user-frontend' );

return;
}

$wpuf_user_status = get_user_meta( $user->ID, 'wpuf_user_status', true );

if ( 'approved' !== $wpuf_user_status ) {
$message = __( 'You can\'t login until an administrator manually approve your account.', 'wp-user-frontend' );

$this->login_errors[] = $message;

return;
}
} else {
$no_captcha = 1;
$invisible_captcha = 0;
Render_Form::init()->validate_re_captcha( $no_captcha, $invisible_captcha );
}

if ( is_email( $log ) && apply_filters( 'wpuf_get_username_from_email', true ) ) {
3 changes: 2 additions & 1 deletion includes/Traits/TaxableTrait.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
use WC_Countries;
use WC_Customer;
use WeDevs\Wpuf\Admin\Forms\Form;
use WeDevs\Wpuf\Admin\Subscription;
use WeDevs\Wpuf\Data\Country_State;

trait TaxableTrait {
@@ -440,7 +441,7 @@ function wpuf_calculate_taxes( $post_data ) {

if ( isset( $post_data['type'] ) && isset( $post_data['id'] ) ) {
if ( 'pack' === $post_data['type'] ) {
$pack = Subscription::init()->get_subscription( $post_data['id'] );
$pack = ( new Subscription() )->get_subscription( $post_data['id'] );
$billing_amount = $pack->meta_value['billing_amount'];
$user_id = $current_user->ID;
} elseif ( 'post' === $post_data['type'] ) {

0 comments on commit 00cd955

Please sign in to comment.