WordPress error with require_once - wordpress

I have this error in my wordpress, on frontend and dashboard:
Warning: require_once(includes/theme-widgets.php) [function.require-once]: failed to open stream: No such file or directory in /home/masqueci/public_html/functions.php on line 2
Fatal error: require_once() [function.require]: Failed opening required 'includes/theme-widgets.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/masqueci/public_html/functions.php on line 2
The problem is that I try to delete this line, rename the file, delete the all theme and delete wp-admin and wp-include and upload it again. But the error continue. How can I fix this problem?

Your problem is that you are using a worng reletive path to the file wanted.
Try on using:
$filePath = get_bloginfo('template_url'); // this line gets you the path to the current theme.
$filePath .= 'includes/theme-widgets.php'; // now we add the relative path to your file
require_once($filePath); // now we place the hole thing inside the 'require_once' function.
now you can minimize the code by:
require_once(get_bloginfo('template_url').'includes/theme-widgets.php');
what was originally responded by the function was that it was trying on going to:
public_html/includes/theme-widgets.php which did not exist while your path was:
public_html/wp-content/themes/{theme_name}/includes/theme-widgets.php
The code i have provided before should do the job for you :)

Related

PHP: Error using include_once function. Failed opening 'mysiteURL' for inclusion

I have never used PHP and need it just to build my WordPress site with an installed theme.
Every time when I open any pages under my wp-admin, I'm getting a warning:
Warning: include_once(): Failed opening
‘/myURL/public_html/wp-content/plugins/dsidxpress/admin.php’
for inclusion (include_path=’.:/usr/local/php56/pear’) in
/myURL/public_html/wp-content/plugins/dsidxpress123/dsidxpress.php
on line 90
When opening .php, I see the following code on line 90:
include_once(str_replace("\\", "/", WP_PLUGIN_DIR) . "/dsidxpress/admin.php");
After changing it per the instrucions:
include_once(include_path='.:/usr/local/php56/pear' . “/dsidxpress/admin.php”);
I'm getting new error:
Parse error: syntax error, unexpected ‘=’ in /myURL/public_html/wp-content/plugins/dsidxpress123/dsidxpress.php on line 90
How exactly do I need to change it?

Can't perform require once in WordPress without displaying the path on the page

Followng accepted answers given here I used the following to call some PHP code on my home page:
require_once (bloginfo('template_directory') . '/home_bloc_horaires.php');
It works, but it also actually displays the path of my template directory on my page! Any way to avoid this?
EDIT:
Tried require_once(get_template_directory().'/home_bloc_horaires.php'); : it doesn't work and I get the following error messages:
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
Warning: include(http://127.0.0.1/wordpress/mirail/wp-content/themes/mmt-2014/home_bloc_horaires.php): failed to open stream: no suitable wrapper could be found in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
Warning: include(): Failed opening 'http://127.0.0.1/wordpress/mirail/wp-content/themes/mmt-2014/home_bloc_horaires.php' for inclusion (include_path='.;C:\php\pear') in D:\EasyPHP\www\wordpress\wp-content\themes\mmt-2014\header.php on line 348
bloginfo() outputs the result, which is why you can see it. Use this instead:
require_once(get_template_directory().'/home_bloc_horaires.php');
You can find more info on loading files in WordPress here.

Unable to view Wordpress site

I had created a wordpress site close to 6 months back. Everything was fine till a few days back when we started to see the Wordpress "White Screen of Death" both at the front and back end.
After a lot of debug attempts, we decided to re-install wordpress and keep the old wp-content file.
Now this is visible on trying to access the site(wp_debug is set to false, so ideally it shouldn't be happening) -
Warning: require(/home/vaidya/public_html/wp-includes/class-wp-error.php) [function.require]: failed to open stream: No such file or directory in /home/vaidya/public_html/wp-settings.php on line 74
Fatal error: require() [function.require]: Failed opening required '/home/vaidya/public_html/wp-includes/class-wp-error.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/vaidya/public_html/wp-settings.php on line 74
Line 74 on wp-settings -
require( ABSPATH . WPINC . '/class-wp-error.php' );
Any suggestions?
The error message says, the the file "class-wp-error.php" is missing.
It should be located in the folder "'/home/vaidya/public_html/wp-includes/". It seems that you did not copy all required files.

Body and Footer gone on homepage and error message after clearing cache Drupal 7

I recently was working on my website and decided to clear all caches and now the homepage only shows the header and nothing else. All the other pages work fine but i do get this error:
Warning: include(page-front.php) [function.include]: failed to open
stream: No such file or directory in include() (line 14 of
/home/anthonyd/public_html/graphicimpress/sites/all/themes/gi_0612/page.tpl.php).
Warning: include(page-front.php) [function.include]: failed to open
stream: No such file or directory in include() (line 14 of
/home/anthonyd/public_html/graphicimpress/sites/all/themes/gi_0612/page.tpl.php).
Warning: include() [function.include]: Failed opening 'page-front.php'
for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in
include() (line 14 of
/home/anthonyd/public_html/graphicimpress/sites/all/themes/gi_0612/page.tpl.php).
I did see a very similar problem someone else posted but it was for drupal 6 and the fix was to rebuild the modules by visiting admin/build/modules
and rebuild themes by visiting admin/build/themes. Unfortunately D7 does not have the same menu options.
Does anyone have an idea how to fix this?
In your file /home/anthonyd/public_html/graphicimpress/sites/all/themes/gi_0612/page.tpl.php on line 14, function include('page-front.php') trying to include file page-front.php into your page.tpl.php, but there's no such file as page-front.php.
Make sure that this file (page-front.php) exist, or remove include('page-front.php') from page.tpl.php.

I can't upload files after migrating a Drupal site to a new server

We have a content type with two imagefield / filefield fields, and after migrating our site to a new server, we have the following problem:
When we submit a new item for this content type, with two images for those fields, drupal gives us the following error and does not upload the images:
warning:
fopen(sites/default/files/.htaccess)
[function.fopen]: failed to open
stream: Permission denied in
/websites/sitename/data/sites/all/modules/filefield/field_file.inc
on line 349. warning:
fopen(sites/default/files/.htaccess)
[function.fopen]: failed to open
stream: Permission denied in
/websites/sitename/data/sites/all/modules/filefield/field_file.inc
on line 349. An image thumbnail was
not able to be created. warning:
fopen(sites/default/files/.htaccess)
[function.fopen]: failed to open
stream: Permission denied in
/websites/sitename/data/sites/all/modules/filefield/field_file.inc
on line 349. warning:
fopen(sites/default/files/.htaccess)
[function.fopen]: failed to open
stream: Permission denied in
/websites/sitename/data/sites/all/modules/filefield/field_file.inc
on line 349. An image thumbnail was
not able to be created.
I understand this is a permissions error, but it is not clear to me where do I have to change permissions.
Line 349 of file.inc has the following code:
if (($fp = fopen("$directory/.htaccess", 'w')) && fputs($fp, $htaccess_lines)) {
fclose($fp);
chmod($directory .'/.htaccess', 0664);
}
else {
$repl = array('%directory' => $directory, '!htaccess' => nl2br(check_plain($htaccess_lines)));
form_set_error($form_item, t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines:<br /><code>!htaccess</code>", $repl));
*EDIT: Solved, The issue was that for some reason drupal needed write permissions in the sites/default/files folder to create a .htaccess file.
The code in file.inc wants to update/create the .htaccess file in the files directory ('sites/default/files' in your case). That it fails could mean that your web server process' do not have write permissions in the files directory at all (unlikely, as this would give more prominent errors in the backend), or that there already exists a .htaccess file in that directory which is set to read only (more likely, could have happened on migration and can easily be overlooked, as the file is hidden by default).

Resources