file_get_contents in php7
If file_get_contents($url) generates error “Warning: file_get_contents(…) failed to open stream: Invalid argument in”, use this curl function below.
function curl_get_file_contents($URL){
//code sample
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
Configure VHost on Windows with Bitnami
1) Configure VHost of windows first by editing this file C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.2 test1.yourdomain.com
127.0.0.3 test2.yourdomain.com
2) Configure Bitnami VHost by editing this file C:\Bitnami\wampstack-7.0.16-1\apache2\conf\bitnami\bitnami-apps-vhosts.conf
Add as many virtualhosts as you need.
VirtualHost test1.yourdomain.com:8070
DocumentRoot "C:/Users/you/Documents/_www_php70/ws"
Directory "C:/Users/you/Documents/_www_php70/ws"
Options Indexes FollowSymLinks
AllowOverride All
IfVersion < 2.3
Order allow,deny
Allow from all
/IfVersion
IfVersion >= 2.3
Require all granted
/IfVersion
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "C:/Bitnami/wampstack-7.0.16-1/apache2/conf/bitnami/bitnami-apps-prefix.conf"
/VirtualHost
Send Email Plugin in WordPress using the Gmail SMTP Server
First you need to install and activate the WP Mail SMTP plugin.
Upon activation, you need to visit Settings » Email page to configure the plugin settings.
Here is how to fill out the plugin settings:
From Email: Enter your Gmail address.
From Name: Enter your name or title of your website.
Mailer: Select ‘Send all WordPress emails via SMTP.
Return Path: Check the box to use the From email as return path.
SMTP Host: smtp.gmail.com
SMTP Port: 465
Encryption: Use SSL encryption
Authentication: Yes, use SMTP authentication
Username: Your complete Gmail address, e.g. john@yourdomain.com or john.smith@gmail.com
Password: Password of your Gmail account
Click on the save changes button to store your settings.
After saving your settings scroll down to the bottom of the page, and you will see ‘Send a test email’ section. Enter an email address to see if everything is working fine.
That’s all, you have successfully setup your WordPress site to send emails using Gmail SMTP servers.
Troubleshooting Gmail SMTP Not Working Issues
We have seen issues of Gmail SMTP not working with certain shared hosting configurations.
Take the following steps to fix the Gmail SMTP issue:
Login to your cPanel account and create an email account that matches your Google apps email address. This might seem strange because you’re not using your server, this step basically tricks your server into believing that you’re sending the email through the server.
In your cPanel account, go to MX Records and change the MX routing from automatic to Remote. It might be a little tricky to find since each host now has custom cPanel interface, but look for a small link next to MX that says Email Routing: Remote Mail Exchanger.
After that log back into your WordPress site and send a test email.
How to disable cache for images in all browsers
This tag was recommended by some developers but it may not work if you have dynamic file uploaded to your server.
<img src="my-image.jpg?cache=1">
The best tag you can add to display a brand new image is to use the function time() in php to generate different time for each time a photo was uploaded to your server.
<img src="my-image.jpg?cache=<?=time()?>">
Bitnami Delay
You’ll need to stop Cache Completely to increase the response time on Bitnami server.
Edit php.ini file and change option opcache.enable=0. Zend OPCache is enabled by default when you install Bitnami on Windows.