MerlinWP icon indicating copy to clipboard operation
MerlinWP copied to clipboard

Cannot modify header information

Open bilalmalkoc opened this issue 7 years ago • 14 comments

I got this error when activating theme.

Warning: Cannot modify header information - headers already sent by (output started at /home/server/public_html/wp-admin/includes/plugin.php:1511) in /home/server/public_html/wp-includes/pluggable.php on line 1223 https://site.com/wp-admin/themes.php?page=mytheme-welcome

$config = array(
    'directory'            => 'inc/merlin', // Location / directory where Merlin WP is placed in your theme.
    'merlin_url'           => 'mytheme-welcome', // The wp-admin page slug where Merlin WP loads.
    'parent_slug'          => 'themes.php', // The wp-admin parent page slug for the admin menu item.
    'capability'           => 'manage_options', // The capability required for this menu to be displayed to the user.
    'child_action_btn_url' => 'https://codex.wordpress.org/child_themes', // URL for the 'child-action-link'.
    'dev_mode'             => true, // Enable development mode for testing.
    'license_step'         => false, // EDD license activation step.
    'license_required'     => false, // Require the license activation step.
    'license_help_url'     => '', // URL for the 'license-tooltip'.
    'edd_remote_api_url'   => 'https://site.com/edd-api/', // EDD_Theme_Updater_Admin remote_api_url.
    'edd_item_name'        => 'My Theme', // EDD_Theme_Updater_Admin item_name.
    'edd_theme_slug'       => 'mytheme', // EDD_Theme_Updater_Admin item_slug.
    'ready_big_button_url' => '', // Link for the big button on the ready step.
),

bilalmalkoc avatar Feb 16 '19 09:02 bilalmalkoc

I get the same error(( What is the reason can be?

kaganvmz avatar Feb 23 '19 17:02 kaganvmz

I don't know. Can't find solution.

bilalmalkoc avatar Feb 23 '19 17:02 bilalmalkoc

@bilalmalkoc the error appears only on my local server. I have tried to install the theme on my hosting and it was ok.

kaganvmz avatar Feb 23 '19 17:02 kaganvmz

@kaganvmz it is interesting. Because it shows this error in real server, but works in localhost.

bilalmalkoc avatar Feb 23 '19 17:02 bilalmalkoc

@bilalmalkoc It seems I have just solved the problem. Which version do you use? I have used 1.0.0 and I just installed 1.0.0-rc.1 and the issue disappeared.

kaganvmz avatar Feb 24 '19 13:02 kaganvmz

@kaganvmz I am using latest release Are you sure want to use old version?

bilalmalkoc avatar Feb 24 '19 13:02 bilalmalkoc

@bilalmalkoc No. But it helped to find where is the problem. The problem is on this commit https://github.com/richtabor/MerlinWP/commit/c199cd24a399868d7aa917796962acb549466692 If you do roll back everything will work even on the latest version.

kaganvmz avatar Feb 24 '19 14:02 kaganvmz

@bilalmalkoc The plugin is printing output (text) to the browser, but then WordPress is redirecting the user (with wp_redirect) away from that page before the whole page is rendered. We can't start printing output and then redirect, or we'll get the error we see.

I've fixed this in my own experience by buffering the output of the script.

In my theme's functions.php file, put the following:

add_action('init', 'do_output_buffer'); function do_output_buffer() { ob_start(); } And now the plugin is working on the right way even I use the latest version. @richtabor We need your help to understand why is it happens?

kaganvmz avatar Feb 24 '19 14:02 kaganvmz

@kaganvmz it works now.

bilalmalkoc avatar Feb 24 '19 15:02 bilalmalkoc

same +

Ninetheme avatar Mar 28 '19 17:03 Ninetheme

It might be a temporary solution. In case anyone wants to solve this issue in the lastest realease( 1.0.0 ), I solved it by passing second parameter as false in merlin/class-merlin.php L373 like below: wp_safe_redirect( menu_page_url( $this->merlin_url, false ) );

sachyya avatar May 14 '19 17:05 sachyya

@sachyya What about Pull Request?

kaganvmz avatar Aug 09 '19 14:08 kaganvmz

I found the fix for this problem. image wp-content\themes\yourtheme\merlin\class-merlin.php 373 line ))

	wp_safe_redirect( admin_url( 'themes.php?page=merlin') );

adhamqodirov avatar Jan 09 '21 13:01 adhamqodirov