Example #1
0
 public static function editor_settings($editor_id, $set)
 {
     global $editor_styles;
     $first_run = false;
     if (empty(self::$first_init)) {
         if (is_admin()) {
             add_action('admin_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('admin_footer', array(__CLASS__, 'enqueue_scripts'), 1);
         } else {
             add_action('nxt_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('nxt_footer', array(__CLASS__, 'enqueue_scripts'), 1);
         }
     }
     if (self::$this_quicktags) {
         $qtInit = array('id' => $editor_id, 'buttons' => '');
         if (is_array($set['quicktags'])) {
             $qtInit = array_merge($qtInit, $set['quicktags']);
         }
         if (empty($qtInit['buttons'])) {
             $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close';
         }
         if ($set['dfw']) {
             $qtInit['buttons'] .= ',fullscreen';
         }
         $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id);
         self::$qt_settings[$editor_id] = $qtInit;
         self::$qt_buttons = array_merge(self::$qt_buttons, explode(',', $qtInit['buttons']));
     }
     if (self::$this_tinymce) {
         if (empty(self::$first_init)) {
             self::$baseurl = includes_url('js/tinymce');
             self::$mce_locale = $mce_locale = '' == get_locale() ? 'en' : strtolower(substr(get_locale(), 0, 2));
             // only ISO 639-1
             $no_captions = (bool) apply_filters('disable_captions', '');
             $plugins = array('inlinepopups', 'spellchecker', 'tabfocus', 'paste', 'media', 'fullscreen', 'nxtclass', 'nxteditimage', 'nxtgallery', 'nxtlink', 'nxtdialogs');
             $first_run = true;
             if ($set['teeny']) {
                 self::$plugins = $plugins = apply_filters('teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'nxtclass', 'nxtlink', 'nxtdialogs'), $editor_id);
                 $ext_plugins = '';
             } else {
                 /*
                 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/nxt-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/nxt-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(content_url(), '', $plugurl);
                             $path = nxt_CONTENT_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";
                         self::$ext_plugins .= $ext_plugins;
                     }
                 }
                 $plugins = array_unique(apply_filters('tiny_mce_plugins', $plugins));
             }
             if ($set['dfw']) {
                 $plugins[] = 'nxtfullscreen';
             }
             self::$plugins = $plugins;
             /*
             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');
             self::$first_init = array('mode' => 'exact', 'width' => '100%', 'theme' => 'advanced', 'skin' => 'nxt_theme', 'language' => self::$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\t\t\t\talignleft : [\n\t\t\t\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\t\t\t{selector : 'img,table', classes : 'alignleft'}\n\t\t\t\t\t\t],\n\t\t\t\t\t\taligncenter : [\n\t\t\t\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\t\t\t{selector : 'img,table', classes : 'aligncenter'}\n\t\t\t\t\t\t],\n\t\t\t\t\t\talignright : [\n\t\t\t\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\t\t\t{selector : 'img,table', classes : 'alignright'}\n\t\t\t\t\t\t],\n\t\t\t\t\t\tstrikethrough : {inline : 'del'}\n\t\t\t\t\t}", 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'remove_linebreaks' => true, 'gecko_spellcheck' => true, 'keep_styles' => false, '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, 'extended_valid_elements' => 'article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr', 'nxteditimage_disable_captions' => $no_captions, 'nxt_fullscreen_content_css' => self::$baseurl . '/plugins/nxtfullscreen/css/nxt-fullscreen.css', 'plugins' => implode(',', $plugins));
             // load editor_style.css if the current theme supports it
             if (!empty($editor_styles) && is_array($editor_styles)) {
                 $mce_css = array();
                 $editor_styles = array_unique($editor_styles);
                 $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}";
                         }
                     }
                     foreach ($editor_styles as $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)) {
                 self::$first_init['content_css'] = $mce_css;
             }
         }
         if ($set['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'), $editor_id);
             $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
         } else {
             $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'nxt_more', '|', 'spellchecker', 'fullscreen', 'nxt_adv'), $editor_id);
             $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'nxt_help'), $editor_id);
             $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id);
             $mce_buttons_4 = apply_filters('mce_buttons_4', array(), $editor_id);
         }
         if ($set['dfw']) {
             // replace the first 'fullscreen' with 'nxt_fullscreen'
             if (($key = array_search('fullscreen', $mce_buttons)) !== false) {
                 $mce_buttons[$key] = 'nxt_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_2)) !== false) {
                 $mce_buttons_2[$key] = 'nxt_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_3)) !== false) {
                 $mce_buttons_3[$key] = 'nxt_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_4)) !== false) {
                 $mce_buttons_4[$key] = 'nxt_fullscreen';
             }
         }
         $mceInit = array('elements' => $editor_id, 'nxtautop' => (bool) $set['nxtautop'], 'remove_linebreaks' => (bool) $set['nxtautop'], 'apply_source_formatting' => (bool) (!$set['nxtautop']), 'theme_advanced_buttons1' => implode($mce_buttons, ','), 'theme_advanced_buttons2' => implode($mce_buttons_2, ','), 'theme_advanced_buttons3' => implode($mce_buttons_3, ','), 'theme_advanced_buttons4' => implode($mce_buttons_4, ','));
         if ($first_run) {
             $mceInit = array_merge(self::$first_init, $mceInit);
         }
         if (is_array($set['tinymce'])) {
             $mceInit = array_merge($mceInit, $set['tinymce']);
         }
         // 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 this filter.
         // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
         if ($set['teeny']) {
             $mceInit = apply_filters('teeny_mce_before_init', $mceInit, $editor_id);
         } else {
             $mceInit = apply_filters('tiny_mce_before_init', $mceInit, $editor_id);
         }
         if (empty($mceInit['theme_advanced_buttons3']) && !empty($mceInit['theme_advanced_buttons4'])) {
             $mceInit['theme_advanced_buttons3'] = $mceInit['theme_advanced_buttons4'];
             $mceInit['theme_advanced_buttons4'] = '';
         }
         self::$mce_settings[$editor_id] = $mceInit;
     }
     // end if self::$this_tinymce
 }
Example #2
0
     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     require_once ABSPATH . 'nxt-admin/includes/nav-menu.php';
     _nxt_ajax_menu_quick_search($_REQUEST);
     exit;
     break;
 case 'nxt-link-ajax':
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     $args = array();
     if (isset($_POST['search'])) {
         $args['s'] = stripslashes($_POST['search']);
     }
     $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     require ABSPATH . nxtINC . '/class-nxt-editor.php';
     $results = _nxt_Editors::nxt_link_query($args);
     if (!isset($results)) {
         die('0');
     }
     echo json_encode($results);
     echo "\n";
     exit;
     break;
 case 'menu-locations-save':
     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
     if (!isset($_POST['menu-locations'])) {
         die('0');
     }
Example #3
0
/**
 * @since 2.7.0
 * @deprecated 3.3
 * @deprecated Use nxt_editor()
 * @see nxt_editor()
 */
function nxt_tiny_mce($teeny = false, $settings = false)
{
    _deprecated_function(__FUNCTION__, '3.3', 'nxt_editor()');
    static $num = 1;
    if (!class_exists('_nxt_Editors')) {
        require_once ABSPATH . nxtINC . '/class-nxt-editor.php';
    }
    $editor_id = 'content' . $num++;
    $set = array('teeny' => $teeny, 'tinymce' => $settings ? $settings : true, 'quicktags' => false);
    $set = _nxt_Editors::parse_settings($editor_id, $set);
    _nxt_Editors::editor_settings($editor_id, $set);
}
Example #4
0
/**
 * Renders an editor.
 *
 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
 * _nxt_Editors should not be used directly. See http://core.trac.nxtclass.org/ticket/17144.
 *
 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
 * running nxt_editor() inside of a metabox is not a good idea unless only Quicktags is used.
 * On the post edit screen several actions can be used to include additional editors
 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
 * See http://core.trac.nxtclass.org/ticket/19173 for more information.
 *
 * @see nxt-includes/class-nxt-editor.php
 * @since 3.3
 *
 * @param string $content Initial content for the editor.
 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
 * @param array $settings See _nxt_Editors::editor().
 */
function nxt_editor($content, $editor_id, $settings = array())
{
    if (!class_exists('_nxt_Editors')) {
        require ABSPATH . nxtINC . '/class-nxt-editor.php';
    }
    _nxt_Editors::editor($content, $editor_id, $settings);
}