Skip to content

Commit

Permalink
Add plugin and setup files
Browse files Browse the repository at this point in the history
  • Loading branch information
jrrdnx committed Nov 1, 2016
1 parent a304e91 commit 7b9a49e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# RD-Cache-Breaker
Appends the last modified time (unix timestamp) to the specified file
Appends the last modified time (unix timestamp) to the specified file:

```html
<link href="{exp:rd_cache_breaker file='/path/to/file' separator='?'}" rel="stylesheet" />
```

This plugin will determine the time that the file was last modified and append that unix timestamp to the file path using the separator, like so: `/path/to/file?1234567890`
11 changes: 11 additions & 0 deletions system/user/addons/rd_cache_breaker/addon.setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return array(
'author' => 'Reusser Design',
'author_url' => 'http://reusserdesign.com',
'docs_url' => 'https://github.com/reusserdesign/RD-Cache-Breaker',
'name' => 'RD Cache Breaker',
'description' => 'Appends the last modified time (unix timestamp) to the specified file.',
'version' => '3.0.2',
'namespace' => 'RDCacheBreaker'
);
55 changes: 55 additions & 0 deletions system/user/addons/rd_cache_breaker/pi.rd_cache_breaker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* RD Cache Breaker
*
* @package ExpressionEngine
* @category Plugin
* @author Jarrod D Nix, Reusser Design
* @license https://opensource.org/licenses/MIT The MIT License (MIT)
*/

class Rd_cache_breaker
{

public $return_data = "";

// --------------------------------------------------------------------

/**
* RD Cache Breaker
*
* This function appends the last modified time (unix timestamp) to the specified file
*
* @access public
* @return string
*/
public function __construct()
{

$return = '';

if (version_compare(APP_VER, '3', '>='))
{
$file = ee()->TMPL->fetch_param('file') ? ee()->TMPL->fetch_param('file') : FALSE;
$separator = ee()->TMPL->fetch_param('separator') ? ee()->TMPL->fetch_param('separator') : "?";

if($file && file_exists($_SERVER['DOCUMENT_ROOT'].$file)) {
$return = $file;
$time = filemtime($_SERVER['DOCUMENT_ROOT'].$file);
if ($time !== FALSE)
{
$return .= $separator . $time;
}
}
}

$this->return_data = $return;

}

}


/* End of file pi.rd_cache_breaker.php */
/* Location: ./system/user/addons/rd_cache_breaker/pi.rd_cache_breaker.php */

0 comments on commit 7b9a49e

Please sign in to comment.