I am having an ambiguous error. The path in the error is correct:
Warning! WP Super Cache caching broken! The script advanced-cache.php
could not load wp-cache-phase1.php.
Please edit /wp-content/advanced-cache.php
and make sure the path to
/wp-content/plugins/wp-super-cache/wp-cache-phase1.php
is correct.
What needs to be fixed?
The problem is that the constant is not defined until after the plugin loads. This error is possible if the line "require_once(ABSPATH . 'wp-settings.php');" is present in wp-config.php . WPCACHEHOME is probably being defined after this line, but needs to be defined above it:
define( 'WPCACHEHOME', '<site root>/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
require_once(ABSPATH . 'wp-settings.php');
http://wangweiqiang.net/warning-wp-super-cache-caching-broken-the-script-advanced-cache-php-could-not-load-wp-cache-phase1-php/
This worked like a charm for me...!
This is a permission issue, U should check that the paths mantioned in the error notice have 777 permisions, BUT, my advice on this issue is simply to NOT use this plugin, I had it installed on some of my site, and almost in all of them it caused errors on diffrent elements on my site.
I'm not saying that using this plugin will cause problems for sure, but this plugin is known as problematic, and for my opinion it doesn't justify itself.
Please use this in your wp-config.php file
define('WPCACHEHOME', dirname(__FILE__) . '/wp-content/plugins/wp-super-cache/');
before
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
Related
I'm trying to use PHP Unit to test an API class that I've written to work with an addon for the WordPress plugin Gravity Forms. The class is dependent on several functions from WordPress such as wp_remote_request().
In order to have access to these WordPress dependencies, I'm trying to require wp-load.php in my PHP Unit test class using:
define( 'WP_USE_THEMES', false );
require '../../../wp-load.php';
However, when I try this, I get the following output in my terminal upon running phpunit:
Cannot modify header information - headers already sent by (output started at phar:///usr/local/Cellar/phpunit/6.4.2/libexec/phpunit-6.4.2.phar/phpunit/Util/Printer.php:112)
../wp-includes/functions.php:3760
../wp-includes/load.php:422
../wp-settings.php:110
../wp-config.php:228
../wp-load.php:37
../wp-content/plugins/gravity-dpo/tests/TestCaseAddon.php:37
Looking at the wp-includes/functions.php file, I can see the following class at line 3760 within the function dead_db(), which is what causes the error:
header( 'Content-Type: text/html; charset=utf-8' );
Surely it should be trivial to require wp-load.php so I can test a class with some WordPress dependencies using PHP Unit? I would appreciate any pointers as to what I'm doing wrong here. I'm trying to avoid having to create a fully fledged WordPress unit testing set up because I just want to test one or two functions from my API class.
On occasion you may want to test some functionality without actually creating a plugin/add on to do so. Create a test.php file with the following code snippet and place it in your WordPress root directory:
<?php
// Load the WordPress Environment
// define( 'WP_DEBUG', true ); /* uncomment for debug mode */
require(./wp-load.php);
// require_once (./wp-admin/admin.php); /* uncomment for is_admin() */
?>
<pre>
<?php
/* test stuff here */
var_dump( is_admin() );
?>
</pre>
This is a quick way to load all of the required WordPress functions to test plugin functionality without actually creating a plugin. As you can see wp-load.php is included at the beginning of the file. You can also include wp-admin/admin.php if you want to test admin side functionality.
Once you have included the required WordPress core files, you want test any code that would otherwise exist reside in your plugin. Don’t forget to remove your test.php file when you are done testing.
I would like to enable debug logs of wordpress site, added following setting at wp-config.php
/* WordPress debug mode for developers. */
define('WP_DEBUG', true);
if (WP_DEBUG) {
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
#ini_set('display_errors', 0);
}
created debug.log file under wp-content folder.
updated 777 on wp-content as well as debug.log..
But still file is blank..
Please let me know how can I fix it...
Just I would like to debug the site, some times home page going in infinite loop..i.e. browser not loading the page.. CPU goes to 100%...
Thanks
You have #ini_set('display_errors', 0); - which will tell PHP (not WordPress) to stop displaying errors. WordPress requires errors to be turned on in order for it to pass them to the appropriate place. define('WP_DEBUG_DISPLAY', false); or define('WP_DEBUG', false); should take care of hiding them on the front end for you.
Also, you should only need to define the constants, the IF statement you've created isn't necessary. What you're essentially saying there is "Turn on error reporting. Now, if error reporting is turned on, do this." - although logically correct, it's verbose. Simply defining the WP_DEBUG constant as true should be enough, as WordPress will do the rest of the work.
Also - if wp_debug.log doesn't exist- WordPress will create it for you (with the correct permissions), assuming it has permission to do so on your server (in most cases this will be true). So - you shouldn't need to change the CHMOD values of wp-content or it's children. I'd advise you to change them to WordPress' recommended values (755 for folders, and 644 for files) - as a CHMOD value of 777 is pretty foolhardy to have.
You should only need the following:
define('WP_DEBUG', true); // Turn on WP Debugging
define('WP_DEBUG_LOG', true); // Log errors to wp_debug.log
define('WP_DEBUG_DISPLAY', false); // Turns off error reporting on the front end
According to Debugging in Wordpress:
You must insert this BEFORE /* That's all, stop editing! Happy
blogging. */ in the wp-config.php file
In your case "this" is:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
It may also be worth checking the WP_CONTENT_DIR as that is where the debug.log file would be put. The value of WP_CONTENT_DIR may be checked as suggested in this question, or using the Wordfence plugin->Tools->Diagnostics->WordPress Settings.
Normally it is not explicitly set unless there's a non-standard setup. Though it can can be set in wp-config.php e.g. define('WP_CONTENT_DIR', '/var/www/sites/wordpress/wp-content');
I've been asked to add an analytics.txt file to a wordpress website so I've created the file and uploaded it to the server document root but when I go to it via the url www.examples.com/analytics.txt all I get is a 404 error.
I've checked the file permissions and I've cleared the wordpress cache but neither have helped.
Any ideas?
The folder structure is as follows:
wp-admin
wp-content
wp-includes
analytics.txt <-- added this file, but cannot seem to access it via a web browser
index.php
etc...
This is NOT the solution but it is a work-around while I carry on trying to figure out why wordpress won't allow me to access my file.
So if you're desperate and HAVE to get it sorted right now, here is what you could do, but I warn you, it's ugly! Open your index.php file and you should see something like this:
<?php
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
?>
Make a backup copy first and then add the wrapping if statement:
<?php
if ($_SERVER[REQUEST_URI] == '/analytics.txt') {
die('Put the text that you were instructed to put into your analytics.txt file in here');
} else {
define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
}
?>
Like I said, this is a dirty solution but when needs must and the client is getting impatient, this could help in the mean time.
Hoping that someone will have a better solution though!
I was able to get this to work with the following for the Sage theme:
Upload the analytics.txt through the theme administration panel
Copy the url of the upload and remove the hostname. For me it looked like this: app/uploads/2018/09/analytics.txt
Open the functions.php file and add the following:
function analytics_txt_rewrite(){
add_rewrite_rule('^analytics\.txt$','<route to your analytics.txt file>','top');
}
add_action('init','analytics_txt_rewrite');
Flush and regenerate the rewrite rules database: From WordPress Administration Screens, Select Settings -> Permalinks and just click Save Changes without any changes.
I am trying to add a function from plugin 1(wp job manager) to plugin 2(woocommerce).
I have decided to do this by including the php file from plugin 1, however I am unable to locate the file directory. I have used:
include( plugin_dir_path( __FILE__ ) . 'wp-job-manager/includes/class-wp-job-manager-applications.php');
but it returns the following error:
Warning:
include(/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/wp-job-manager/includes/class-wp-job-manager-applications.php): failed to open stream: No such file or directory in
/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/functions.php
on line 77
Please advise me as I've been stuck on this issue for really long... Thanks!!!
Wordpress setups have a constant ABSPATH defined (look at the bottom lines of wp_config.php) which points to the full and absolute path of the Wordpress setup, so in your case echo ABSPATH; would return /home/content/p3pnexwpnas05_data02/78/2394078/html/.
For most installations, appending wp-content/plugins/ to that string would point you to your plugins directory.
However, in a Wordpress configuration one can also customize the wp-content and or plugins directory to their own preference, so building plugins on ABSPATH.'wp-content/plugins/ is not recommended. Unfortunately Wordpress simply doesn't have a get_absolute_pluginspath() function or something available. A trick would be to fetch the plugins-URL, and remove the site-URL from it, so the remaining data is wp-content/plugins/ (or whatever the user has made of it). In code:
$plugins_directory = ABSPATH.str_replace(site_url()."/","",plugins_url())."/";
Which in your case would return:
/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/plugins/
You probably mean:
plugin_dir_path(__FILE__)
That gives you the directory path to the file that statement is in. So what that returns depends on where you run it. If you use this statement
include( plugin_dir_path(__FILE__) . 'wp-job-manager/includes/class-wp-job-manager-applications.php');
in the main plugin file for wp_job_manager (probably wp_job_manager.php), then plugin_dir_path(__FILE__) give the path of the directory that file is in (the plugin directory).
If you use it in some other file, you will need to adjust the rest of the path string accordingly.
I moved Drupal from one Linux server to another by copying files to PC then back to new server. I made changes to settings.php to reflect new database name. I got PHPmyADMIN working, so I know database and server are running.
When I run index.php, I get white screen. However in index.php when I echo out menu_execute_active_handler(), I get some part of my home page without menus. I think that this means that I am getting through bootstrap but failing somewhere else. Any ideas?
index.php
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$return = menu_execute_active_handler();
echo $return ;
Turn display_errors on in your php.ini file.
Your new server probably has them disabled.
Put this code in your index.php to see the error
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);