Archived topic
Broken website after update
5 replies · Started by Morgan on November 25, 2021
Hello guys,
I updated a website which uses generatepress but everything is broke now.
Here is the debug info :
Notice: Undefined variable: defaults in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 319
Notice: Trying to access array offset on value of type null in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 319
Notice: Undefined variable: palettes in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 334
Notice: Undefined variable: defaults in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 342
Notice: Trying to access array offset on value of type null in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 342
Notice: Undefined variable: defaults in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 364
Notice: Trying to access array offset on value of type null in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 364
Notice: Undefined variable: palettes in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 379
Notice: Undefined variable: defaults in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 387
Notice: Trying to access array offset on value of type null in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 387
Fatal error: Uncaught Error: Call to undefined function generate_get_color_setting() in /home/mywebsite/wp-content/themes/generatepress_child/functions.php:71 Stack trace: #0 /home/mywebsite/wp-includes/class-wp-hook.php(303): eb_add_css_in_head('') #1 /home/mywebsite/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array) #2 /home/mywebsite/wp-includes/plugin.php(470): WP_Hook->do_action(Array) #3 /home/mywebsite/wp-includes/general-template.php(3015): do_action('wp_head') #4 /home/mywebsite/wp-content/themes/generatepress/header.php(17): wp_head() #5 /home/mywebsite/wp-includes/template.php(770): require_once('/home/fmen1996/...') #6 /home/mywebsite/wp-includes/template.php(716): load_template('/home/fmen1996/...', true, Array) #7 /home/mywebsite/wp-includes/general-template.php(48): locate_template(Array, tru in /home/mywebsite/wp-content/themes/generatepress_child/functions.php on line 71
Hi there,
thats a problem with a function in your Child Themes functions.php - do you have a function like this here for setting your color pallet ?
If so can you remove that, as the new Global Colors doesn't require it.
It was a custom theme developed so i have stuff like that :
function eb_add_css_in_head() {
echo '<style>
body.single .inside-article h2 {
border-left: 4px solid '.generate_get_color_setting('form_button_background_color').';
padding-left: 20px;
}
h1.entry-title:before,
h1.entry-title:after,
h1.page-title:before,
h1.page-title:after,
.special-title:before,
.special-title:after {
color: '.generate_get_color_setting('form_button_background_color').';
}
.review-result-wrapper .review-result {
color: '.generate_get_color_setting('form_button_background_color').' !important;
}
.circular-chart .circle {
stroke: '.generate_get_color_setting('form_button_background_color').';
}
.button.cta {
background-color: '.generate_get_color_setting('cta_button_background_color').' !important;
color: '. generate_get_color_setting('cta_button_text_color').' !important;
}
.button.cta:hover {
background-color: '. generate_get_color_setting('cta_button_background_color_hover').' !important;
color: '. generate_get_color_setting('cta_button_text_color_hover').' !important;
}
</style>';
}
add_action('wp_head', 'eb_add_css_in_head', 99);
or
function gp_customize_cta_color( $wp_customize ) {
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_cta_button_colors',
array(
'section' => 'buttons_color_section',
'type' => 'generatepress-customizer-title',
'title' => 'Couleurs boutons Call To Action',
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 10,
)
)
);
$wp_customize->add_setting(
'generate_settings[cta_button_background_color]',
array(
'default' => $defaults['form_button_background_color'],
'type' => 'option',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[cta_button_background_color]',
array(
'label' => __( 'Background', 'gp-premium' ),
'section' => 'buttons_color_section',
'settings' => 'generate_settings[cta_button_background_color]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[cta_button_text_color]',
array(
'default' => $defaults['form_button_text_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[cta_button_text_color]',
array(
'label' => __( 'Text', 'gp-premium' ),
'section' => 'buttons_color_section',
'settings' => 'generate_settings[cta_button_text_color]',
)
)
);
$wp_customize->add_setting(
'generate_settings[cta_button_background_color_hover]',
array(
'default' => $defaults['form_button_background_color_hover'],
'type' => 'option',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[cta_button_background_color_hover]',
array(
'label' => __( 'Background Hover', 'gp-premium' ),
'section' => 'buttons_color_section',
'settings' => 'generate_settings[cta_button_background_color_hover]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[cta_button_text_color_hover]',
array(
'default' => $defaults['form_button_text_color_hover'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[cta_button_text_color_hover]',
array(
'label' => __( 'Text Hover', 'gp-premium' ),
'section' => 'buttons_color_section',
'settings' => 'generate_settings[cta_button_text_color_hover]',
)
)
);
}
add_action('customize_register', 'gp_customize_cta_color');
Do i need to rewrite everything ?
Yeah - that color functions aren't going to work.
The possible good news is though you shouldn't require those PHP to do this now.
In the the new Global Colors see here:
https://docs.generatepress.com/article/using-global-colors/
you can add your own color variables. eg. my-color can be simply added to your CSS properties eg.
.element {
color: var(--my-color);
}
So you just need a bunch of global colors to add into your CSS.
Thanks David for your help. I will try to do it myself so.
You're welcome