Skip to content

Commit

Permalink
Merge branch 'release/4.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sapayth committed Jan 24, 2024
2 parents d85771a + 764965d commit 99a446e
Show file tree
Hide file tree
Showing 30 changed files with 2,071 additions and 590 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Plugin asset/readme update
on:
push:
branches:
- trunk
jobs:
trunk:
name: Push to trunk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
2 changes: 1 addition & 1 deletion Lib/WeDevs_Insights.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WeDevs_Insights {
/**
* @var object|Appsero\Insights|Insights
*/
private $insights;
public $insights;

/**
* Initialize the class
Expand Down
38 changes: 38 additions & 0 deletions admin/html/whats-new.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
<?php
$changelog = [
[
'version' => 'Version 4.0.4',
'released' => '2024-01-25',
'changes' => [
[
'title' => __( 'Add visibility to the Columns field', 'wp-user-frontend' ),
'type' => 'Enhance',
],
[
'title' => __( 'Login with reCAPTCHA gives error', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'AJAX image upload', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Error on multi select form custom taxonomy', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Frontend registration form is not showing', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Handle email for guest post', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Default form template not selecting', 'wp-user-frontend' ),
'type' => 'Fix',
],
[
'title' => __( 'Error in setup wizard', 'wp-user-frontend' ),
'type' => 'Fix',
],
],
],
[
'version' => 'Version 4.0.3',
'released' => '2024-01-05',
Expand Down
2 changes: 1 addition & 1 deletion admin/posting.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct() {
add_action( 'add_meta_boxes', [ $this, 'add_meta_box_form_select'] );
add_action( 'add_meta_boxes', [ $this, 'add_meta_box_post_lock'] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_script'] );
add_action( 'save_post', [ $this, 'save_meta'], 100, 2 ); // save the custom fields
add_action( 'save_post', [ $this, 'save_meta' ], 100, 2 ); // save the custom fields
add_action( 'save_post', [ $this, 'form_selection_metabox_save' ], 1, 2 ); // save edit form id
add_action( 'save_post', [ $this, 'post_lock_metabox_save' ], 1, 2 ); // save post lock option
add_action( 'wp_ajax_wpuf_clear_schedule_lock', [$this, 'clear_schedule_lock'] );
Expand Down
3 changes: 3 additions & 0 deletions assets/css/frontend-forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,9 @@ body .wpuf-dashboard-container .wpuf-dashboard-content .wpuf-fields textarea:not
body .wpuf-dashboard-container .wpuf-dashboard-content .wpuf-fields input:not([type="reset"]) {
width: 100%;
}
body .wpuf-dashboard-container .wpuf-dashboard-content .wpuf-fields input[type="radio"] {
width: initial;
}
body .wpuf-dashboard-container .items-table-container,
body .wpuf-dashboard-container .wpuf-dashboard-content.invoices {
max-width: 100%;
Expand Down
3 changes: 0 additions & 3 deletions assets/js/wpuf-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,13 @@ jQuery(function($) {
// align with WooCommerce _downloadable meta key
var downloadableRadio = $('.wpuf-fields input[type="radio"][name="_downloadable"]');
var downloadableCheckbox = $('#woocommerce-product-data input[type="checkbox"][name="_downloadable"]');
var virtualCheckbox = $('#woocommerce-product-data input[type="checkbox"][name="_virtual"]');
downloadableRadio.click(function() {
var downloadable = $(this).val();

if ($(this).is(':checked') && downloadable === 'yes') {
downloadableCheckbox.prop('checked', true);
virtualCheckbox.prop('checked', true);
} else {
downloadableCheckbox.prop('checked', false);
virtualCheckbox.prop('checked', false);
}
});

Expand Down
6 changes: 6 additions & 0 deletions assets/less/frontend-forms.less
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,12 @@ body.rtl{
}
}

.wpuf-fields {
input[type="radio"] {
width: initial;
}
}

}

.items-table-container,
Expand Down
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
= v4.0.4 (25 Jan, 2024) =
* Enhance - Add visibility to the Columns field
* Fix - Login with reCAPTCHA gives error
* Fix - AJAX image upload
* Fix - Error on multi select form custom taxonomy
* Fix - Frontend registration form is not showing
* Fix - Handle email for guest post
* Fix - Default form template not selecting
* Fix - Error in setup wizard

= v4.0.3 (05 Jan, 2024) =
* Enhance - Restructure plugin codes
* Fix - Error when editing the featured post
Expand Down
4 changes: 2 additions & 2 deletions class/render-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ public function image_upload( $attr, $post_id, $type, $form_id ) {

if ( $thumb_id ) {
$has_featured_image = true;
$featured_image = WPUF_Upload::attach_html( $thumb_id, 'featured_image' );
$featured_image = WeDevs\Wpuf\Ajax\Upload_Ajax::attach_html( $thumb_id, 'featured_image' );
}
} else {
// it must be a user avatar
Expand Down Expand Up @@ -1692,7 +1692,7 @@ public function image_upload( $attr, $post_id, $type, $form_id ) {

if ( $has_images ) {
foreach ( $images as $attach_id ) {
echo esc_attr( WPUF_Upload::attach_html( $attach_id, $attr['name'] ) );
echo esc_attr( WeDevs\Wpuf\Ajax\Upload_Ajax::attach_html( $attach_id, $attr['name'] ) );
}
} ?>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function __construct() {
'wp-user-frontend' ),
'edit_url' => '',
'update_text' => __( 'Update Event', 'wp-user-frontend' ),
'form_template' => __CLASS__,
'form_template' => 'post_form_template_events_calendar',
'notification' => [
'new' => 'on',
'new_to' => get_option( 'admin_email' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function __construct() {
'update_message' => __( 'Post has been updated successfully. <a target="_blank" href="%link%">View post</a>', 'wp-user-frontend' ),
'edit_url' => '',
'update_text' => __( 'Update Post', 'wp-user-frontend' ),
'form_template' => __CLASS__,
'form_template' => 'post_form_template_post',
'notification' => [
'new' => 'on',
'new_to' => get_option( 'admin_email' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function __construct() {
'update_message' => 'Product has been updated successfully. <a target="_blank" href="%link%">View Product</a>',
'edit_url' => '',
'update_text' => 'Update Product',
'form_template' => __CLASS__,
'form_template' => 'post_form_template_woocommerce',
'notification' => [
'new' => 'on',
'new_to' => get_option( 'admin_email' ),
Expand Down
62 changes: 36 additions & 26 deletions includes/Admin/Upgrades.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ class Upgrades {
* @var array
*/
private static $upgrades = [
'2.1.9' => 'upgrades/upgrade-2.1.9.php',
'2.6.0' => 'upgrades/upgrade-2.6.0.php',
'2.7.0' => 'upgrades/upgrade-2.7.0.php',
'2.8.0' => 'upgrades/upgrade-2.8.0.php',
'2.8.2' => 'upgrades/upgrade-2.8.2.php',
'2.8.5' => 'upgrades/upgrade-2.8.5.php',
'2.9.2' => 'upgrades/upgrade-2.9.2.php',
'3.6.0' => 'upgrades/upgrade-3.6.0.php',
'2.1.9' => 'upgrades/upgrade-2.1.9.php',
'2.6.0' => 'upgrades/upgrade-2.6.0.php',
'2.7.0' => 'upgrades/upgrade-2.7.0.php',
'2.8.0' => 'upgrades/upgrade-2.8.0.php',
'2.8.2' => 'upgrades/upgrade-2.8.2.php',
'2.8.5' => 'upgrades/upgrade-2.8.5.php',
'2.9.2' => 'upgrades/upgrade-2.9.2.php',
'3.6.0' => 'upgrades/upgrade-3.6.0.php',
'4.0.4' => 'upgrades/upgrade-4.0.4.php',
];

/**
Expand Down Expand Up @@ -52,13 +53,13 @@ public function get_version() {
* @return bool
*/
public function needs_update() {

// may be it's the first install
if ( ! $this->get_version() ) {
return false;
}
//check if current version is greater then installed version and any update key is available
if ( version_compare( $this->get_version(), WPUF_VERSION, '<' ) && in_array( WPUF_VERSION,
array_keys( self::$upgrades ) ) ) {
// check if current version is greater than installed version and any update key is available
if ( version_compare( $this->get_version(), WPUF_VERSION, '<' ) && in_array( WPUF_VERSION, array_keys( self::$upgrades ), true ) ) {
return true;
}

Expand All @@ -71,20 +72,26 @@ public function needs_update() {
* @return void
*/
public function perform_updates() {
if ( empty( $_GET['wpuf_do_update'] ) ) {
if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'wpuf_do_update' ) ) {
return;
}
if ( ! sanitize_text_field( wp_unslash( $_GET['wpuf_do_update'] ) ) ) {

if ( empty( $_GET['wpuf_do_update'] ) || ! sanitize_text_field( wp_unslash( $_GET['wpuf_do_update'] ) ) ) {
return;
}

$installed_version = $this->get_version();
$path = trailingslashit( __DIR__ );

foreach ( self::$upgrades as $version => $file ) {
if ( version_compare( $installed_version, $version, '<' ) ) {
include $path . $file;
$path = WPUF_ROOT . '/includes/' . $file;
if ( file_exists( $path ) ) {
include_once $path;
}
update_option( 'wpuf_version', $version );
}
}

update_option( 'wpuf_version', WPUF_VERSION );
}

Expand All @@ -99,23 +106,26 @@ public function show_upgrade_notice() {
if ( ! current_user_can( 'update_plugins' ) || ! $this->needs_update() ) {
return;
}

if ( $this->needs_update() ) {
$url = ! empty( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$url = ! empty( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$link = add_query_arg(
[
'wpuf_do_update' => true,
'nonce' => wp_create_nonce( 'wpuf_do_update' ),
],
$url
);
?>
<div id="message" class="updated">
<p><?php printf( '<strong>%s</strong>',
esc_attr__( 'WPUF Data Update Required', 'wp-user-frontend' ) ); ?></p>
<p class="submit"><a
href="<?php echo esc_url( add_query_arg( [ 'wpuf_do_update' => true ], $url ) ); ?>"
class="wpuf-update-btn button-primary"><?php esc_attr_e( 'Run the updater',
'wp-user-frontend' ); ?></a></p>
<p><?php printf( '<strong>%s</strong>', esc_attr__( 'WPUF Data Update Required', 'wp-user-frontend' ) ); ?></p>
<p class="submit"><a href="<?php echo esc_url( $link ); ?>" class="wpuf-update-btn button-primary"><?php esc_attr_e( 'Run the updater', 'wp-user-frontend' ); ?></a></p>
</div>

<script type="text/javascript">
jQuery( '.wpuf-update-btn' ).click( 'click', function () {
return confirm( '<?php esc_attr_e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?',
'wp-user-frontend' ); ?>' );
} );
jQuery('.wpuf-update-btn').click('click', function() {
return confirm( '<?php esc_attr_e( 'It is strongly recommended that you backup your database before proceeding. Are you sure you wish to run the updater now?', 'wp-user-frontend' ); ?>' );
});
</script>
<?php
}
Expand Down
27 changes: 21 additions & 6 deletions includes/Ajax/Frontend_Form_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ public function submit_post() {
}
}

$protected_shortcodes = wpuf_get_protected_shortcodes();

// check each form field for restricted shortcodes
foreach ( $this->form_fields as $single_field ) {
if ( empty( $single_field['rich'] ) || 'yes' !== $single_field['rich'] ) {
Expand All @@ -119,7 +117,7 @@ public function submit_post() {
foreach ( $protected_shortcodes as $shortcode ) {
$search_for = '[' . $shortcode;
if ( strpos( $current_data, $search_for ) !== false ) {
$this->send_error( sprintf( __( 'Using %s as shortcode is restricted', 'wp-user-frontend' ), $shortcode ) );
wpuf()->ajax->send_error( sprintf( __( 'Using %s as shortcode is restricted', 'wp-user-frontend' ), $shortcode ) );
}
}
}
Expand All @@ -145,8 +143,7 @@ public function submit_post() {
}

$is_update = false;
$post_author = null;
$default_post_author = wpuf_get_option( 'default_post_owner', 'wpuf_frontend_posting', 1 );
// $default_post_author = wpuf_get_option( 'default_post_owner', 'wpuf_frontend_posting', 1 );
$post_author = $this->wpuf_get_post_user();

$allowed_tags = wp_kses_allowed_html( 'post' );
Expand Down Expand Up @@ -493,7 +490,25 @@ public function wpuf_get_post_user() {

// is valid email?
if ( ! is_email( $guest_email ) ) {
wpuf()->ajax->send_error( __( 'Invalid email address.', 'wp-user-frontend' ) );
echo json_encode(
[
'success' => false,
'error' => __( 'Invalid email address.', 'wp-user-frontend' ),
]
);

die();

// $this->send_error( __( 'Invalid email address.', 'wp-user-frontend' ) );
// wp_send_json(
// [
// 'success' => false,
// 'error' => __( "You already have an account in our site. Please login to continue.\n\nClicking 'OK' will redirect you to the login page and you will lose the form data.\nClick 'Cancel' to stay at this page.", 'wp-user-frontend' ),
// 'type' => 'login',
// 'redirect_to' => wp_login_url( get_permalink( $page_id ) ),
// ]
// );
// wpuf()->ajax->send_error( __( 'Invalid email address.', 'wp-user-frontend' ) );
}

// check if the user email already exists
Expand Down
Loading

0 comments on commit 99a446e

Please sign in to comment.