Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Warning: Cannot modify header information

Open QwertyAzerY opened this issue 8 years ago • 2 comments

There was a problem with customization of the framework. I created my "myblock" element but produces an error:

Warning: Cannot modify header information - headers already sent by (output started at C:\OSPanel\domains\wordpress\wp-content\themes\megart-theme\framework-customizations\extensions\shortcodes\shortcodes\myblock\options.php:1) in C:\OSPanel\domains\wordpress\wp-admin\post.php on line 198

Warning: Cannot modify header information - headers already sent by (output started at C:\OSPanel\domains\wordpress\wp-content\themes\megart-theme\framework-customizations\extensions\shortcodes\shortcodes\myblock\options.php:1) in C:\OSPanel\domains\wordpress\wp-includes\pluggable.php on line 1216

my options.php ` <?php if (!defined('FW')) {
  die('Forbidden');
 }

$options = array(
    'myblockname' => array(
    'type'  => 'text',
    'value' => 'div',
    'label' => __('Name', 'fw'),
),
    'myblockclass' => array(
    'type'  => 'text',
    'value' => '',
    'label' => __('Class', 'fw'),
),
    'myblockid' => array(
    'type'  => 'text',
    'value' => '',
    'label' => __('ID', 'fw'),
),
    'myblockin' => array(
		'type'   => 'wp-editor',
		'label'  => __( 'Content', 'fw' ),
		'desc'   => __( 'Enter some content for this texblock', 'fw' )
	),
    'myblockstyle' => array(
    'type'  => 'textarea',
    'value' => '',
    'label' => __('Styles', 'fw'),
),
);

`

my config.php
<?php if (!defined('FW')) {
 die('Forbidden');
}


$cfg = array(
    'page_builder' => array(
        'title'         => __('myblock', 'fw'),
        'description'   => __('Demo shortcode description', 'fw'),
        'tab'           => __('myTab', 'fw'),
        'popup_size'    => 'small', // can be large, medium or small

     
    )
);


my view.php 
<?php if (!defined('FW')) {
 die('Forbidden');
}
$myblock_style= ( isset( $atts['myblockstyle'] ) && $atts['myblockstyle'] ) ? ' ' . $atts['myblockstyle']  . ' ': '';
$myblock_id= ( isset( $atts['myblockid'] ) && $atts['myblockid'] ) ? ' ' . $atts['myblockid']  . ' ': '';
$myblock_class= ( isset( $atts['myblockclass'] ) && $atts['myblockclass'] ) ? ' ' . $atts['myblockclass']  . ' ': '';
$myblock_in= ( isset( $atts['myblockclass'] ) && $atts['myblockclass'] ) ? ' ' . $atts['myblockclass']  . ' ': '';


?>
<div style="<?php echo "$myblock_style"; ?>" id="<?php echo "$myblock_id"; ?>" class="<?php echo "$myblock_class"; ?>"><?php echo "$myblock_in"; ?></div>

QwertyAzerY avatar Jun 07 '18 20:06 QwertyAzerY

I tested your shortcode but didn't get any warning...

I have a suggestion though, for a cleaner code, try to use the 'multi' option http://manual.unyson.io/en/latest/options/built-in/multi.html

myblock

  • name
  • class
  • id ....

and to output your code, use helpers fw_html_tag or fw_attr_to_html http://manual.unyson.io/en/latest/helpers/php.html

jonmlas avatar Jun 11 '18 16:06 jonmlas

I also tested your code and everything is fine there is no issues. Check your hooks, and server configurations.

ViorelEremia avatar Jun 15 '18 15:06 ViorelEremia