Showing posts with label wordpress. Show all posts
Showing posts with label wordpress. Show all posts
Thursday, 23 April 2020

How to fix a "cURL error 28: Connection timed out" in WordPress?



My Wordpress Site Health Status check showed me some critical issues that I needed to take further look at. "The REST API request failed due to an error."

The REST API request failed due to an error

Error: cURL error 28: Operation timed out after 10000 milliseconds
 with 0 bytes received (http_request_failed)

After a lot of search results that did NOT lead me to the right direction I finally stumbled up on a short article about this subject. A few items in a list on "How to Fix" this. The most interesting line in the article mentioned the Query Monitor plugin to check the status of the HTTP API Calls in the admin page where the error is displayed. And that vas the single most helpful plugin I ever found. Within a minute I had identified the problem the problem which was I my case the WP Social Avatar plugin.

wp-social-avatar error

This Query Monitor plugin saved my day, but mostly a lot of time.

*** EDIT *** It turned out I had second plugin causing the same error. "PHP Code For Posts" that has has been closed and is no longer available for download.

--cheers
Monday, 19 February 2018

WordPress Memory Exhausted Error


I've got allowed memory size exhausted error in WordPress. Well not for the first time and I guess it's not the last time.

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 12288 bytes) in /home/user/public_html/wp-admin/includes/menu.php on line 65

So the I increase PHP Memory Limit in WordPress in one easy step, by editing the wp-config.php file on the WordPress site. It is located in the WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.

Add this line:

define( 'WP_MEMORY_LIMIT', '256M' );


before the line that says ‘That’s all, stop editing! Happy blogging.’

This tells WordPress to increase the PHP memory limit to 256MB And once you are done, you need to save your changes and upload your wp-config.php file back to your server, or save your file in the file managers editor.

Monday, 8 June 2015

How to embed a Google Calendar in a responsive site

I'm using embedded google calendar on a responsive website and in my opinion it works quite well on a mobile device. Well it works on my LG G3 with Android 5.0 Lollipop.
But there seems to be a problem as I had some complaints from some iPhone users where the calendar would display fine but not populate any actual events.

So, what to do. One solution was brought to my attention where two versions of the calender code is used in two div's. One div for normal view and one div for mobile view and some css to hide or show based on the width of the screen. Yes, it works. But the calender view in this solution looses part of it's functions like the week view. I think it is a bad solution where you "fix" one thing by making it worse for those where it works.

My solution might not be the best in the world, but I'm trying to fix only what is broken. The iPhone view. That's why I use php to find out what device or browser is viewing the page and then I select which calender code I use. And I use a bit from fhe CSS from the other solution.

The main difference is the URL to the calender is "embed" vs. "htmlembed"
Original:
https://www.google.com/calendar/embed?
The fixed version:
https://www.google.com/calendar/htmlembed?

The web page has a Wordpress cms and to use php code on a page or a post we need to install some plugin for that, I choose PHP Code for posts for this job, but you can use anything that works for you.

Here is the code I use to select how I display the calendar
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'ipod'))
 {
 
 ?>
<div class="responsive-iframe-container">
<iframe style="border-width: 0;" src="https://www.google.com/calendar/htmlembed?***"></iframe>
</div>
 <?
}else {
 
 ?>
<div class="responsive-iframe-container-normal">
<iframe src="https://www.google.com/calendar/embed?***"></iframe>
</div>
 <?
}
?>
Here is the CSS I added, it might need some adjustments.
.responsive-iframe-container-normal iframe,   
.vresponsive-iframe-container-normal object,  
.vresponsive-iframe-container-normal embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.responsive-iframe-container {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 30px;
    height: 400px;
    overflow: hidden;
}
.responsive-iframe-container iframe,   
.vresponsive-iframe-container object,  
.vresponsive-iframe-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
If you have any improvement to this or a better method, please feel free to share it here in the comments.