Skip to content

Commit

Permalink
Update to 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Herman committed May 12, 2016
1 parent fc76440 commit edd1078
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 102 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.1
# Timeline Express - v1.2.2
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' );
define( 'TIMELINE_EXPRESS_VERSION_CURRENT', '1.2.2' );
}

/**
Expand Down
10 changes: 10 additions & 0 deletions lib/admin/cpt/timeline-express-admin-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
*/
add_filter( 'manage_edit-te_announcements_columns', 'add_new_timeline_express_columns' );
function add_new_timeline_express_columns( $timeline_express_announcement_columns ) {
// Assign a new date column to the end of our table
$date_column = $timeline_express_announcement_columns['date'];
unset( $timeline_express_announcement_columns['date'] );
foreach( $timeline_express_announcement_columns as $key => $value ) {
if( $key === 'past_announcement' ) { // when we find the date column
$new['date'] = $date_column; // put the tags column before it
}
$new[ $key ] = $value;
}
$timeline_express_announcement_columns['cb'] = '<input type="checkbox" />';
$timeline_express_announcement_columns['title'] = sprintf( _x( '%s Name', 'timeline-express' ), apply_filters( 'timeline_express_singular_name', 'Announcement' ) );
$timeline_express_announcement_columns['color'] = _x( 'Color', 'timeline-express' );
Expand All @@ -30,6 +39,7 @@ function add_new_timeline_express_columns( $timeline_express_announcement_column
$timeline_express_announcement_columns['announcement_date'] = sprintf( _x( '%s Date', 'timeline-express' ), apply_filters( 'timeline_express_singular_name', 'Announcement' ) );
$timeline_express_announcement_columns['image'] = _x( 'Image', 'timeline-express' );
$timeline_express_announcement_columns['past_announcement'] = sprintf( _x( '%s Past?', 'timeline-express' ), apply_filters( 'timeline_express_singular_name', 'Announcement' ) );
$timeline_express_announcement_columns['date'] = 'Published Date';
return $timeline_express_announcement_columns;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/admin/css/min/timeline-express-admin.min.css

Large diffs are not rendered by default.

50 changes: 13 additions & 37 deletions lib/admin/css/timeline-express-settings.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/admin/js/min/timeline-express-admin.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/admin/js/min/timeline-express-tinymce.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.0
* @Build 05-09-2016
* @Build 05-10-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)})})}();
33 changes: 31 additions & 2 deletions lib/admin/metaboxes/metaboxes.announcements.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'default' => 'fa-' . $timeline_express_options['default-announcement-icon'],
) );

// Email text field
// Announcement Date
$announcement_metabox->add_field( array(
'name' => __( 'Announcement Date', 'timeline-express' ),
'desc' => __( 'Enter the date of the announcement. the announcements will appear in chronological order according to this date. ', 'timeline-express' ),
Expand All @@ -46,7 +46,7 @@
'default' => strtotime( date( 'm/d/Y' ) ),
) );

// Email text field
// Announcement Image
$announcement_metabox->add_field( array(
'name' => __( 'Announcement Image', 'timeline-express' ),
'desc' => __( 'Select a banner image for this announcement (optional). (recommended 650px wide or larger)', 'timeline-express' ),
Expand Down Expand Up @@ -197,3 +197,32 @@

// Action hook to allow users to hook in and define new metaboxes
do_action( 'timeline_express_metaboxes', $timeline_express_options );

/**
* Localize the datepicker fields for international Users
* @resource https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/filters-and-actions/localize-date-format.php
* @since 1.2.2
*/
add_filter( 'cmb2_localized_data', 'timeline_express_internationalize_datepicker' );
function timeline_express_internationalize_datepicker( $l10n ) {
switch ( get_option( 'date_format' ) ) {
// EG: 04/15/2016 - April 15th, 2016
default:
case 'm/d/Y':
$l10n['defaults']['date_picker']['dateFormat'] = 'mm/dd/yy';
break;
// EG: 2016-04-15 - April 15th, 2016
case 'd/m/Y':
case 'd/M/Y':
case 'd-m-Y':
$l10n['defaults']['date_picker']['dateFormat'] = 'dd/mm/yy';
break;
case 'Y-m-d':
$l10n['defaults']['date_picker']['dateFormat'] = 'yy-mm-dd';
break;
case 'F j, Y':
$l10n['defaults']['date_picker']['dateFormat'] = 'MM d, yy';
break;
}
return apply_filters( 'timeline_express_date_picker_format', $l10n );
}
9 changes: 5 additions & 4 deletions lib/admin/metaboxes/partials/time-stamp-custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
#ui-datepicker-div { z-index: 99999 !important; }
#wpbody-content { overflow: hidden !important; }
.cmb_id_announcement_image td .cmb_upload_button { height: 32px !important; }
#announcement_date { width: auto !important; }
</style>

<?php
if ( $meta && isset( $meta ) ) {
$value = ( '' !== $meta ) ? apply_filters( 'timeline_express_admin_render_date_format', date( 'm/d/Y', $meta ), $meta ) : $field->args['default'];
echo '<input class="cmb2-text-small cmb2-datepicker" type="text" name="' . esc_attr__( $field->args['id'] ) . '" id="' . esc_attr__( $field->args['id'] ) . '" value="' . esc_attr__( $value ) . '" />';
$value = ( '' !== $meta ) ? apply_filters( 'timeline_express_admin_render_date_format', date( get_option( 'date_format' ), $meta ), $meta ) : $field->args['default'];
echo '<input class="cmb2-text-small cmb2-datepicker" type="text" name="' . esc_attr( $field->args['id'] ) . '" id="' . esc_attr( $field->args['id'] ) . '" value="' . esc_attr( $value ) . '" />';
} else {
echo '<input class="cmb2-text-small cmb2-datepicker" type="text" name="' . esc_attr__( $field->args['id'] ) . '" id="' . esc_attr__( $field->args['id'] ) . '" value="' . esc_attr__( apply_filters( 'timeline_express_admin_render_date_format', date( 'm/d/Y' ), false ) ) .'" />';
echo '<input class="cmb2-text-small cmb2-datepicker" type="text" name="' . esc_attr( $field->args['id'] ) . '" id="' . esc_attr( $field->args['id'] ) . '" value="' . esc_attr( apply_filters( 'timeline_express_admin_render_date_format', date( get_option( 'date_format' ) ), false ) ) .'" />';
}
echo '<p class="cmb2-metabox-description">' . esc_attr__( $field->args['desc'] ) . '</p>';
echo '<p class="cmb2-metabox-description">' . esc_attr( $field->args['desc'] ) . '</p>';
49 changes: 38 additions & 11 deletions lib/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function cmb2_render_callback_te_help_docs_metabox( $field, $meta, $object_id, $
*/
function cmb2_sanitize_te_date_time_stamp_custom_callback( $value, $new ) {
if ( isset( $new ) && ! empty( $new ) ) {
return apply_filters( 'timeline_express_sanitize_date_format', strtotime( $new ), $new );
$date_object = date_create_from_format( get_option( 'date_format' ), $new );
return $date_object ? apply_filters( 'timeline_express_sanitize_date_format', $date_object->setTime( 0, 0, 0 )->getTimeStamp(), $new ) : apply_filters( 'timeline_express_sanitize_date_format', strtotime( $new ), $new );
}
/* If all else fails, return current date/time UNIX time stamp */
return strtotime( 'now' );
Expand Down Expand Up @@ -365,8 +366,8 @@ function timeline_express_get_announcement_icon_markup( $post_id ) {
return $custom_icon_html;
}
/* If read more visibility is set to true, wrap the icon in a link. */
if ( 0 !== $timeline_express_options['read-more-visibility'] ) { ?>
<a class="cd-timeline-icon-link" href="<?php esc_attr_e( get_the_permalink( $post_id ) ); ?>">
if ( '1' === $timeline_express_options['read-more-visibility'] ) { ?>
<a class="cd-timeline-icon-link" href="<?php echo esc_attr( apply_filters( 'timeline-express-read-more-link', esc_url( get_the_permalink( $post_id ) ) ) ); ?>">
<?php } ?>
<div class="cd-timeline-img cd-picture" style="background:<?php esc_attr_e( timeline_express_get_announcement_icon_color( $post_id ) ); ?>;">
<!-- Custom Action Hook -->
Expand All @@ -384,7 +385,7 @@ function timeline_express_get_announcement_icon_markup( $post_id ) {
</div> <!-- cd-timeline-img -->
<?php
/* If read more visibility is set to true, wrap the icon in a link. */
if ( 0 !== $timeline_express_options['read-more-visibility'] ) { ?>
if ( '1' === $timeline_express_options['read-more-visibility'] ) { ?>
</a>
<?php }
}
Expand Down Expand Up @@ -453,37 +454,63 @@ function timeline_express_get_announcement_content( $post_id ) {
*/
function timeline_express_get_announcement_excerpt( $post_id ) {
/* Setup the excerpt */
return apply_filters( 'timeline_express_frontend_excerpt', get_the_excerpt(), $post_id );
return apply_filters( 'the_content', apply_filters( 'timeline_express_frontend_excerpt', get_the_excerpt(), $post_id ) );
}

/**
* Setup a custom or random excerpt length based on the options set in the settings
* @return string The announcement excerpt
* @since 1.2
*/
add_filter( 'excerpt_length', 'timeline_express_custom_excerpt_length' );
add_filter( 'excerpt_length', 'timeline_express_custom_excerpt_length', 999 );
function timeline_express_custom_excerpt_length( $length ) {
global $post;
// if not an announcement post, abort
if ( 'te_announcements' !== get_post_type( $post ) ) {
return $length;
}
$timeline_express_options = timeline_express_get_options();
if ( 1 === $timeline_express_options['excerpt-random-length'] ) {
$random_length = (int) rand( apply_filters( 'timeline_express_random_excerpt_min', 50 ), apply_filters( 'timeline_express_random_excerpt_max', 200 ) );
return (int) $random_length;
}
return $length;
return (int) apply_filters( 'timeline_express_excerpt_length', $timeline_express_options['excerpt-trim-length'] );
}

/**
* Filter the read more links to a custom state
* Trim the excerpt and add ellipses to the end fo it
* @param string $more The default HTML markup for the read more link.
* @since 1.2
*/
add_filter( 'excerpt_more', 'timeline_express_custom_read_more', 999 );
function timeline_express_custom_read_more( $more ) {
global $post;
$timeline_express_options = timeline_express_get_options();
if ( '1' !== $timeline_express_options['read-more-visibility'] || 'te_announcements' !== get_post_type( $post ) ) {
// if not timeline post
if ( 'te_announcements' !== get_post_type( $post ) ) {
return $more;
}
return apply_filters( 'timeline_express_read_more_link', '... <a class="' . esc_attr__( apply_filters( 'timeline_express_read_more_class', 'timeline-express-read-more-link', $post->ID ) ) . '" href="'. esc_attr__( esc_url( get_permalink( $post->ID ) ) ) . '"> ' . esc_attr__( apply_filters( 'timeline_express_read_more_text', __( 'Read more', 'timeline-express' ), $post->ID ) ) . '</a>', $post->ID );
// if read more visibility is set to hidden
if ( '1' !== $timeline_express_options['read-more-visibility'] ) {
return '';
}
// return the default
return apply_filters( 'timeline_express_read_more_ellipses', '...' );
}

/**
* Hook in and generate a read more link below each announcement
* @return string HTML markup for the new read me link.
*/
add_action( 'timeline-express-after-excerpt', 'timeline_express_custom_read_more_link', 10 );
function timeline_express_custom_read_more_link() {
global $post;
$timeline_express_options = timeline_express_get_options();
// if read more visibility is set to hidden
if ( '1' !== $timeline_express_options['read-more-visibility'] ) {
return;
}
echo wp_kses_post( apply_filters( 'timeline_express_read_more_link', '<a class="' . esc_attr( apply_filters( 'timeline_express_read_more_class', 'timeline-express-read-more-link', $post->ID ) ) . '" href="'. apply_filters( 'timeline-express-read-more-link', esc_url( get_permalink( $post->ID ) ), $post->ID ) . '"> ' . esc_attr( apply_filters( 'timeline_express_read_more_text', __( 'Read more', 'timeline-express' ), $post->ID ) ) . '</a>', $post->ID ) );
}

/**
Expand All @@ -492,7 +519,7 @@ function timeline_express_custom_read_more( $more ) {
* @return string The announcement excerpt of random length
*/
function timeline_express_generate_random_announcement( $post_id ) {
return apply_filters( 'timeline_express_random_excerpt', get_the_content( $post_id ), $post_id );
return apply_filters( 'the_content', apply_filters( 'timeline_express_random_excerpt', get_the_excerpt(), $post_id ) );
}

/**
Expand Down
16 changes: 1 addition & 15 deletions lib/public/css/min/timeline-express-single-page.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.0
* @Build 05-09-2016
*/
/*
* @Plugin Timeline Express
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.0
* @Build 05-08-2016
*/
/*
* @Plugin Timeline Express
* @Author Code Parrots
* @Site http://www.wp-timelineexpress.com
* @Version 1.2.0
* @Build 05-08-2016
* @Build 05-10-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 edd1078

Please sign in to comment.