10up / plugin-scaffold

DEPRECATED. Use https://github.com/10up/wp-scaffold

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fatal error in post editor

Kluny opened this issue · comments

Action:

Edit a page in wp-admin

Expected:

No php errors

Instead:

I see this error:

Fatal error: Cannot redeclare Facebook\Elearning\Plugin\Core\style_url() 
(previously declared in /srv/www/fbelearning/public_html/wp-content/plugins/fb-elearning/includes/functions/core.php:115) 
in /srv/www/fbelearning/public_html/wp-content/plugins/fb-elearning/includes/functions/core.php 
on line 261

core.php contains these two snippets:

https://github.com/10up/plugin-scaffold/blob/master/includes/functions/core.php#L98

function style_url( $stylesheet, $context ) {
	if( !in_array( $context, ['admin', 'frontend', 'shared'], true) ) {
		error_log('Invalid $context specfied in TenUpScaffold stylesheet loader.');
		return '';
	}
	return ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ?
		TENUP_SCAFFOLD_URL . "assets/css/${context}/{$stylesheet}.css" :
		TENUP_SCAFFOLD_URL . "dist/css/${stylesheet}.min.css" ;
}

https://github.com/10up/plugin-scaffold/blob/master/includes/functions/core.php#L225

function mce_css( $stylesheets ) {

	function style_url() {

		return FB_ELEARNING_PLUGIN_URL . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ?
			"assets/css/frontend/editor-style.css" :
			"dist/css/editor-style.min.css" );

	}

	return $stylesheets . ',' . style_url();
}

Suggested fix

Possibly the second instance of style_url() should be an anonymous function?

@Kluny is this one fixed? Your PR was opened on your fork repo.

This should be fixed here: #14

#14 is a better fix.