• Resolved Josh Feck

    (@builtbynorthby)


    Hi there,

    In aioseop_module_class.php starting around line 1254, some inline JavaScript runs in the post editor aiseop metabox:

    if ( !empty( $options['count'] ) ) {
    	$n++;
    	$attr .= " onKeyDown='countChars(document.{$this->form}.$name,document.{$this->form}.{$prefix}length$n)' onKeyUp='countChars(document.{$this->form}.$name,document.{$this->form}.{$prefix}length$n)'";
    	$onload = "countChars(document.{$this->form}.$name,document.{$this->form}.{$prefix}length$n);";
    }

    There’s a problem that happens when the file that defines the countChars function isn’t enqueued. Why isn’t it enqueued? Because there’s a conditional wrapped around the part where aiosep_module.js is enqueued.

    The conditional check on whether to enqueue aiosep_module.js doesn’t always work as expected. When the JS file isn’t loaded, and there’s a metabox in the post editor, it creates a bad experience for the user because they end up with a post editor with broken JavaScript, with this JavaScript error:

    Uncaught ReferenceError: countChars is not defined

    Please check if this function exists before calling it to avoid the error.

    https://wordpress.org/plugins/all-in-one-seo-pack/

Viewing 1 replies (of 1 total)
  • Hi Josh,

    I just saw this duplicate post; this is just a note that I’ll be using the other thread for this, and that this will be fixed in the next release as well.

Viewing 1 replies (of 1 total)
  • The topic ‘Please check for the presence of the countChars function before calling it’ is closed to new replies.