Skip to content

Commit

Permalink
fix: Event Created in FrontEnd not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sapayth committed Oct 28, 2024
1 parent 2decc63 commit 197b9dd
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,41 @@ public function __construct() {
'wpuf_cond' => $this->conditionals,
],
[
'input_type' => 'url',
'template' => 'website_url',
'required' => 'no',
'label' => __( 'Event Website', 'wp-user-frontend' ),
'name' => '_EventURL',
'is_meta' => 'yes',
'width' => 'large',
'size' => 40,
'wpuf_cond' => $this->conditionals,
'input_type' => 'url',
'template' => 'website_url',
'required' => 'no',
'label' => __( 'Event Website', 'wp-user-frontend' ),
'name' => '_EventURL',
'placeholder' => '',
'default' => '',
'is_meta' => 'yes',
'width' => 'large',
'size' => 40,
'wpuf_cond' => $this->conditionals,
],
[
'input_type' => 'text',
'template' => 'text_field',
'required' => 'no',
'label' => __( 'Currency Symbol', 'wp-user-frontend' ),
'name' => '_EventCurrencySymbol',
'is_meta' => 'yes',
'size' => 40,
'wpuf_cond' => $this->conditionals,
'input_type' => 'text',
'template' => 'text_field',
'required' => 'no',
'label' => __( 'Currency Symbol', 'wp-user-frontend' ),
'name' => '_EventCurrencySymbol',
'placeholder' => '',
'default' => '',
'is_meta' => 'yes',
'size' => 40,
'wpuf_cond' => $this->conditionals,
],
[
'input_type' => 'text',
'template' => 'text_field',
'required' => 'no',
'label' => __( 'Cost', 'wp-user-frontend' ),
'name' => '_EventCost',
'is_meta' => 'yes',
'wpuf_cond' => $this->conditionals,
'input_type' => 'text',
'template' => 'text_field',
'required' => 'no',
'label' => __( 'Cost', 'wp-user-frontend' ),
'name' => '_EventCost',
'placeholder' => '',
'default' => '',
'size' => 40,
'is_meta' => 'yes',
'wpuf_cond' => $this->conditionals,
],
[
'input_type' => 'image_upload',
Expand Down
2 changes: 2 additions & 0 deletions includes/Fields/Form_Field_Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace WeDevs\Wpuf\Fields;

use WP_Query;

/**
* DropDown Field Class
*/
Expand Down
3 changes: 2 additions & 1 deletion includes/Fields/Form_Field_Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ public function render( $field_settings, $form_id, $type = 'post', $post_id = nu

$this->field_print_label( $field_settings, $form_id );

do_action( 'WPUF_radio_field_after_label', $field_settings ); ?>
do_action( 'wpuf_radio_field_after_label', $field_settings ); ?>

<div class="wpuf-fields">

<?php
if ( $field_settings['options'] && count( $field_settings['options'] ) > 0 ) {
foreach ( $field_settings['options'] as $value => $option ) {
$selected = is_array( $selected ) ? '' : $selected;
?>

<label <?php echo $field_settings['inline'] == 'yes' ? 'class="wpuf-radio-inline"' : 'class="wpuf-radio-block"'; ?>>
Expand Down
10 changes: 6 additions & 4 deletions includes/Integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ class Integrations {
public $container = [];

private $integrations = [
'WeDevs_Dokan' => 'WPUF_Dokan_Integration',
'WC_Vendors' => 'WPUF_WC_Vendors_Integration',
'WCMp' => 'WPUF_WCMp_Integration',
'ACF' => 'WPUF_ACF_Compatibility',
'WeDevs_Dokan' => 'WPUF_Dokan_Integration',
'WC_Vendors' => 'WPUF_WC_Vendors_Integration',
'WCMp' => 'WPUF_WCMp_Integration',
'ACF' => 'WPUF_ACF_Compatibility',
'Tribe__Events__Main' => 'The_Events_Calendar',
'Tribe__Events__Pro__Main' => 'The_Events_Calendar',
];

public function __construct() {
Expand Down
35 changes: 35 additions & 0 deletions includes/Integrations/The_Events_Calendar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace WeDevs\Wpuf\Integrations;

if ( ! class_exists( 'WeDevs\Wpuf\Integrations\The_Events_Calendar' ) ) {
class The_Events_Calendar {

public function __construct() {
add_action( 'wpuf_before_updating_post_meta_fields', [ $this, 'add_event' ], 10, 2 );
}

public function add_event( $post_id, $meta_key_value ) {
if ( 'tribe_events' !== get_post_type( $post_id ) ) {
return;
}

$args = [];

if ( ! empty( $meta_key_value['_EventAllDay'] ) ) {
$args['all_day'] = 'yes' === $meta_key_value['_EventAllDay'];
}

$default = [
'title' => '',
'all_day' => true,
];

$args = wp_parse_args( $args, $default );

if ( function_exists( 'tribe_update_event' ) ) {
tribe_update_event( $post_id, $args );
}
}
}
}
10 changes: 10 additions & 0 deletions includes/Traits/FieldableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ public function update_post_meta( $meta_vars, $post_id ) {
[ $meta_key_value, $multi_repeated, $files ] = self::prepare_meta_fields( $meta_vars );
// set featured image if there's any

/**
* Fires before updating post meta fields
*
* @param int $post_id
* @param array $meta_key_value
* @param array $multi_repeated
* @param array $files
*/
do_action( 'wpuf_before_updating_post_meta_fields', $post_id, $meta_key_value, $multi_repeated, $files );

// @codingStandardsIgnoreStart
$wpuf_files = isset( $_POST['wpuf_files'] ) ? $_POST['wpuf_files'] : [];

Expand Down

0 comments on commit 197b9dd

Please sign in to comment.