[PR] Refactor codebase to remove unnecessary applyWpFilters() and doWpAction()#317
Open
[PR] Refactor codebase to remove unnecessary applyWpFilters() and doWpAction()#317
Conversation
Now that WordPress is exposing the standard WP hook/filter library in the early phase, we don't need our own method for this. This also drops backwards compatibility with ZenCache filters. ZenCache has not been supported for more than a year now. See wpsharks/comet-cache#893
Now that WordPress is exposing the standard WP hook/filter library in the early phase, we don't need our own method for this. This also drops backwards compatibility with ZenCache actions. ZenCache has not been supported for more than a year now. See wpsharks/comet-cache#893
Contributor
Author
|
@jaswrks How about |
Contributor
|
@raamdev writes...
Awesome work on removing I think the following would work:
New AC Plugin Example<?php
/**
* Example AC (Advanced Cache) Plugin File.
*
* If implemented; this file should go in this special directory:
* `/wp-content/ac-plugins/my-ac-plugin.php`
*/
if (!defined('WPINC')) {
exit('Do NOT access this file directly.');
}
function my_ac_version_salt_shaker($version_salt)
{
if (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') !== false) {
$version_salt .= 'iphones'; // Give iPhones their own variation of the cache.
} elseif (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'android') !== false) {
$version_salt .= 'androids'; // Androic variation.
} else {
$version_salt .= 'other'; // A default group.
}
return $version_salt;
}
add_filter('comet_cache_version_salt', 'my_ac_version_salt_shaker');Old AC Plugin Example<?php
/**
* Example AC (Advanced Cache) Plugin File.
*
* If implemented; this file should go in this special directory:
* `/wp-content/ac-plugins/my-ac-plugin.php`
*/
if (!defined('WPINC')) {
exit('Do NOT access this file directly.');
}
function my_ac_plugin() // Example plugin.
{
$ac = $GLOBALS['comet_cache_advanced_cache']; // Comet Cache instance.
$ac->addFilter('comet_cache_version_salt', 'my_ac_version_salt_shaker');
}
function my_ac_version_salt_shaker($version_salt)
{
if (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') !== false) {
$version_salt .= 'iphones'; // Give iPhones their own variation of the cache.
} elseif (mb_stripos($_SERVER['HTTP_USER_AGENT'], 'android') !== false) {
$version_salt .= 'androids'; // Androic variation.
} else {
$version_salt .= 'other'; // A default group.
}
return $version_salt;
}
my_ac_plugin(); // Run this plugin.The only change is that you can now call WP core functions in this early phase. You still need a special file in the |
jaswrks
approved these changes
May 27, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See: wpsharks/comet-cache#893