Wordpress problem, fail to open stream in function.php - php

I'm getting this weird message while trying to enter some of the pages of my WordPress.
Warning: require_once(/home3/alexismoyano/calendario/calendario/wp-content/themes/twentynineteen/includes/bootstrap.php): failed to open stream: No such file or directory in /home3/alexismoyano/calendario/calendario/wp-content/themes/Avada/functions.php on line 51
Fatal error: require_once(): Failed opening required '/home3/alexismoyano/calendario/calendario/wp-content/themes/twentynineteen/includes/bootstrap.php' (include_path='.:/opt/php70/lib/php') in /home3/alexismoyano/calendario/calendario/wp-content/themes/Avada/functions.php on line 51
I don't understand what could it be, it seems to be related to the theme "Twentnineteen" despite I'm not even using it.
This is what it's on LINE 51:
This is what it says on line 51:
LINE 51 : " require_once get_template_directory() . '/includes/bootstrap.php'; "
/**
* Check that the site meets the minimum requirements for the theme before proceeding.
* #since 6.0
*/
if ( version_compare( $GLOBALS['wp_version'], AVADA_MIN_WP_VER_REQUIRED, '<' ) || version_compare( PHP_VERSION, AVADA_MIN_PHP_VER_REQUIRED, '<' ) ) {
require_once get_template_directory() . '/includes/bootstrap-compat.php';
return;
}
/**
* Bootstrap the theme.
*
* #since 6.0
*/
require_once get_template_directory() . '/includes/bootstrap.php';
Does someone know how can I solve it?

Based on your comments, it looks like the twentynineteen theme is set as a template theme, and Avada is set as a child theme.
The function get_template_directory() is identical to get_stylesheet_directory() except for the fact it looks at the Template/Parent theme first instead of the current (child) theme.
Take a look at the documentation for Child Themes. You'll notice there's a comment block at the top of the style.css file that determines the parent/template theme, as an example:
/*
Theme Name: Some Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentynineteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
You see in line in there Template: twentynineteen, that's telling your active theme to use that as a parent theme.
Now, I'm not familiar with Avada, but is it supposed to be a child theme of Twentynineteen? I don't believe so, but if it is, try reinstalling the twentynineteen theme. If it's not supposed to be, then make sure you don't have a Template: twentynineteen line in your style.css file.
If neither of those things work, you could also try replacing the get_template_{…}() functions with get_stylesheet_{…}() functions, but those would get reverted if/when you updated the theme.

Related

Fatal error: Cannot declare class MYCLASS Woocommerce Settings

I have a website, and when I go to the WordPress admin page and click on woocommerce-settings it shows this error:
Fatal error: Cannot declare class WC_Settings_General, because the
name is already in use in
/(hosting)/website/wp-content/plugins/woocommerce/includes/admin/settings/class-wc-settings-general.php
on line 0 The site is experiencing technical difficulties. Please
check your site admin email inbox for instructions.
The beginning of class-wc-settings-general.php looks like this:
<?php
/**
* WooCommerce General Settings
*
* #package WooCommerce/Admin
*/
defined( 'ABSPATH' ) || exit;
if ( class_exists( 'WC_Settings_General', false ) ) {
return new WC_Settings_General();
}
/**
* WC_Admin_Settings_General.
*/
class WC_Settings_General extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'general';
$this->label = __( 'General', 'woocommerce' );
parent::__construct();
}
/**
* Get settings array.
*
* #return array
*/
public function get_settings() {
etc. The webpage url that is generating this error is: https://www.(mywebsite).com/wp-admin/admin.php?page=wc-settings
I need to know how to resolve this issue and get to the woocommerce settings. I have other websites that have woocommerce and do not have this issue, and I do not know where the other place it is declared would be.
If you need to know the list of plugins, please, let me know.
Please do not flag as a duplicate post as this is a very specific issue regarding woocommerce and WordPress that the other posts I have looked at (around 8 others) do not fix. I have checked for require to change to require_once
Thank you in advance!
I had exactly the same error, except it was pointing to line 0. I switched theme to Storefront and deactivated all plugins except WooCommerce, which fixed the problem... then switched the theme back and gradually added plugins back in to find out which was the problem.
Hopefully this can work for you as well - it was just a conflict with me on an old plugin I thankfully wasn't using any more anyway.

Class 'Timber' not found when running timber-starter-theme

I have recently installed Timber on to my WordPress instance but whenever I try to run single.php for the timber-starter I get the following error:
Fatal error: Uncaught Error: Class 'Timber' not found in
www\Website\wp\wp-content\plugins\timber-library\timber-starter-theme\single.php:12
Stack trace: #0 {main} thrown in
www\Website\wp\wp-content\plugins\timber-library\timber-starter-theme\single.php
on line 12
I have read that there can be issues with namespace and to update it to Timber\Timber. I have tried this also and get the same class not found for Timber\Timber. Interestingly, if I open it in PHPStorm I can navigate to the function directly from the class call so it is able to recognise it there.
Does anyone have any ideas? I've tried different versions of PHP, different versions of WordPress and installing via WP-Admin and manually. None of these options are fixing this issue. (Please note, I also get this error for going to index.php in this directory).
Here is the code from single.php with the added namespace definition.
<?php
/**
* The Template for displaying all single posts
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* #package WordPress
* #subpackage Timber
* #since Timber 0.1
*/
use Timber\Timber;
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
if ( post_password_required( $post->ID ) ) {
Timber::render( 'single-password.twig', $context );
} else {
Timber::render( array( 'single-' . $post->ID . '.twig', 'single-' . $post->post_type . '.twig', 'single.twig' ), $context );
}
It must seems trivial, but this error is commonly caused by a misinstallation.
If you use Timber as a plugin, check if it is activated.
If you have installed trough a package manager, check you have used the right package name composer require timber/timber.
You can also try to remove your package and re-install it.
If all is correct, check your functions.php, myabe there is a misuse of the Timber Instance

How do you add a lib namespace to Wordpress roots sage?

Following the documentation written here, I added a file to lib directory containing:
<?php
namespace Theme\URIs;
/**
* Returns theme images directory uri
*/
function get_images_directory_uri() {
return get_template_directory_uri() . '/assets/images';
}
Which I then tried calling from a template file with:
<?php print Theme\URIs\get_images_directory_uri(); ?>
Calling this however, returned a Fatal error: Call to undefined function Theme\URIs\get_images_directory_uri().
The solution is to add the file to the $sage_includes array in functions.php, so it looks like this:
$sage_includes = [
'lib/assets.php', // Scripts and stylesheets
'lib/extras.php', // Custom functions
'lib/setup.php', // Theme setup
'lib/titles.php', // Page titles
'lib/wrapper.php', // Theme wrapper class
'lib/uris.php' // Project URIs
];
This imports the file to be used in the theme.
The present documentation does not explain this. (I assumed it simply imported all files in the libs directory...)
Not the question (I can't comment yet) but unless you've changed the directory structure your function should probably return:
get_template_directory_uri() . '/dist/images';
As the images in /assets/images get optimised and then copied to /dist/images.

How to add last-modified/version for PHP code block using PHPDoc?

I'm developing a WP theme and I'm commenting my PHP code using PHPDoc. I would like to add versions of large code blocks, so the customer knows when it's updated.
Let's say I release initial version 1.0.0, then I update some code in version 1.0.2. How do I document that the code is changed? Will this be correct:
/**
* Code block #1
*
* #since ThemeVersion 1.0.0
* #version 1.0.2
*/
I'm not sure this is a correct way to use #version, since on the other hand I have another case when another block of code have not been changed after the update:
/**
* Code block #2
*
* #since ThemeVersion 1.0.2
* #version 1.0.0
*/
So not sure if this makes sense.. please let me know your thoughts.
Thank you.
Your use case is a reasonable use of the combination of both tags.
As such, I would expect your usage in Code Block #1 to mean:
this block was created in Theme v1.0.0
this block was last modified by Theme v1.0.2
(note that the current Theme version in use by the consumer could be v2.0.0, but these tag values still mean what they mean -- even if this installed Theme is v2.0.0, this code block #1 was added originally in v1.0.0, and was last changed in v1.0.2)
Now, on your Code Block #2:
#since ThemeVersion 1.0.2 should be telling me that the block was first created in Theme v.1.0.2
but #version 1.0.0 tells me it was last modified by v1.0.0... but that can't be right, because it wasn't even in the code until v1.0.2.
(if you set both tag values to 1.0.0, that would say to me "block #2 was created in v1.0.0 and has not been changed yet).

Error when migrating wordpress site from subfolder to root folder

This is what I'm seeing in the browser, after going through the steps at http://wp.smashingmagazine.com/2013/04/08/moving-wordpress-website/
Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home4/brycepj/public_html/index.php on line 17
Parse error: syntax error, unexpected '.' in /home4/brycepj/public_html/index.php on line 17
Here's the code from the relevant file:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* #package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* #var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require ('./dev/wp-blog-header.php);
What am I missing? Thanks in advance!
Figured it out! Just missing an apostrophe after the wp-blog-header.php --- if you're using Smashing Magazine's tutorial, this is your problem. I copy and pasted directly from their post.

Categories