Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Time and Date merge tag :format modifier #2080

Merged

Conversation

omarkasem
Copy link
Collaborator

@omarkasem omarkasem commented Jun 14, 2024

This implements #2040.

  • I created merge tags modifier 'format' for both time and date
  • The only thing that is not clear to me is when does this hook run
    gravityview/merge_tags/modifiers/value
    I tried a lot of values and modifiers but I can't get it to run so i can see if it has anything to do with date or time
    {Time:4:format:g:i a}
    {Date:3:format:m-d-Y}

💾 Build file (2930ecf).

@omarkasem omarkasem requested a review from mrcasual June 14, 2024 04:32
@omarkasem omarkasem self-assigned this Jun 14, 2024
@omarkasem omarkasem linked an issue Jun 14, 2024 that may be closed by this pull request
@mrcasual mrcasual added this to the 2.26 milestone Jun 24, 2024
Copy link
Collaborator

@mrcasual mrcasual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@omarkasem, in addition to my comments, could you also please add some unit tests?

includes/class-gravityview-merge-tags.php Outdated Show resolved Hide resolved
includes/fields/class-gravityview-field-date.php Outdated Show resolved Hide resolved
@omarkasem
Copy link
Collaborator Author

@mrcasual
So the tests are working fine because I'm calling process_modifiers directly but the main issue here is with the view in custom content with any date or time formats that has uppercase like D for days or F for months, gravityforms do strtolower to the modifier before it reaches to our function so there's no way to know what it was before or prevent that (see screenshot)

Screenshot from 2024-07-12 11-00-30

Do you have any idea how to bypass that? or should i try process the date and time away from that function like i was doing before.

@zackkatz zackkatz changed the title Add fied time and date merge tags modifier Add Time and Date merge tag :format modifier Aug 5, 2024
@zackkatz zackkatz requested a review from mrcasual August 5, 2024 15:39
@mrcasual
Copy link
Collaborator

mrcasual commented Aug 7, 2024

@omarkasem, please see my solution: 2930ecf.

@mrcasual mrcasual merged commit 8b0e5dd into develop Aug 7, 2024
1 check passed
@mrcasual mrcasual deleted the issue/2040-time-field-merge-tag-doesnt-support-fomatting branch August 7, 2024 19:02
@omarkasem
Copy link
Collaborator Author

@mrcasual
Yeah that's very smart to store it in a variable then call it back, well done 👍 🎩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time field Merge Tag doesn't support fomatting
2 participants