Skip to content
Open
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
12 changes: 12 additions & 0 deletions countdown/addon.setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return [
'author' => 'Jack McDade, EEHarbor',
'author_url' => 'https://eeharbor.com/',
'name' => 'Countdown',
'description' => 'Countdown plug-in allows you to insert a simple countdown to a specified date into your templates.',
'version' => '1.0.0',
'namespace' => 'EEHarbor\Countdown',
'settings_exist' => false,
// Advanced settings
];
1 change: 1 addition & 0 deletions countdown/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Directory access is forbidden.
40 changes: 40 additions & 0 deletions countdown/pi.countdown.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

if (! defined('BASEPATH')) {
exit('No direct script access allowed');
}

class Countdown
{
public $return_data = "";

public function __construct()
{
$day = ee()->TMPL->fetch_param('day');
$month = ee()->TMPL->fetch_param('month');
$year = ee()->TMPL->fetch_param('year');
$hour = ee()->TMPL->fetch_param('hour');

// get current unix timestamp
$today = time();

//make unix timestamp for given date
$countdowndate = mktime(0, 0, $hour, $month, $day, $year);

//calculate difference
$difference = $countdowndate - $today;
$difference = $difference < 0 ? 0 : $difference;

$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);

$variables = array();
$variables[] = array(
'days' => $days_left,
'hours' => $hours_left
);

$this->return_data = ee()->TMPL->parse_variables(ee()->TMPL->tagdata, $variables);
return $this->return_data;
}
}
1 change: 0 additions & 1 deletion pi.countdown.php

This file was deleted.