Back in the day, I decided to use the stray random quotes plugin to place a random quote at the bottom of each page. It worked, and still does. Only, if you clicked on a quote it didn’t refresh – instead it said ‘Loading…’ and then placed an error in my web server log like this (not that it looked like you could even click on a quote anyway – the mouse cursor didn’t change to the ‘pointy-finger’):
PHP Fatal error: Call to undefined function get_stray_quotes() in <path>/stray_ajax.php
I’ve known it didn’t work for ages, but not especially cared, and then this morning I’m putting off doing actual work, so I fixed it.
The problem was that like many people, I’ve moved the file wp-config.php outside of the web-facing folder, so instead of living in /var/www/ it actually lives in /var/. Stray_random_quotes tells you that if you’ve moved your wp-config.php then you need to provide the modified path in stray_ajax.php itself, right near the top – so do so!
The first two lines of stray_ajax.php should now read:
// If your 'wp-content' directory is not in the default location you have to enter the path to your blog here. Example: '/home/www/public_html/wp' $changedDir = '/var/';
That should do ‘er – now, stray_ajax.php should be able to call wp-config, which will allow it to call get_stray_quotes().
When monkeying with wp-config, I saw that it was calling wp-settings, but the call was failing because they expect to be in the same folder, only as mentioned – wp-config.php is up a level from wp-settings.php (which holds no credentials), so, to fix this:
– Edit /var/wp-settings.php and right at the bottom, change the path to the wp-config.php file to be:
/** WordPress absolute path to the Wordpress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/www/'); <------ changed this from '/' to '/www/' /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php');