Example #1
0
 public function print_footer_scripts()
 {
     global $concatenate_scripts;
     if (!did_action('shopp_print_footer_scripts')) {
         do_action('shopp_print_footer_scripts');
     }
     script_concat_settings();
     $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true;
     $this->do_concat = $concatenate_scripts;
     $this->do_footer_items();
     if (apply_filters('shopp_print_footer_scripts', true)) {
         $this->print_script_request();
     }
     $this->reset();
     return $this->done;
 }
Example #2
0
    /**
     *
     * @static
     * @global string $wp_version
     * @global string $tinymce_version
     * @global bool   $concatenate_scripts
     * @global bool   $compress_scripts
     */
    public static function editor_js()
    {
        global $wp_version, $tinymce_version, $concatenate_scripts, $compress_scripts;
        /**
         * Filters "tiny_mce_version" is deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = 'ver=' . $tinymce_version;
        $tmce_on = !empty(self::$mce_settings);
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
        $mceInit = $qtInit = '';
        if ($tmce_on) {
            foreach (self::$mce_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $mceInit .= "'{$editor_id}':{$options},";
            }
            $mceInit = '{' . trim($mceInit, ',') . '}';
        } else {
            $mceInit = '{}';
        }
        if (!empty(self::$qt_settings)) {
            foreach (self::$qt_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $qtInit .= "'{$editor_id}':{$options},";
            }
            $qtInit = '{' . trim($qtInit, ',') . '}';
        } else {
            $qtInit = '{}';
        }
        $ref = array('plugins' => implode(',', self::$plugins), 'theme' => 'modern', 'language' => self::$mce_locale);
        $suffix = SCRIPT_DEBUG ? '' : '.min';
        /**
         * Fires immediately before the TinyMCE settings are printed.
         *
         * @since 3.2.0
         *
         * @param array $mce_settings TinyMCE settings array.
         */
        do_action('before_wp_tiny_mce', self::$mce_settings);
        ?>

		<script type="text/javascript">
		tinyMCEPreInit = {
			baseURL: "<?php 
        echo self::$baseurl;
        ?>
",
			suffix: "<?php 
        echo $suffix;
        ?>
",
			<?php 
        if (self::$drag_drop_upload) {
            echo 'dragDropUpload: true,';
        }
        ?>
			mceInit: <?php 
        echo $mceInit;
        ?>
,
			qtInit: <?php 
        echo $qtInit;
        ?>
,
			ref: <?php 
        echo self::_parse_init($ref);
        ?>
,
			load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
		};
		</script>
		<?php 
        $baseurl = self::$baseurl;
        // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
        $mce_suffix = false !== strpos($wp_version, '-src') ? '' : '.min';
        if ($tmce_on) {
            if ($compressed) {
                echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;{$version}'></script>\n";
            } else {
                echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?{$version}'></script>\n";
                echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?{$version}'></script>\n";
            }
            echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
            if (self::$ext_plugins) {
                // Load the old-format English strings to prevent unsightly labels in old style popups
                echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
            }
        }
        /**
         * Fires after tinymce.js is loaded, but before any TinyMCE editor
         * instances are created.
         *
         * @since 3.9.0
         *
         * @param array $mce_settings TinyMCE settings array.
         */
        do_action('wp_tiny_mce_init', self::$mce_settings);
        ?>
		<script type="text/javascript">
		<?php 
        if (self::$ext_plugins) {
            echo self::$ext_plugins . "\n";
        }
        if (!is_admin()) {
            echo 'var ajaxurl = "' . admin_url('admin-ajax.php', 'relative') . '";';
        }
        ?>

		( function() {
			var init, id, $wrap;

			if ( typeof tinymce !== 'undefined' ) {
				for ( id in tinyMCEPreInit.mceInit ) {
					init = tinyMCEPreInit.mceInit[id];
					$wrap = tinymce.$( '#wp-' + id + '-wrap' );

					if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) {
						tinymce.init( init );

						if ( ! window.wpActiveEditor ) {
							window.wpActiveEditor = id;
						}
					}
				}
			}

			if ( typeof quicktags !== 'undefined' ) {
				for ( id in tinyMCEPreInit.qtInit ) {
					quicktags( tinyMCEPreInit.qtInit[id] );

					if ( ! window.wpActiveEditor ) {
						window.wpActiveEditor = id;
					}
				}
			}
		}());
		</script>
		<?php 
        if (in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) {
            self::wp_link_dialog();
        }
        /**
         * Fires after any core TinyMCE editor instances are created.
         *
         * @since 3.2.0
         *
         * @param array $mce_settings TinyMCE settings array.
         */
        do_action('after_wp_tiny_mce', self::$mce_settings);
    }
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8
 */
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
Example #4
0
/**
 * Adds the TinyMCE editor used on the Write and Edit screens.
 *
 * Has option to output a trimmed down version used in Press This.
 *
 * @package WordPress
 * @since 2.7
 */
function wp_tiny_mce($teeny = false)
{
    global $concatenate_scripts, $compress_scripts;
    if (!user_can_richedit()) {
        return;
    }
    $baseurl = includes_url('js/tinymce');
    $mce_locale = '' == get_locale() ? 'en' : strtolower(substr(get_locale(), 0, 2));
    // only ISO 639-1
    /*
    The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
    By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
    The + sign marks the default language. More information:
    http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
    */
    $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
    if ($teeny) {
        $plugins = apply_filters('teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'autosave', 'fullscreen'));
        $ext_plugins = '';
    } else {
        $plugins = array('safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery');
        /*
        The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
        It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
        The url should be absolute and should include the js file name to be loaded. Example:
        array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
        If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
        */
        $mce_external_plugins = apply_filters('mce_external_plugins', array());
        $ext_plugins = '';
        if (!empty($mce_external_plugins)) {
            /*
            The following filter loads external language files for TinyMCE plugins.
            It takes an associative array 'plugin_name' => 'path', where path is the
            include path to the file. The language file should follow the same format as
            /tinymce/langs/wp-langs.php and should define a variable $strings that
            holds all translated strings.
            When this filter is not used, the function will try to load {mce_locale}.js.
            If that is not found, en.js will be tried next.
            */
            $mce_external_languages = apply_filters('mce_external_languages', array());
            $loaded_langs = array();
            $strings = '';
            if (!empty($mce_external_languages)) {
                foreach ($mce_external_languages as $name => $path) {
                    if (@is_file($path) && @is_readable($path)) {
                        include_once $path;
                        $ext_plugins .= $strings . "\n";
                        $loaded_langs[] = $name;
                    }
                }
            }
            foreach ($mce_external_plugins as $name => $url) {
                if (is_ssl()) {
                    $url = str_replace('http://', 'https://', $url);
                }
                $plugins[] = '-' . $name;
                $plugurl = dirname($url);
                $strings = $str1 = $str2 = '';
                if (!in_array($name, $loaded_langs)) {
                    $path = str_replace(WP_PLUGIN_URL, '', $plugurl);
                    $path = WP_PLUGIN_DIR . $path . '/langs/';
                    if (function_exists('realpath')) {
                        $path = trailingslashit(realpath($path));
                    }
                    if (@is_file($path . $mce_locale . '.js')) {
                        $strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
                    }
                    if (@is_file($path . $mce_locale . '_dlg.js')) {
                        $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
                    }
                    if ('en' != $mce_locale && empty($strings)) {
                        if (@is_file($path . 'en.js')) {
                            $str1 = @file_get_contents($path . 'en.js');
                            $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str1, 1) . "\n";
                        }
                        if (@is_file($path . 'en_dlg.js')) {
                            $str2 = @file_get_contents($path . 'en_dlg.js');
                            $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str2, 1) . "\n";
                        }
                    }
                    if (!empty($strings)) {
                        $ext_plugins .= "\n" . $strings . "\n";
                    }
                }
                $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
                $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
            }
        }
    }
    $plugins = implode($plugins, ',');
    if ($teeny) {
        $mce_buttons = apply_filters('teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen'));
        $mce_buttons = implode($mce_buttons, ',');
        $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
    } else {
        $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv'));
        $mce_buttons = implode($mce_buttons, ',');
        $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help'));
        $mce_buttons_2 = implode($mce_buttons_2, ',');
        $mce_buttons_3 = apply_filters('mce_buttons_3', array());
        $mce_buttons_3 = implode($mce_buttons_3, ',');
        $mce_buttons_4 = apply_filters('mce_buttons_4', array());
        $mce_buttons_4 = implode($mce_buttons_4, ',');
    }
    $no_captions = apply_filters('disable_captions', '') ? true : false;
    // TinyMCE init settings
    $initArray = array('mode' => 'none', 'onpageload' => 'switchEditors.edInit', 'width' => '100%', 'theme' => 'advanced', 'skin' => 'wp_theme', 'theme_advanced_buttons1' => "{$mce_buttons}", 'theme_advanced_buttons2' => "{$mce_buttons_2}", 'theme_advanced_buttons3' => "{$mce_buttons_3}", 'theme_advanced_buttons4' => "{$mce_buttons_4}", 'language' => "{$mce_locale}", 'spellchecker_languages' => "{$mce_spellchecker_languages}", 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, 'dialog_type' => 'modal', 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'apply_source_formatting' => false, 'remove_linebreaks' => true, 'paste_convert_middot_lists' => true, 'paste_remove_spans' => true, 'paste_remove_styles' => true, 'gecko_spellcheck' => true, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => true, 'tab_focus' => ':prev,:next', 'save_callback' => 'switchEditors.saveCallback', 'wpeditimage_disable_captions' => $no_captions, 'plugins' => "{$plugins}");
    $mce_css = trim(apply_filters('mce_css', ''), ' ,');
    if (!empty($mce_css)) {
        $initArray['content_css'] = "{$mce_css}";
    }
    // For people who really REALLY know what they're doing with TinyMCE
    // You can modify initArray to add, remove, change elements of the config before tinyMCE.init
    // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
    // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
    if ($teeny) {
        $initArray = apply_filters('teeny_mce_before_init', $initArray);
    } else {
        $initArray = apply_filters('tiny_mce_before_init', $initArray);
    }
    if (!isset($concatenate_scripts)) {
        script_concat_settings();
    }
    $language = $initArray['language'];
    $zip = $compress_scripts ? 1 : 0;
    $ver = apply_filters('tiny_mce_version', '3211');
    if ('en' != $language) {
        include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
    }
    $mce_options = '';
    foreach ($initArray as $k => $v) {
        $mce_options .= $k . ':"' . $v . '", ';
    }
    $mce_options = rtrim(trim($mce_options), '\\n\\r,');
    ?>

<script type="text/javascript">
/* <![CDATA[ */
tinyMCEPreInit = {
	base : "<?php 
    echo $baseurl;
    ?>
",
	suffix : "",
	query : "ver=<?php 
    echo $ver;
    ?>
",
	mceInit : {<?php 
    echo $mce_options;
    ?>
},
	load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
};
/* ]]> */
</script>

<?php 
    if ($concatenate_scripts) {
        echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c={$zip}&ver={$ver}'></script>\n";
    } else {
        echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?ver={$ver}'></script>\n";
    }
    if ('en' != $language && isset($lang)) {
        echo "<script type='text/javascript'>\n{$lang}\n</script>\n";
    } else {
        echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?ver={$ver}'></script>\n";
    }
    ?>

<script type="text/javascript">
<?php 
    if ($ext_plugins) {
        echo "{$ext_plugins}\n";
    }
    if ($concatenate_scripts) {
        ?>
tinyMCEPreInit.go();
<?php 
    } else {
        ?>
(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php 
    }
    ?>
tinyMCE.init(tinyMCEPreInit.mceInit);
</script>
<?php 
}
Example #5
0
/**
 * Prints the styles that were queued too late for the HTML head.
 *
 * @since 3.3.0
 *
 * @global WP_Styles $wp_styles
 * @global bool      $concatenate_scripts
 *
 * @return array|void
 */
function print_late_styles()
{
    global $wp_styles, $concatenate_scripts;
    if (!$wp_styles instanceof WP_Styles) {
        return;
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $wp_styles->do_footer_items();
    /**
     * Filters whether to print the styles queued too late for the HTML head.
     *
     * @since 3.3.0
     *
     * @param bool $print Whether to print the 'late' styles. Default true.
     */
    if (apply_filters('print_late_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
Example #6
0
 /**
  * Queues script files and styles if logged in user has any editable areas and current page is not in admin.
  * Hookable through action 'wa_fronted_scripts'
  */
 public function scripts_and_styles()
 {
     if (is_array(WA_Fronted::$options) && !empty(WA_Fronted::$options) && WA_Fronted::$options !== false) {
         global $post, $wp_version, $tinymce_version, $concatenate_scripts, $compress_scripts;
         if (!isset($concatenate_scripts)) {
             script_concat_settings();
         }
         require_once ABSPATH . '/wp-admin/includes/post.php';
         do_action('wa_fronted_before_scripts', WA_Fronted::$options);
         load_plugin_textdomain('wa-fronted', false, plugin_basename(dirname(__FILE__)) . '/languages');
         wp_enqueue_media(array('post' => $post));
         add_thickbox();
         wp_deregister_script('tinymce');
         wp_enqueue_script('tinymce', includes_url('js/tinymce') . '/wp-tinymce.php?c=1', array(), $tinymce_version, true);
         wp_enqueue_script('wplink');
         wp_localize_script('wplink', 'ajaxurl', admin_url('admin-ajax.php'));
         wp_enqueue_script('wp-lists');
         wp_localize_script('wp-lists', 'ajaxurl', admin_url('admin-ajax.php'));
         wp_enqueue_script('jquery-ui-core');
         wp_enqueue_script('jquery-ui-draggable');
         wp_enqueue_script('jquery-ui-droppable');
         wp_enqueue_script('jquery-ui-datepicker');
         wp_enqueue_script('jqueryui-timepicker-addon', plugins_url('/bower_components/jqueryui-timepicker-addon/dist/jquery-ui-timepicker-addon.min.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), '1.5.5', true);
         wp_enqueue_script('wa-fronted-scripts', plugins_url('/js/min/scripts.min.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-datepicker', 'jqueryui-timepicker-addon', 'tinymce', 'wp-util', 'editor', 'wplink', 'wp-lists'), '0.1', true);
         wp_localize_script('wa-fronted-scripts', 'global_vars', array('wp_lang' => get_bloginfo('language'), 'i18n' => $this->get_js_i18n(), 'ajax_url' => admin_url('admin-ajax.php'), 'options' => json_encode(WA_Fronted::$options), 'image_sizes' => $this->get_image_sizes(), 'nonce' => wp_create_nonce('wa_fronted_save_nonce')));
         wp_enqueue_style('buttons');
         wp_enqueue_style('dashicons');
         wp_enqueue_style('open-sans');
         wp_enqueue_style('wa-fronted-timepicker-addon', plugins_url('/bower_components/jqueryui-timepicker-addon/dist/jquery-ui-timepicker-addon.min.css', __FILE__));
         wp_enqueue_style('wa-fronted-style', plugins_url('/css/style.css', __FILE__));
         do_action('wa_fronted_after_scripts', WA_Fronted::$options);
     }
 }
function print_footer_scripts()
{
    global $wp_scripts, $concatenate_scripts;
    if (!$wp_scripts instanceof WP_Scripts) {
        return array();
        // No need to run if not instantiated.
    }
    script_concat_settings();
    $wp_scripts->do_concat = $concatenate_scripts;
    $wp_scripts->do_footer_items();
    if (apply_filters('print_footer_scripts', true)) {
        _print_scripts();
    }
    $wp_scripts->reset();
    return $wp_scripts->done;
}
 public function wp_enqueue_scripts()
 {
     global $tinymce_version, $concatenate_scripts, $compress_scripts, $wp_version;
     // Concatenate Scripts
     if (!isset($concatenate_scripts)) {
         script_concat_settings();
     }
     // TinyMCE Compressed
     if ($compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
         wp_enqueue_script('note-tinymce', includes_url('js/tinymce') . '/wp-tinymce.php?c=1', false, $tinymce_version, true);
     } else {
         wp_enqueue_script('note-tinymce', includes_url('js/tinymce') . '/tinymce.min.js', false, $tinymce_version, true);
         wp_enqueue_script('note-tinymce-compat3x', includes_url('js/tinymce') . '/plugins/compat3x/plugin.min.js', array('note-tinymce'), $tinymce_version, true);
     }
     // Localize the Note TinyMCE script information
     wp_localize_script('note-tinymce', 'note_tinymce', $this->note_tinymce_localize);
     // If less than WordPress 4.0
     if (version_compare($wp_version, '4.0', '<')) {
         // Load our version of 'wpview' plugin
         wp_enqueue_script('note-tinymce-wpview', Note::plugin_url() . '/assets/js/note-tinymce-view.js', array('note-tinymce'), Note::$version, true);
         // Load backwards compatibility 'lists' plugin
         wp_enqueue_script('note-tinymce-lists', Note::plugin_url() . '/assets/js/note-tinymce-lists.js', array('note-tinymce'), Note::$version, true);
     }
     // Note TinyMCE Insert Plugin
     wp_enqueue_script('note-tinymce-insert', Note::plugin_url() . '/assets/js/note-tinymce-insert.js', array('note-tinymce'), Note::$version, true);
     // Note TinyMCE Image Plugin
     wp_enqueue_script('note-tinymce-image', Note::plugin_url() . '/assets/js/note-tinymce-image.js', array('note-tinymce'), Note::$version, true);
     // Note TinyMCE Theme
     wp_enqueue_script('note-tinymce-theme', Note::plugin_url() . '/assets/js/note-tinymce-theme.js', array('note-tinymce'), Note::$version, true);
     // Note Core
     wp_enqueue_script('note', Note::plugin_url() . '/assets/js/note.js', array('note-tinymce', 'wp-util', 'editor', 'wp-lists', 'customize-preview-widgets', 'jquery-ui-core', 'underscore'), Note::$version, true);
     wp_localize_script('note', 'note', $this->note_localize);
     // WordPress Lists
     wp_enqueue_script('wp-lists');
     wp_localize_script('wp-lists', 'ajaxurl', admin_url('admin-ajax.php'));
     // WordPress Links
     wp_enqueue_script('wplink');
     wp_localize_script('wplink', 'ajaxurl', admin_url('admin-ajax.php'));
     // WordPress Core/Modal Styles
     wp_enqueue_style('wp-core-ui', Note::plugin_url() . '/assets/css/wp-core-ui.css', false, Note::$version);
     wp_enqueue_style('buttons');
     wp_enqueue_style('note-modal', Note::plugin_url() . '/assets/css/modal.css', false, Note::$version);
     wp_enqueue_style('note-link-modal', Note::plugin_url() . '/assets/css/link-modal.css', false, Note::$version);
     // WordPress Media (has to come after WordPress Core/Modal Styles)
     wp_enqueue_media();
     // TinyMCE Core CSS
     wp_enqueue_style('tinymce-core', Note::plugin_url() . '/assets/css/tinymce-core.css', false, Note::$version);
     // TinyMCE View CSS
     wp_enqueue_style('tinymce-view', Note::plugin_url() . '/assets/css/tinymce-view.css', false, Note::$version);
     // Note Theme CSS
     wp_enqueue_style('note', Note::plugin_url() . '/assets/css/note.css', false, Note::$version);
     // Dashicons
     wp_enqueue_style('dashicons');
 }
 function wp_enqueue_scripts()
 {
     global $post, $wp_version, $tinymce_version, $concatenate_scripts, $compress_scripts;
     if (!isset($concatenate_scripts)) {
         script_concat_settings();
     }
     $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || file_exists(dirname(__FILE__) . '/.gitignore') ? '' : '.min';
     if ($this->has_fee()) {
         wp_enqueue_style('wp-core-ui', $this->url('/css/wp-core-ui.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('wp-core-ui-colors', $this->url('/css/wp-core-ui-colors.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('buttons');
         wp_enqueue_style('wp-auth-check');
         wp_enqueue_script('wp-auth-check');
         wp_enqueue_script('autosave-custom', $this->url('/js/autosave' . $suffix . '.js'), array('schedule', 'wp-ajax-response', 'fee'), self::VERSION, true);
         wp_localize_script('autosave-custom', 'autosaveL10n', array('autosaveInterval' => AUTOSAVE_INTERVAL, 'blog_id' => get_current_blog_id()));
         // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)
         $mce_suffix = false !== strpos($wp_version, '-src') ? '' : '.min';
         if ($compressed) {
             wp_enqueue_script('fee-tinymce', includes_url('js/tinymce') . '/wp-tinymce.php?c=1', array(), $tinymce_version, true);
         } else {
             wp_enqueue_script('fee-tinymce', includes_url('js/tinymce') . '/tinymce' . $mce_suffix . '.js', array(), $tinymce_version, true);
             wp_enqueue_script('fee-tinymce-compat3x', includes_url('js/tinymce') . '/plugins/compat3x/plugin' . $suffix . '.js', array('fee-tinymce'), $tinymce_version, true);
         }
         if (empty($suffix)) {
             wp_enqueue_script('fee-tinymce-image', $this->url('/js/tinymce.image.js'), array('fee-tinymce'), self::VERSION, true);
             wp_enqueue_script('fee-tinymce-insert', $this->url('/js/tinymce.insert.js'), array('fee-tinymce'), self::VERSION, true);
             wp_enqueue_script('fee-tinymce-markdown', $this->url('/js/tinymce.markdown.js'), array('fee-tinymce'), self::VERSION, true);
             wp_enqueue_script('fee-tinymce-more', $this->url('/js/tinymce.more.js'), array('fee-tinymce'), self::VERSION, true);
             wp_enqueue_script('fee-tinymce-view', $this->url('/js/tinymce.view.js'), array('fee-tinymce'), self::VERSION, true);
             wp_enqueue_script('fee-tinymce-theme', $this->url('/js/tinymce.theme.js'), array('fee-tinymce'), self::VERSION, true);
         } else {
             wp_enqueue_script('fee-tinymce-plugins', $this->url('/js/tinymce.min.js'), array('fee-tinymce'), self::VERSION, true);
         }
         $tinymce_plugins = array('feeImage', 'feeMarkDown', 'wpmore', 'wplink', 'wpview', 'paste', 'insert', 'hr', 'lists');
         $tinymce_toolbar = array('bold', 'italic', 'strikethrough', 'link', 'unlink', 'blockquote', 'h2', 'h3');
         $tinymce_blocks = array('wp_image', 'wp_gallery', 'wp_audio', 'wp_audio_playlist', 'wp_video', 'wp_video_playlist', 'hr', 'wp_more', 'wp_page');
         $tinymce = array('selector' => '#fee-mce-' . $post->ID, 'plugins' => implode(' ', array_unique(apply_filters('fee_tinymce_plugins', $tinymce_plugins))), 'toolbar' => apply_filters('fee_tinymce_toolbar', $tinymce_toolbar), 'blocks' => apply_filters('fee_tinymce_blocks', $tinymce_blocks), 'theme' => 'fee', 'inline' => true, 'relative_urls' => false, 'convert_urls' => false, 'browser_spellcheck' => true, 'placeholder' => apply_filters('fee_content_placeholder', __('Just write&hellip;')), 'wpeditimage_html5_captions' => current_theme_supports('html5', 'caption'));
         wp_enqueue_script('wp-lists');
         wp_localize_script('wp-lists', 'ajaxurl', admin_url('admin-ajax.php'));
         wp_enqueue_script('fee', $this->url('/js/fee' . $suffix . '.js'), array('fee-tinymce', 'wp-util', 'heartbeat', 'editor', 'wp-lists'), self::VERSION, true);
         wp_localize_script('fee', 'fee', array('tinymce' => apply_filters('fee_tinymce_config', $tinymce), 'postOnServer' => $post, 'permalink' => $this->get_sample_permalink($post->ID), 'nonces' => array('post' => wp_create_nonce('update-post_' . $post->ID), 'slug' => wp_create_nonce('slug-nonce_' . $post->ID), 'categories' => wp_create_nonce('fee-categories_' . $post->ID)), 'lock' => !wp_check_post_lock($post->ID) ? implode(':', wp_set_post_lock($post->ID)) : false, 'notices' => array('autosave' => $this->get_autosave_notice()), 'postTaxOnServer' => $this->get_post_tax_and_terms(), 'taxonomies' => $this->get_tax_and_terms()));
         wp_localize_script('fee', 'feeL10n', array('saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 'title' => apply_filters('fee_title_placeholder', __('Title'))));
         wp_enqueue_media(array('post' => $post));
         wp_deregister_script('mce-view');
         wp_enqueue_script('mce-view', $this->url('/js/mce-view' . $suffix . '.js'), array('shortcode', 'media-models', 'media-audiovideo', 'wp-playlist'), self::VERSION, true);
         wp_enqueue_script('wplink');
         wp_localize_script('wplink', 'ajaxurl', admin_url('admin-ajax.php'));
         wp_enqueue_script('fee-modal', $this->url('/js/modal' . $suffix . '.js'), array('jquery'), self::VERSION, true);
         wp_enqueue_style('fee-modal', $this->url('/css/modal.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('fee-link-modal', $this->url('/css/link-modal.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('tinymce-core', $this->url('/css/tinymce.core.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('tinymce-view', $this->url('/css/tinymce.view.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('fee', $this->url('/css/fee.css'), false, self::VERSION, 'screen');
         wp_enqueue_style('dashicons');
     }
     if (current_user_can('edit_posts')) {
         if (is_singular()) {
             require_once ABSPATH . '/wp-admin/includes/post.php';
             $user_id = wp_check_post_lock($post->ID);
             $user = get_userdata($user_id);
         }
         wp_enqueue_style('fee-adminbar', $this->url('/css/fee-adminbar.css'), false, self::VERSION, 'screen');
         wp_enqueue_script('fee-adminbar', $this->url('/js/fee-adminbar' . $suffix . '.js'), array('wp-util'), self::VERSION, true);
         wp_localize_script('fee-adminbar', 'fee', array('lock' => is_singular() && $user_id ? $user->display_name : false, 'supportedPostTypes' => $this->get_supported_post_types(), 'postNew' => admin_url('post-new.php'), 'nonce' => wp_create_nonce('fee-new')));
     }
 }
    function initTinyMCE()
    {
        global $concatenate_scripts, $compress_scripts, $tinymce_version;
        if (!user_can_richedit()) {
            return;
        }
        $baseurl = includes_url('js/tinymce');
        $mce_locale = '' == get_locale() ? 'en' : strtolower(substr(get_locale(), 0, 2));
        // only ISO 639-1
        /*
        The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
        By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
        The + sign marks the default language. More information:
        http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
        */
        $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
        $plugins = array('safari', 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus');
        $plugins = implode($plugins, ',');
        $mce_buttons = apply_filters('_mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'link', 'unlink', 'code'));
        $mce_buttons = implode($mce_buttons, ',');
        $mce_buttons_2 = array();
        if (is_multisite()) {
            unset($mce_buttons_2[array_search('media', $mce_buttons_2)]);
        }
        $mce_buttons_2 = apply_filters('_mce_buttons_2', $mce_buttons_2);
        $mce_buttons_2 = implode($mce_buttons_2, ',');
        $mce_buttons_3 = apply_filters('_mce_buttons_3', array());
        $mce_buttons_3 = implode($mce_buttons_3, ',');
        $mce_buttons_4 = apply_filters('_mce_buttons_4', array());
        $mce_buttons_4 = implode($mce_buttons_4, ',');
        $no_captions = (bool) apply_filters('disable_captions', '');
        // TinyMCE init settings
        $initArray = array('mode' => 'specific_textareas', 'editor_selector' => 'lmceEditor', 'width' => '100%', 'theme' => 'advanced', 'skin' => 'wp_theme', 'theme_advanced_buttons1' => $mce_buttons, 'theme_advanced_buttons2' => $mce_buttons_2, 'theme_advanced_buttons3' => $mce_buttons_3, 'theme_advanced_buttons4' => $mce_buttons_4, 'language' => $mce_locale, 'spellchecker_languages' => $mce_spellchecker_languages, 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, 'dialog_type' => 'modal', 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'apply_source_formatting' => false, 'remove_linebreaks' => false, 'convert_newlines_to_brs' => true, 'gecko_spellcheck' => true, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => true, 'tabfocus_elements' => 'major-publishing-actions', 'media_strict' => false, 'paste_remove_styles' => true, 'paste_remove_spans' => true, 'paste_strip_class_attributes' => 'all', 'wpeditimage_disable_captions' => $no_captions, 'plugins' => $plugins);
        if (empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4'])) {
            $initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4'];
            $initArray['theme_advanced_buttons4'] = '';
        }
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $language = $initArray['language'];
        $compressed = false;
        /**
         * Deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = apply_filters('tiny_mce_version', '');
        $version = 'ver=' . $tinymce_version . $version;
        if ('en' != $language) {
            include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
        }
        $mce_options = '';
        foreach ($initArray as $k => $v) {
            $mce_options .= $k . ':"' . $v . '", ';
        }
        $mce_options = rtrim(trim($mce_options), '\\n\\r,');
        ?>
		<script type="text/javascript">
		/* <![CDATA[ */
		tinyMCEPreInit = {
			base : "<?php 
        echo $baseurl;
        ?>
",
			suffix : "",
			query : "<?php 
        echo $version;
        ?>
",
			mceInit : {<?php 
        echo $mce_options;
        ?>
},
			load_ext : function(url,lang) {var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
		};
		/* ]]> */
		</script>
		
		<?php 
        /*
        	if ( $compressed )
        		echo "<script type='text/javascript' src='$baseurl/wp-tinymce.php?c=1&amp;$version'></script>\n";
        	else
        		echo "<script type='text/javascript' src='$baseurl/tiny_mce.js?$version'></script>\n";
        	
        	if ( 'en' != $language && isset($lang) )
        		echo "<script type='text/javascript'>\n$lang\n</script>\n";
        	else
        		echo "<script type='text/javascript' src='$baseurl/langs/wp-langs-en.js?$version'></script>\n";
        */
        ?>
		
		<script type="text/javascript">
		/* <![CDATA[ */
		<?php 
        if ($ext_plugins) {
            echo "{$ext_plugins}\n";
        }
        ?>
		<?php 
        if ($compressed) {
            ?>
		tinyMCEPreInit.go();
		<?php 
        } else {
            ?>
		(function() {var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n) {if(n&&n.charAt(0)!='-') {sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
		<?php 
        }
        ?>
		tinyMCE.init(tinyMCEPreInit.mceInit);
		/* ]]> */
		</script>
		<?php 
    }
Example #11
0
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8.0
 */
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    /**
     * Filter whether to print the admin styles.
     *
     * @since 2.8.0
     *
     * @param bool $print Whether to print the admin styles. Default true.
     */
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
Example #12
0
/**
 * Adds the TinyMCE editor used on the Write and Edit screens.
 *
 * @package WordPress
 * @since 2.7.0
 *
 * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
 * and optionaly pre-compressed version of the core and all default plugins. Additional plugins are loaded
 * directly by TinyMCE using non-blocking method. Custom plugins can be refreshed by adding a query string
 * to the URL when queueing them with the mce_external_plugins filter.
 *
 * @param bool $teeny optional Output a trimmed down version used in Press This.
 * @param mixed $settings optional An array that can add to or overwrite the default TinyMCE settings.
 */
function wp_tiny_mce($teeny = false, $settings = false)
{
    global $concatenate_scripts, $compress_scripts, $tinymce_version, $editor_styles;
    if (!user_can_richedit()) {
        return;
    }
    $baseurl = includes_url('js/tinymce');
    $mce_locale = '' == get_locale() ? 'en' : strtolower(substr(get_locale(), 0, 2));
    // only ISO 639-1
    /*
    The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
    By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
    The + sign marks the default language. More information:
    http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
    */
    $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
    if ($teeny) {
        $plugins = apply_filters('teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs'));
        $ext_plugins = '';
    } else {
        $plugins = array('inlinepopups', 'spellchecker', 'paste', 'wordpress', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink', 'wpdialogs');
        /*
        The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
        It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
        The url should be absolute and should include the js file name to be loaded. Example:
        array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
        If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
        */
        $mce_external_plugins = apply_filters('mce_external_plugins', array());
        $ext_plugins = '';
        if (!empty($mce_external_plugins)) {
            /*
            The following filter loads external language files for TinyMCE plugins.
            It takes an associative array 'plugin_name' => 'path', where path is the
            include path to the file. The language file should follow the same format as
            /tinymce/langs/wp-langs.php and should define a variable $strings that
            holds all translated strings.
            When this filter is not used, the function will try to load {mce_locale}.js.
            If that is not found, en.js will be tried next.
            */
            $mce_external_languages = apply_filters('mce_external_languages', array());
            $loaded_langs = array();
            $strings = '';
            if (!empty($mce_external_languages)) {
                foreach ($mce_external_languages as $name => $path) {
                    if (@is_file($path) && @is_readable($path)) {
                        include_once $path;
                        $ext_plugins .= $strings . "\n";
                        $loaded_langs[] = $name;
                    }
                }
            }
            foreach ($mce_external_plugins as $name => $url) {
                if (is_ssl()) {
                    $url = str_replace('http://', 'https://', $url);
                }
                $plugins[] = '-' . $name;
                $plugurl = dirname($url);
                $strings = $str1 = $str2 = '';
                if (!in_array($name, $loaded_langs)) {
                    $path = str_replace(WP_PLUGIN_URL, '', $plugurl);
                    $path = WP_PLUGIN_DIR . $path . '/langs/';
                    if (function_exists('realpath')) {
                        $path = trailingslashit(realpath($path));
                    }
                    if (@is_file($path . $mce_locale . '.js')) {
                        $strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
                    }
                    if (@is_file($path . $mce_locale . '_dlg.js')) {
                        $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
                    }
                    if ('en' != $mce_locale && empty($strings)) {
                        if (@is_file($path . 'en.js')) {
                            $str1 = @file_get_contents($path . 'en.js');
                            $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str1, 1) . "\n";
                        }
                        if (@is_file($path . 'en_dlg.js')) {
                            $str2 = @file_get_contents($path . 'en_dlg.js');
                            $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str2, 1) . "\n";
                        }
                    }
                    if (!empty($strings)) {
                        $ext_plugins .= "\n" . $strings . "\n";
                    }
                }
                $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
                $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
            }
        }
    }
    if ($teeny) {
        $mce_buttons = apply_filters('teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen'));
        $mce_buttons = implode($mce_buttons, ',');
        $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
    } else {
        $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv'));
        $mce_buttons = implode($mce_buttons, ',');
        $mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help');
        $mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2);
        $mce_buttons_2 = implode($mce_buttons_2, ',');
        $mce_buttons_3 = apply_filters('mce_buttons_3', array());
        $mce_buttons_3 = implode($mce_buttons_3, ',');
        $mce_buttons_4 = apply_filters('mce_buttons_4', array());
        $mce_buttons_4 = implode($mce_buttons_4, ',');
    }
    $no_captions = (bool) apply_filters('disable_captions', '');
    // TinyMCE init settings
    $initArray = array('mode' => 'specific_textareas', 'editor_selector' => 'theEditor', 'width' => '100%', 'theme' => 'advanced', 'skin' => 'wp_theme', 'theme_advanced_buttons1' => $mce_buttons, 'theme_advanced_buttons2' => $mce_buttons_2, 'theme_advanced_buttons3' => $mce_buttons_3, 'theme_advanced_buttons4' => $mce_buttons_4, 'language' => $mce_locale, 'spellchecker_languages' => $mce_spellchecker_languages, 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, 'dialog_type' => 'modal', 'formats' => "{\n\t\t\talignleft : [\n\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},\n\t\t\t\t{selector : 'img,table', classes : 'alignleft'}\n\t\t\t],\n\t\t\taligncenter : [\n\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},\n\t\t\t\t{selector : 'img,table', classes : 'aligncenter'}\n\t\t\t],\n\t\t\talignright : [\n\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},\n\t\t\t\t{selector : 'img,table', classes : 'alignright'}\n\t\t\t],\n\t\t\tstrikethrough : {inline : 'del'}\n\t\t}", 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'apply_source_formatting' => false, 'remove_linebreaks' => true, 'gecko_spellcheck' => true, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => true, 'tabfocus_elements' => 'major-publishing-actions', 'media_strict' => false, 'paste_remove_styles' => true, 'paste_remove_spans' => true, 'paste_strip_class_attributes' => 'all', 'paste_text_use_dialog' => true, 'wpeditimage_disable_captions' => $no_captions, 'plugins' => implode(',', $plugins));
    if (!empty($editor_styles) && is_array($editor_styles)) {
        $mce_css = array();
        $style_uri = get_stylesheet_directory_uri();
        if (!is_child_theme()) {
            foreach ($editor_styles as $file) {
                $mce_css[] = "{$style_uri}/{$file}";
            }
        } else {
            $style_dir = get_stylesheet_directory();
            $template_uri = get_template_directory_uri();
            $template_dir = get_template_directory();
            foreach ($editor_styles as $file) {
                if (file_exists("{$template_dir}/{$file}")) {
                    $mce_css[] = "{$template_uri}/{$file}";
                }
                if (file_exists("{$style_dir}/{$file}")) {
                    $mce_css[] = "{$style_uri}/{$file}";
                }
            }
        }
        $mce_css = implode(',', $mce_css);
    } else {
        $mce_css = '';
    }
    $mce_css = trim(apply_filters('mce_css', $mce_css), ' ,');
    if (!empty($mce_css)) {
        $initArray['content_css'] = $mce_css;
    }
    if (is_array($settings)) {
        $initArray = array_merge($initArray, $settings);
    }
    // For people who really REALLY know what they're doing with TinyMCE
    // You can modify initArray to add, remove, change elements of the config before tinyMCE.init
    // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
    // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
    if ($teeny) {
        $initArray = apply_filters('teeny_mce_before_init', $initArray);
    } else {
        $initArray = apply_filters('tiny_mce_before_init', $initArray);
    }
    if (empty($initArray['theme_advanced_buttons3']) && !empty($initArray['theme_advanced_buttons4'])) {
        $initArray['theme_advanced_buttons3'] = $initArray['theme_advanced_buttons4'];
        $initArray['theme_advanced_buttons4'] = '';
    }
    if (!isset($concatenate_scripts)) {
        script_concat_settings();
    }
    $language = $initArray['language'];
    $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip');
    /**
     * Deprecated
     *
     * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
     * These plugins can be refreshed by appending query string to the URL passed to mce_external_plugins filter.
     * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
     */
    $version = apply_filters('tiny_mce_version', '');
    $version = 'ver=' . $tinymce_version . $version;
    if ('en' != $language) {
        include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
    }
    $mce_options = '';
    foreach ($initArray as $k => $v) {
        if (is_bool($v)) {
            $val = $v ? 'true' : 'false';
            $mce_options .= $k . ':' . $val . ', ';
            continue;
        } elseif (!empty($v) && is_string($v) && ('{' == $v[0] || '[' == $v[0])) {
            $mce_options .= $k . ':' . $v . ', ';
            continue;
        }
        $mce_options .= $k . ':"' . $v . '", ';
    }
    $mce_options = rtrim(trim($mce_options), '\\n\\r,');
    ?>

<script type="text/javascript">
/* <![CDATA[ */
tinyMCEPreInit = {
	base : "<?php 
    echo $baseurl;
    ?>
",
	suffix : "",
	query : "<?php 
    echo $version;
    ?>
",
	mceInit : {<?php 
    echo $mce_options;
    ?>
},
	load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
};
/* ]]> */
</script>

<?php 
    if ($compressed) {
        echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;{$version}'></script>\n";
    } else {
        echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?{$version}'></script>\n";
    }
    if ('en' != $language && isset($lang)) {
        echo "<script type='text/javascript'>\n{$lang}\n</script>\n";
    } else {
        echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
    }
    ?>

<script type="text/javascript">
/* <![CDATA[ */
<?php 
    if ($ext_plugins) {
        echo "{$ext_plugins}\n";
    }
    if (!$compressed) {
        ?>
(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.mceInit.language,th=t.mceInit.theme,pl=t.mceInit.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php 
    }
    ?>
tinyMCE.init(tinyMCEPreInit.mceInit);
/* ]]> */
</script>
<?php 
    // Load additional inline scripts based on active plugins.
    if (in_array('wpdialogs', $plugins)) {
        wp_print_scripts(array('wpdialogs-popup'));
        wp_print_styles('wp-jquery-ui-dialog');
    }
    if (in_array('wplink', $plugins)) {
        require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
        add_action('tiny_mce_preload_dialogs', 'wp_link_dialog');
        wp_print_scripts('wplink');
        wp_print_styles('wplink');
    }
}
Example #13
0
    public static function editor_js()
    {
        global $tinymce_version, $concatenate_scripts, $compress_scripts;
        /**
         * Filter "tiny_mce_version" is deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = 'ver=' . $tinymce_version;
        $tinyMceMajorVersion = substr($tinymce_version, 0, 1);
        $tmce_on = !empty(self::$mce_settings);
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
        if ($tinyMceMajorVersion < 4 && $tmce_on && 'en' != self::$mce_locale) {
            include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
        }
        $mceInit = $qtInit = '';
        if ($tmce_on) {
            foreach (self::$mce_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $mceInit .= "'{$editor_id}':{$options},";
            }
            $mceInit = '{' . trim($mceInit, ',') . '}';
        } else {
            $mceInit = '{}';
        }
        if (!empty(self::$qt_settings)) {
            foreach (self::$qt_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $qtInit .= "'{$editor_id}':{$options},";
            }
            $qtInit = '{' . trim($qtInit, ',') . '}';
        } else {
            $qtInit = '{}';
        }
        $ref = array('plugins' => implode(',', self::$plugins), 'theme' => 'advanced', 'language' => self::$mce_locale);
        do_action('before_wp_tiny_mce', self::$mce_settings);
        ?>

        <script type="text/javascript">
            tinyMCEPreInit = {
                base : "<?php 
        echo self::$baseurl;
        ?>
",
                suffix : "",
                query : "<?php 
        echo $version;
        ?>
",
                mceInit : <?php 
        echo $mceInit;
        ?>
,
                qtInit : <?php 
        echo $qtInit;
        ?>
,
                ref : <?php 
        echo self::_parse_init($ref);
        ?>
,
                load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
            };
        </script>
        <?php 
        $baseurl = self::$baseurl;
        if ($tmce_on) {
            if ($compressed) {
                echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;{$version}'></script>\n";
                //wp_enqueue_script(OP_SN.'-wp-tinymce', $baseurl.'/wp-tinymce.php?c=1&amp;'.$version, array(OP_SN.'-noconflict-js'), OP_VERSION);
            } else {
                if ($tinyMceMajorVersion < 4) {
                    echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?{$version}'></script>\n";
                } else {
                    echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?{$version}'></script>\n";
                }
                //$tiny_mce_url = $baseurl.'/tiny_mce.js?'.$version;
                //wp_enqueue_script(OP_SN.'-tiny_mce', $tiny_mce_url, false, OP_VERSION, true);
                //wp_print_scripts(OP_SN.'-tiny_mce');
            }
            if ($tinyMceMajorVersion < 4) {
                echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
            } else {
                echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n";
                if (self::$ext_plugins) {
                    // Load the old-format English strings to prevent unsightly labels in old style popups
                    echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
                }
            }
        }
        ?>

    <script type="text/javascript">
        (function($){

            var init, ed, qt, first_init, mce = true;

            if ( typeof tinymce === 'object' ) {

                // mark wp_theme/ui.css as loaded
                tinymce.DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true;

                for ( ed in tinyMCEPreInit.mceInit ) {
                    if ( first_init ) {
                        init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] );
                    } else {
                        init = first_init = tinyMCEPreInit.mceInit[ed];
                    }

                    // if ( mce ) {
                    //     try {
                    //         tinymce.init(init);
                    //     } catch(e){
                    //         console.error('TinyMCE init error', e);
                    //     }
                    // }
                }

                init.setup = function(ed) {

                    /**
                     * Fixes for TinyMCE version 3
                     * This stuff is functioning properly in TinyMCE 4, so it's not needed in that case.
                     */
                     if (tinymce.majorVersion < 4) {

                        // Wait for toolbar to be initialized, then add tabindex to the empty a element to prevent focus on it in chrome.
                        ed.onInit.add(function(ed) {
                            $('#' + ed.editorId).parent().find('.mceToolbar > a').attr('tabindex', '-1');
                        });

                        // Tabbing through elements of the page (in relation to tinymce) is inconsistent in FF & Chrome, this unifies it.
                        // tabfocus plugin is also not functioning properly.
                        ed.onKeyPress.add(function(ed, e) {
                            var $parentWindowActiveElement;
                            if (e.keyCode === 9 && e.shiftKey) {
                                tinymce.dom.Event.cancel(e);
                                var $parentWindowActiveElement = $(window.top.document.activeElement);
                                $(document.activeElement).blur();
                                $parentWindowActiveElement.blur();
                                $parentWindowActiveElement.parentsUntil('.wp-editor-container').eq(-1).parent().prev().find('.insert-media').focus();
                                e.preventDefault();
                            }
                        });

                    }

                }

                try {
                    window.op_tinymce_initialized = true;
                    tinymce.init(init);
                } catch(e){
                    throw new Error('Error initializing TinyMCE.');
                }
            }

            if ( typeof(QTags) == 'function' ) {

                for ( qt in tinyMCEPreInit.qtInit ) {
                    try {
                        quicktags( tinyMCEPreInit.qtInit[qt] );
                    } catch (e) {
                        throw new Error('Error initializing quicktags.');
                    }
                }
            }
        }(opjq));

        // var wpActiveEditor;

        //jQuery('.wp-editor-wrap').mousedown(function(e){
        //jQuery('body').on('mousedown', '.wp-editor-wrap', function(e){
        //  wpActiveEditor = this.id.slice(3, -5);
        //});

<?php 
        if (self::$ext_plugins) {
            echo self::$ext_plugins . "\n";
        }
        if (!$compressed && $tmce_on) {
            ?>
        (function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php 
        }
        if (!is_admin()) {
            echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
        }
        ?>
    </script>
<?php 
        // if (substr($tinymce_version, 0, 1) < 4) {
        if (in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) {
            self::wp_link_dialog();
        }
        // }
        if (in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true)) {
            self::wp_fullscreen_html();
        }
        do_action('after_wp_tiny_mce', self::$mce_settings);
    }
    function editor_js()
    {
        global $tinymce_version, $concatenate_scripts, $compress_scripts;
        /**
         * Filter "tiny_mce_version" is deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = 'ver=' . $tinymce_version;
        $tmce_on = !empty($this->mce_settings);
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
        if ($tmce_on && 'en' != $this->mce_locale) {
            include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
        }
        $mceInit = $qtInit = '';
        if ($tmce_on) {
            foreach ($this->mce_settings as $editor_id => $init) {
                $options = $this->_parse_init($init);
                $mceInit .= "'{$editor_id}':{$options},\n";
            }
            $mceInit = '{' . trim($mceInit, '\\n,') . '}';
        } else {
            $mceInit = '{}';
        }
        if (!empty($this->qt_settings)) {
            foreach ($this->qt_settings as $editor_id => $init) {
                $options = $this->_parse_init($init);
                $qtInit .= "'{$editor_id}':{$options},\n";
            }
            $qtInit = '{' . trim($qtInit, '\\n,') . '}';
        } else {
            $qtInit = '{}';
        }
        $ref = array('plugins' => implode(',', $this->plugins), 'theme' => 'advanced', 'language' => $this->mce_locale);
        do_action('before_wp_tiny_mce', $this->mce_settings);
        ?>

	<script type="text/javascript">
		tinyMCEPreInit = {
			base : "<?php 
        echo $this->baseurl;
        ?>
",
			suffix : "",
			query : "<?php 
        echo $version;
        ?>
",
			mceInit : <?php 
        echo $mceInit;
        ?>
,
			qtInit : <?php 
        echo $qtInit;
        ?>
,
			ref : <?php 
        echo $this->_parse_init($ref);
        ?>
,
			load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
		};
	</script>
<?php 
        if ($tmce_on) {
            if ($compressed) {
                echo "<script type='text/javascript' src='{$this->baseurl}/wp-tinymce.php?c=1&amp;{$version}'></script>\n";
            } else {
                echo "<script type='text/javascript' src='{$this->baseurl}/tiny_mce.js?{$version}'></script>\n";
            }
            if ('en' != $this->mce_locale && isset($lang)) {
                echo "<script type='text/javascript'>\n{$lang}\n</script>\n";
            } else {
                echo "<script type='text/javascript' src='{$this->baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
            }
        }
        ?>

	<script type="text/javascript">
		(function(){
			var init, ed, qt, first_init, mce = <?php 
        echo $this->default_editor == 'tinymce' ? 'true' : 'false';
        ?>
;

			if ( typeof(tinymce) == 'object' ) {
				for ( ed in tinyMCEPreInit.mceInit ) {
					if ( first_init ) {
						init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] );
					} else {
						init = first_init = tinyMCEPreInit.mceInit[ed];
					}

					if ( mce )
						try { tinymce.init(init); } catch(e){}
				}
			}

			if ( typeof(QTags) == 'function' ) {
				for ( qt in tinyMCEPreInit.qtInit ) {
					try { quicktags( tinyMCEPreInit.qtInit[qt] ); } catch(e){}
				}
			}
		})();

		var wpActiveEditor;

		jQuery('.wp-editor-wrap').mousedown(function(e){
	    	wpActiveEditor = this.id.slice(3, -5);
		});

<?php 
        if ($this->ext_plugins) {
            echo "{$this->ext_plugins}\n";
        }
        if (!$compressed && $tmce_on) {
            ?>
		(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
<?php 
        }
        if (!is_admin()) {
            echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '";';
        }
        ?>
	</script>
<?php 
        if (in_array('wplink', $this->plugins, true)) {
            $this->wp_link_dialog();
        }
        if (in_array('wpfullscreen', $this->plugins, true)) {
            $this->wp_fullscreen_html();
        }
        do_action('after_wp_tiny_mce', $this->mce_settings);
    }
Example #15
0
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8.0
 *
 * @global bool $concatenate_scripts
 *
 * @return array
 */
function print_admin_styles()
{
    global $concatenate_scripts;
    $wp_styles = wp_styles();
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $wp_styles->do_items(false);
    /**
     * Filter whether to print the admin styles.
     *
     * @since 2.8.0
     *
     * @param bool $print Whether to print the admin styles. Default true.
     */
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $wp_styles->reset();
    return $wp_styles->done;
}
function print_admin_styles()
{
    global $wp_styles, $concatenate_scripts, $compress_css;
    if (!is_a($wp_styles, 'WP_Styles')) {
        $wp_styles = new WP_Styles();
    }
    script_concat_settings();
    $wp_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $wp_styles->do_items(false);
    if (apply_filters('print_admin_styles', true)) {
        if (!empty($wp_styles->concat)) {
            $dir = $wp_styles->text_direction;
            $ver = md5("{$wp_styles->concat_version}{$dir}");
            $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . "&ver={$ver}";
            echo "<link rel='stylesheet' href='" . esc_attr($href) . "' type='text/css' media='all' />\n";
        }
        if (!empty($wp_styles->print_html)) {
            echo $wp_styles->print_html;
        }
    }
    $wp_styles->do_concat = false;
    $wp_styles->concat = $wp_styles->concat_version = $wp_styles->print_html = '';
    return $wp_styles->done;
}
    public static function editor_js()
    {
        global $tinymce_version, $concatenate_scripts, $compress_scripts;
        /**
         * Filter "tiny_mce_version" is deprecated
         *
         * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE.
         * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter.
         * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code).
         */
        $version = 'ver=' . $tinymce_version;
        $tmce_on = !empty(self::$mce_settings);
        if (!isset($concatenate_scripts)) {
            script_concat_settings();
        }
        $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
        if ($tmce_on && 'en' != self::$mce_locale) {
            include_once ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php';
        }
        $mceInit = $qtInit = '';
        if ($tmce_on) {
            foreach (self::$mce_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $mceInit .= "'{$editor_id}':{$options},";
            }
            $mceInit = '{' . trim($mceInit, ',') . '}';
        } else {
            $mceInit = '{}';
        }
        if (!empty(self::$qt_settings)) {
            foreach (self::$qt_settings as $editor_id => $init) {
                $options = self::_parse_init($init);
                $qtInit .= "'{$editor_id}':{$options},";
            }
            $qtInit = '{' . trim($qtInit, ',') . '}';
        } else {
            $qtInit = '{}';
        }
        $ref = array('plugins' => implode(',', self::$plugins), 'theme' => 'advanced', 'language' => self::$mce_locale);
        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '_src' : '';
        do_action('before_wp_tiny_mce', self::$mce_settings);
        ?>

	<script type="text/javascript">
		tinyMCEPreInit = {
			base : "<?php 
        echo self::$baseurl;
        ?>
",
			suffix : "<?php 
        echo $suffix;
        ?>
",
			query : "<?php 
        echo $version;
        ?>
",
			mceInit : <?php 
        echo $mceInit;
        ?>
,
			qtInit : <?php 
        echo $qtInit;
        ?>
,
			ref : <?php 
        echo self::_parse_init($ref);
        ?>
,
			load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');}
		};
	</script>
<?php 
        $baseurl = self::$baseurl;
        if ($tmce_on) {
            if ($compressed) {
                echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&amp;{$version}'></script>\n";
            } else {
                echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?{$version}'></script>\n";
                echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce-schema.js?{$version}'></script>\n";
            }
            if ('en' != self::$mce_locale && isset($lang)) {
                echo "<script type='text/javascript'>\n{$lang}\n</script>\n";
            } else {
                echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?{$version}'></script>\n";
            }
        }
        $mce = self::$has_tinymce && wp_default_editor() == 'tinymce' || !self::$has_quicktags;
        ?>

	<script type="text/javascript">
		var wpActiveEditor;

		(function(){
			var init, ed, qt, first_init, DOM, el, i, mce = <?php 
        echo (int) $mce;
        ?>
;

			if ( typeof(tinymce) == 'object' ) {
				DOM = tinymce.DOM;
				// mark wp_theme/ui.css as loaded
				DOM.files[tinymce.baseURI.getURI() + '/themes/advanced/skins/wp_theme/ui.css'] = true;

				DOM.events.add( DOM.select('.wp-editor-wrap'), 'mousedown', function(e){
					if ( this.id )
						wpActiveEditor = this.id.slice(3, -5);
				});

				for ( ed in tinyMCEPreInit.mceInit ) {
					if ( first_init ) {
						init = tinyMCEPreInit.mceInit[ed] = tinymce.extend( {}, first_init, tinyMCEPreInit.mceInit[ed] );
					} else {
						init = first_init = tinyMCEPreInit.mceInit[ed];
					}

					if ( mce )
						try { tinymce.init(init); } catch(e){}
				}
			} else {
				if ( tinyMCEPreInit.qtInit ) {
					for ( i in tinyMCEPreInit.qtInit ) {
						el = tinyMCEPreInit.qtInit[i].id;
						if ( el )
							document.getElementById('wp-'+el+'-wrap').onmousedown = function(){ wpActiveEditor = this.id.slice(3, -5); }
					}
				}
			}

			if ( typeof(QTags) == 'function' ) {
				for ( qt in tinyMCEPreInit.qtInit ) {
					try { quicktags( tinyMCEPreInit.qtInit[qt] ); } catch(e){}
				}
			}
		})();
		<?php 
        if (self::$ext_plugins) {
            echo self::$ext_plugins . "\n";
        }
        if (!$compressed && $tmce_on) {
            ?>
			(function(){var t=tinyMCEPreInit,sl=tinymce.ScriptLoader,ln=t.ref.language,th=t.ref.theme,pl=t.ref.plugins;sl.markDone(t.base+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'.js');sl.markDone(t.base+'/themes/'+th+'/langs/'+ln+'_dlg.js');sl.markDone(t.base+'/themes/advanced/skins/wp_theme/ui.css');tinymce.each(pl.split(','),function(n){if(n&&n.charAt(0)!='-'){sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'.js');sl.markDone(t.base+'/plugins/'+n+'/langs/'+ln+'_dlg.js');}});})();
			<?php 
        }
        if (!is_admin()) {
            echo 'var ajaxurl = "' . admin_url('admin-ajax.php', 'relative') . '";';
        }
        ?>
		</script>
		<?php 
        if (in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true)) {
            self::wp_link_dialog();
        }
        if (in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true)) {
            self::wp_fullscreen_html();
        }
        do_action('after_wp_tiny_mce', self::$mce_settings);
    }
 public function wp_enqueue_scripts()
 {
     global $concatenate_scripts, $compress_scripts;
     $object_id = $this->get_post_to_edit();
     if (!$object_id) {
         return;
     }
     if (!isset($concatenate_scripts)) {
         script_concat_settings();
     }
     $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     if ($this->is_edit()) {
         wp_enqueue_style('wp-auth-check');
         wp_enqueue_style('bon-fee', trailingslashit(BON_CSS) . 'frontend/fee.css', '', null, null);
         wp_enqueue_style('dashicons');
         //wp_enqueue_style( 'wpadmin', admin_url( 'css/wp-admin.css' ) , '', null, null );
         wp_enqueue_style('bon-meta-box', BON_CSS . '/metabox.css', '', '1.0', 'all');
         wp_enqueue_script('jquery');
         wp_enqueue_script('jquery-ui-selectable');
         wp_enqueue_script('heartbeat');
         wp_enqueue_script('wp-auth-check');
         wp_enqueue_script('autosave');
         wp_enqueue_script('schedule');
         wp_enqueue_script('wp-ajax-response');
         wp_enqueue_script('bon-meta-box', BON_JS . '/metabox.js', array('jquery', 'jquery-ui-slider', 'jquery-ui-draggable', 'jquery-ui-datepicker'), null, true);
         wp_enqueue_script('bon-fee', trailingslashit(BON_JS) . 'frontend/fee.js', array('jquery', 'wp-lists', 'utils', 'suggest', 'heartbeat'), null, true);
         $vars = array('ok' => __('OK'), 'cancel' => __('Cancel'), 'publishOn' => __('Publish on:'), 'publishOnFuture' => __('Schedule for:'), 'publishOnPast' => __('Published on:'), 'dateFormat' => __('%1$s %2$s, %3$s @ %4$s : %5$s'), 'showcomm' => __('Show more comments'), 'endcomm' => __('No more comments found.'), 'publish' => __('Publish'), 'schedule' => __('Schedule'), 'update' => __('Update'), 'savePending' => __('Save as Pending'), 'saveDraft' => __('Save Draft'), 'private' => __('Private'), 'public' => __('Public'), 'publicSticky' => __('Public, Sticky'), 'password' => __('Password Protected'), 'privatelyPublished' => __('Privately Published'), 'published' => __('Published'), 'comma' => _x(',', 'tag delimiter'));
         wp_localize_script('autosave', 'autosaveL10n', array('autosaveInterval' => AUTOSAVE_INTERVAL, 'blog_id' => get_current_blog_id()));
         wp_localize_script('bon-fee', 'autosaveL10n', array('autosaveInterval' => AUTOSAVE_INTERVAL, 'savingText' => __('Saving Draft&#8230;'), 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.'), 'blog_id' => get_current_blog_id()));
         wp_localize_script('bon-fee', 'postL10n', $vars);
         wp_localize_script('wp-link', 'wpLinkL10n', array('title' => __('Insert/edit link'), 'update' => __('Update'), 'save' => __('Add Link'), 'noTitle' => __('(no title)'), 'noMatchesFound' => __('No matches found.')));
         //wp_enqueue_media( array( 'post' => get_post( $object_id ) ) );
     }
 }