我的 WordPress 网站上遇到多个错误。我无法解决它们,我尝试了网络上的多种解决方案,但没有一个有效。每当我尝试上传图像时,都会收到以下错误:
The response is not a valid json reponse;
此外,我在更新网站上的当前页面时面临困难,并且在添加新插件和主题时也面临问题。 SSL 插件还给出错误:
Status code: 500, Server response: <script></script>{"fields":[{"default":false,"id":"ssl_enabled","visible":true,"disabled":false,"rec...
我尝试在 wp-config 文件中进行调试,并在仪表板上出现以下错误:
注意:函数 wp_enqueue_style 被错误调用。在 wp_enqueue_scripts、admin_enqueue_scripts 或 login_enqueue_scripts 挂钩之前,不应注册或排队脚本和样式。该通知是由 low_diagnostic_glance_styles 句柄触发的。请参阅 WordPress 中的调试以获取更多信息。 (此消息是在3.3.0版本中添加的。)在/home/s3uoygwak2m1/public_html/wp-includes/functions.php第6085行
注意:函数 is_feed 被错误调用。条件查询标记在查询运行之前不起作用。在此之前,它们总是返回 false。请参阅 WordPress 中的调试以获取更多信息。 (此消息是在3.1.0版本中添加的。)在/home/s3uoygwak2m1/public_html/wp-includes/functions.php第6085行
注意:函数 wp_enqueue_script 被错误调用。在 wp_enqueue_scripts、admin_enqueue_scripts 或 login_enqueue_scripts 挂钩之前,不应注册或排队脚本和样式。此通知是由 low_diagnostic_glance_custom_admin_script 句柄触发的。请参阅 WordPress 中的调试以获取更多信息。 (此消息是在3.3.0版本中添加的。)在/home/s3uoygwak2m1/public_html/wp-includes/functions.php第6085行
注意:WP_Theme_JSON_Resolver::get_user_data():解码用户数据的 theme.json 架构时出错。 /home/s3uoygwak2m1/public_html/wp-includes/functions.php 第 6085 行有语法错误
注意:WP_Theme_JSON_Resolver::get_user_data():解码用户数据的 theme.json 架构时出错。 /home/s3uoygwak2m1/public_html/wp-includes/functions.php 第 6085 行有语法错误
注意:WP_Theme_JSON_Resolver::get_user_data():解码用户数据的 theme.json 架构时出错。 /home/s3uoygwak2m1/public_html/wp-includes/functions.php 第 6085 行有语法错误
主题的Functions.php:
<?php
/**
* Astra functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Astra
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Define Constants
*/
define( 'ASTRA_THEME_VERSION', '4.7.3' );
define( 'ASTRA_THEME_SETTINGS', 'astra-settings' );
define( 'ASTRA_THEME_DIR', trailingslashit( get_template_directory() ) );
define( 'ASTRA_THEME_URI', trailingslashit( esc_url( get_template_directory_uri() ) ) );
/**
* Minimum Version requirement of the Astra Pro addon.
* This constant will be used to display the notice asking user to update the Astra addon to the version defined below.
*/
define( 'ASTRA_EXT_MIN_VER', '4.7.0' );
/**
* Setup helper functions of Astra.
*/
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-theme-options.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-theme-strings.php';
require_once ASTRA_THEME_DIR . 'inc/core/common-functions.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-icons.php';
define( 'ASTRA_PRO_UPGRADE_URL', astra_get_pro_url( 'https://wpastra.com/pro/', 'dashboard', 'free-theme', 'upgrade-now' ) );
define( 'ASTRA_PRO_CUSTOMIZER_UPGRADE_URL', astra_get_pro_url( 'https://wpastra.com/pro/', 'customizer', 'free-theme', 'upgrade' ) );
/**
* Update theme
*/
require_once ASTRA_THEME_DIR . 'inc/theme-update/astra-update-functions.php';
require_once ASTRA_THEME_DIR . 'inc/theme-update/class-astra-theme-background-updater.php';
/**
* Fonts Files
*/
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-font-families.php';
if ( is_admin() ) {
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-fonts-data.php';
}
require_once ASTRA_THEME_DIR . 'inc/lib/webfont/class-astra-webfont-loader.php';
require_once ASTRA_THEME_DIR . 'inc/lib/docs/class-astra-docs-loader.php';
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-fonts.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/custom-menu-old-header.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/container-layouts.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/astra-icons.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-walker-page.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-enqueue-scripts.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-gutenberg-editor-css.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-wp-editor-css.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/block-editor-compatibility.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/inline-on-mobile.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/content-background.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-dynamic-css.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-global-palette.php';
/**
* Custom template tags for this theme.
*/
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-attr.php';
require_once ASTRA_THEME_DIR . 'inc/template-tags.php';
require_once ASTRA_THEME_DIR . 'inc/widgets.php';
require_once ASTRA_THEME_DIR . 'inc/core/theme-hooks.php';
require_once ASTRA_THEME_DIR . 'inc/admin-functions.php';
require_once ASTRA_THEME_DIR . 'inc/core/sidebar-manager.php';
/**
* Markup Functions
*/
require_once ASTRA_THEME_DIR . 'inc/markup-extras.php';
require_once ASTRA_THEME_DIR . 'inc/extras.php';
require_once ASTRA_THEME_DIR . 'inc/blog/blog-config.php';
require_once ASTRA_THEME_DIR . 'inc/blog/blog.php';
require_once ASTRA_THEME_DIR . 'inc/blog/single-blog.php';
/**
* Markup Files
*/
require_once ASTRA_THEME_DIR . 'inc/template-parts.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-loop.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-mobile-header.php';
/**
* Functions and definitions.
*/
require_once ASTRA_THEME_DIR . 'inc/class-astra-after-setup-theme.php';
// Required files.
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-admin-helper.php';
require_once ASTRA_THEME_DIR . 'inc/schema/class-astra-schema.php';
/* Setup API */
require_once ASTRA_THEME_DIR . 'admin/includes/class-astra-api-init.php';
if ( is_admin() ) {
/**
* Admin Menu Settings
*/
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-admin-settings.php';
require_once ASTRA_THEME_DIR . 'admin/class-astra-admin-loader.php';
require_once ASTRA_THEME_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
}
/**
* Metabox additions.
*/
require_once ASTRA_THEME_DIR . 'inc/metabox/class-astra-meta-boxes.php';
require_once ASTRA_THEME_DIR . 'inc/metabox/class-astra-meta-box-operations.php';
/**
* Customizer additions.
*/
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-customizer.php';
/**
* Astra Modules.
*/
require_once ASTRA_THEME_DIR . 'inc/modules/posts-structures/class-astra-post-structures.php';
require_once ASTRA_THEME_DIR . 'inc/modules/related-posts/class-astra-related-posts.php';
/**
* Compatibility
*/
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-gutenberg.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-jetpack.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/woocommerce/class-astra-woocommerce.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/edd/class-astra-edd.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/lifterlms/class-astra-lifterlms.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/learndash/class-astra-learndash.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-beaver-builder.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-bb-ultimate-addon.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-contact-form-7.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-visual-composer.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-site-origin.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-gravity-forms.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-bne-flyout.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-ubermeu.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-divi-builder.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-amp.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-yoast-seo.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/surecart/class-astra-surecart.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-starter-content.php';
require_once ASTRA_THEME_DIR . 'inc/addons/transparent-header/class-astra-ext-transparent-header.php';
require_once ASTRA_THEME_DIR . 'inc/addons/breadcrumbs/class-astra-breadcrumbs.php';
require_once ASTRA_THEME_DIR . 'inc/addons/scroll-to-top/class-astra-scroll-to-top.php';
require_once ASTRA_THEME_DIR . 'inc/addons/heading-colors/class-astra-heading-colors.php';
require_once ASTRA_THEME_DIR . 'inc/builder/class-astra-builder-loader.php';
// Elementor Compatibility requires PHP 5.4 for namespaces.
if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-elementor.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-elementor-pro.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-web-stories.php';
}
// Beaver Themer compatibility requires PHP 5.3 for anonymous functions.
if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-beaver-themer.php';
}
require_once ASTRA_THEME_DIR . 'inc/core/markup/class-astra-markup.php';
/**
* Load deprecated functions
*/
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-filters.php';
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-hooks.php';
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-functions.php';
function add_custom_js_inline() {
?>
<script>
document.addEventListener('DOMContentLoaded', () => {
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.edplus_anim-L5I9H8second, .edplus_anim-L5I9H8third').forEach(element => {
observer.observe(element);
});
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_js_inline');
您的某个插件出现错误,您应该尝试禁用所有插件并逐一启用,直到错误再次出现。
具体来说,错误是 JSON 响应是脏的,事实上您的数据不应该包含除有效 JSON 之外的任何内容,但您的响应以
<script></script>
开头,这意味着某些插件正在尝试以错误的方式注入 JavaScript。
所有 JSON 错误都是同一问题的结果。
这可能与
Notice: Function wp_enqueue_script was called incorrectly.
有关,但您的问题中没有足够的信息让我告诉您哪个插件做了错误的事情,所以我的建议是再次禁用所有插件并尝试重新启用它们一一。
我想让你明白的一件事是,错误可以放在其他地方,即使你看到类似
Notice: WP_Theme_JSON_Resolver::get_user_data(): Error
的内容,也许它与你的主题无关,但有些东西正在向你网站中的任何 JSON 响应添加无效的输出,这只是错误导致问题的地方之一。