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

Enhancement / Date format setting #757

Merged
merged 12 commits into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions includes/admin/class-wp-job-manager-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
)
),
array(
'name' => 'job_manager_enable_types',
'std' => '1',
Expand Down
2 changes: 1 addition & 1 deletion templates/content-job_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<?php if ( get_option( 'job_manager_enable_types' ) ) { ?>
<li class="job-type <?php echo get_the_job_type() ? sanitize_title( get_the_job_type()->slug ) : ''; ?>"><?php the_job_type(); ?></li>
<?php } ?>
<li class="date"><date><?php printf( __( '%s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); ?></date></li>
<li class="date"><?php the_job_publish_date(); ?></li>

<?php do_action( 'job_listing_meta_end' ); ?>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion templates/content-single-job_listing-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<li class="location" itemprop="jobLocation"><?php the_job_location(); ?></li>

<li class="date-posted" itemprop="datePosted"><date><?php printf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); ?></date></li>
<li class="date-posted" itemprop="datePosted"><?php the_job_publish_date(); ?></li>

<?php if ( is_position_filled() ) : ?>
<li class="position-filled"><?php _e( 'This position has been filled', 'wp-job-manager' ); ?></li>
Expand Down
2 changes: 1 addition & 1 deletion templates/content-summary-job_listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<h1><?php the_title(); ?></h1>

<p class="meta"><?php the_job_location( false ); ?> &mdash; <date><?php printf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) ); ?></date></p>
<p class="meta"><?php the_job_location( false ); ?> &mdash; <?php the_job_publish_date(); ?></p>

</div>
</a>
34 changes: 34 additions & 0 deletions wp-job-manager-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,40 @@ 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' ) {
$display_date = __( 'Posted on ', 'wp-job-manager' ) . get_post_time( get_option( 'date_format' ) );
} else {
$display_date = sprintf( __( 'Posted %s ago', 'wp-job-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) );
}

echo '<time datetime="' . get_post_time( 'Y-m-d' ) . '">' . $display_date . '</time>';
}


/**
* 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_post_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
Expand Down