• Please, can somebody help me?

    I created plugin for Woocommerce. Plugin is generating XML FEED for Woocommerce products. But after activating it gives me “Headers already sent” and WordPress gone white.

    Some people got after activating “possible duplicate of Headers”

    Do not know, where is bug. This is, where I have it – GitHub.com – my plugin.

    I have done everything that I could (red all articles). BOM is OK, spaces are OK, no “print” and “echo” is under header …

    Thank you for helping me.

    <?php
    
    if (!isset($wpdb)) $wpdb = $GLOBALS['wpdb'];
    
    //Define the product feed php page
    function podujatie3_feed_rss3() {
     $rss_template = dirname(__FILE__) . '/product-feed.php';
     load_template ( $rss_template );
    }
    
    //Add the product feed RSS
    add_action('do_feed_heureka', 'podujatie3_feed_rss3', 10, 1);
    
    //Update the Rerewrite rules
    add_action('init', 'moje_pridanie_produkt_heureka');
    
    //function to add the rewrite rules
    function moje_prepisanie_produktov_pravidlo3( $wp_rewrite ) {
     $new_rules = array(
     'feed/(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1)
     );
     $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
    }
    
    //add the rewrite rule
    function moje_pridanie_produkt_heureka( ) {
     global $wp_rewrite;
     add_action('generate_rewrite_rules', 'moje_prepisanie_produktov_pravidlo3');
     $wp_rewrite->flush_rules();
    }
    
    $podujatie3_ver = '2.00';
    
    add_option('products_in_feed', 50);
    add_option('feed_title', '');
    add_option('product_condition', 'nové');
    add_option('product_dph', 'DPH');
    add_option('product_na_sklade', 'na sklade');
    add_option('product_out_stock', 'mimo skladu');
    add_option('product_type', 'Software > WordPress > Plugin');
    
    add_option('podujatie3_what_to_show', 'both');
    add_option('podujatie3_which_first', 'posts');
    add_option('podujatie3_post_sort_order', 'title');
    add_option('podujatie3_page_sort_order', 'title');
    add_option('podujatie3_comments_on_posts', FALSE);
    add_option('podujatie3_comments_on_pages', FALSE);
    add_option('podujatie3_show_zero_comments', FALSE);
    add_option('podujatie3_hide_future', FALSE);
    add_option('podujatie3_new_window', FALSE);
    add_option('podujatie3_show_post_date', FALSE);
    add_option('podujatie3_show_page_date', FALSE);
    add_option('podujatie3_date_format', 'F jS, Y');
    add_option('podujatie3_hide_protected', TRUE);
    
    add_option('podujatie3_excluded_pages', '');
    add_option('podujatie3_page_nav', '1');
    add_option('podujatie3_page_nav_where', 'top');
    add_option('podujatie3_xml_path', '');
    
    add_option('podujatie3_xml_where', 'last');
    
    function podujatie3_xml_feed2() {
        if (function_exists('add_options_page')) {
            add_options_page('XML Feed heureka', 'XML Feed heureka', 8, __FILE__, 'podujatie3_options_page');
        }
    }
    
    /*
     * Generating options
     */
    function podujatie3_options_page() {
    
        global $podujatie3_ver;
    
        if (isset($_POST['set_defaults'])) {
            echo '<div id="message" class="updated fade"><p><strong>';
    
            update_option('products_in_feed', 50);
            update_option('feed_title', '');
            update_option('product_condition', 'new');
            update_option('podujatie3_what_to_show', 'both');
            update_option('podujatie3_which_first', 'posts');
            update_option('podujatie3_post_sort_order', 'title');
            update_option('podujatie3_page_sort_order', 'title');
            update_option('podujatie3_comments_on_posts', FALSE);
            update_option('podujatie3_comments_on_pages', FALSE);
            update_option('podujatie3_show_zero_comments', FALSE);
            update_option('podujatie3_hide_future', FALSE);
            update_option('podujatie3_new_window', FALSE);
            update_option('podujatie3_show_post_date', FALSE);
            update_option('podujatie3_show_page_date', FALSE);
            update_option('podujatie3_date_format', 'F jS, Y');
            update_option('podujatie3_hide_protected', TRUE);
            update_option('podujatie3_excluded_pages', '');
            update_option('podujatie3_page_nav', '1');
            update_option('podujatie3_page_nav_where', 'top');
            update_option('podujatie3_xml_path', '');
            update_option('product_type', 'Software > WordPress > Plugin');
                update_option('product_dph', 'DPH');
                update_option('product_na_sklade', 'na sklade');
                update_option('product_out_stock', 'mimo skladu');
            update_option('podujatie3_xml_where', 'last');
    
            echo podujatie3_DEFAULTS_LOADED;
            echo '</strong></p></div>'; 
    
        } else if (isset($_POST['info_update'])) {
    
            echo '<div id="message" class="updated fade"><p><strong>';
    
            update_option('podujatie_language3', (string) $_POST["podujatie_language3"]);
            update_option('products_in_feed', (int) $_POST["products_in_feed"]);
            update_option('feed_title', (string) $_POST["feed_title"]);
            update_option('podujatie3_what_to_show', (string) $_POST["podujatie3_what_to_show"]);
            update_option('podujatie3_which_first', (string) $_POST["podujatie3_which_first"]);
            update_option('podujatie3_post_sort_order', (string) $_POST["podujatie3_post_sort_order"]);
            update_option('podujatie3_page_sort_order', (string) $_POST["podujatie3_page_sort_order"]);
            update_option('podujatie3_comments_on_posts', (bool) $_POST["podujatie3_comments_on_posts"]);
            update_option('podujatie3_comments_on_pages', (bool) $_POST["podujatie3_comments_on_pages"]);
            update_option('podujatie3_show_zero_comments', (bool) $_POST["podujatie3_show_zero_comments"]);
            update_option('podujatie3_hide_future', (bool) $_POST["podujatie3_hide_future"]);
            update_option('podujatie3_new_window', (bool) $_POST["podujatie3_new_window"]);
            update_option('podujatie3_show_post_date', (bool) $_POST["podujatie3_show_post_date"]);
            update_option('podujatie3_show_page_date', (bool) $_POST["podujatie3_show_page_date"]);
            update_option('podujatie3_date_format', (string) $_POST["podujatie3_date_format"]);
            update_option('podujatie3_hide_protected', (bool) $_POST["podujatie3_hide_protected"]);
            update_option('product_condition', (string) $_POST["product_condition"]);
            update_option('podujatie3_excluded_pages', (string) $_POST["podujatie3_excluded_pages"]);
            update_option('podujatie3_page_nav', (string) $_POST["podujatie3_page_nav"]);
            update_option('podujatie3_page_nav_where', (string) $_POST["podujatie3_page_nav_where"]);
            update_option('podujatie3_xml_path', (string) $_POST["podujatie3_xml_path"]);
            update_option('product_type', (string) $_POST["product_type"]);
                update_option('product_dph', (string) $_POST["product_dph"]);
    update_option('product_na_sklade', (string) $_POST["product_na_sklade"]);
    update_option('product_out_stock', (string) $_POST["product_out_stock"]);
            update_option('podujatie3_xml_where', (string) $_POST["podujatie3_xml_where"]); 
    
            echo podujatie3_CONFIG_UPDATED;
            echo '</strong></p></div>';
        } ?>
    
        <div class="wrap">
    
        <h2>Woocommerce xml feed pre web heureka od Podujatie.eu - v. <?php echo $podujatie3_ver; ?> - Free verzia</h2>
    
        <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
        <input type="hidden" name="info_update" id="info_update" value="true" />
    
        <fieldset class="options">
    
        <table width="100%" border="0" cellspacing="0" cellpadding="6">
    
        <tr valign="top">
    
        <th width="45%" valign="top" align="right" scope="row">Titulok xml feed-u</th><td valign="top">
        <input name="feed_title" type="text" size="35" value="<?php echo bloginfo_rss('name'); wp_title_rss(); ?>"/><br />
        Prednastavené je<strong><?php echo bloginfo_rss('name'); wp_title_rss(); ?></strong>
        </td></tr>
    
        <tr><th width="45%" valign="top" align="right" scope="row">Popis feed-u</th><td valign="top">
        <input name="feed_description" type="text" size="45" value="<?php bloginfo_rss('description') ?>"/><br />
        Prednastavené je<strong><?php bloginfo_rss('description') ?></strong>
        </td></tr>
    
        <tr><th width="45%" valign="top" align="right" scope="row">Stav produktu</th><td valign="top">
        <input name="product_condition" type="radio" value="new" <?php if (get_option('product_condition') == "new") echo "checked='checked'"; ?> />&nbsp;&nbsp; new
        <input name="product_condition" type="radio" value="used" <?php if (get_option('product_condition') == "used") echo "checked='checked'"; ?> />&nbsp;&nbsp; used
        <input name="product_condition" type="radio" value="refurbished" <?php if (get_option('product_condition') == "refurbished") echo "checked='checked'"; ?>/>&nbsp;&nbsp; refurbished<br />
        Prednastavené je<strong>nové</strong>. M??e? ale nastavi? na <strong>pou?ívané</strong> alebo <strong>repasované</strong>.<br /><br />
            </td></tr>
    
        <tr><th width="45%" valign="top" align="right" scope="row">Na sklade - mo?nosti</th><td valign="top">
        <input name="product_na_sklade" type="radio" value="na sklade" <?php if (get_option('product_na_sklade') == "na sklade") echo "checked='checked'"; ?> />&nbsp;&nbsp; na sklade
        <input name="product_na_sklade" type="radio" value="available for order" <?php if (get_option('product_na_sklade') == "available for order") echo "checked='checked'"; ?> />&nbsp;&nbsp; mo?né na objednávku<br />
            Prednastavené je<strong>na sklade</strong>. M??e? tie? nastavi? na <strong>mo?né na objednávku</strong>.<br /><br />
             </td></tr>
    
        <tr><th width="45%" valign="top" align="right" scope="row">Mimo skladu - mo?nosti</th><td valign="top">
        <input name="product_out_stock" type="radio" value="mimo skladu" <?php if (get_option('product_out_stock') == "mimo skladu") echo "checked='checked'"; ?> />&nbsp;&nbsp; mimo skladu
        <input name="product_out_stock" type="radio" value="preorder" <?php if (get_option('product_out_stock') == "preorder") echo "checked='checked'"; ?> />&nbsp;&nbsp; predobjednávka<br />
            Prednastavené je<strong>mimo skladu</strong>. M??e? tie? nastavi? na <strong>predobjednávka</strong>.<br /><br />
        </td></tr>
    
        <tr></td><th width="45%" valign="top" align="right" scope="row">DPH</th><td valign="top">
        <input name="product_dph" type="text" size="25" value="<?php echo get_option('product_dph') ?>"/><br />
        </td></tr>
    
    <tr><th width="45%" valign="top" align="right" scope="row">Typ produktu</th><td valign="top">
        <input name="product_type" type="text" size="75" value="<?php echo get_option('product_type') ?>"/><br />
        Prednastavené je<strong>Software > WordPress > Plugin</strong><br />
        Atribúty produktu m??e? nastavi? aj pod?a taxanómie Google merchant. Prosím zadaj pre vyhladávanie a plugin ti pom??e. Nie je to v?ak potrebné zadáva? znova (u? raz si to zadal/a)<br />
        </td></tr>
    
        <br /><br /><br /><br />
    
        </table>
        </fieldset>
    
        <div class="submit">
            <input type="submit" name="set_defaults" value="Nastavi? na prednastavené &raquo;" />
            <input type="submit" name="info_update" value="Ulo?i? nastavenia &raquo;" />
        </div>
    
        </form>
    
        <h2> Tvoj celkovy xml feed m??e? vzhliadnu? tu <a target="_blank" href="<?php bloginfo_rss('wpurl') ?>/feed/heureka/"><?php bloginfo_rss('wpurl') ?>/feed/heureka/</a></h2>
    
    <table width="100%" border="0" cellspacing="0" cellpadding="6">
    <tr>
    <th>ID produktu</th>
    <th>Názov</th>
    <th>Popis</th>
    <th>URL link</th>
    <th>Cena s DPH</th>
    <th>Kategória</th>
    <th>EAN</th>
    </tr>
        <?php
        $args = array( 'post_type' => 'product', 'posts_per_page' => 1 );
        $loop = new WP_Query( $args );
        while ( $loop->have_posts() ) : $loop->the_post(); global $product;
        ?>
    
        <product>
        <tr>
            <td><ITEM_ID><?php echo $product->get_sku(); ?></ITEM_ID></td>
            <td><PRODUCTNAME><?php the_title_rss() ?></PRODUCTNAME></td>
    <td><?php if (get_option('rss_use_excerpt')) : ?>
            <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    <?php else : ?>
            <description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
    <?php endif; ?></td>
            <td><URL><?php the_permalink_rss() ?></URL></td>
            <td><PRICE_VAT><?php echo $product->price ?></PRICE_VAT></td>
            <td><CATEGORYTEXT><?php echo get_option('product_type') ?></CATEGORYTEXT></td>
            <td><EAN><?php echo $product->get_sku(); ?></EAN></td>
    
    <?php rss_enclosure(); ?>
        <?php do_action('rss2_item'); ?>
        </tr></product>
    
        <?php endwhile; ?>
    </table>
    
        </div><?php
    }
    add_action('admin_menu', 'podujatie3_xml_feed2');
Viewing 1 replies (of 1 total)
  • Thread Starter Brand Institute

    (@podujatie)

    Specific error is Warning: Cannot modify header information - headers already sent by (output started at /domains1/xxxx/public/www_root/wp-includes/functions.php:2925) in /domains1/xxxx/public/www_root/wp-includes/pluggable.php on line 876

    Please

Viewing 1 replies (of 1 total)
  • The topic ‘my Woocommerce plugin gives Headers already sent’ is closed to new replies.