Skip to content

Commit

Permalink
⚡ BUILD: package build
Browse files Browse the repository at this point in the history
  • Loading branch information
mahafuz committed May 2, 2022
2 parents e06d935 + 636eaab commit b78b3fb
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 3,025 deletions.
20 changes: 19 additions & 1 deletion assets/css/pqfw-frontend.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,22 @@ a.button.pqfw-button.pqfw-add-to-quotation {
transition: all 0.3s ease-in-out;
}

a.pqfw-view-quotation-cart {font-size: 14px;display: block;text-decoration: underline;}
a.pqfw-view-quotation-cart {font-size: 14px;display: block;text-decoration: underline;}

li.pqfw-privacy-policy {
margin-left: 0;
margin-bottom: 10px;
padding: 0 10px;
}

.pqfw-privacy-policy-inner p {
margin: 0 0 10px;
}

.pqfw-privacy-policy-inner {
font-size: 16px;
}

.pqfw-privacy-policy-inner label {
margin-bottom: 0 !important;
}
9 changes: 9 additions & 0 deletions assets/js/pqfw-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ jQuery(function ( $ ) {
}
});

if ( ! errors ) {
var privacyPolicy = $( '#pqfw_privacy_policy_checkbox' );
if ( privacyPolicy.length && ! privacyPolicy.prop('checked') ) {
errors = true;
privacyPolicy.parents( '.pqfw-privacy-policy' ).addClass('hasError');
alert( 'Please accept privacy policy If you want to proceed.' );
}
}

if ( ! errors ) {
// preparing data
var data = {};
Expand Down
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-element'), 'version' => '9ec528758fc3f9592913d4b74a35ca73');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-components', 'wp-element'), 'version' => '11773b60f52872ed16ec7b3f3137b87b');
2,386 changes: 1 addition & 2,385 deletions build/index.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion build/index.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions includes/Classes/class-form-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function submitQuotation() {

$fullname = sanitize_user( $_POST['pqfw_customer_name'] );
$email = sanitize_email( $_POST['pqfw_customer_email'] );
$phone = pqfw()->utils->sanitize_phone_number( $_POST['pqfw_customer_phone'] );
$phone = pqfw()->helpers->sanitizePhoneNumber( $_POST['pqfw_customer_phone'] );
$subject = sanitize_text_field( $_POST['pqfw_customer_subject'] );
$comments = sanitize_text_field( $_POST['pqfw_customer_comments'] );
$mapedDataToSave = [
Expand All @@ -52,7 +52,7 @@ public function submitQuotation() {
'comments' => $comments
];

$validate = pqfw()->utils->validate( $mapedDataToSave );
$validate = pqfw()->helpers->validate( $mapedDataToSave );

if ( $validate->has_errors() ) {
wp_send_json_error( $validate->errors );
Expand Down
12 changes: 12 additions & 0 deletions includes/Classes/class-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public function form() {

<ul class="pqfw-frontend-form">
<?php pqfw()->controlsManager->generate_fields(); ?>
<?php if ( pqfw()->settings->get( 'privacy_policy' ) ) : ?>
<li class="pqfw-privacy-policy">
<div class="pqfw-privacy-policy-inner">
<p><?php echo wp_kses_post( pqfw()->helpers->generatePrivacyPolicy( pqfw()->settings->get( 'privacy_policy_content' ) ) ); ?></p>

<div class="pqfw-privacy-policy-checkbox">
<input type="checkbox" name="pqfw_privacy_policy_checkbox" id="pqfw_privacy_policy_checkbox" required="1">
<label for="pqfw_privacy_policy_checkbox"><?php echo wp_kses_post( pqfw()->helpers->generatePrivacyPolicy( pqfw()->settings->get( 'privacy_policy_label' ) ) ); ?></label>
</div>
</div>
</li>
<?php endif; ?>
</ul>

<div class="pqfw-form-field pqfw-submit">
Expand Down
85 changes: 85 additions & 0 deletions includes/Classes/class-helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Contains the plugin helper methods.
*
* @since 1.0.0
* @package PQFW
*/

namespace PQFW\Classes;

// if direct access than exit the file.
defined( 'ABSPATH' ) || exit;

/**
* Contains the plugin helper methods.
*
* @since 1.0.0
* @package PQFW
*/
class Helpers {

/**
* Replaces placeholders with links to WooCommerce policy pages.
*
* @since 2.0.0
* @param string $text Text to find/replace within.
* @return string Text with replaced placeholders.
*/
public function generatePrivacyPolicy( $text ) {
return function_exists( 'wc_replace_policy_page_link_placeholders' ) ? wc_replace_policy_page_link_placeholders( $text ) : $text;
}

/**
* Sanitize phone number.
* Allows only numbers and "+" (plus sign).
*
* @param string $phone Phone number.
*
* @return string
* @since 1.0.0
*/
public function sanitizePhoneNumber( $phone ) {
return preg_replace( '/[^\d+]/', '', $phone );
}

/**
* Validate user data.
*
* @since 2.0.0
* @param array $fields The input fields value to validate.
* return mixed
*/
public function validate( $fields ) {
$errors = new \WP_Error();

$requiredFields = [
'fullname',
'email'
];

foreach ( $requiredFields as $required ) {
if ( empty( $fields[ $required ] ) ) {
$errors->add( 'field', sprintf( '%s %s', $required, __( 'is required.', 'pqfw' ) ) );
}
}

if ( $errors->has_errors() ) {
return $errors;
}

if ( strlen( $fields['fullname'] ) < 4 ) {
$errors->add( 'username_length', __( 'Username too short. At least 4 characters is required', 'pqfw' ) );
}

if ( ! validate_username( $fields['fullname'] ) ) {
$errors->add( 'username_invalid', __( 'Sorry, the username you entered is not valid', 'pqfw' ) );
}

if ( ! is_email( $fields['email'] ) ) {
$errors->add( 'email_invalid', __( 'Email is not valid', 'pqfw' ) );
}

return $errors;
}
}
4 changes: 4 additions & 0 deletions includes/Classes/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ protected function getAll() {
'hide_product_prices' => false,
'button_position' => 'woocommerce_after_shop_loop_item',
'button_position_single_product' => 'woocommerce_after_add_to_cart_quantity',
'privacy_policy' => false,
'privacy_policy_label' => __( 'I have read and agree to the website terms and conditions.', 'pqfw' ),
'privacy_policy_content' => __( 'Your personal data will be used to process your request,
support your experience throughout this website, and for other purposes described in our [privacy_policy].', 'pqfw' )
];

$this->saved = get_option( 'pqfw_settings', $this->default );
Expand Down
Loading

0 comments on commit b78b3fb

Please sign in to comment.