[Plugin: Front-end Editor] Frontend Editor and WordPress MU Domain Mapping plugins
-
Hello everyone, specially to Scribu who made this awesome plugin posible.
I have a WordPress Multisite instance which uses WordPress MU Domain Mapping plugin to map domains like domain1.com with the subdomains in my WordPress network like: domain1.mynetwork.com.
Yasterday I started using Frontend Editor plugin in my network as a “must use” plugin (inside mu-plugins folder), but noticed it didn’t work in mapped domains but it did with no problem in no mapped websites (subdomain.mynetwork.com). A little bit of research showed me that the problem as that some of the Javascript files used by FEE (Frontend Editor) were not being included with the propper URL in the src attribute, like this:
OK (no mapped domains):
<script src="https://subdomain.mynetwork.com/wp-content/mu-plugins/front-end-editor/lib/aloha-editor/lib/aloha.js" ...
WRONG (mapped domains):
<script src="<strong>https://mapped-domain.coms</strong>" ...
So, it looked like there was a problem when generating the javascript files URL, time to read the plugin code! This is a step by step description of what I did:
- I compared the source code present in a blog with mapped domain and another without it, one of the missing files was “aloha.js”
- Opened /wp-content/mu-plugins/front-end-editor/php/core.php, and started looking for “aloha.js”, found it around line 144:
'src' => plugins_url( 'lib/aloha-editor/lib/aloha.js', FEE_MAIN_FILE ),
- Ok so, plugins_url( ‘lib/aloha-editor/lib/aloha.js’, FEE_MAIN_FILE ) was returning a wrong path to the file (a very wrong one), it seems that it just adds an “s” (from “.js” maybe?) to the end of the mapped domain, don’t know why and didn’t researched more about it, since I was focused on getting it working for now.
- In order to retrieve the right URL I replaced that piece of code with this: WPMU_PLUGIN_URL.’/front-end-editor/lib/aloha-editor/lib/aloha.js’. That did the trick by retrieving the URL as if it was a no-mapped domain, this means that you will include the file from: subdomain.mynetwork.com instead of from mappeddomain.com, which is fine, the file is actually there.
- Once that was done, I looked for other similar problems, and found the same issue with editor.min.js, editor.css and aloha.css and other ones that are included when the plugin’s debut mode is enabled.
So, to recap, I’ll show you which pieces of code I replaced. Italic is the original code, Bold is the one I replaced it with:
Line #61 /wp-content/mu-plugins/front-end-editor/php/core.php
if ( in_array( 'rich', $wrapped ) ) { <em>//wp_register_style( 'aloha-editor', plugins_url( 'lib/aloha-editor/css/aloha.css', FEE_MAIN_FILE ), array(), ALOHA_VERSION );</em> <strong>wp_register_style( 'aloha-editor', WPMU_PLUGIN_URL.'/front-end-editor/lib/aloha-editor/css/aloha.css', array(), ALOHA_VERSION );</strong> $css_dependencies[] = 'aloha-editor'; }
Line #92 /wp-content/mu-plugins/front-end-editor/php/core.php
} else { $min = defined('SCRIPT_DEBUG') ? '' : '.min'; <em>//self::register_script( 'fee-editor', "build/editor$min.js" );</em> <strong>wp_enqueue_script( 'fee-editor', WPMU_PLUGIN_URL."/front-end-editor/build/editor$min.js" ); </strong> $css_path = 'build/editor.css'; }
Line #99 /wp-content/mu-plugins/front-end-editor/php/core.php
// Core style <em>//wp_register_style( 'fee-editor', plugins_url( $css_path, FEE_MAIN_FILE ), $css_dependencies, FEE_VERSION );</em> <strong>wp_register_style( 'fee-editor', WPMU_PLUGIN_URL.'/front-end-editor/'.$css_path, $css_dependencies, FEE_VERSION );</strong> scbUtil::do_styles( 'fee-editor' );
Line #144
echo html( 'script', array( <em>//'src' => plugins_url( 'lib/aloha-editor/lib/aloha.js', FEE_MAIN_FILE ),</em> <strong>'src' => WPMU_PLUGIN_URL.'/front-end-editor/lib/aloha-editor/lib/aloha.js',</strong> 'data-aloha-plugins' => implode( ',', $plugins ) ) ) . "\n";
People, I hope this help others but also I hope Scribu get to see this and comment something, as long as I have tried this, it works, but maybe he has something to say about my “fix” because remember this is not an official fix..
** Note for Scribu: I get this warning in Chrome:
event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.
Maybe it can be fixed by using a more general attribute of the event?
Thanks a lot and best regards to all of you.
Davo.PS: I also published this article in my website: https://davoscript.com/2012/02/07/front-end-editor-and-wordpress-mu-domain-mapping-plugins/
- The topic ‘[Plugin: Front-end Editor] Frontend Editor and WordPress MU Domain Mapping plugins’ is closed to new replies.