From d113c11cd75f1b2c2490ff43a956367228c40af2 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 12:51:26 -0400 Subject: [PATCH 01/11] Added "Date Format" setting to the "Job Listings" section. --- includes/admin/class-wp-job-manager-settings.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/admin/class-wp-job-manager-settings.php b/includes/admin/class-wp-job-manager-settings.php index bf8751111..ba021d5c6 100644 --- a/includes/admin/class-wp-job-manager-settings.php +++ b/includes/admin/class-wp-job-manager-settings.php @@ -96,6 +96,17 @@ protected function init_settings() { 'all' => __( 'Jobs will be shown if within ALL selected categories', 'wp-job-manager' ), ) ), + array( + 'name' => 'job_manager_date_format', + 'std' => 'relative', + 'label' => __( 'Date Format', 'wp-job-manager' ), + 'desc' => __( 'Choose how you want the published date for jobs to be displayed on the front-end.', 'wp-job-manager' ), + 'type' => 'select', + 'options' => array( + 'relative' => __( 'Relative to the current date (e.g., 1 day, 1 week, 1 month ago)', 'wp-job-manager' ), + 'default' => __( 'Default date format as defined in Setttings', 'wp-job-manager' ), + ) + ), ), ), 'job_submission' => array( From b286c5112ec0c068d1c5db2762abcd18a627b497 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 12:56:32 -0400 Subject: [PATCH 02/11] Added "the_job_publish_date" function that outputs the current job published date using the date format defined in the plugin settings. --- wp-job-manager-template.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wp-job-manager-template.php b/wp-job-manager-template.php index 60f9b7a6c..14ae56a18 100644 --- a/wp-job-manager-template.php +++ b/wp-job-manager-template.php @@ -266,6 +266,22 @@ function get_the_job_type( $post = null ) { } +/** + * the_job_publish_date function. + * @param mixed $post (default: null) + * @return [type] + */ +function the_job_publish_date( $post = null ) { + $date_format = get_option( 'job_manager_date_format' ); + + if ( $date_format === 'default' ) { + the_time( get_option( 'date_format' ) ); + } else { + printf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); + } +} + + /** * the_job_location function. * @param boolean $map_link whether or not to link to google maps From 7ce9797857765c3a04b28806ac9864c3df45561b Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 12:58:53 -0400 Subject: [PATCH 03/11] Added "get_the_job_publish_date" function that returns the date for a job using the display format selected in the plugin settings. --- wp-job-manager-template.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wp-job-manager-template.php b/wp-job-manager-template.php index 14ae56a18..0330605b5 100644 --- a/wp-job-manager-template.php +++ b/wp-job-manager-template.php @@ -282,6 +282,22 @@ function the_job_publish_date( $post = null ) { } +/** + * get_the_job_publish_date function. + * @param mixed $post (default: null) + * @return [type] + */ +function get_the_job_publish_date( $post = null ) { + $date_format = get_option( 'job_manager_date_format' ); + + if ( $date_format === 'default' ) { + return get_the_time( get_option( 'date_format' ) ); + } else { + return sprintf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); + } +} + + /** * the_job_location function. * @param boolean $map_link whether or not to link to google maps From cda3c926b6ac8fc784196d796ff711ee34f905c9 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:00:50 -0400 Subject: [PATCH 04/11] Updated the date output for job listings to use the "the_job_publish_date" function. --- templates/content-job_listing.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/content-job_listing.php b/templates/content-job_listing.php index da9f022ca..747b9a110 100644 --- a/templates/content-job_listing.php +++ b/templates/content-job_listing.php @@ -16,9 +16,9 @@
  • -
  • +
  • - \ No newline at end of file + From 55768a6c7c35e2fd844b36925e223e4e93824806 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:02:09 -0400 Subject: [PATCH 05/11] Updated the date output for the single job listing to use the "the_job_publish_date" function. --- templates/content-single-job_listing-meta.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/content-single-job_listing-meta.php b/templates/content-single-job_listing-meta.php index 7a8ec0745..51d665951 100644 --- a/templates/content-single-job_listing-meta.php +++ b/templates/content-single-job_listing-meta.php @@ -17,7 +17,7 @@
  • -
  • +
  • From 80be5aabfc658bf782ada0b9c5a0ff50da699389 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:05:45 -0400 Subject: [PATCH 06/11] Updated to use "the_job_publish_date" function for rendering the job listing date. --- templates/content-summary-job_listing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/content-summary-job_listing.php b/templates/content-summary-job_listing.php index e30319035..2bdf0b187 100644 --- a/templates/content-summary-job_listing.php +++ b/templates/content-summary-job_listing.php @@ -11,7 +11,7 @@

    -

    +

    From 4f488d2fa9de1c4e6ee2c63ffc2ba4c5ccf82e74 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:10:43 -0400 Subject: [PATCH 07/11] Updated the "the_job_publish_date" function to include the element. --- wp-job-manager-template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-job-manager-template.php b/wp-job-manager-template.php index 0330605b5..a1d253278 100644 --- a/wp-job-manager-template.php +++ b/wp-job-manager-template.php @@ -275,10 +275,12 @@ function the_job_publish_date( $post = null ) { $date_format = get_option( 'job_manager_date_format' ); if ( $date_format === 'default' ) { - the_time( get_option( 'date_format' ) ); + $display_date = get_the_time( get_option( 'date_format' ) ); } else { - printf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); + $display_date = sprintf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); } + + echo '' . $display_date . ''; } From ed396559f5f44e122d40547d277d908b228d0cd0 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:11:43 -0400 Subject: [PATCH 08/11] Removed redundent element. --- templates/content-job_listing.php | 2 +- templates/content-single-job_listing-meta.php | 2 +- templates/content-summary-job_listing.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/content-job_listing.php b/templates/content-job_listing.php index 747b9a110..6a1772318 100644 --- a/templates/content-job_listing.php +++ b/templates/content-job_listing.php @@ -16,7 +16,7 @@
  • -
  • +
  • diff --git a/templates/content-single-job_listing-meta.php b/templates/content-single-job_listing-meta.php index 51d665951..1491e80c6 100644 --- a/templates/content-single-job_listing-meta.php +++ b/templates/content-single-job_listing-meta.php @@ -17,7 +17,7 @@
  • -
  • +
  • diff --git a/templates/content-summary-job_listing.php b/templates/content-summary-job_listing.php index 2bdf0b187..b59dc6400 100644 --- a/templates/content-summary-job_listing.php +++ b/templates/content-summary-job_listing.php @@ -11,7 +11,7 @@

    -

    +

    From 9594776b3ff08f5d565576da9978cd88e205fa54 Mon Sep 17 00:00:00 2001 From: Christian Nolen Date: Mon, 12 Sep 2016 13:20:06 -0400 Subject: [PATCH 09/11] Updated "the_job_publish_date" to use the