Search code examples
phpwordpresssyntax-errorfilezilla

WordPress site with unending Parse Syntax Errors


I am very new to coding - I was actually just trying to learn to edit an old website for a friend using WordPress, to make it more visually appealing and fresh.

Everything was way out of date, so I backed up the site, then started updating things in what I thought was the right order, but I was probably wrong since once I updated the plugins I got a Parse Syntax error and can't get into the wp-admin now.

I went through the steps in this tutorial (using FileZilla and Notepad++) to try and fix it, but it keeps giving me a new Parse Syntax error in the same file. Now I'm worried I'm just making things worse in there and I'm not certain what I should do.

The initial error was an unexpected "[" (or "]"? idr now...) on line 344, so I thought I needed to just get rid of it, but I don't think I was right. This is the error I have now, after trying to change things 2-3 times:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/67/14065667/html/wp-content/plugins/page-links-to/classes/plugin.php on line 346

Here is the section of coding I've been having issues in (lines 340-351):

public function enqueue_block_editor_assets() {
    // Gutenberg.
    if ( self::is_block_editor() && self::is_supported_post_type() ) {
        wp_enqueue_script( 'plt-block-editor', $this->get_url() . 'dist/block-editor.js', array( 'wp-edit-post', 'wp-element', 'wp-plugins' ), self::CSS_JS_VERSION, true );
        wp_localize_script( 'plt-block-editor', 'pltOptions', 
            'supports'  
                'newTab' => self::supports( 'new_tab' ),
            ],
        ]);
        do_action( 'page_links_to_enqueue_block_editor_assets' );
    }
}

What can I try to fix this?


Solution

  • Seems your argument list for wp_localize_script is malformed. It should be something like

    wp_localize_script( string $handle, string $object_name, array $l10n )
    

    Address that and you should be good. Without more context of what should belong to the $handle, $object_name and $l10n, can't fully type an answer to clear it up.

    WP Localized Script Docs