Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the subscribe-to-comments domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home1/davoscri/public_html/wp-includes/functions.php on line 6170

Warning: Cannot modify header information - headers already sent by (output started at /home1/davoscri/public_html/wp-includes/functions.php:6170) in /home1/davoscri/public_html/wp-includes/feed-rss2.php on line 8
solved – DAVOSCRIPT http://davoscript.com Desarrollo de Software, Aplicaciones y Sitios Web Thu, 22 Mar 2012 18:31:19 +0000 en-US hourly 1 https://wordpress.org/?v=7.0 212403021 Front-end Editor and WordPress MU Domain Mapping plugins http://davoscript.com/blog/desarrollo/front-end-editor-and-wordpress-mu-domain-mapping-plugins/ http://davoscript.com/blog/desarrollo/front-end-editor-and-wordpress-mu-domain-mapping-plugins/#comments Tue, 07 Feb 2012 05:51:40 +0000 http://davoscript.com/?p=93 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="http://subdomain.mynetwork.com/wp-content/mu-plugins/front-end-editor/lib/aloha-editor/lib/aloha.js" ...

WRONG (mapped domains):
<script src="http://mapped-domain.coms" ...

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:

  1. I compared the source code present in a blog with mapped domain and another without it, one of the missing files was “aloha.js”
  2. 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 ),
  3. 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.
  4. 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.
  5. 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 (I didn’t fixed this ones, you can do it the same way if you need it).

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 ) ) {
//wp_register_style( 'aloha-editor', plugins_url( 'lib/aloha-editor/css/aloha.css', FEE_MAIN_FILE ), array(), ALOHA_VERSION );
wp_register_style( 'aloha-editor', WPMU_PLUGIN_URL.'/front-end-editor/lib/aloha-editor/css/aloha.css', array(), ALOHA_VERSION );
$css_dependencies[] = 'aloha-editor';
}

Line #92 /wp-content/mu-plugins/front-end-editor/php/core.php
} else {
$min = defined('SCRIPT_DEBUG') ? '' : '.min';
//self::register_script( 'fee-editor', "build/editor$min.js" );
wp_enqueue_script( 'fee-editor', WPMU_PLUGIN_URL."/front-end-editor/build/editor$min.js" );

$css_path = ‘build/editor.css’;
}

Line #99 /wp-content/mu-plugins/front-end-editor/php/core.php
// Core style
//wp_register_style( 'fee-editor', plugins_url( $css_path, FEE_MAIN_FILE ), $css_dependencies, FEE_VERSION );
wp_register_style( 'fee-editor', WPMU_PLUGIN_URL.'/front-end-editor/'.$css_path, $css_dependencies, FEE_VERSION );
scbUtil::do_styles( 'fee-editor' );

Line #144 /wp-content/mu-plugins/front-end-editor/php/core.php
echo html( 'script', array(
//'src' => plugins_url( 'lib/aloha-editor/lib/aloha.js', FEE_MAIN_FILE ),
'src' => WPMU_PLUGIN_URL.'/front-end-editor/lib/aloha-editor/lib/aloha.js',
'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.

 

UPDATE

As you can see in the comments of this post, I shared some thoughts with Scribu, Front-end Editor plugin’s author and after some research on the issue I found what I think is a bug (?) in the WordPress MU Domain Mapping plugin, so if you are having the same problem described in this post I’d say forget about hacking Front-end Editor plugin and try this new small fix in Domain Mapping plugin instead.

thoughts

]]>
http://davoscript.com/blog/desarrollo/front-end-editor-and-wordpress-mu-domain-mapping-plugins/feed/ 251 93