Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…press-plugins/flags/) and [Nearby](https://development.azurecurve.co.uk/classicpress-plugins/nearby/) to display a country flag next to timeline entry.

 * Fix bug with default timeline parameter when slug not provided.
  • Loading branch information
azurecurve committed Sep 17, 2020
1 parent a8d05f1 commit 3a4cf47
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
56 changes: 51 additions & 5 deletions azrcrv-timelines.php
Expand Up @@ -2,8 +2,8 @@
/**
* ------------------------------------------------------------------------------
* Plugin Name: Timelines
* Description: Create a multiple timelines and place on pages or posts using the timeline shortcode.
* Version: 1.1.6
* Description: Create a timeline and place on pages or posts using the timeline shortcode.
* Version: 1.2.0
* Author: azurecurve
* Author URI: https://development.azurecurve.co.uk/classicpress-plugins/
* Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/timelines/
Expand Down Expand Up @@ -130,7 +130,8 @@ function azrcrv_t_set_default_options($networkwide){
'date' => 'd/m/Y',
'dateleftalignment' => '-150px',
'orderby' => 'Ascending',
'updated' => strtotime('2020-04-04'),
'integrate-with-flags-and-nearby' => 0,
'updated' => strtotime('2020-09-17'),
);

// set defaults for multi-site
Expand Down Expand Up @@ -340,6 +341,26 @@ function azrcrv_t_display_options(){
?>
</select>
</td></tr>

<?php
if (azrcrv_t_is_plugin_active('azrcrv-flags/azrcrv-flags.php')){
$flags = '<a href="admin.php?page=azrcrv-f">Flags</a>';
}else{
$flags = '<a href="https://development.azurecurve.co.uk/classicpress-plugins/flags/">Flags</a>';
}
?>
<?php
if (azrcrv_t_is_plugin_active('azrcrv-nearby/azrcrv-nearby.php')){
$nearby = '<a href="admin.php?page=azrcrv-n">Nearby</a>';
}else{
$nearby = '<a href="https://development.azurecurve.co.uk/classicpress-plugins/nearby/">Nearby</a>';
}
?>
<tr><th scope="row"><label for="integrate-with-flags-and-nearby"><?php printf(__('Integrate with %s and %s?', 'timelines'), $flags, $nearby); ?></label></th><td>
<fieldset><legend class="screen-reader-text"><span><?php printf(esc_html_e('Integrate with %s and %s?', 'timelines'), $flags, $nearby); ?></span></legend>
<label for="integrate-with-flags-and-nearby"><input name="integrate-with-flags-and-nearby" type="checkbox" id="integrate-with-flags-and-nearby" value="1" <?php checked('1', $options['integrate-with-flags-and-nearby']); ?> /><?php esc_html_e('Display flag next to timeline entry', 'timelines'); ?></label>
</fieldset>
</td></tr>

</table>
<input type="submit" value="<?php esc_html_e('Submit', 'timelines'); ?>" class="button-primary"/>
Expand All @@ -349,6 +370,16 @@ function azrcrv_t_display_options(){
<?php
}

/**
* Check if function active (included due to standard function failing due to order of load).
*
* @since 1.2.0
*
*/
function azrcrv_t_is_plugin_active($plugin){
return in_array($plugin, (array) get_option('active_plugins', array()));
}

/**
* Save settings.
*
Expand Down Expand Up @@ -388,12 +419,18 @@ function azrcrv_t_save_options(){
if (isset($_POST[$option_name])){
$options[$option_name] = sanitize_text_field($_POST[$option_name]);
}

$option_name = 'orderby';
if (isset($_POST[$option_name])){
$options[$option_name] = sanitize_text_field($_POST[$option_name]);
}

$option_name = 'integrate-with-flags-and-nearby';
if (isset($_POST[$option_name])){
$options[$option_name] = 1;
}else{
$options[$option_name] = 0;
}

update_option('azrcrv-t', $options);

// Redirect the page to the configuration form that was processed
Expand All @@ -415,7 +452,7 @@ function azrcrv_t_shortcode($atts, $content = null){
$options = get_option('azrcrv-t');

$args = shortcode_atts(array(
'slug' => stripslashes(sanitize_text_field($options['timeline'])),
'slug' => stripslashes(sanitize_text_field($options['default'])),
'color' => stripslashes(sanitize_text_field($options['color'])),
'date' => stripslashes(sanitize_text_field($options['date'])),
'left' => stripslashes(sanitize_text_field($options['dateleftalignment'])),
Expand Down Expand Up @@ -454,11 +491,20 @@ function azrcrv_t_shortcode($atts, $content = null){
$return .= "<li class='azrcrv-t-work'>
<div class='azrcrv-t-relative'>
<span class='azrcrv-t-title'><label class='azcrv-t' for='azrcrv-t-work$count'>".$timeline_entry->post_title;

// get link
$meta_fields = get_post_meta($timeline_entry->ID, 'azc_t_metafields', true);
if (is_array($meta_fields)){
if (isset($meta_fields['timeline-link'])){
if (strlen($meta_fields['timeline-link']) > 0){
$linked_post_id = url_to_postid($meta_fields['timeline-link']);
$linked_post_country = get_post_meta( $linked_post_id, '_azrcrv_n_country', true );
// get country and display flag
if (strlen($linked_post_country) > 0){
$return .= '&nbsp;'.do_shortcode('[flag='.$linked_post_country.']');
}
$return .= "&nbsp;<a href='".$meta_fields['timeline-link']."'><img class='azc_t' src='".plugin_dir_url(__FILE__)."assets/images/link.png' /></a>";

}
}
}
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
@@ -1,12 +1,12 @@
=== Timelines ===

Description: Create timelines showing the sequence of events and place in any post or page using a shortcode.
Version: 1.1.6
Version: 1.2.0
Tags: timeline, timelines, custom post type
Author: azurecurve
Author URI: https://development.azurecurve.co.uk/
Plugin URI: https://development.azurecurve.co.uk/classicpress-plugins/timelines/
Download link: https://github.com/azurecurve/azrcrv-timelines/releases/download/v1.1.6/azrcrv-timelines.zip
Download link: https://github.com/azurecurve/azrcrv-timelines/releases/download/v1.2.0/azrcrv-timelines.zip
Donate link: https://development.azurecurve.co.uk/support-development/
Requires PHP: 5.6
Requires: 1.0.0
Expand All @@ -26,6 +26,8 @@ Create timelines showing the sequence of events and place in any post or page us

Timelines create a custom post type for timeline entry; timelines are used by adding the **[timeline={timeline name}]** shortcode

Integrate with [Flags](https://development.azurecurve.co.uk/classicpress-plugins/flags/) and [Nearby](https://development.azurecurve.co.uk/classicpress-plugins/nearby/) to display a country flag next to timeline entry.; Nearby is required for the setting of a country on a post or page.

This plugin is multisite compatible; each site will need settings to be configured in the admin dashboard.

== Installation ==
Expand All @@ -51,6 +53,10 @@ This plugin is developed for ClassicPress, but will likely work on WordPress.

# Changelog

### [Version 1.2.0](https://github.com/azurecurve/azrcrv-timelines/releases/tag/v1.2.0)
* Integrate with [Flags](https://development.azurecurve.co.uk/classicpress-plugins/flags/) and [Nearby](https://development.azurecurve.co.uk/classicpress-plugins/nearby/) to display a country flag next to timeline entry.
* Fix bug with default timeline parameter when slug not provided.

### [Version 1.1.6](https://github.com/azurecurve/azrcrv-timelines/releases/tag/v1.1.6)
* Fix bug with undefined index in save metabox function.

Expand Down

0 comments on commit 3a4cf47

Please sign in to comment.