Answer the question
In order to leave comments, you need to log in
Correctly migrate Wordpress which uses caching?
There are problems with migrating wordpress to a local machine for editing. Previously, I just transferred the site, changed the url links in the database using a script or in the database. After that everything worked properly. Faced a problem, the previous developer uses wp-super-cache, wp-super-minify and other optimizations. As a result, the styles have disappeared, the pictures are floating. How can I deploy a site one to one on local?
Answer the question
In order to leave comments, you need to log in
Hello!
If you don't want to disable plugins in production, then you can do the following:
- Download site files (using plugin or via ftp || sftp).
- Next, locally rename the folders with the plugin names that are in wp-content/plugins, thereby disabling these plugins locally.
- Also delete the cache folder where the cache is stored.
Please note that if, after disabling the cache, the site no longer displays correctly, which it should not, it means that the necessary materials have been cached, but this is not in the non-cached version of the site.
Once I came across such a site when the materials the client needed were in the cached version and he somehow managed to delete these materials (almost half of the site) and, accordingly, had to write a parser, parse the data from the cache and then add everything back...
As I understand it, you are talking about curl and the page that we are parsing. Try this, here is the conversion to utf8, I think it will not be a problem to tear out the necessary pieces for you
<?php
/**
* @author
* @copyright 2014
*/
function curl_exec_utf8($ch) {
$data = curl_exec($ch);
if (!is_string($data)) return $data;
unset($charset);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
/* 1: HTTP Content-Type: header */
preg_match( '@([\w/+]+)(;\s*charset=(\S+))[email protected]', $content_type, $matches );
if ( isset( $matches[3] ) )
$charset = $matches[3];
/* 2: <meta> element in the page */
if (!isset($charset)) {
preg_match( '@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*charset=([^\s"]+))[email protected]', $data, $matches );
if ( isset( $matches[3] ) )
$charset = $matches[3];
}
/* 3: <xml> element in the page */
if (!isset($charset)) {
preg_match( '@<\?xml.+encoding="([^\s"]+)@si', $data, $matches );
if ( isset( $matches[1] ) )
$charset = $matches[1];
}
/* 4: PHP's heuristic detection */
if (!isset($charset)) {
$encoding = mb_detect_encoding($data);
if ($encoding)
$charset = $encoding;
}
/* 5: Default for HTML */
if (!isset($charset)) {
if (strstr($content_type, "text/html") === 0)
$charset = "ISO 8859-1";
}
/* Convert it if it is anything but UTF-8 */
/* You can change "UTF-8" to "UTF-8//IGNORE" to
ignore conversion errors and still output something reasonable */
if (isset($charset) && strtoupper($charset) != "UTF-8")
$data = iconv($charset, 'UTF-8', $data);
return $data;
}
?>
It is impossible to determine - the string does not contain an encoding. You can guess.
Better yet, use the same encoding everywhere so that you don’t have to guess or recode anything. This has happened on the web for a long time. the standard is UTF-8.
Try passing the header Accept-Charset: the encoding you need in the request .
You can read more about her here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question