Wordpress tinyMCE不会在生产服务器上打开窗口

Ok so here's the deal. Using the code below, I have created a custom button in the tinyMCE editor which opens a modal window and loads a php file I created. This is NOT a plugin for Wordpress, I've built the functionality directly into my theme.

It works perfectly on my local environment (Ubuntu running LAMP with a vhost file loading the site as wordpress.loc if any of this helps) but on my production server, running cpanel the modal window cant seem to find the php file. It 404s. So I guess the WP routing system is getting in the way.. but I'm having this issue with both the latest version of WP and tinyMCE and the last.

Here is how Im setting it up:

function register_button($buttons) {  
   array_push($buttons,"|" ,"kjdShortCodeInjection");  
   return $buttons;  
}  

function add_plugin($plugin_array) {  
    $admin_dir = get_stylesheet_directory_uri().'/lib/admin';
    $mce_plugin_js = $admin_dir.'/functions/shortcode-injector/mcePlugin.js';

    $plugin_array['kjdShortCodeInjection'] = $mce_plugin_js;  
    return $plugin_array;  
} 

     add_filter('mce_external_plugins', 'add_plugin');  
     add_filter('mce_buttons', 'register_button');  

And the JS which I need for tinyMCE:

    init : function(ed, url) {
        ed.addCommand('mcekjdShortCodeInjection', function() {
            ed.windowManager.open({
                file : url+'/shortcode_window.php',
                title: "Select a shortcode",
                popup_css: "bootstrap.css",
                width : 900 + ed.getLang('kjdShortCodeInjection.delta_width', 0),
                height : 600 + ed.getLang('kjdShortCodeInjection.delta_height', 0),
                inline : 1
            }, {
                plugin_url : url // Plugin absolute URL
            });
        });

Almost every example or tutorial I've found has the button added as a plugin, and therefor is using WP_PLUGIN_URL or plugins_url

Is there a way I can get the accessible absolute path?

Here is how you can get the Absolute Path in mcePlugin.js

Add the following code in your functions.php file

add_action('admin_head','my_js_var_admin');
function my_js_var_admin() {

    if ( is_admin() ) {
    ?>
    <script type="text/javascript">
    var ABSURL = '<?php echo __DIR__; ?>';
    </script>
    <?php
    }
}

Now this is how you can user the ABSURL in your mcePlugin.js file

file : ABSURL+'/shortcode_window.php',  // Assign your File Path here

Hope this is help you.

The correct way of injecting variables from PHP into the scripts is this:

wp_enqueue_script('my-tinymce-admin-script', get_template_directory_uri() . 'assets/js/admin.js', array('jquery'), $version);

//Inject variables into the script. The script slug(first parameter) must match the slug used in wp_enqueue_script.
wp_localize_script('my-tinymce-admin-script', 'my_vars', array(
    'theme_url' => get_template_directory_uri(),
));

Then you can access the variable in the script with my_vars.theme_url.

Much better if you can use plugins... CF7MCE is one plugin.. . link below

http://wordpress.org/plugins/bootstrap-mce-css/

http://ecolosites.eelv.fr/cf7mce-editeur-visuel-pour-contact-form-7/

All the while coding and adding scripts are much admirable, wordpress supports plugins, and there are many plugins that help you achieve whatever you want. Also, plugins mostly have code programmed according to professional standards (read reviews wherever available.)

It helps you with a lot of work automatically done, switching between themes is easier too. And you have a plugin for almost everything.