Okay
  Public Ticket #2123942
End date and time
Closed

Comments

  • Waldelmar started the conversation
    Hi!
    Could you please let me know, if there is any code to make checkbox "All day" enabled by default only on the front-end event submission page? 
    The idea is, that it is needed only the start date without start time on front-end event submission page (no ending date and no ending time)
    Hope someone already asked you about that and there is already solution or something similar, I would be very appreciated for helping me.
    

    UPDATE

    I think, I've figured it out with css. The only thing, now I need to hide "time 00.00" on the frontend agenda and calendar view. I found the comment https://codecanyon.net/item/stachethemes-event-calendar-wordpress-events-calendar-plugin/16168229/comments?page=33&filter=all#comment_16211456

    There are a lot of new updates after publishing this comment, so is there any solution to change

    "event.all_day" to "1" in stec.js and tooltip.js
    

    with help of functions.php? To be able update the plugin in future without any changes in code...

  •  894
    Zhivko replied

    Remove your changes and open your theme functions.php file.

    At the bottom add this filter:

    add_action('stec_builder_front_elements', function($elements) {
        
        // Hides all day check and sets it to true by default
        $elements['all-day-check'] = array(
            '<input type="hidden" name="all_day" value=1 />'
        );
        
        // Removes time settings for start date
        $elements['start-date'] = array(
            "<input {{params}} type='text' name='start_date' placeholder='" . __('Starts on', 'stec') . "' />",
            "<input type='hidden' name='start_date_alt' />"
        );
        
        // Hides end date
        $elements['end-date'] = array(
            "<input type='hidden' name='end_date' />",
            "<input type='hidden' name='end_date_alt' />"
        );     return $elements;
    });


    Stachethemes Developer

  • Waldelmar replied

    Thank you so much!!!! )

    The only thing is, that

    00:00 - 00:00

    is still showing in front view (agenda, month, week modes), pls find screenshots below.

    And there is no css class on time to make it display none...

    _________________________________________________

    Please, if it could be possible, one last question:

    The file is class.builder-elements.php in .../plugins/stachethemes_event_calendar/assets/php/

    Lines 35-41

    Is there any possibility to change (using functions.php) this

    <div class="stec-builder-submission-new-location">
                <input class="stec-builder-element-content-input-style" type="text" name="location_address" placeholder="<?php _e('Address', 'stec'); ?>">
                <input class="stec-builder-element-content-input-style" type="text" name="location_city" placeholder="<?php _e('City', 'stec'); ?>">
                <input class="stec-builder-element-content-input-style" type="text" name="location_country" placeholder="<?php _e('Country', 'stec'); ?>">
                <input class="stec-builder-element-content-input-style" type="text" name="location_coordinates" placeholder="<?php _e('Coordinates', 'stec'); ?>">
                <textarea class="stec-builder-element-content-textarea-style" name="location_details" placeholder="<?php _e('Details', 'stec'); ?>"></textarea>
    </div>
    

    to this

    <div class="stec-builder-submission-new-location">
                <input class="stec-builder-element-content-input-style" type="text" name="location_address" placeholder="<?php _e('Theater', 'stec'); ?>">
                <input class="stec-builder-element-content-input-style" type="text" name="location_city" placeholder="<?php _e('City', 'stec'); ?>">
                <input class="stec-builder-element-content-input-style" type="text" name="location_country" placeholder="<?php _e('Country', 'stec'); ?>">
    </div>
    

    - rename Address to Theater and delete Coordinates and Details in frontend event submission...

    I am very sorry to bother you, but this is the last step to make your plugin perfect for me )) and make my update process much faster

  •  894
    Zhivko replied

    Here's the revised code:

    add_action('stec_builder_front_elements', function($elements) {
        // Hides all day check and sets it to true by default
        $elements['all-day-check'] = array(
            '<input type="hidden" name="all_day" value="1" />'
        );     // Removes time settings for start date
        $elements['start-date'] = array(
            "<input {{params}} type='text' name='start_date' placeholder='" . __('Starts on', 'stec') . "' />",
            "<input type='hidden' name='start_date_alt' />"
        );     // Hides end date
        $elements['end-date'] = array(
            "<input type='hidden' name='end_date' />",
            "<input type='hidden' name='end_date_alt' />"
        );
             $options   = array();
        $locations = Locations::get_locations_list();
        $options[] = "<optgroup label='" . __('New location', 'stec') . "'>";
        $options[] = "<option value='custom'>" . __('Add new location', 'stec') . "</option>";
        $options[] = "</optgroup>";
        $options[] = "<optgroup label='" . __('Locations', 'stec') . "'>";
        $options[] = "<option selected value=''>" . __('No location', 'stec') . "</option>";
        foreach ($locations as $k => $v) :
            $options[] = "<option value='{$k}'>{$v}</option>";
        endforeach;
        $options[] = "</optgroup>";     ob_start();
        ?>
        <div class="stec-builder-submission-new-location">
            <input class="stec-builder-element-content-input-style" type="text" name="location_address" placeholder="<?php _e('Theater', 'stec'); ?>" >
            <input class="stec-builder-element-content-input-style" type="text" name="location_city" placeholder="<?php _e('City', 'stec'); ?>" >
            <input class="stec-builder-element-content-input-style" type="text" name="location_country" placeholder="<?php _e('Country', 'stec'); ?>" >
            <textarea class="stec-builder-element-content-textarea-style" name="location_details" placeholder="<?php _e('Details', 'stec'); ?>"></textarea>
        </div>
        <?php
        $elements["location"] = array(
            "<select {{params}} name='location'>" . implode(PHP_EOL, $options) . "</select>",
            ob_get_clean()
        );
        return $elements;
    });

    Regarding the time 00:00 : were these events submitted before adding this filter?


    Stachethemes Developer

  •   Waldelmar replied privately
  •  894
    Zhivko replied

    The Location class was called outside its namespace and this was causing the issue. I've placed the code in your theme child functions.php file.


    Stachethemes Developer

  • Waldelmar replied

    Thank you! Much better, but still, the only thing is, that it is showing 00:00 - 00:00 (calendar tooltip and agenda, week views) ...

    I am trying to submit event after adding code to functions.php...

    Step by step:

    - pasted the code to functions.php

    - on the frontend I submited the event

    - next, as an admin, I approve it in the admin area (maybe, here could be mistake... but I haven't edited the event, only approved it) 

    - all looks fine, but on the front it shows 00:00 - 00:00 ...

    PS. Unchecking "Require approval by admin for events added from font-end" doesn't help...

  • Waldelmar replied

    screenshots

  •  894
    Zhivko replied

    The all day value was not being passed because the element was missing in your builder form, so I've inserted the value along with the start date input.

    Should be ok now.


    Stachethemes Developer

  • Waldelmar replied

    Thank you so much!!!

    It's perfect now!