Skip to content

Commit

Permalink
Merge pull request #16 from EvanHerman/development
Browse files Browse the repository at this point in the history
Merge dev into master
  • Loading branch information
Evan Herman committed May 17, 2016
2 parents 8303326 + f2bc6c2 commit 79c498f
Show file tree
Hide file tree
Showing 19 changed files with 167 additions and 256 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Build Status](https://scrutinizer-ci.com/g/EvanHerman/Timeline-Express/badges/build.png?b=Refactor---v1.2)](https://scrutinizer-ci.com/g/EvanHerman/Timeline-Express/build-status/Refactor---v1.2)
[![Project Stats](https://www.openhub.net/p/timeline-express/widgets/project_thin_badge.gif)](https://www.openhub.net/p/timeline-express)

# Timeline Express - v1.2.4
# Timeline Express - v1.2.5
This repository is a re-factor of the original code base.

[![WordPress plugin](https://img.shields.io/wordpress/plugin/v/timeline-express.svg?style=flat-square)](https://wordpress.org/plugins/timeline-express/)
Expand Down
2 changes: 1 addition & 1 deletion constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Define the current version of Timeline Express
*/
if ( ! defined( 'TIMELINE_EXPRESS_VERSION_CURRENT' ) ) {
define( 'TIMELINE_EXPRESS_VERSION_CURRENT', '1.2.4' );
define( 'TIMELINE_EXPRESS_VERSION_CURRENT', '1.2.5' );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/admin/css/min/timeline-express-admin.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/admin/js/min/timeline-express-admin.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/admin/js/min/timeline-express-tinymce.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Plugin Timeline Express
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.4
* @Build 05-16-2016
* @Version 1.2.5
* @Build 05-17-2016
*/
!function(){tinymce.PluginManager.add("timeline_express",function(a,b){function c(){this.disabled(!this.disabled()),a.insertContent("[timeline-express]")}a.on("keyup",function(){a.getContent().indexOf("[timeline-express]")>-1?a.controlManager.setDisabled("timeline_express_shortcode_button",!0):a.controlManager.setDisabled("timeline_express_shortcode_button",!1)}),a.addButton("timeline_express_shortcode_button",{title:"Timeline Express Shortcode",text:!1,image:b+"/../../images/timeline-express-menu-icon.png",onclick:c}),a.onSetContent.add(function(a,b){a.getContent().indexOf("[timeline-express]")>-1&&a.controlManager.setDisabled("timeline_express_shortcode_button",!0)})})}();
!function(){tinymce.PluginManager.add("timeline_express",function(a,b){function c(){this.disabled(!this.disabled()),a.insertContent("[timeline-express]")}a.on("keyup",function(){a.getContent().indexOf("[timeline-express]")>-1?a.controlManager.setDisabled("timeline_express_shortcode_button",!0):a.controlManager.setDisabled("timeline_express_shortcode_button",!1)}),a.addButton("timeline_express_shortcode_button",{title:"Timeline Express Shortcode",text:!1,image:b+"/../../images/timeline-express-menu-icon.png",onclick:c}),a.onSetContent.add(function(a,b){a.getContent().indexOf("[timeline-express]")>-1&&a.controlManager.setDisabled("timeline_express_shortcode_button",!0)})})}();
7 changes: 0 additions & 7 deletions lib/classes/class.timeline-express-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ public function __construct() {
* @since 1.2
*/
add_action( 'admin_enqueue_scripts', array( $this, 'add_timeline_express_admin_scripts_and_styles' ) );

// Define a custom Timeline Express widget area
register_sidebar( array(
'id' => 'timeline-express-announcement-sidebar',
'name' => __( 'Announcement Widget', 'timeline-express' ),
'description' => __( 'This sidebar displays on all single announcement templates.', 'timeline-express' ),
) );
}

/**
Expand Down
70 changes: 58 additions & 12 deletions lib/classes/class.timeline-express-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ public function __construct() {
/* Define our [timeline-express] shortcode, so it's usable on the frontend */
add_shortcode( 'timeline-express', array( $this, 'process_timeline_express_shortcode' ) );
/* load a custom page template (override the default) */
// add_filter( 'single_template', array( $this, 'timeline_express_announcement_single_page_template' ) );
/* Load custom template */
add_filter( 'template_include', array( $this, 'timeline_express_announcement_single_page_template' ) );
add_filter( 'single_template', array( $this, 'timeline_express_announcement_single_page_template' ) );
/* Filter the single announcement content. */
add_action( 'loop_start', array( $this, 'condition_to_timeline_content' ) );
add_filter( 'the_content', array( $this, 'timeline_express_single_page_content' ), 0 );
/* Enqueue single announcement template styles */
add_action( 'wp_enqueue_scripts', array( $this, 'timeline_express_single_template_styles' ) );
/* Add appropriate container class for sidebar/no-sidebar styles */
add_filter( 'timeline-express-single-container-class', array( $this, 'timeline_express_single_container_classes' ) );
}

/**
Expand Down Expand Up @@ -55,23 +54,70 @@ public function process_timeline_express_shortcode( $atts ) {
* @return string The page template to be used for the single announcements.
* @since 1.2
*/
public function timeline_express_announcement_single_page_template( $template ) {
public function timeline_express_announcement_single_page_template( $single_template ) {
global $post;
if ( ! isset( $post->post_type ) || 'te_announcements' !== $post->post_type ) {
return $template;
if ( ! isset( $post->post_type ) && 'te_announcements' !== $post->post_type ) {
return $single_template;
}
/* If custom template file exists */
if ( file_exists( get_stylesheet_directory() . '/timeline-express/single-announcement-template.php' ) ) {
$template = get_stylesheet_directory() . '/timeline-express/single-announcement-template.php';
} else {
$single_template = get_stylesheet_directory() . '/timeline-express/single-announcement-template.php';
} else if ( file_exists( get_stylesheet_directory() . 'single.php' ) ) {
/* If single.php exists */
$template = TIMELINE_EXPRESS_PATH . 'lib/public/partials/single.timeline-express.php';
$single_template = get_stylesheet_directory() . 'single.php';
} else if ( file_exists( get_stylesheet_directory() . 'page.php' ) ) {
/* If page.php exists */
$single_template = get_stylesheet_directory() . 'page.php';
}
/**
* Return our template, passed through filters
* Legacy Support, 2 filters
*/
return apply_filters( 'timeline_express_single_page_template', apply_filters( 'timeline-express-single-page-template', $template ) );
return apply_filters( 'timeline_express_single_page_template', apply_filters( 'timeline-express-single-page-template', $single_template ) );
}

/**
* Conditional to check which page is being displayed
* - This allows for the proper template
* - This fixes single templates loading in place of the timeline-container template
* when the timeline is displayed inside of a post.
* @param $query array Query object used as the conditional.
* @return null Filter to use when displaying the content.
* @since 1.2.3
*/
public function condition_to_timeline_content( $query ) {
global $wp_query;
if ( $query !== $wp_query ) {
remove_filter( 'the_content', array( $this, 'timeline_express_single_page_content' ) );
}
}

/**
* Filter the content, and load our template in it's place.
* @param array $the_content The page content to filter.
* @return array The single page content to display for this announcement.
* @since 1.0
*/
public function timeline_express_single_page_content( $the_content ) {
global $post, $wp_query;
$post_id = ( isset( $post->ID ) ) ? $post->ID : '';
// When this is not a single post, or it is and it isn't an announcement, abort
if ( ! is_singular() || 'te_announcements' !== $post->post_type || in_the_loop() || ! is_main_query() ) {
return $the_content;
}
// setup the post data
the_post();
ob_start();
/* Store the announcement content from the WYSIWYG editor */
$announcement_content = $the_content;
/* Include the single template */
get_timeline_express_template( 'single-announcement' );
/* Return the output buffering */
$the_content = ob_get_clean();
// reset the post data
wp_reset_postdata();
/* Return announcement meta & append the announcement content */
return apply_filters( 'timeline_express_single_content', $the_content . $announcement_content, $post_id );
}

/**
Expand Down
11 changes: 1 addition & 10 deletions lib/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,6 @@ function get_timeline_express_template( $template_name = 'timeline-container' )
include( TIMELINE_EXPRESS_PATH . 'lib/public/partials/' . $file_name . '.php' );
}

/**
* Generate the parent container class on the single announcement template
* @return [type] [description]
*/
function timeline_express_container_classes( $classes ) {
$container_classes = ( ! is_active_sidebar( 'timeline-express-announcement-sidebar' ) ) ? ' container-full-width' : ' container-two-thirds';
echo 'class="' . esc_attr( $classes . $container_classes ) . '"';
}

/**
* Helper function used to clear out the timeline express transients
* This is fired when the settings are saved, and when an announcement is updated/published
Expand Down Expand Up @@ -424,7 +415,7 @@ function timeline_express_get_announcement_date( $post_id ) {
*/
function timeline_express_get_announcement_content( $post_id ) {
$announcement_object = get_post( $post_id );
return ( isset( $announcement_object->post_content ) ) ? apply_filters( 'the_content', $announcement_object->post_content ) : '';
return ( isset( $announcement_object->post_content ) ) ? $announcement_object->post_content : '';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/public/css/min/timeline-express-single-page.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Plugin Timeline Express
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.4
* @Build 05-16-2016
* @Version 1.2.5
* @Build 05-17-2016
*/
body.single-te_announcements .timeline-express-single-page-announcement-date{display:block;margin:.5em 0}body.single-te_announcements .timeline-express-single-page-content{margin:.5em 0 1em}
Loading

0 comments on commit 79c498f

Please sign in to comment.