I've got a problem on my Wordpress site which I tracked down to admin_init being called twice.
I tried deactivating all the plugins and the problem goes away. I then reinstated each plugin and found which one is causing the problem.
My question is, how can I find the cause of the extra admin_init call ?
The plugin is bespoke to the site so I can't simply replace with a different plugin and it's one (blushes profusely) that I have muddled together myself.
Here's what I've got so far after doing some research on the subject...
I've added
remove_filter("wp_head", "adjacent_posts_rel_link_wp_head",10);
to the functions.php file (although this may only stop the "init" hook being called twice and not the "admin_init")?
I set up a function that sends me an email every time admin_init is called. Whilst generating the email I added the following code to it:
$backtrace = print_r(debug_backtrace(), true);
and then added $backtrace to the email text.
The first email I get has the full backtrace showing all the functions that have led up to the admin_init call originating from "admin-ajax.php". The second admin_init call email doesn't have any backtrace info at all ?
I also read that multiple calls to the init (and presumably admin_init hook) can be caused by images on the site (or other inclusions) returning a 404 error.
I have right-clicked and "inspected element" on the page to open the Firebug window and had a look through the tabs but I'm not 100% sure how to check for this. I didn't see anything odd or 404'ing under any of the tabs but if someone could just clarify the procedure for checking this I'll be able re-check for definite.
So... any other ideas as to why I'm getting this extra admin_init call and what I can check in the software to see where it's being generated?
Thanks.
I have managed to cure this problem now.
I set the following in wp-config.php:
error_reporting(E_ALL); ini_set('display_errors', 1);
This turned on strict fault reporting.
My site was immediately peppered with Notices about problems.
I systematically went through and fixed every one of them and then my original problem disappeared as well.
I'm unsure of the exact fix but that would probably be site specfiic anyway so thought I'd post this in case it helps anyone else in the future.
Related
On the admin dashboard, I display admin notice to display the result of changes. I have production site and staging site. On the staging site, it works well. If I made changes, it's displaying the notice of appropriate message. But on production, it's same code as staging site. When I made changes, it's displaying the "cached" notice but not the appropriate message.
Here is my approach to solve this.
$flash_messages = maybe_unserialize(get_option('wp_flash_messages', array()));
print_r(flash_messages); exit;
This displays the 'cached' message.
delete_option('wp_flash_messages');
$flash_messages = maybe_unserialize(get_option('wp_flash_messages', array()));
print_r($flash_messages); exit;
I added delete_option() before get the message. But it returns the 'cached' message again.
EDIT : I cleared server cache as well.
It's really annoyed.
Can anyone help me?
Finally I found the issue is because of get_option() function is cached.
https://developer.wordpress.org/reference/functions/get_option/#source
Here you can see the function get cached data first and if not, look through db and get option.
ANSWER
wp_cache_flush();
This resolved the problem.
1) You can delete cacle from WPEngine is a managed WordPress hosting provider. They run their own caching solution, so their customers don’t need to install a caching plugin.
If you are unable to notice changes take effect immediately, then you can easily clear WPEngine cache from your WordPress admin area.
2) You can also delete cache by using wp super cache plugin
I have a simple question, what could cause this:
At magento success page there are no order number
Its just empty, what could cause this problem?
Order id are loaded by this line
$this->escapeHtml($this->getOrderId())
Code are loaded by manabee ordershare module.
Also this shop have many modules and code changes.
So I need as many as possible ways you can suggest why this is happening. I will check them all.
Meanbee_OrderShare_Block_Ordershare extends Mage_Checkout_Block_Onepage_Success so it should work as the standard success page block. The getOrderId metod comes from Mage_Checkout_Block_Onepage_Success. I recomend you check the exception.log, system.log and php error log, maybe you have an error. I allways recomend to read core files, then you will know how it works.
I think that you should check what you have in chechout session at first.
I have a form with about 25 inputs and the code to process it. The last time the code was edited in any way was 3 weeks ago. I randomly started getting reset connection issues. To investigate, I began cutting out sections of the code to find the guilty sections (cut section, refresh, repeat). Once I narrowed it down to a particular section (one which when I cut it out, the error did not occur), I started to repeat the process with smaller sections of the culprit section. Finally, I had the entire section commented out. Still got the error. Then I deleted the commented out sections and no error!
This leads me to conclude that the error isn't in my code, but some recent change to the configuration of the server (I host with GoDaddy) or something like that. Any suggestions as to what could cause this error? I've never removed comments from code and fixed an error before.
Further information: The form loads correctly initially. Clicking any of the buttons gives me the error, however the code does completely precess before the error (I do some file in/output so I can see that it's working). This even happens with the "Clear All" button which skips the section I mentioned above, and simply reloads the form.
I am using no database interaction whatsoever. The script does utilize both Facebook and twitter APIs.
I really don't know how to proceed from this point. I'm willing to post the code from the entire file if necessary, but my investigation reveals that to be pointless. I can also provide a link to the offending page.
Update: I commented out all the code except the output of the HTML form itself. No processing code at all. Just one function to output the form. Clicking any button causes the connection reset. However if I delete this commented out code, I do NOT get the connection reset, the form just reloads.
Update #2. I uploaded the site to another host. The code runs fine with no issues.
Update #3. After an exhaustive examination, I've determined that the cause of the problem is the following function call:
preg_replace('/\b(\w)/e', 'strtoupper("$1")', $_POST['dessert_name'])
If I comment out this line, I get the connection reset error... If I delete it, the script runs perfectly.
You need to increase your php timeout limit in php.ini
This in my experience is almost always a timeout.
max_execution_time = 60
or at the top of your script add
set_time_limit(60);
I moved my WordPress website to another server and URL, and now my homepage is coming up blank, even when I preview it in the dashboard.
EDIT: I tried to jerryrig it so that an index.html file would redirect to a faux homepage (start.php), and I'd then change my menus. But when I used my homepage template, I got a blank result, even if the page wasn't set as my home page.
your problem is a plugin Contact Form 7 ( I just deactivate this plugin).
Pdt: Change the admin password.
It's possible these error log errors may have existed on your other site- they don't seem like deal breakers.
Here are some things I often try to troubleshoot when come across problems in moving sites:
Flush permalinks (Settings->Permalinks and hit Save)
Make sure you changed the url in wp_options (home and siteurl)
If your Dashboard is coming up, that's a good sign. Make sure your database has been imported, and that the correct theme is activated
To troublesheet, start deactivating plugins (try deactivating all first and add them on one by one)
Check that the PHP (and MySQL) version of your new server matches your old server (http://php.net/manual/en/function.phpinfo.php)
Check that the settings for PHP shorthand are the same on both servers (broke one of mine for me once: http://www.php.net/manual/en/ini.core.php#ini.short-open-tag)
Check that your php.ini file for your new server matches your old one to some extent- something breaking could be due to a different setting (this option is similar to the previous suggestions)
Good luck!
You likely had this issue before, but error reporting was set not to show E_NOTICE. This is the default, to show all errors except E_NOTICE
error_reporting(E_ALL ^ E_NOTICE);
the best way to move wordpress server is to use a importer .There are many importer plugins for that purpose .I suggest you to have a fresh installation and than import the posts that would solve your problem in the process
There is something that does an output before the header is send....
if you see the message, cannot modify header.... click on show source of the browser and look what invokes the output directly before the first <br />
<br />
<b>Warning</b>: Cannot modify header information … in <b>…</b> on line <b>…</b><br />
I just migrated a Wordpress install from one of my servers to another for a client (client's website which I set up and manage) and as a precautionary measure, I was perusing the 'Theme > Edit' listed files in the Wordpress Admin panel just to check for any links to the old server/domain and try to clean everything up.
When I got to the 'admin_panel.php' file, I found this entry at the very bottom of the file (it was the last entry):
function ranking() {
$pshow = " <span style='display:none;'><a href='http://www.ellelive.com/'>Live sex</a> , <a href='http://www.2.livejasmin.com/listpage.php?psid=elenaa'>webcam sex</a> , <a href='http://www.2.livejasmin.com/listpage.php?tags=mature&psid=elenaa'>Mature Female</a> , <a href='http://www.2.livejasmin.com/freechat.php?random&psid=elenaa'>Livejasmin</a> , <a href='http://www.2.livejasmin.com/listpage.php?tags=girl&psid=elenaa'>Girl</a></span>";
echo $pshow;
}
Now, I'm not sure where the theme that I modified for the client came from, as he supplied it, but this is just... odd.
To note, the admin_panel.php file is for the backend theme settings section, so it isn't seen by the public. I also couldn't find anything in there that reflects this entry, but then again I'm not sure I would.
I'm not a coder, so I figured I would just see if anyone had any input on this. Is this likely something that was included by the theme coder? Or should I grill my client about where he sourced this theme and see if he got it from some shady website?
I'm just really unfamiliar with PHP, and while this looks harmless as far as site security is concerned, I figured I'd make sure.
I did remove the entry and everything seems fine, but better safe than sorry, right?
Thanks!
Whoever has made the template ( I presume "elenaa") chucked some hidden links in there to increase the google rankings of these websites. Replace the function with the following if your worried about it.
function ranking(){ return ''; }
If you just delete it you could get missing function errors.
Although the function is in the admin section is it possible the function could be called somewhere on the front end of the website?
Another possible issue: this is something that happens fairly frequently if you have the wrong permissions set on your files - this is especially true if it's at the very bottom of the file.
I've had spammers run scripts on my WP builds that will check to see if the page permissions are set incorrectly, and if they are, the script will write in some links off-site at the very end of the file. This is nice and effective because the spammer gets a Google rankings boost, and most people are never the wiser.
I'd keep an eye on your file permissions, and check back to see if these mysterious links have returned in a couple of months.