Answers.Body: <p><strong>tl;dr: Uncomment and fill in the</strong> <code>define('CIVICRM_CMSDIR', '/path/to/install/root/');</code> in <code>civicrm.settings.php</code>.</p>
  
  <p>I traced through the functions that go toward building the URL for loadins <code>crm.ckeditor.js</code>.  It seems there's a problem with the logic of the WordPress <a href="https://github.com/civicrm/civicrm-core/blob/c9a664cbd3d1c5d30490e57696533c16b5ef48a0/CRM/Utils/System/WordPress.php#L483" rel="nofollow noreferrer">cmsRootPath</a> function.  </p>
  
  <p>I can't tell you what the specific issue you're having that's causing that function to fail; I know it struggles with symlinks, and I'd guess there's other edge cases as well.</p>
  
  <p>If I understand <a href="https://github.com/civicrm/civicrm-core/blob/c9a664cbd3d1c5d30490e57696533c16b5ef48a0/CRM/Utils/System/WordPress.php#L490" rel="nofollow noreferrer">this line of code</a> correctly, in addition to <code>$civicrm_root</code>, there's also a lesser-known cousin <code>CIVICRM_CMSDIR</code>, which is actually the relevant data here.  In my 4.7.22 WordPress instance's <code>civicrm.settings.php</code>, that constant is present but commented out.</p>
  
  <p>See also: <a href="https://issues.civicrm.org/jira/browse/CRM-18221" rel="nofollow noreferrer">CRM-18221</a> for what appears to be a similar issue on earlier versions of Civi 4.7.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-14T23:39:46.693Z
Answers.Text: Uncommenting the `global $civicrm_setting` and defining `CIVICRM_CMSDIR` seems to have fixed the URL Variable calculation errors as evidenced . This issue has been bugging me for a long time. Thank you very much.
Answers.UserDisplayName: Tomulent
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-10T17:58:33.243Z
Answers.Text: I'm pretty certain that I have the same problem: https://civicrm.stackexchange.com/questions/20888/wysiwyg-editor-not-present-with-wordpress. But defining CIVICRM_CSDIR only makes matters worse (duplicating more of [civicrm.root]. I have two servers one live in mysite.org and the other test.mysite.org with all the files in subdirectory test of the live site. I have a quick fix by replacing (by trial and error) [civicrm.root] in the call to CKEditor with wp-content/plugins/civicrm/civicrm. Can you be more specific on what you changed?
Answers.UserDisplayName: Mick Kahn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-14T22:11:06.030Z
Answers.LastActivityDate: 2017-08-14T22:11:06.030Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I believe <code>[civicrm.root]</code> is being computed incorrectly. Entering the absolute URLs in <code>Settings &gt; Resource URLs</code> has been sufficient to fix most problems, but some problems persist.</p>
  
  <p>For example, when i encounter an error like  crm.ckeditor.js  getting an error, the console tells me it can't find it at <code>https://mysite.org/mysite.org/wp-content/plugins/civicrm/civicrm/js/wysiwyg/crm.ckeditor.js.</code></p>
  
  <p>You'll notice that <code>mysite.org</code> is repeated.</p>
  
  <p>I'm running (CiviCRM 4.7.22) on an "Addon Domain" on my host. When you manage files for your addon domains, they show up as a folder on in your file manager. So my Civi files are installed at:</p>
  
  <ul>
  <li><code>/home/username/public_html/mysite.org/wp-content/plugins/civicrm/civicrm/</code></li>
  </ul>
  
  <p>I assume that when Civi is computing the <code>[civicrm.root]</code> variable, it just assumes it can replace <code>/home/username/public_html</code> with the base url defined by <code>CIVICRM_UF_BASEURL</code>, which would explain why I'm getting this <code>https://mysite.org/mysite.org/wp-content...</code>.</p>
  
  <p>So how do I fix this permanently? Clearly using absolute URLs in <code>Settings &gt; Resource URLs</code> isn't sufficient for every case. To clarify the values frrom <code>settings.civicrm.php</code>:</p>
  
  <ul>
  <li><code>define( 'CIVICRM_UF_BASEURL'      , 'https://mysite.org/');</code></li>
  <li><code>$civicrm_root = '/home/user/public_html/mysite.org/wp-content/plugins/civicrm/civicrm/';</code></li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-12T19:09:27.963Z
Comments.Text: [civicrm_root] is calculated from `$civicrm_root`, which is defined in `civicrm.settings.php`.  You should edit `civicrm.settings.php` to use CKEditor.  As to your original question - 90% of what's posted here is a red herring.  Could you please rewrite the question to be reflective of what you've found regarding the calculation issue?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-14T17:15:25.360Z
Comments.Text: Rewrote for clarity. I know that `[civicrm.root]` is defined in `civicrm.settings.php` but I need to know _what_ to change so that my URLs are calculated correctly.
Comments.UserDisplayName: Tomulent
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-14T18:47:30.423Z
Comments.Text: Can you please edit your question to include the values of `CIVICRM_UF_BASEURL` and also of `$civicrm_root`?  I'm having a hard time visualizing the values from the outputs.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-14T19:27:35.870Z
Comments.Text: Edited. Thanks for sticking with me :). I think the issue is stemming from the fact that the files are in a directory called `mysite.org`.
Comments.UserDisplayName: Tomulent
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-14T21:53:06.483Z
Comments.Text: Hmm - I think you might be hitting the WordPress CiviCRM symlink issue.  Is there a symlink in your file path?  Particularly to mysite.org?
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <wordpress><civimail><civicrm.settings.php><resource-urls>
Title: How can I fix [civicrm.root] variable on an addon domain?
ThreadText: # How can I fix [civicrm.root] variable on an addon domain?
  
  (Asked by: username_0 on 2017-08-10)
  
  I believe `[civicrm.root]` is being computed incorrectly. Entering the absolute URLs in `Settings > Resource URLs` has been sufficient to fix most problems, but some problems persist.
  
  For example, when i encounter an error like crm.ckeditor.js getting an error, the console tells me it can't find it at `https://mysite.org/mysite.org/wp-content/plugins/civicrm/civicrm/js/wysiwyg/crm.ckeditor.js.`
  
  You'll notice that `mysite.org` is repeated.
  
  I'm running (CiviCRM 4.7.22) on an "Addon Domain" on my host. When you manage files for your addon domains, they show up as a folder on in your file manager. So my Civi files are installed at:
  
  * `/home/username/public_html/mysite.org/wp-content/plugins/civicrm/civicrm/`
  
  I assume that when Civi is computing the `[civicrm.root]` variable, it just assumes it can replace `/home/username/public_html` with the base url defined by `CIVICRM_UF_BASEURL`, which would explain why I'm getting this `https://mysite.org/mysite.org/wp-content...`.
  
  So how do I fix this permanently? Clearly using absolute URLs in `Settings > Resource URLs` isn't sufficient for every case. To clarify the values frrom `settings.civicrm.php`:
  
  * `define( 'CIVICRM_UF_BASEURL' , 'https://mysite.org/');`
  * `$civicrm_root = '/home/user/public_html/mysite.org/wp-content/plugins/civicrm/civicrm/';`
  
  **Tags:** wordpress, civimail, civicrm.settings.php, resource-urls
  
  > **Comments:**
  > **username_1**: [civicrm_root] is calculated from `$civicrm_root`, which is defined in `civicrm.settings.php`.  You should edit `civicrm.settings.php` to use CKEditor.  As to your original question - 90% of what's posted here is a red herring.  Could you please rewrite the question to be reflective of what you've found regarding the calculation issue?  
  > **username_0**: Rewrote for clarity. I know that `[civicrm.root]` is defined in `civicrm.settings.php` but I need to know _what_ to change so that my URLs are calculated correctly.  
  > **username_1**: Can you please edit your question to include the values of `CIVICRM_UF_BASEURL` and also of `$civicrm_root`?  I'm having a hard time visualizing the values from the outputs.  
  > **username_0**: Edited. Thanks for sticking with me :). I think the issue is stemming from the fact that the files are in a directory called `mysite.org`.  
  > **username_1**: Hmm - I think you might be hitting the WordPress CiviCRM symlink issue.  Is there a symlink in your file path?  Particularly to mysite.org?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-08-14. Score: 3 | Accepted answer
  
  **tl;dr: Uncomment and fill in the** `define('CIVICRM_CMSDIR', '/path/to/install/root/');` in `civicrm.settings.php`.
  
  I traced through the functions that go toward building the URL for loadins `crm.ckeditor.js`. It seems there's a problem with the logic of the WordPress [cmsRootPath](https://github.com/civicrm/civicrm-core/blob/c9a664cbd3d1c5d30490e57696533c16b5ef48a0/CRM/Utils/System/WordPress.php#L483) function.
  
  I can't tell you what the specific issue you're having that's causing that function to fail; I know it struggles with symlinks, and I'd guess there's other edge cases as well.
  
  If I understand [this line of code](https://github.com/civicrm/civicrm-core/blob/c9a664cbd3d1c5d30490e57696533c16b5ef48a0/CRM/Utils/System/WordPress.php#L490) correctly, in addition to `$civicrm_root`, there's also a lesser-known cousin `CIVICRM_CMSDIR`, which is actually the relevant data here. In my 4.7.22 WordPress instance's `civicrm.settings.php`, that constant is present but commented out.
  
  See also: [CRM-18221](https://issues.civicrm.org/jira/browse/CRM-18221) for what appears to be a similar issue on earlier versions of Civi 4.7.
  
  > **Comments:**
  > **username_0**: Uncommenting the `global $civicrm_setting` and defining `CIVICRM_CMSDIR` seems to have fixed the URL Variable calculation errors as evidenced . This issue has been bugging me for a long time. Thank you very much.  
  > **username_2**: I'm pretty certain that I have the same problem: https://civicrm.stackexchange.com/questions/20888/wysiwyg-editor-not-present-with-wordpress. But defining CIVICRM_CSDIR only makes matters worse (duplicating more of [civicrm.root]. I have two servers one live in mysite.org and the other test.mysite.org with all the files in subdirectory test of the live site. I have a quick fix by replacing (by trial and error) [civicrm.root] in the call to CKEditor with wp-content/plugins/civicrm/civicrm. Can you be more specific on what you changed?  
  
  ---
  
  