• ResueltoModerador almendron

    (@almendron)


    1) WordPress 5.9.1, PHP 7.4.8, servidor local

    2) Tema: https://wordpress.org/themes/stargazer/
    Nota: Es ya viejo pero lo he ido modificando para resolver todos los problemas que han ido surgiendo.

    Tras efectuar las correspondientes comprobaciones, todo parece indicar que se trata de algún problema con el tema.

    Ahora bien, con WordPress 5.9 ni en local ni en el servidor aparece el problema. En https://www.almendron.com/artehistoria/ está dicha versión (5.9) y todo funciona bien.

    En local, al actualizar a WP 5.9.1:

    Con PHP 7.4.8, el mensaje de error es el siguiente:

    Warning: Invalid argument supplied for foreach() in C:\wamp64\www\artehistoria\wp-includes\class-wp-theme-json.php on line 1091
    Call Stack
    #	Time	Memory	Function	Location
    1	0.0007	368360	{main}( )	...\index.php:0
    2	0.0012	368720	require( 'C:\wamp64\www\artehistoria\wp-blog-header.php' )	...\index.php:17
    3	0.9579	13137784	require_once( 'C:\wamp64\www\artehistoria\wp-includes\template-loader.php' )	...\wp-blog-header.php:19
    4	0.9667	13155504	include( 'C:\wamp64\www\artehistoria\wp-content\themes\stargazer\index.php' )	...\template-loader.php:106
    5	0.9667	13155504	get_header( )	...\index.php:1
    6	0.9667	13155880	locate_template( )	...\general-template.php:48
    7	0.9668	13155976	load_template( )	...\template.php:716
    8	0.9672	13156648	require_once( 'C:\wamp64\www\artehistoria\wp-content\themes\stargazer\header.php' )	...\template.php:770
    9	0.9759	13221848	wp_head( )	...\header.php:12
    10	0.9759	13221848	do_action( )	...\general-template.php:3042
    11	0.9759	13222224	WP_Hook->do_action( )	...\plugin.php:474
    12	0.9759	13222224	WP_Hook->apply_filters( )	...\class-wp-hook.php:331
    13	0.9764	13226744	wp_enqueue_scripts( )	...\class-wp-hook.php:307
    14	0.9764	13226744	do_action( )	...\script-loader.php:2105
    15	0.9764	13227120	WP_Hook->do_action( )	...\plugin.php:474
    16	0.9764	13227120	WP_Hook->apply_filters( )	...\class-wp-hook.php:331
    17	0.9780	13235136	wp_enqueue_global_styles( )	...\class-wp-hook.php:307
    18	0.9781	13235136	wp_get_global_stylesheet( )	...\script-loader.php:2328
    19	0.9853	13414736	WP_Theme_JSON->get_stylesheet( )	...\global-styles-and-settings.php:124
    20	0.9853	13417744	WP_Theme_JSON->get_css_variables( )	...\class-wp-theme-json.php:700
    21	0.9853	13417744	WP_Theme_JSON::compute_preset_vars( )	...\class-wp-theme-json.php:918
    22	0.9853	13417744	WP_Theme_JSON::get_settings_values_by_slug( )	...\class-wp-theme-json.php:1180

    Si cambio a PHP 8, el mensaje de error es el siguiente:

    PHP Warning: foreach() argument must be of type array|object, string given in C:\wamp64\www\artehistoria\wp-includes\class-wp-theme-json.php on line 1091

    Si cambio a PHP 8.1.3, la información se amplía:

    Call Stack
    #	Time	Memory	Function	Location
    1	0.0007	367624	{main}( )	...\index.php:0
    2	0.0010	368016	require( 'C:\wamp64\www\artehistoria\wp-blog-header.php )	...\index.php:17
    3	0.6012	13017512	require_once( 'C:\wamp64\www\artehistoria\wp-includes\template-loader.php )	...\wp-blog-header.php:19
    4	0.6058	13020616	include( 'C:\wamp64\www\artehistoria\wp-content\themes\stargazer\index.php )	...\template-loader.php:106
    5	0.6058	13020616	get_header( $name = ???, $args = ??? )	...\index.php:1
    6	0.6058	13020992	locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $require_once = TRUE, $args = [] )	...\general-template.php:48
    7	0.6059	13021088	load_template( $_template_file = 'C:\\wamp64\\www\\artehistoria/wp-content/themes/stargazer/header.php', $require_once = TRUE, $args = [] )	...\template.php:716
    8	0.6062	13021984	require_once( 'C:\wamp64\www\artehistoria\wp-content\themes\stargazer\header.php )	...\template.php:770
    9	0.6238	13114616	wp_head( )	...\header.php:12
    10	0.6238	13114616	do_action( $hook_name = 'wp_head' )	...\general-template.php:3042
    11	0.6238	13114992	WP_Hook->do_action( $args = [0 => ''] )	...\plugin.php:474
    12	0.6238	13114992	WP_Hook->apply_filters( $value = '', $args = [0 => ''] )	...\class-wp-hook.php:331
    13	0.6242	13118760	wp_enqueue_scripts( '' )	...\class-wp-hook.php:307
    14	0.6242	13118760	do_action( $hook_name = 'wp_enqueue_scripts' )	...\script-loader.php:2105
    15	0.6242	13119136	WP_Hook->do_action( $args = [0 => ''] )	...\plugin.php:474
    16	0.6242	13119136	WP_Hook->apply_filters( $value = '', $args = [0 => ''] )	...\class-wp-hook.php:331
    17	0.6253	13127904	wp_enqueue_global_styles( '' )	...\class-wp-hook.php:307
    18	0.6254	13127904	wp_get_global_stylesheet( $types = ??? )	...\script-loader.php:2328
    19	0.6307	13302160	WP_Theme_JSON->get_stylesheet( $types = [0 => 'variables'], $origins = ??? )	...\global-styles-and-settings.php:124
    20	0.6307	13305168	WP_Theme_JSON->get_css_variables( $nodes = [0 => ['path' => [...], 'selector' => 'body'], 1 => ['path' => [...], 'selector' => '.wp-block-button__link'], 2 => ['path' => [...], 'selector' => '.wp-block-pullquote']], $origins = [0 => 'default', 1 => 'theme', 2 => 'custom'] )	...\class-wp-theme-json.php:700
    21	0.6307	13305168	WP_Theme_JSON::compute_preset_vars( $settings = ['appearanceTools' => FALSE, 'border' => ['color' => FALSE, 'radius' => FALSE, 'style' => FALSE, 'width' => FALSE], 'color' => ['background' => TRUE, 'custom' => TRUE, 'customDuotone' => TRUE, 'customGradient' => TRUE, 'defaultGradients' => TRUE, 'defaultPalette' => FALSE, 'duotone' => [...], 'gradients' => [...], 'link' => FALSE, 'palette' => [...], 'text' => TRUE], 'spacing' => ['blockGap' => NULL, 'margin' => FALSE, 'padding' => FALSE, 'units' => FALSE], 'typography' => ['customFontSize' => TRUE, 'dropCap' => TRUE, 'fontSizes' => [...], 'fontStyle' => TRUE, 'fontWeight' => TRUE, 'letterSpacing' => TRUE, 'lineHeight' => FALSE, 'textDecoration' => TRUE, 'textTransform' => TRUE], 'blocks' => ['core/button' => [...], 'core/pullquote' => [...]]], $origins = [0 => 'default', 1 => 'theme', 2 => 'custom'] )	...\class-wp-theme-json.php:918
    22	0.6307	13305168	WP_Theme_JSON::get_settings_values_by_slug( $settings = ['appearanceTools' => FALSE, 'border' => ['color' => FALSE, 'radius' => FALSE, 'style' => FALSE, 'width' => FALSE], 'color' => ['background' => TRUE, 'custom' => TRUE, 'customDuotone' => TRUE, 'customGradient' => TRUE, 'defaultGradients' => TRUE, 'defaultPalette' => FALSE, 'duotone' => [...], 'gradients' => [...], 'link' => FALSE, 'palette' => [...], 'text' => TRUE], 'spacing' => ['blockGap' => NULL, 'margin' => FALSE, 'padding' => FALSE, 'units' => FALSE], 'typography' => ['customFontSize' => TRUE, 'dropCap' => TRUE, 'fontSizes' => [...], 'fontStyle' => TRUE, 'fontWeight' => TRUE, 'letterSpacing' => TRUE, 'lineHeight' => FALSE, 'textDecoration' => TRUE, 'textTransform' => TRUE], 'blocks' => ['core/button' => [...], 'core/pullquote' => [...]]], $preset_metadata = ['path' => [0 => 'color', 1 => 'palette'], 'override' => [0 => 'color', 1 => 'defaultPalette'], 'use_default_names' => FALSE, 'value_key' => 'color', 'css_vars' => '--wp--preset--color--$slug', 'classes' => ['.has-$slug-color' => 'color', '.has-$slug-background-color' => 'background-color', '.has-$slug-border-color' => 'border-color'], 'properties' => [0 => 'color', 1 => 'background-color', 2 => 'border-color']], $origins = [0 => 'default', 1 => 'theme', 2 => 'custom'] )
    • Este debate fue modificado hace 2 años, 1 mes por almendron.

    La página con la que necesito ayuda: [accede para ver el enlace]

Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
  • Moderador almendron

    (@almendron)

    Ya está solucionando. Luego pongo la solución.

    Moderador almendron

    (@almendron)

    Gracias a @kallookoo he descubierto que el error tiene relación con «add_theme_support» y la nueva forma de gestionar Gutenberg esos soportes.

    En el archivo functions.php del tema me he encontrado con

    add_theme_support( 'editor-color-palette', '#cc4a00', '#252525', '#2d2d2d', '#ffffff' );

    Esto provocaba un error porque no estaba en un array. La solución ha consistido en cambiar esa línea por

    add_theme_support( 'editor-color-palette',
    	array(
    		'colors' => array( '#cc4a00', '#252525', '#2d2d2d', '#ffffff' ),
    	)
    );
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
  • El debate ‘Warning class-wp-theme-json.php’ está cerrado a nuevas respuestas.