';
// return $output;
//}
//safe_post event
add_action( 'save_post', 'updateHash' );
function updateHash( $post_id ){
if ( !wp_is_post_revision( $post_id ) ) {
global $wpdb;
$isset = $wpdb->get_results("
SELECT option_value
FROM wp_options
WHERE option_name='appcacheupdatehash$post_id'
");
if(empty($isset)){
$hash = md5(time());
$wpdb->query("
INSERT INTO wp_options (option_name, option_value)
VALUES ('appcacheupdatehash$post_id','".$hash."')
");
}else{
$hash = md5(time());
$wpdb->query("
UPDATE wp_options
SET option_value='".$hash."'
WHERE option_name='appcacheupdatehash$post_id'
");
}
}
}
if(in_array("HTTP_REFERRER", $_SERVER)){
header('Content-Type: text/plain');
}
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
add_options_page('Appcache Settings', 'Appcache', 'manage_options', 'plugin', 'plugin_options_page');
}
function plugin_options_page() {
?>
Appcache Settings
FIRST: Simply add the manifest="" statement to your html tag in your theme's header.php file.
<\html manifest="<\?php echo site_url(); ?>/wp-content/plugins/appcache/manifest.appcache.php?appcache_id=<\?php echo the_ID()."&referrer=".urlencode($_SERVER['SCRIPT_URL']); ?>"> And remove the backslashes obviously.
Per default this plugin runs through the (currently activated) theme directory and caches it.
If you use the Advanced Customfields Plugin (http://www.advancedcustomfields.com/) be sure to tick the checkbox below. The Images will then be cached.
The text-input-fields below are for extra folders that you want to be cached. e.g. if you want to cache the /wp-content/uploads folder just type it in the inputfield. the '/' at the beginning and at the end are optional. ONLY USE URLs relative to the home directory (where your wp-config.php is).
This script ignores .less, .sass, .scss files per default - you can add other file-extensions in your configuration below. These are global settings.
";
echo " Do you use the Customfields plugin? ";
echo "
Enter filetypes you want to ignore: e.g.: .md or .txt (each seperated only with a vertical bar - no space in between) like: .md|.txt|.sql
";
echo"";
echo "
disable dynamic filecaching in current theme directory
";
echo "
Your Customfolders you want to be cached: use relative url like: \"/wp-content/uploads/\"
";
echo "
disable dynamic filecaching:
";
echo "
disable dynamic filecaching:
";
echo "
disable dynamic filecaching:
";
echo "
disable dynamic filecaching:
";
echo "
additional information
If you want to debug the Application cache try the following:
Use Google Chrome: CMD+ALT+J for debugger tool; go to the \"Console\"-Tab you can see the events and files triggered by the Application Cache.
you can see the Cache Manifest at http://www.yoururl.com/wp-content/plugins/appcache/manifest.appcache.php?appcache_id=ID-OF-YOUR-PAGE-OR-ARTICLE&referrer=%2F
This is where you can see all the Files and directories that are cached. Be sure that all images exist. The \"Cache Progress event\" gets cancelled if ONLY ONE FILE is not Found (http error 404).
Type in the Addressbar \"chrome://appcache-internals/\" to see the currently Cached websites.