Additions to "supercache_filename_str" action not applied; proposed fix
-
Trying to implement geotargeting without losing the benefits of caching, I found this discussion very helpful.
Following one of Donncha’s suggestions, I wrote a plugin of my own (although based on the very nice Visitor Country by Izhaki) to set up a
supercache_filename_str
cache action, in the hope of thereby obtaining one set of cache files per country. E.g.,index.html
would be replaced byindex-SE.html
,index-US.html
etc.Turning on the debugging feature, I was happy to see that WP Super Cache now checked for
index-SE.html
, rather thanindex.html
. However, the newly generated file was still saved asindex.html
.The problem seems to have been that the function
supercache_filename
inwp-cache-phase1.php
callsapply_filters
rather thando_cacheaction
once the previous function is available. This is normally fine, sincesupercache_filename_str
is converted into a filter by the functionwp_cache_phase2
inwp-cache-phase2.php
. However, my addition tosupercache_filename_str
was not.To get my plugin working, I therefore edited
wp_cache_phase2.php
, addingglobal $wp_supercache_actions;
at the top and replacing
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
by
foreach($wp_supercache_actions['supercache_filename_str'] as $key => $action) add_filter( 'supercache_filename_str', $action);
To my great joy, this seems to have solved my problem!
If the above addresses a real issue with WP Super Cache, and isn’t just some sort of misunderstanding on my part, feel free to include it (or another, better solution) in a future release.
Best regards,
Erik Nordblad,
Stockholm, Sweden
- The topic ‘Additions to "supercache_filename_str" action not applied; proposed fix’ is closed to new replies.