mustardBees/cmb_field_map

Global var issue when using the script through a manual require_once rather than as a WP plugin

Closed this issue · 1 comments

Hi,

Thank you for this useful plugin.
If I am not missing something, I suggest adding the following to the readme file.

When adding cmb_field_map folder to - let's say - "my_theme_folder/cmb_plugins/", only setting a require_once order would not be sufficient as the JS & CSS files won't be enqueued properly.

Indeed, the following constant points towards WP's plugins folder.

// Useful global constants
define( 'PW_GALLERY_URL', plugin_dir_url( __FILE__ ) );

Source: https://github.com/mustardBees/cmb_field_map/blob/master/cmb-field-map.php#L12-13

Instead, I would need to define it this way in my case:

// Useful global constants
define( 'PW_GALLERY_URL', get_bloginfo('template_directory') . '/cmb_plugins/cmb-field-map/ );

NB: This is also applicable to your other CMB plugins.

Best

I'm going to remove that sentence from the documentation. While it is possible to bundle the field type with a theme/plugin, as you have found, there is a little work involved. I feel the plugin route is the way to go.

If this is something a lot of people are doing, maybe it's worth using the wiki to document this kind of usage...