Loading scripts on localhost
opened this issue · comments
Hi guys, I had a problem with loading scripts on localhost, and I modified the code a little then it works. I think I should let you know about my issue.
On the file CMB2_hookup.php
Changed the commented code to uncommented code.
//wp_register_style( 'cmb2-styles', cmb2_utils()->url( "css/cmb2{$min}.css" ), $styles );
wp_register_style( 'cmb2-styles',get_template_directory_uri()."/inc/cmb2/css/cmb2{$min}.css", $styles );
Before I making changes, scripts were loading like this
src="http://website.com/D:\workspace\projects\myproject\file.js"
Thanks
Sounds like you're on windows, and this condition is not being met:
https://github.com/WebDevStudios/CMB2/blob/master/includes/CMB2_Utils.php#L106
Can you do me a favor and place this at the top of your functions.php and let me know what it gives you?
wp_die( '<xmp>PHP_OS: '. print_r( PHP_OS, true ) .'</xmp>' );
Yes, I am on wndows. And already fixed my issue.
Your code returns this output:
PHP_OS: WINNT
Thanks
I'm having the same issue. Yes, Win 7. ServerPress 3.6.5. Looks like cmb2_utils()->url is busted. I think I upgraded CMB2 and WP around the same notice before noticing this. That is, I'm not sure if it's WP core or some new update to CMB2.
p.s. I'm curious, what does cmb2_utils() do that WP doesn't already offer? I presume it somehow detects how CMB2 is being used / where it's installed, correct?
Testing in IIS7.5 everything is working as expected. Going to test further with Apache on Windows to see if that breaks it somehow.
Closing as this is over a year old.
I get this issue developing on XAMPP - PHP_OS: WINNT
Able to fix it on dev using
add_filter( 'cmb2_meta_box_url', 'filter_cmb2_meta_box_url', 10, 2 );
function filter_cmb2_meta_box_url( $cmb2_url, $cmb2_version ) {
return "/wp-content/plugins/my-plugin-name/admin/CMB2/";
}
But would be nice not to
Thank - the str_replace is a good idea. Its a Windows mklink that caused the issue