You can write long and tedious about the virtues of WordPress, but sometimes with updates, developers surprise me by disabling useful (charms) things, such as “turning off the browser cache in the admin panel”, which happened in the latest update 4.6. * And is still present.
It turns out the following picture - you activate a new theme and when activated, new menu items should appear, for example,
theme settings and others, but when activated, this will not happen because your browser has cached the page and only through
Ctrl + F5 you can get the latest result. So, editors of posts can be overwritten, any changes in the fields that are not updated to the new data. For those who are interested in solving the problem and a mini simple plugin, I ask for cat.
I did not like this for a long time, since I work with a large number of sites made on Wordpress, and I decided to find the problem. I rolled back my own sites to the old version, where everything worked correctly and began to compare the difference, it turned out that the whole problem in the simple
Pragma: no-cache header, which the developers in the new version just cut out from the source code, is that cool? )
And now let's solve this problem, by the way, the plug-in itself can be found through the search for plug-ins in the admin panel on the query “wp admin no cache”, or on the
link . The plugin does not require any settings, just activate and it will work.
')
To implement the plugin, we need to override the array of headers that are passed to the
nocache_headers function via the
wp_get_nocache_headers function.
Let's create a class and the init method that will run our plugin, calling a single filter.
$WPAdminNoCache = new WPAdminNoCache(); $WPAdminNoCache->init(); class WPAdminNoCache { public function init() { add_filter('nocache_headers', array($this, 'addHeader')); } public function addHeader($headers) { $headers['Pragma'] = 'no-cache'; return $headers; } }
Plugin ready. Very small, but very useful.