WordPress.org

Ready to get started?Download WordPress

Forums

Front-end Editor
Frontend Editor and WordPress MU Domain Mapping plugins (24 posts)

  1. davoscript
    Member
    Posted 2 years ago #

    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="<strong>http://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:

    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.

    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: http://davoscript.com/2012/02/07/front-end-editor-and-wordpress-mu-domain-mapping-plugins/

    http://wordpress.org/extend/plugins/front-end-editor/

  2. davoscript
    Member
    Posted 2 years ago #

    People, I've been commeting about this on my website with Scribu http://davoscript.com/2012/02/07/front-end-editor-and-wordpress-mu-domain-mapping-plugins/#comments and after some research I've found that the problem is actually with WordPress MU Domain Mapping plugi, check out this code:

    domain_mapping.php Line #656

    // fixes the plugins_url
    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    	return get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 );
    }
    
    function domain_mapping_themes_uri( $full_url ) {
    	return str_replace( get_original_url ( 'siteurl' ), get_option( 'siteurl' ), $full_url );
    }
    
    if ( defined( 'DOMAIN_MAPPING' ) ) {
    	add_filter( 'plugins_url', 'domain_mapping_plugins_uri', 1 );

    The domain_mapping_plugins_uri function is used to filter the plugins_url function and return the plugins folder (or file inside it) url with the mapped domain, it does it by searching "wp-content/plugins" but it fails when the plugin is loaded from the "wp-content/mu-plugins". This can be fixed by validating if the passed URL contains the "mu-plugins" string or not.

    This is the fix I added:

    // fixes the plugins_url
    function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
      if ( !empty($plugin) && 0 === strpos($full_url, 'wp-content/mu-plugins') )
        $mapped_url = get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, 'wp-content/mu-plugins' ) - 1 );
      else
        $mapped_url = get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, 'wp-content/plugins' ) - 1 );
    	return $mapped_url;
    }

    Note that I use "wp-content/plugins" and "wp-content/mu-plugins" instead of the "PLUGINDIR" constant which is deprecated by the way.

    Please not that this is not an official fix, since I'm not the author of the plugin, however I hope this can solve this problem for other people as it did for me, so you can enjoy and empower your network with this 2 amazing wordpress plugins!

    Regards,
    Davo.

  3. praveen88
    Member
    Posted 2 years ago #

    Is it possible to use the admin editor with all the buttons in the front end. If so could you please help me on this.

  4. davoscript
    Member
    Posted 2 years ago #

    Hello praveen88, actually havent seen that, but check this plugin http://wordpress.org/extend/plugins/quick-post-widget/

    Good luck!

  5. diesel12
    Member
    Posted 2 years ago #

    I am also unable to get the plugin to work on mapped domains, but we are using the WPMUDEV Domain Mapping plugin (paid plugin), not the free WordPress MU Domain Mapping plugin .... The issue is that when you click the edit button, the progress wheel spins and never stops spinning .... not sure if this helps, but figured it was worth mentioning .... no problems on domains that have not been mapped.

  6. davoscript
    Member
    Posted 2 years ago #

    Diesel12, you should check if the URLs for the JS and CSS files included by FEE, if they are wrong it might be an issue with a filter added by the Mapped Domain plugin to try to figure out the new mapped URL.

    Regards,
    David.

  7. diesel12
    Member
    Posted 2 years ago #

    David, url's look ok .... 2 CSS, one for editor and one for aloha and 2 JS, one for editor and one for aloha as well that are working URL's ... also, I've corrected original message, editor button is visible, progress wheel just spins and never stops after clicking edit button ....

  8. davoscript
    Member
    Posted 2 years ago #

    Oh, that sounds like a JS conflict to me, have you checked with firebug or something? are you using other plugins that might be loading jQuery, Mootools or other libary?

  9. diesel12
    Member
    Posted 2 years ago #

    Not seeing any JS errors in firebug ... the unmapped site and mapped sites are using the exact same plugins / themes ... of which there are a couple plugins loading Jquery ...

  10. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Look for { ajaxurl: 'http://...} in the HTML source. It's probably set to the wrong domain.

  11. diesel12
    Member
    Posted 2 years ago #

    There's one ajax link and it appears it's going to right domain ... I'm assuming backwards slashes are normal? http:\/\/correctdomain.com\/wp-admin\/admin-ajax.php

  12. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Then you'll have to inspect the AJAX request using either Firebug or Webkit inspector. Plenty of tutorials on Google for that.

  13. diesel12
    Member
    Posted 2 years ago #

    Thanks, I will take a look. In comparing the source for non-mapped (FEE working) sites vs mapped sites (FEE not working) the code is identical ... so it doesn't look like CSS or JS is getting bad links ....

    Also changed to 2011 theme and turned off all plugins to no avail ...

    Did notice the following in error logs though ...

    [09-Feb-2012 22:21:23] PHP Warning: Missing argument 3 for FEE_Field_Category::wrap() in /home/folder/public_html/wp-content/plugins/front-end-editor/php/fields/post.php on line 305

  14. davoscript
    Member
    Posted 2 years ago #

    Scribu, everytime I try to save a widget's title change I get the following JS error in firebug:

    in editor.js (and editor.min.js)

    this.save_button is undefined
    this.save_button.click();

    I checked the JS and noticed that the when I edit the title of a text widget the "start_editing" method from FrontEndEditor.fieldTypes.group is used, but then I hit ESC or ENTER the launched functions are defined in the FrontEndEditor.fieldTypes.input object.

    You have any tip on how to solve this or where to check?

    Regards,
    David.

  15. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    My first tip would be to open a new thread.

    This goes for praveen88 too.

    If everyone just posted their issues in the same thread, what would be the point of threads?

  16. noriise
    Member
    Posted 2 years ago #

    Thanks for this very insightful post... I have this problem too (with the paid domain mapping plugin) and will have a fiddle with the code and see if I can fix it.

    Thanks for posting.

  17. noriise
    Member
    Posted 2 years ago #

    Ok - no avail - Did you have any luck: diesel12 ??

    I've the same problem as you.

    Cheers

  18. noriise
    Member
    Posted 2 years ago #

    Here is what i get;

    <script type="text/javascript">var ajaxurl = "http://elliottaylor.com/wp-load.php";</script>

    Where elliottaylor.com is the remapped domain and the WPMU main domain is at artfulworks.co.uk

    Any ideas? Thanks for the help

  19. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    That is from another plugin. FEE uses admin-ajax.php.

  20. noriise
    Member
    Posted 2 years ago #

    Thanks for spotting that. I'm not too confident what to do with this, although it is from FEE - Any ideas? Thanks Scribu

    </script><script type='text/javascript'>
    var FrontEndEditor = {};
    FrontEndEditor.data = {"edit_text":"Edit","save_text":"Save","cancel_text":"Cancel","add_buttons":false,"spinner":"http:\/\/elliottaylor.com\/wp-admin\/images\/loading.gif","ajax_url":"http:\/\/elliottaylor.com\/wp-admin\/admin-ajax.php","nonce":"e5b218a311","image":{"url":"http:\/\/elliottaylor.com\/wp-admin\/media-upload.php?post_id=0&editable_image=1&TB_iframe=true&width=640","change":"Change Image","insert":"Insert Image","revert":"(Clear)","tb_close":"http:\/\/elliottaylor.com\/wp-includes\/js\/thickbox\/tb-close.png"}};
    </script>
  21. noriise
    Member
    Posted 2 years ago #

    Ok - Found this... Looks very complicated though:

    Ajax is going to return an empty response in WP3.x.x MultiSite (with domain mapping) because, by design (in FF), ajax does not allow calls to a different domain (if not in jsonp as it's the case).

    Th issue is that WP inits all the scripts with the siteurl domain (e.g. sub.mysite.com), but when the admin is invoked within a mapped site (www.mymappedsite.com) the ajax call needs to happen within that mapped domain too.

    http://wordpress.org/support/topic/empty-ajax-response-multisite-fix?replies=3

  22. diesel12
    Member
    Posted 2 years ago #

    @norilse: Unfortunately we had no luck and your last response may be the reason why .... we would LOVE to get this type of plugin working on a multisite install .... it will happen soon enough, but this plugin looks great, so we'll see if anything changes in the future to enable multisite functionality .... :)

  23. noriise
    Member
    Posted 2 years ago #

    I'm not using the WPMU plugin anymore as it is not compatible. Instead I'm using the dev edition of the Remapping Plugin from the wordpress repository and then deselected the options in settings - it now works. But it seems a compromise is that if you log onto the main site and then go to a child site, you have to login once again.

    Fix one problem and another pops up!

  24. diesel12
    Member
    Posted 2 years ago #

    If you are having login issues with child sites, that may be a cookie problem .... something that may be related to your different authentication keys and salts in wp-config ..... that has been my experience in the past at least. So you're able to get FEE working when using reverting from WPMU mapping plugin to another mapping plugin... interesting. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic