• If you’re getting warning errors like this:

    Warning: Illegal string offset 'type' in /YOUR-PATH/wp-content/plugins/tc-comment-out/tc-comment-out.php on line 24
    
    Warning: Illegal string offset 'type' in /YOUR-PATH/wp-content/plugins/tc-comment-out/tc-comment-out.php on line 29

    You can fix it by editing the tc-comment-out.php file to add this code as the first line in the first function:

    $attr = array();

    so that it looks like this:

    function tc_comment_out_shortcode( $attr, $content ) {
    
        /**
        THEIR COMMENT BLOCK -- DELETED FOR BREVITY
         */
         
        $attr = array();
        
        if ( ( ( is_array( $attr ) ) && ( ! array_key_exists( 'type', $attr ) ) ) || ( ! is_array( $attr ) ) ) {
            $attr['type'] = 'html';
        }
    ...etc...
    • This topic was modified 5 years, 9 months ago by jandreasen.
Viewing 1 replies (of 1 total)
  • That is right way to handle dynamic block.Please try this.
    Note: As you define attributes in JS same you need to define in PHP

    register_block_type( 'my_namespace/my_block', [
        'render_callback' => 'render_callback',
        'attributes'      => [
            'some_string' => [
                'default' => 'default string',
                'type'    => 'string'
            ],
            'some_array'  => [
                'type'  => 'array',
                'items' => [
                    'type' => 'string',
                ],
            ]
        ]
    ] );
    
    function render_callback( $attr, $content ){
    }
    • This reply was modified 5 years, 5 months ago by Sharaz Shahid.
Viewing 1 replies (of 1 total)
  • The topic ‘Fix for Illegal string offset PHP Warning’ is closed to new replies.