[Resolved] Problems with child theme / code snippets

Home Forums Support [Resolved] Problems with child theme / code snippets

Home Forums Support Problems with child theme / code snippets

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1539342
    perlfan

    Hi,
    So I realized that I need to secure my additional css and functions.php alterations if I don’t want to loose them when updating. Therefore I copied the additional CSS (added in customizer) to a Simple CSS plugin. After that I copied the custom php from my functions.php to a code snippet. Then I got a Fatal error and had to restore my site (before that I had tried to install a child theme and copy the custom php from my functions.php to the functions.php of the child theme, but that didn’t work either). What I’m missing are simple instruction how to secure functions.php alterations correctly. Thanks for help. Frank

    The error:
    Fatal error: Cannot redeclare woocommerce_template_product_reviews() (previously declared in /var/www/web41/html/belaubigteuebersetzung/wp-content/plugins/code-snippets/php/snippet-ops.php(446) : eval()’d code:63) in /var/www/web41/html/belaubigteuebersetzung/wp-content/themes/generatepress/functions.php on line 162

    #1539401
    Leo
    Staff
    Customer Support

    Hi there,

    I believe that error is saying that you are using woocommerce_template_product_reviews() twice.

    Can you disable Code Snippets before activating the child theme?

    #1543479
    perlfan

    Hi Leo, thanks for your answer. Now I copied piece by piece from the main functions.php to the child functions.php. It works – except when I copied the last piece, I get a fatal error when opening the child functions.php. When I copy the code piece back to the main functions.php, the site works again (without an error). I know that it is a redeclare error, but the main functions.php is the default version without any custom code in it, so no chance to redeclare. The code which triggers the error is below the error message. Why is the child functions.php not able to process the code correctly? Thanks, Frank

    Fatal error: Cannot redeclare wpf_dev_math_captcha_settings() (previously declared in /var/www/web41/html/belaubigteuebersetzung/wp-content/themes/generatepress_child/functions.php:85) in /var/www/web41/html/belaubigteuebersetzung/wp-content/themes/generatepress/functions.php on line 151

    function wpf_dev_math_captcha_settings( $settings ) {
         
        /* Default settings
            array(
                'min' => 1,
                'max' => 15,
                'cal' => array( '+', '*' ),
            );
         */
     
        // Change max number 4 for easier math
        $settings['max'] = 4;
    	$settings['cal'] = '+';
     
        return $settings;
    }
    add_filter( 'wpforms_math_captcha', 'wpf_dev_math_captcha_settings' );
    #1543494
    Leo
    Staff
    Customer Support

    Have you checked with WP Forms support team on this?

    I’m not familiar with that code.

    #1543617
    perlfan

    Ok, I’ll try to resolve with them. Thanks, Frank

    #1544686
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.