Ideally the date picker would be configured to return an acceptable date. If that’s not possible, the format could be converted at some point before the validation step. For example, PHP can convert nearly any date string into a timestamp with strtotime(), then a timestamp can be formatted in any manner you like with date().
If the validation is being done client side with JavaScript, there are equivalent JavaScript functions you could use to do the same.
How you would insert this conversion step into the data flow depends on how that actually happens. Ideally there’d be a filter or action hook to use. Otherwise it may require directly altering the source code that’s involved.
Thank you for your reply!
[ EDIT – it is NOT the jQuery. i forgot i added that comment line, which is not appearing in the view source ]
I think it has something to do with some custom jQuery code, but i’m not sure.
jQuery(document).ready(function($){
// Setup - add a text input to each footer cell
$('#users tfoot th').each( function () {
var title = $('#users thead th').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="'+title+'" /><!-- line 135 -->' );
} );
I’ll have to debug again. As far as I could tell, Chrome’s inspector is telling me that $('#users tfoot th').each( function () is not a function.
What dev tool might you recommend for debugging this?
-
This reply was modified 3 years, 11 months ago by
ajaxStardust.
-
This reply was modified 3 years, 11 months ago by
ajaxStardust.
-
This reply was modified 3 years, 11 months ago by
ajaxStardust.
-
This reply was modified 3 years, 11 months ago by
ajaxStardust. Reason: revision - this is NOT the issue
Sorry. My reply didn’t make sense.
In other words. I think the date is being messed up by jQuery, or the jQuery code is what’s converting it to 12 hr format.
It’s just proven quite difficult for me to even find where i can evaluate the date data in the PHP code. I don’t see any date specific functions in the PHP for this plugin.
@bcworkz when you say “validation step”, are you referring to a specific function in the WP core code?
-
This reply was modified 3 years, 11 months ago by
ajaxStardust.
Validation step as in what ever is responsible for the message ‘”2022-01-09T15:31″ is not a valid date.’ If the date can be made into a valid format before this point, all should be well. I don’t even know if it’s client side or server side.
You can use your browser’s developer tools to help you debug JavaScript and jQuery (sources tab). You can set breakpoints and watch variable values. Less sophisticated but still often effective would be to simply insert console.log() calls at strategic points in the code that tell you the value of key variables.
On the PHP side, the equivalent to console log is error_log(). Unless you have an integrated development environment set up, logging or outputting messages is about all you can do to debug PHP code. It helps a lot to have a test site installed on localhost to assist in debugging PHP. It then becomes much easier to frequently edit source code as is often necessary in debugging work.
Thank you very much for your thoughtful reply!
I think I need to do some Unit testing. Never done it w/ PHP before, but this seems like a perfect opportunity to learn. Have you any recommendations for PHP Unit testing with WordPress? Would you recommend I pursue this route?
-
This reply was modified 3 years, 11 months ago by
ajaxStardust.
There is a large suite of unit tests for core WP code. Unit testing is required for all contributions to core. IMO, unit testing for a custom breadcrumb function is probably overkill. But if you want to be a PHP developer, it is something that you’ll want to learn and you have to start somewhere π
Generic PHPUnit tutorial.
Thank you very much, @bcworkz
I look forward to being part of the ww.wp.xz.cn community.
best regards.