Support » Plugin: Classic Editor » Fatal Error: [] operator not supported for strings line 681

  • Resolved presswizards

    (@presswizards)


    I installed on a site with older plugins, and was getting this error on the Plugins page of the back-end Admin area:
    Fatal error: Uncaught Error: [] operator not supported for strings in /plugins/classic-editor/classic-editor.php:681

    I edited the plugin as a kludge fix, added this line:
    $links = array($links);

    So it is now:

    	/**
    	 * Add a link to the settings on the Plugins screen.
    	 */
    	public static function add_settings_link( $links, $file ) {
    		$settings = self::get_settings();
    		$links = array($links);
    		if ( $file === 'classic-editor/classic-editor.php' && ! $settings['hide-settings-ui'] && current_user_can( 'manage_options' ) ) {
    			(array) $links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'options-writing.php#classic-editor-options' ), __( 'Settings', 'classic-editor' ) );
    		}
    
    		return $links;
    	}
    

    The site is running 7.1.x and I understand some other plugin is probably causing this, but your plugin should probably include this line so it is more compatible with newer PHP and older plugins.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andrew Ozz

    (@azaozz)

    Thanks for the bug report.

    Yes, this is caused by another plugin not returning an array after using the plugin_action_links filter.

    It is already fixed in the next version, hoping we can release it in a few days. (Note that we need to cast $links to array, not wrap it in another array, see: https://github.com/WordPress/classic-editor/blob/master/classic-editor.php#L720.)

    presswizards

    (@presswizards)

    Thanks, this fixes the Fatal error, but the display of links under the plugins was still broken. It was caused by an old plugin that was not using an array for it’s $links modification, WP Editor, which is also abandoned and not updated, which is a major security risk as well, so we deactivated it.

    But thank you for your help in patching it while we figured that out, and this should help with other plugins also causing similar issues.

    Rob

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal Error: [] operator not supported for strings line 681’ is closed to new replies.