'; // 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.

"; } function plugin_options_validate($input) { $options = get_option('appcache_plugin'); $options['url1'] = $input['url1']; $options['url2'] = $input['url2']; $options['url3'] = $input['url3']; $options['url4'] = $input['url4']; $options['ddf1'] = $input['ddf1']; $options['ddf2'] = $input['ddf2']; $options['ddf3'] = $input['ddf3']; $options['ddf4'] = $input['ddf4']; $options['theme_dynamic_caching'] = $input['theme_dynamic_caching']; $options['ignored_files'] = $input['ignored_files']; $options['customfield'] = $input['customfield']; return $options; } }else{ header("Content-type: text/html; charset=windows-1252"); ?> Application cache plugin

Hello, world!

If you're looking for this application cache plugin visit: wordpress plugins.

fwd.io
'true'); } $template = $wpdb->get_results("SELECT option_value FROM wp_options WHERE option_name='template'"); $dbhash = $wpdb->get_results(" SELECT option_value FROM wp_options WHERE option_name='appcacheupdatehash$appcache_id' "); header("Content-Type: text/cache-manifest"); echo "CACHE MANIFEST\n"; if($dbhash[0]->option_value != ''){ echo "# version: ".$dbhash[0]->option_value."\n"; }else{ echo '# version: v1.0'; } //echo "# timestamp: ".time()."\n"; echo "\nCACHE:\n"; /********************************************* * CACHE POST-SPECIFIC IMAGES FROM postmeta *********************************************/ echo "#cache id @ wp_postmeta\n"; $postimg = $wpdb->get_results(" SELECT meta_value FROM wp_postmeta WHERE post_id=$appcache_id "); foreach($postimg as $content){ if($content->meta_value != ''){ $doc = new DOMDocument(); $doc->strictErrorChecking = false; // $doc throws an error, cause html is not well-formed @$doc->loadHTML($content->meta_value); $imageTags = $doc->getElementsByTagName('img'); foreach($imageTags as $tag){ echo $tag->getAttribute('src')."\n"; } }else{ echo "#none.\n"; } } /********************************************* * CACHE POST-SPECIFIC IMAGES FROM wp_posts *********************************************/ echo "#cache id @ wp_posts\n"; $postimg = $wpdb->get_results("SELECT post_content FROM wp_posts WHERE ID=$appcache_id "); foreach($postimg as $content){ if($content->post_content != ''){ $doc = new DOMDocument(); $doc->strictErrorChecking = false; // $doc throws an error, cause html is not well-formed @$doc->loadHTML($content->post_content); $imageTags = $doc->getElementsByTagName('img'); foreach($imageTags as $tag){ echo $tag->getAttribute('src')."\n"; } }else{ echo "#none.\n"; } } /********************************************* * PARSE TEXTWIDGETS FOR IMAGE TAGS *********************************************/ echo "#cache widgets @ wp_options\n"; $textwidget = $wpdb->get_results("SELECT option_value FROM wp_options WHERE option_name LIKE '%widget%' AND autoload='yes'"); foreach($textwidget as $content){ if($content->option_value != ''){ $doc = new DOMDocument(); $doc->strictErrorChecking = false; // $doc throws an error, cause html is not well-formed @$doc->loadHTML($content->option_value); $imageTags = $doc->getElementsByTagName('img'); foreach($imageTags as $tag){ echo $tag->getAttribute('src')."\n"; } }else{ echo "#none.\n"; } } /********************************************* * PARSE wp_postmeta for customfields *********************************************/ echo "#cache customfields: ".$appcache_plugin_options['customfield']."\n"; if($appcache_plugin_options['customfield'] == 'true'){ $customfields = $wpdb->get_results("SELECT meta_value FROM wp_postmeta WHERE post_id=$appcache_id "); //check if meta_value is INT $matches = array(); foreach($customfields as $field){ if(!preg_match('/[a-zA-Z:,;"{}\/]+/', $field->meta_value)){ if(preg_match('/[0-9]{1,7}/', $field->meta_value)){ $matches[] = $field->meta_value; } } } // lookup the values in the database foreach($matches as $content){ if($content != ''){ $guid = $wpdb->get_results(" SELECT guid FROM wp_posts WHERE id=$content AND post_type='attachment' AND ( post_mime_type='image/png' OR post_mime_type='image/jpeg' OR post_mime_type='image/gif' ) "); foreach($guid as $url){ $result[] = $url->guid; echo $url->guid."\n"; } } } if(empty($result)){echo "#no matches for this post.\n";} } /********************************************* * PARSE FRONTPAGE POSTS FOR IMAGE TAGS *********************************************/ echo "#frontpage posts\n"; if($_GET['referrer'] == '/'){ $entries_count = $wpdb->get_results(" SELECT option_value FROM wp_options WHERE option_name='posts_per_page' AND autoload='yes'"); $count = $entries_count[0]->option_value; $posts = $wpdb->get_results(" SELECT post_content FROM wp_posts WHERE post_type='post' AND post_parent=0 AND post_status='publish' ORDER BY post_date DESC LIMIT 0, $count "); if(!empty($posts)){ foreach($posts as $content){ //parse html for IMG tag and echo out SRC $doc = new DOMDocument(); $doc->loadHTML($content->post_content); $imageTags = $doc->getElementsByTagName('img'); foreach($imageTags as $tag){ echo $tag->getAttribute('src')."\n"; } } }else{ echo "#none.\n"; } }else{ echo "#not for this page!\n"; } /************************** **** CACHE THEME DIRECTORY **************************/ echo "\n#Cached Folders:\n"; $theme = get_bloginfo('stylesheet_directory'); $slash = strrpos($theme,"/"); $themename = substr($theme, $slash); $themename = str_replace("/", "", $themename); run_dir("../../themes/".$themename."/", 'php', $appcache_plugin_options['theme_dynamic_caching'], $appcache_plugin_options['ignored_files']); /************************** **** CACHE CUSTOM FOLDERS **************************/ if($appcache_plugin_options !== false){ foreach($appcache_plugin_options as $key=>$folder){ if(substr($key, 0, 3) == 'url' && !empty($folder)){ //check first char $fc = substr($folder,0,1); if($fc != '/'){ $folder = '/'.$folder; } //check last char $lc = substr($folder, -1, 1); if($lc != '/'){ $folder = $folder.'/'; } $id = substr($key, -1, 1); $option = $appcache_plugin_options['ddf'.$id]; if(empty($option)){ $option == FALSE; } echo "#".$folder."\n"; run_dir('../../..'.$folder, '.php', $option, $appcache_plugin_options['ignored_files']); }else{ continue; } } } foreach($run_dir['cache'] as $key=>$value){ if(file_exists($value)){ echo $value."\n"; } } echo "\nNETWORK:\n*\n"; } ?>