Using Iris Colorpicker on TinyMCE shortcodes page [duplicate]

Your problem probably is the following line in your JavaScript file:

file : url.replace('/js','')+'../../tinymce_shortcode.php'

First, this way you’re bringing it out of context. Just load it up front when you init the plugin (and when you’re on a post.php or post-new.php request – see current_screen() return values to narrow that down to the needed requests where you want to load your plugin).

The TinyMCE windowManager isn’t meant to load PHP files. It can load HTML files to outsource the needed MarkUp/the view. Nothing more. If you need to generate MarkUp server side, simply build it inside a function or method and push the result to your JS file by localizing this values (more about it in the next paragraph). Then use either .confirm() or .open() depending on your task.

Next, you’re replace-ing URis. That makes it highly dependent on the actual file location. Remember that the plugin directory can be moved. And that additional plugin directories can be added next to the original one. Simply don’t do that. If you need a relative URL in a JavaScript file, simply use wp_localize_script() and plugins_url( __FILE__, "your-file.php" ) and plugin_dir_path( __FILE__ )."your-file.php". Not that you’d need that in this case.

Last, never ever go and load stuff outside the WP context if you aren’t loading it outside of WP at all. In short: If you need to load wp-load.php – and therefore the whole WP core – you’re doing something pretty wrong.

tech