diff --git a/assets/js/datepicker.js b/assets/js/datepicker.js index 1d8e248a5..cb71f76c4 100644 --- a/assets/js/datepicker.js +++ b/assets/js/datepicker.js @@ -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', @@ -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 ) { diff --git a/includes/admin/class-wp-job-manager-cpt.php b/includes/admin/class-wp-job-manager-cpt.php index 8c9d7d343..b03d0d3e9 100644 --- a/includes/admin/class-wp-job-manager-cpt.php +++ b/includes/admin/class-wp-job-manager-cpt.php @@ -446,6 +446,7 @@ public function enter_title_here( $text, $post ) { */ public function post_updated_messages( $messages ) { global $post, $post_ID, $wp_post_types; + $wp_date_format = get_option( 'date_format' ) ?: JOB_MANAGER_DATE_FORMAT_FALLBACK; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- No changes based on input. $revision_title = isset( $_GET['revision'] ) ? wp_post_revision_title( (int) $_GET['revision'], false ) : false; @@ -470,7 +471,7 @@ public function post_updated_messages( $messages ) { // translators: %1$s is the singular name of the post type; %2$s is the date the post will be published; %3$s is the URL to preview the listing. __( '%1$s scheduled for: %2$s. Preview', 'wp-job-manager' ), $wp_post_types[ \WP_Job_Manager_Post_Types::PT_LISTING ]->labels->singular_name, - wp_date( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), get_post_timestamp() ), + wp_date( $wp_date_format . ' @ ' . get_option( 'time_format' ), get_post_timestamp() ), esc_url( get_permalink( $post_ID ) ) ), // translators: %1$s is the singular name of the job listing post type; %2$s is the URL to view the listing. @@ -593,6 +594,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: @@ -658,14 +660,14 @@ public function custom_columns( $column ) { } break; case 'job_posted': - echo '' . esc_html( wp_date( get_option( 'date_format' ), get_post_timestamp() ) ) . ''; + echo '' . esc_html( wp_date( $date_format, get_post_timestamp() ) ) . ''; // 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' ), '' . esc_html( get_the_author() ) . '' ) ) . ''; break; case 'job_expires': $job_expiration = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $post ); if ( $job_expiration ) { - echo '' . esc_html( wp_date( get_option( 'date_format' ), $job_expiration->getTimestamp() ) ) . ''; + echo '' . esc_html( wp_date( $date_format, $job_expiration->getTimestamp() ) ) . ''; } else { echo '–'; } diff --git a/includes/admin/class-wp-job-manager-writepanels.php b/includes/admin/class-wp-job-manager-writepanels.php index 89af731f0..3fe9d76bc 100644 --- a/includes/admin/class-wp-job-manager-writepanels.php +++ b/includes/admin/class-wp-job-manager-writepanels.php @@ -94,15 +94,15 @@ public function job_listing_fields() { } if ( isset( $fields['_job_expires'] ) && ! isset( $fields['_job_expires']['value'] ) ) { - $job_expires = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $post_id ); - + $job_expires = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $post_id ); + $wp_date_format = get_option( 'date_format' ) ?: 'F j, Y'; $fields['_job_expires']['placeholder'] = null; if ( ! empty( $job_expires ) ) { $fields['_job_expires']['value'] = $job_expires->format( 'Y-m-d' ); } else { $assumed_expiration_date = calculate_job_expiry( $post_id, true ); if ( $assumed_expiration_date ) { - $fields['_job_expires']['placeholder'] = wp_date( get_option( 'date_format' ), $assumed_expiration_date->getTimestamp() ); + $fields['_job_expires']['placeholder'] = wp_date( $wp_date_format, $assumed_expiration_date->getTimestamp() ); } $fields['_job_expires']['value'] = ''; } @@ -584,8 +584,8 @@ public static function input_radio( $key, $field ) { public function job_listing_data( $post ) { global $post, $thepostid, $wp_post_types; - $thepostid = $post->ID; - + $thepostid = $post->ID; + $wp_date_format = get_option( 'date_format' ) ?: JOB_MANAGER_DATE_FORMAT_FALLBACK; echo '
'; wp_nonce_field( 'save_meta_data', 'job_manager_nonce' ); @@ -618,7 +618,7 @@ public function job_listing_data( $post ) { // translators: %1$s is placeholder for singular name of the job listing post type; %2$s is the intl formatted date the listing was last modified. esc_html__( '%1$s was last modified by the user on %2$s.', 'wp-job-manager' ), esc_html( $wp_post_types[ \WP_Job_Manager_Post_Types::PT_LISTING ]->labels->singular_name ), - esc_html( wp_date( get_option( 'date_format' ), (int) $user_edited_timestamp ) ) + esc_html( wp_date( $wp_date_format, (int) $user_edited_timestamp ) ) ); echo ''; echo '

'; diff --git a/includes/class-wp-job-manager-email-notifications.php b/includes/class-wp-job-manager-email-notifications.php index 38ea63dbc..2f8a3e570 100644 --- a/includes/class-wp-job-manager-email-notifications.php +++ b/includes/class-wp-job-manager-email-notifications.php @@ -311,9 +311,10 @@ private static function get_job_detail_fields( WP_Post $job, $sent_to_admin, $pl ]; } - $job_expires = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $job ); + $job_expires = WP_Job_Manager_Post_Types::instance()->get_job_expiration( $job ); + $wp_date_format = get_option( 'date_format' ) ?: JOB_MANAGER_DATE_FORMAT_FALLBACK; if ( ! empty( $job_expires ) ) { - $job_expires_str = wp_date( get_option( 'date_format' ), $job_expires->getTimestamp() ); + $job_expires_str = wp_date( $wp_date_format, $job_expires->getTimestamp() ); $fields['job_expires'] = [ 'label' => __( 'Listing expires', 'wp-job-manager' ), 'value' => $job_expires_str, diff --git a/templates/job-dashboard.php b/templates/job-dashboard.php index cba5b6230..60f98a6d4 100644 --- a/templates/job-dashboard.php +++ b/templates/job-dashboard.php @@ -25,6 +25,7 @@ $submission_limit = ! empty( get_option( 'job_manager_submission_limit' ) ) ? absint( get_option( 'job_manager_submission_limit' ) ) : false; $submit_job_form_page_id = get_option( 'job_manager_submit_job_form_page_id' ); +$wp_date_format = get_option( 'date_format' ) ?: 'F j, Y'; ?>

@@ -73,11 +74,11 @@ ?> - getTimestamp() ) ); ?> + getTimestamp() ) ); ?> get_job_expiration( $job ); - echo esc_html( $job_expires ? wp_date( get_option( 'date_format' ), $job_expires->getTimestamp() ) : '–' ); + echo esc_html( $job_expires ? wp_date( $wp_date_format, $job_expires->getTimestamp() ) : '–' ); ?> diff --git a/wp-job-manager-template.php b/wp-job-manager-template.php index 7a0ce1a19..e17255937 100644 --- a/wp-job-manager-template.php +++ b/wp-job-manager-template.php @@ -758,10 +758,11 @@ function wpjm_get_registration_fields() { * @param int|WP_Post $post (default: null). */ function the_job_publish_date( $post = null ) { - $date_format = get_option( 'job_manager_date_format' ); + $date_format = get_option( 'job_manager_date_format' ); + $wp_date_format = get_option( 'date_format' ) ?: JOB_MANAGER_DATE_FORMAT_FALLBACK; if ( 'default' === $date_format ) { - $display_date = esc_html__( 'Posted on ', 'wp-job-manager' ) . wp_date( get_option( 'date_format' ), get_post_timestamp( $post ) ); + $display_date = esc_html__( 'Posted on ', 'wp-job-manager' ) . wp_date( $wp_date_format, get_post_timestamp( $post ) ); } else { $post_timestamp = get_post_timestamp( $post ); $current_time = time(); @@ -786,10 +787,11 @@ function the_job_publish_date( $post = null ) { * @return string|int|false */ function get_the_job_publish_date( $post = null ) { - $date_format = get_option( 'job_manager_date_format' ); + $date_format = get_option( 'job_manager_date_format' ); + $wp_date_format = get_option( 'date_format' ) ?: JOB_MANAGER_DATE_FORMAT_FALLBACK; if ( 'default' === $date_format ) { - return wp_date( get_option( 'date_format' ), get_post_datetime()->getTimestamp() ); + return wp_date( $wp_date_format, get_post_datetime()->getTimestamp() ); } else { // translators: Placeholder %s is the relative, human readable time since the job listing was posted. return sprintf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_timestamp(), time() ) ); diff --git a/wp-job-manager.php b/wp-job-manager.php index fbb25f095..fc91ac7dd 100644 --- a/wp-job-manager.php +++ b/wp-job-manager.php @@ -25,6 +25,7 @@ define( 'JOB_MANAGER_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); define( 'JOB_MANAGER_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); define( 'JOB_MANAGER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); +define( 'JOB_MANAGER_DATE_FORMAT_FALLBACK', 'F j, Y' ); require_once dirname( __FILE__ ) . '/wp-job-manager-autoload.php'; WP_Job_Manager_Autoload::init();