-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin Styles and Scripts not loading due to wrong path #432
Comments
Please don't hack the plugin as you could break it for other plugins/themes depending on it. There is documentation for updating that url if it is not working properly: https://github.com/WebDevStudios/CMB2/wiki/Troubleshooting TL;DR: there is a filter in place so hacking the plugin is not necessary. |
I'm having the issue with CMB2 symlinked locally in my dev environment. My workaround:
I wonder why |
Because CMB2 can be loaded as a plugin, from a plugin, from mu-plugins, from a theme, etc. I would like to solve this a bit better though. Can you provide more insight into your file structure and where CMB2 is loaded? |
Ah, yes, forgot it could be packaged with a theme. I have all my own plugins, and any I may contribute to, in a local folder outside the web root, /www-projects/, cloned from GitHub. I then just symlink those plugins locally. I can see there's a problem if you have to cater for the different locations CMB2 may be in - and maybe the filter is the best or only option? That's working for me for now, so no urgency, but interested if you find a solution that covers all bases. |
I didn't realise this had happened, I guess I only started symlinking plugins after 3.9. But maybe of use: https://make.wordpress.org/core/2014/04/14/symlinked-plugins-in-wordpress-3-9/ |
Similar issue here. We're including a bunch of composer dependencies in our WP root, and when I require . . . I end up with a console error with CMB2 attempting to pull in the following file (notice the bogus path): I know CMB2 is meant to be used as a standalone library, however it seems like it is required to live within wp-content for any of this to work, which ends up not working so well for the use case I'm describing. Any ideas on this one? |
@MickeyKay Yep, just need to filter that URL. https://github.com/WebDevStudios/CMB2/wiki/Troubleshooting#cmb2-urls-issues (like mentioned above). function update_cmb2_meta_box_url( $url ) {
return site_url( '/vendor/webdevstudios/cmb2' );
}
add_filter( 'cmb2_meta_box_url', 'update_cmb2_meta_box_url' ); |
This issue should be solved for almost all use-cases now (without need to filter). If any of you are able to test with the |
Tried trunk, doesn't help on my local development environment when bundling CMB2 with a symlinked plugin. |
@justnorris yes, the filter is there for the scenarios where CMB2 is not smart enough to figure it out. I've updated the documentation though, as there are some caveats to consider when using the filter (namely, try not to break CMB2 for other implementors): https://github.com/WebDevStudios/CMB2/wiki/Troubleshooting#cmb2-urls-issues Can you provide me the broken URL vs the correct URL for your install? I want to see if there's ways to smarten CMB2's logic a bit more. |
@jtsternberg Missed the github notification, sorry for the late response. I'm running a local MAMP, with an actual domain, pointing to 10.0.0.10 ( my local IP assigned to my computer by the router ). So I get 404 that looks like this:
And it should be something like this:
|
Honestly, URLs for these types of resources should probably utilize the appropriate functions to get browser friendly URLs, and not server path versions. In the meatime, @justnorris could use https://github.com/WebDevStudios/CMB2/wiki/Troubleshooting#cmb2-urls-issues and have it return the following, if I'm seeing things correctly.
|
This is not possible since CMB2 can be bundled/included in many places. Believe me, it's been discussed/hashed out before, including the rest of this thread. |
fair enough. |
This works perfectly for me:
So I'm not really looking for a solution anymore, but thanks anyway 👍 . I'll probably remove that function when building for production. |
Just hit this issue with a (locally symlinked) plugin that bundles CMB2. Just thinking about it... if I run the filter in my plugin, but another plugin bundling CMB2 gets loaded first, won't my filter still run and screw things up? |
Logically, it would, but at the same time, the file you're referring to with the filter would still exist and load. At that point, the primary potential errors would be js selectors not finding things like expected, or some styles mismatching. |
Interesting note, it only fails on my term metabox. Not on my post/page metabox. The filter fixed it, though i'm leery to use it. |
Perhaps conditionally add the filter? Limit the scope of where it gets added. |
The trick (as identified in the docs for that filter) is to do a |
problem solved by just commenting these lines in init.php |
Given that those two lines are more or less essential to CMB2 running as a whole, it's definitely not a solution by any means. |
As said in title, CSS and JS get the wrong path (absolute file system path) on registration.
The problem is, that the
url
function inCMB2_Utils
class utilizescmb2_dir()
and so theCMB2_DIR
constant which is constructed for for includes.I replaced the line
with
as a workaround.
Please find a better solution.
The text was updated successfully, but these errors were encountered: