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

Set the default dateFormat if it’s empty #2779

Merged
merged 4 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion assets/js/datepicker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* global job_manager_datepicker */
jQuery(document).ready( function() {
if ( jQuery.datepicker._defaults.dateFormat == '' ) {
jQuery.datepicker._defaults.dateFormat = 'MM d, yy';
}
var $date_today = new Date();
var datePickerOptions = {
altFormat : 'yy-mm-dd',
Expand All @@ -21,7 +24,6 @@ jQuery(document).ready( function() {
}
} );
$target.datepicker( jQuery.extend( {}, datePickerOptions, { altField: $hidden_input } ) );
$target.datepicker("option", "dateFormat", $target.datepicker("option", "dateFormat") || "MM d, yy");
if ( $target.val() ) {
var dateParts = $target.val().split('-');
if ( 3 === dateParts.length ) {
Expand Down
5 changes: 3 additions & 2 deletions includes/admin/class-wp-job-manager-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ public function row_actions( $actions, $post ) {
*/
public function custom_columns( $column ) {
global $post;
$date_format = get_option( 'date_format' ) ?: 'F j, Y';

switch ( $column ) {
case \WP_Job_Manager_Post_Types::TAX_LISTING_TYPE:
Expand Down Expand Up @@ -658,14 +659,14 @@ public function custom_columns( $column ) {
}
break;
case 'job_posted':
echo '<strong>' . esc_html( wp_date( get_option( 'date_format' ), get_post_timestamp() ) ) . '</strong><span>';
echo '<strong>' . esc_html( wp_date( $date_format, get_post_timestamp() ) ) . '</strong><span>';
// translators: %s placeholder is the username of the user.
echo ( empty( $post->post_author ) ? esc_html__( 'by a guest', 'wp-job-manager' ) : sprintf( esc_html__( 'by %s', 'wp-job-manager' ), '<a href="' . esc_url( add_query_arg( 'author', $post->post_author ) ) . '">' . esc_html( get_the_author() ) . '</a>' ) ) . '</span>';
break;
case 'job_expires':
$job_expiration = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $post );
if ( $job_expiration ) {
echo '<strong>' . esc_html( wp_date( get_option( 'date_format' ), $job_expiration->getTimestamp() ) ) . '</strong>';
echo '<strong>' . esc_html( wp_date( $date_format, $job_expiration->getTimestamp() ) ) . '</strong>';
} else {
echo '&ndash;';
}
Expand Down
Loading