diff --git a/README.txt b/README.txt index b50104c..f1f3353 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ === Plugin Name === Contributors: alexkingorg, crowdfavorite Tags: content, timeline, display, presentation, story, storyline, context -Requires at least: 3.5 -Tested up to: 3.5.1 +Requires at least: 4.4.0 +Tested up to: 4.5.1 Stable tag: 1.0b1 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/threads.php b/threads.php index 3945e6f..57c2093 100644 --- a/threads.php +++ b/threads.php @@ -135,12 +135,16 @@ function cfth_thread_notice($posts, $query) { function cfth_timeline_posts($term_id) { $term = get_term_by('id', $term_id, 'threads'); + if ( function_exists( 'get_term_meta' ) ) { + $term_meta = get_term_meta( $term_id, 'threads_meta', true ); + } + $order = isset( $term_meta['order_term_meta'] ) ? $term_meta['order_term_meta'] : 'ASC'; if ($term) { $query_params = apply_filters('threads_timeline_posts_query', array( 'posts_per_page' => -1, 'taxonomy' => 'threads', 'term' => $term->slug, - 'order' => 'ASC', + 'order' => $order, )); $query = new WP_Query($query_params); return $query->posts; @@ -149,6 +153,11 @@ function cfth_timeline_posts($term_id) { } function cfth_timeline_content($term_id) { + $term = get_term_by('id', $term_id, 'threads'); + if ( function_exists( 'get_term_meta' ) ) { + $term_meta = get_term_meta( $term_id, 'threads_meta', true ); + } + $order = isset( $term_meta['order_term_meta'] ) ? $term_meta['order_term_meta'] : 'ASC'; $posts = cfth_timeline_posts($term_id); if (!count($posts)) { return array(); @@ -170,7 +179,14 @@ function cfth_timeline_content($term_id) { if ($prev) { $prev_timestamp = strtotime($prev->post_date_gmt); $this_timestamp = strtotime($_post->post_date_gmt); - $prev->threads_data['time_offset'] = $this_timestamp - $prev_timestamp; + + if( isset( $term_meta['order_term_meta'] ) && 'DESC' === $term_meta['order_term_meta'] ) { + // offset calculation if post order selected as DESC. + $prev->threads_data['time_offset'] = $prev_timestamp - $this_timestamp; + } else { + // offset calculation if post order selected as ASC. + $prev->threads_data['time_offset'] = $this_timestamp - $prev_timestamp; + } } $prev = $_post; } @@ -375,3 +391,66 @@ function cfth_timeline_css() { +
+ + +

+
+term_id, 'threads_meta', true ); + } + ?> + + + + + +

+ + +