• Resolved periago89

    (@periago89)


    Buenos días, estoy dise?ando mi tienda online y me esta dando el siguiente error cuando a?ado un producto al carrito:

    Warning: Cannot modify header information – headers already sent by (output started at /home/customer/www/perlighting.com/public_html/wp-content/themes/generatepress/header.php:12) in /home/customer/www/perlighting.com/public_html/wp-content/themes/generatepress/header.php on line 81

    Os paso el functios.php para ver si me podéis dar una solución.

    <?php
    /**
     * GeneratePress.
     *
     * Please do not make any edits to this file. All edits should be done in a child theme.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    // Set our theme version.
    define( 'GENERATE_VERSION', '2.4.2' );
    
    if ( ! function_exists( 'generate_setup' ) ) {
    	add_action( 'after_setup_theme', 'generate_setup' );
    	/**
    	 * Sets up theme defaults and registers support for various WordPress features.
    	 *
    	 * @since 0.1
    	 */
    	function generate_setup() {
    		// Make theme available for translation.
    		load_theme_textdomain( 'generatepress' );
    
    		// Add theme support for various features.
    		add_theme_support( 'automatic-feed-links' );
    		add_theme_support( 'post-thumbnails' );
    		add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'status' ) );
    		add_theme_support( 'woocommerce' );
    		add_theme_support( 'title-tag' );
    		add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
    		add_theme_support( 'customize-selective-refresh-widgets' );
    		add_theme_support( 'align-wide' );
    		add_theme_support( 'responsive-embeds' );
    
    		add_theme_support( 'custom-logo', array(
    			'height' => 70,
    			'width' => 350,
    			'flex-height' => true,
    			'flex-width' => true,
    		) );
    
    		// Register primary menu.
    		register_nav_menus( array(
    			'primary' => __( 'Primary Menu', 'generatepress' ),
    		) );
    
    		/**
    		 * Set the content width to something large
    		 * We set a more accurate width in generate_smart_content_width()
    		 */
    		global $content_width;
    		if ( ! isset( $content_width ) ) {
    			$content_width = 1200; /* pixels */
    		}
    
    		// This theme styles the visual editor to resemble the theme style.
    		add_editor_style( 'css/admin/editor-style.css' );
    	}
    }
    
    /**
     * Get all necessary theme files
     */
    $theme_dir = get_template_directory();
    
    require $theme_dir . '/inc/theme-functions.php';
    require $theme_dir . '/inc/defaults.php';
    require $theme_dir . '/inc/class-css.php';
    require $theme_dir . '/inc/css-output.php';
    require $theme_dir . '/inc/general.php';
    require $theme_dir . '/inc/customizer.php';
    require $theme_dir . '/inc/markup.php';
    require $theme_dir . '/inc/typography.php';
    require $theme_dir . '/inc/plugin-compat.php';
    require $theme_dir . '/inc/block-editor.php';
    require $theme_dir . '/inc/migrate.php';
    require $theme_dir . '/inc/deprecated.php';
    
    if ( is_admin() ) {
    	require $theme_dir . '/inc/meta-box.php';
    	require $theme_dir . '/inc/dashboard.php';
    }
    
    /**
     * Load our theme structure
     */
    require $theme_dir . '/inc/structure/archives.php';
    require $theme_dir . '/inc/structure/comments.php';
    require $theme_dir . '/inc/structure/featured-images.php';
    require $theme_dir . '/inc/structure/footer.php';
    require $theme_dir . '/inc/structure/header.php';
    require $theme_dir . '/inc/structure/navigation.php';
    require $theme_dir . '/inc/structure/post-meta.php';
    require $theme_dir . '/inc/structure/sidebars.php';
    
    /**
     * Use WC 2.0 variable price format, now include sale price strikeout
     *
     * @param  string $price
     * @param  object $product
     * @return string
     */
    function wc_wc20_variation_price_format( $price, $product ) {
        // Main Price
        $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
        $price = $prices[0] !== $prices[1] ? sprintf( __( 'Desde: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    
        // Sale Price
        $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
        sort( $prices );
        $saleprice = $prices[0] !== $prices[1] ? sprintf( __( '', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
    
        if ( $price !== $saleprice ) {
            $price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
        }
        
        return $price;
    }
    add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
    
    add_filter('woof_use_chosen', function($is)
    {
     if (wp_is_mobile())
     {
         return false;
     }
     
     return $is;
    });
    
    add_filter ('wc_add_to_cart_message_html', '__return_null');

    Creo que falta el ?> y por eso me está dando fallo, es posible?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter periago89

    (@periago89)

    Perdón, me he dado cuenta de que el problema lo está dando el archivo Header.php

    Os paso el codigo para ver si podemos solucionarlo.

    <?php
    /**
     * The template for displaying the header.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    	<meta charset="<?php bloginfo( 'charset' ); ?>">
    	<link rel="profile" href="https://gmpg.org/xfn/11">
    	<?php wp_head(); ?>
    	<script data-ad-client="ca-pub-3246605877989131" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    	<script src="https://cdn.aplazame.com/aplazame.js"
            data-aplazame="2ee92b6cd56749221c4cc48abb8356f70e7cff6e"
            data-sandbox="true"></script>
    </head>
    
    <body <?php body_class(); ?> <?php generate_do_microdata( 'body' ); ?>>
    	<?php
    	/**
    	 * wp_body_open hook.
    	 *
    	 * @since 2.3
    	 */
    	do_action( 'wp_body_open' );
    
    	/**
    	 * generate_before_header hook.
    	 *
    	 * @since 0.1
    	 *
    	 * @hooked generate_do_skip_to_content_link - 2
    	 * @hooked generate_top_bar - 5
    	 * @hooked generate_add_navigation_before_header - 5
    	 */
    	do_action( 'generate_before_header' );
    
    	/**
    	 * generate_header hook.
    	 *
    	 * @since 1.3.42
    	 *
    	 * @hooked generate_construct_header - 10
    	 */
    	do_action( 'generate_header' );
    
    	/**
    	 * generate_after_header hook.
    	 *
    	 * @since 0.1
    	 *
    	 * @hooked generate_featured_page_header - 10
    	 */
    	do_action( 'generate_after_header' );
    	?>
    
    	<div id="page" class="hfeed site grid-container container grid-parent">
    		<?php
    		/**
    		 * generate_inside_site_container hook.
    		 *
    		 * @since 2.4
    		 */
    		do_action( 'generate_inside_site_container' );
    		?>
    		<div id="content" class="site-content">
    			<?php
    			/**
    			 * generate_inside_container hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_inside_container' );
    			
    			header("Cache-Control: must-revalidate");
    
    header("Expires: ".gmdate ("D, d M Y H:i:s", time() + 60*60*24*30)." GMT");
    Leo

    (@leohsiang)

    Hi there,

    Have you resolved this? The topic is marked as resolved.

    Please make sure not to modify the theme’s core files.

    The header.php file should be exactly like this:
    https://github.com/tomusborne/generatepress/blob/master/header.php

    Changes like above should be done in a child theme environment.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Warning: Cannot modify header information’ is closed to new replies.