_WP_Editors

Facilitates adding of the WordPress editor as used on the Write and Edit screens.

Defined (1)

The class is defined in the following location(s).

/wp-includes/class-wp-editor.php  
  1. final class _WP_Editors { 
  2. public static $mce_locale; 
  3.  
  4. private static $mce_settings = array(); 
  5. private static $qt_settings = array(); 
  6. private static $plugins = array(); 
  7. private static $qt_buttons = array(); 
  8. private static $ext_plugins; 
  9. private static $baseurl; 
  10. private static $first_init; 
  11. private static $this_tinymce = false; 
  12. private static $this_quicktags = false; 
  13. private static $has_tinymce = false; 
  14. private static $has_quicktags = false; 
  15. private static $has_medialib = false; 
  16. private static $editor_buttons_css = true; 
  17. private static $drag_drop_upload = false; 
  18. private static $old_dfw_compat = false; 
  19. private static $translation; 
  20.  
  21. private function __construct() {} 
  22.  
  23. /** 
  24. * Parse default arguments for the editor instance. 
  25. * @static 
  26. * @param string $editor_id ID for the current editor instance. 
  27. * @param array $settings { 
  28. * Array of editor arguments. 
  29. * @type bool $wpautop Whether to use wpautop(). Default true. 
  30. * @type bool $media_buttons Whether to show the Add Media/other media buttons. 
  31. * @type string $default_editor When both TinyMCE and Quicktags are used, set which 
  32. * editor is shown on page load. Default empty. 
  33. * @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false. 
  34. * Requires the media modal. 
  35. * @type string $textarea_name Give the textarea a unique name here. Square brackets 
  36. * can be used here. Default $editor_id. 
  37. * @type int $textarea_rows Number rows in the editor textarea. Default 20. 
  38. * @type string|int $tabindex Tabindex value to use. Default empty. 
  39. * @type string $tabfocus_elements The previous and next element ID to move the focus to 
  40. * when pressing the Tab key in TinyMCE. Default ':prev, :next'. 
  41. * @type string $editor_css Intended for extra styles for both Visual and Text editors. 
  42. * Should include `<style>` tags, and can use "scoped". Default empty. 
  43. * @type string $editor_class Extra classes to add to the editor textarea element. Default empty. 
  44. * @type bool $teeny Whether to output the minimal editor config. Examples include 
  45. * Press This and the Comment editor. Default false. 
  46. * @type bool $dfw Deprecated in 4.1. Since 4.3 used only to enqueue wp-fullscreen-stub.js 
  47. * for backward compatibility. 
  48. * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to 
  49. * TinyMCE using an array. Default true. 
  50. * @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to 
  51. * Quicktags using an array. Default true. 
  52. * } 
  53. * @return array Parsed arguments array. 
  54. */ 
  55. public static function parse_settings( $editor_id, $settings ) { 
  56.  
  57. /** 
  58. * Filters the wp_editor() settings. 
  59. * @since 4.0.0 
  60. * @see _WP_Editors()::parse_settings() 
  61. * @param array $settings Array of editor arguments. 
  62. * @param string $editor_id ID for the current editor instance. 
  63. */ 
  64. $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); 
  65.  
  66. $set = wp_parse_args( $settings, array( 
  67. 'wpautop' => true,  
  68. 'media_buttons' => true,  
  69. 'default_editor' => '',  
  70. 'drag_drop_upload' => false,  
  71. 'textarea_name' => $editor_id,  
  72. 'textarea_rows' => 20,  
  73. 'tabindex' => '',  
  74. 'tabfocus_elements' => ':prev, :next',  
  75. 'editor_css' => '',  
  76. 'editor_class' => '',  
  77. 'teeny' => false,  
  78. 'dfw' => false,  
  79. '_content_editor_dfw' => false,  
  80. 'tinymce' => true,  
  81. 'quicktags' => true 
  82. ) ); 
  83.  
  84. self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); 
  85.  
  86. if ( self::$this_tinymce ) { 
  87. if ( false !== strpos( $editor_id, '[' ) ) { 
  88. self::$this_tinymce = false; 
  89. _deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' ); 
  90.  
  91. self::$this_quicktags = (bool) $set['quicktags']; 
  92.  
  93. if ( self::$this_tinymce ) 
  94. self::$has_tinymce = true; 
  95.  
  96. if ( self::$this_quicktags ) 
  97. self::$has_quicktags = true; 
  98.  
  99. if ( $set['dfw'] ) { 
  100. self::$old_dfw_compat = true; 
  101.  
  102. if ( empty( $set['editor_height'] ) ) 
  103. return $set; 
  104.  
  105. if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { 
  106. // A cookie (set when a user resizes the editor) overrides the height. 
  107. $cookie = (int) get_user_setting( 'ed_size' ); 
  108.  
  109. if ( $cookie ) 
  110. $set['editor_height'] = $cookie; 
  111.  
  112. if ( $set['editor_height'] < 50 ) 
  113. $set['editor_height'] = 50; 
  114. elseif ( $set['editor_height'] > 5000 ) 
  115. $set['editor_height'] = 5000; 
  116.  
  117. return $set; 
  118.  
  119. /** 
  120. * Outputs the HTML for a single instance of the editor. 
  121. * @static 
  122. * @param string $content The initial content of the editor. 
  123. * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). 
  124. * @param array $settings See the _parse_settings() method for description. 
  125. */ 
  126. public static function editor( $content, $editor_id, $settings = array() ) { 
  127. $set = self::parse_settings( $editor_id, $settings ); 
  128. $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; 
  129. $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; 
  130. $default_editor = 'html'; 
  131. $buttons = $autocomplete = ''; 
  132. $editor_id_attr = esc_attr( $editor_id ); 
  133.  
  134. if ( $set['drag_drop_upload'] ) { 
  135. self::$drag_drop_upload = true; 
  136.  
  137. if ( ! empty( $set['editor_height'] ) ) { 
  138. $height = ' style="height: ' . (int) $set['editor_height'] . 'px"'; 
  139. } else { 
  140. $height = ' rows="' . (int) $set['textarea_rows'] . '"'; 
  141.  
  142. if ( ! current_user_can( 'upload_files' ) ) { 
  143. $set['media_buttons'] = false; 
  144.  
  145. if ( self::$this_tinymce ) { 
  146. $autocomplete = ' autocomplete="off"'; 
  147.  
  148. if ( self::$this_quicktags ) { 
  149. $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor(); 
  150. // 'html' is used for the "Text" editor tab. 
  151. if ( 'html' !== $default_editor ) { 
  152. $default_editor = 'tinymce'; 
  153.  
  154. $buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce" class="wp-switch-editor switch-tmce"' . 
  155. ' data-wp-editor-id="' . $editor_id_attr . '">' . __('Visual') . "</button>\n"; 
  156. $buttons .= '<button type="button" id="' . $editor_id_attr . '-html" class="wp-switch-editor switch-html"' . 
  157. ' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) . "</button>\n"; 
  158. } else { 
  159. $default_editor = 'tinymce'; 
  160.  
  161. $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; 
  162. $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; 
  163.  
  164. if ( $set['_content_editor_dfw'] ) { 
  165. $wrap_class .= ' has-dfw'; 
  166.  
  167. echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">'; 
  168.  
  169. if ( self::$editor_buttons_css ) { 
  170. wp_print_styles( 'editor-buttons' ); 
  171. self::$editor_buttons_css = false; 
  172.  
  173. if ( ! empty( $set['editor_css'] ) ) { 
  174. echo $set['editor_css'] . "\n"; 
  175.  
  176. if ( ! empty( $buttons ) || $set['media_buttons'] ) { 
  177. echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; 
  178.  
  179. if ( $set['media_buttons'] ) { 
  180. self::$has_medialib = true; 
  181.  
  182. if ( ! function_exists( 'media_buttons' ) ) 
  183. include( ABSPATH . 'wp-admin/includes/media.php' ); 
  184.  
  185. echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; 
  186.  
  187. /** 
  188. * Fires after the default media button(s) are displayed. 
  189. * @since 2.5.0 
  190. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  191. */ 
  192. do_action( 'media_buttons', $editor_id ); 
  193. echo "</div>\n"; 
  194.  
  195. echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n"; 
  196. echo "</div>\n"; 
  197.  
  198. $quicktags_toolbar = ''; 
  199.  
  200. if ( self::$this_quicktags ) { 
  201. if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && $GLOBALS['current_screen']->base === 'post' ) { 
  202. $toolbar_id = 'ed_toolbar'; 
  203. } else { 
  204. $toolbar_id = 'qt_' . $editor_id_attr . '_toolbar'; 
  205.  
  206. $quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar"></div>'; 
  207.  
  208. /** 
  209. * Filters the HTML markup output that displays the editor. 
  210. * @since 2.1.0 
  211. * @param string $output Editor's HTML markup. 
  212. */ 
  213. $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . 
  214. $quicktags_toolbar . 
  215. '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . 
  216. 'id="' . $editor_id_attr . '">%s</textarea></div>' ); 
  217.  
  218. // Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat). 
  219. if ( self::$this_tinymce ) { 
  220. add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); 
  221.  
  222. /** 
  223. * Filters the default editor content. 
  224. * @since 2.1.0 
  225. * @param string $content Default editor content. 
  226. * @param string $default_editor The default editor for the current user. 
  227. * Either 'html' or 'tinymce'. 
  228. */ 
  229. $content = apply_filters( 'the_editor_content', $content, $default_editor ); 
  230.  
  231. // Remove the filter as the next editor on the same page may not need it. 
  232. if ( self::$this_tinymce ) { 
  233. remove_filter( 'the_editor_content', 'format_for_editor' ); 
  234.  
  235. // Back-compat for the `htmledit_pre` and `richedit_pre` filters 
  236. if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) { 
  237. // TODO: needs _deprecated_filter(), use _deprecated_function() as substitute for now 
  238. _deprecated_function( 'add_filter( htmledit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); 
  239. $content = apply_filters( 'htmledit_pre', $content ); 
  240. } elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) { 
  241. _deprecated_function( 'add_filter( richedit_pre )', '4.3.0', 'add_filter( format_for_editor )' ); 
  242. $content = apply_filters( 'richedit_pre', $content ); 
  243.  
  244. if ( false !== stripos( $content, 'textarea' ) ) { 
  245. $content = preg_replace( '%</textarea%i', '</textarea', $content ); 
  246.  
  247. printf( $the_editor, $content ); 
  248. echo "\n</div>\n\n"; 
  249.  
  250. self::editor_settings( $editor_id, $set ); 
  251.  
  252. /** 
  253. * @static 
  254. * @global string $tinymce_version 
  255. * @param string $editor_id 
  256. * @param array $set 
  257. */ 
  258. public static function editor_settings($editor_id, $set) { 
  259. global $tinymce_version; 
  260.  
  261. if ( empty(self::$first_init) ) { 
  262. if ( is_admin() ) { 
  263. add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); 
  264. add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); 
  265. } else { 
  266. add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); 
  267. add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); 
  268.  
  269. if ( self::$this_quicktags ) { 
  270.  
  271. $qtInit = array( 
  272. 'id' => $editor_id,  
  273. 'buttons' => '' 
  274. ); 
  275.  
  276. if ( is_array($set['quicktags']) ) 
  277. $qtInit = array_merge($qtInit, $set['quicktags']); 
  278.  
  279. if ( empty($qtInit['buttons']) ) 
  280. $qtInit['buttons'] = 'strong, em, link, block, del, ins, img, ul, ol, li, code, more, close'; 
  281.  
  282. if ( $set['_content_editor_dfw'] ) { 
  283. $qtInit['buttons'] .= ', dfw'; 
  284.  
  285. /** 
  286. * Filters the Quicktags settings. 
  287. * @since 3.3.0 
  288. * @param array $qtInit Quicktags settings. 
  289. * @param string $editor_id The unique editor ID, e.g. 'content'. 
  290. */ 
  291. $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); 
  292.  
  293. self::$qt_settings[$editor_id] = $qtInit; 
  294.  
  295. self::$qt_buttons = array_merge( self::$qt_buttons, explode(', ', $qtInit['buttons']) ); 
  296.  
  297. if ( self::$this_tinymce ) { 
  298.  
  299. if ( empty( self::$first_init ) ) { 
  300. self::$baseurl = includes_url( 'js/tinymce' ); 
  301.  
  302. $mce_locale = get_user_locale(); 
  303. self::$mce_locale = $mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 
  304.  
  305. /** This filter is documented in wp-admin/includes/media.php */ 
  306. $no_captions = (bool) apply_filters( 'disable_captions', '' ); 
  307. $ext_plugins = ''; 
  308. $shortcut_labels = array(); 
  309.  
  310. foreach ( self::get_translation() as $name => $value ) { 
  311. if ( is_array( $value ) ) { 
  312. $shortcut_labels[$name] = $value[1]; 
  313.  
  314. if ( $set['teeny'] ) { 
  315.  
  316. /** 
  317. * Filters the list of teenyMCE plugins. 
  318. * @since 2.7.0 
  319. * @param array $plugins An array of teenyMCE plugins. 
  320. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  321. */ 
  322. self::$plugins = $plugins = apply_filters( 'teeny_mce_plugins', array( 'colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink' ), $editor_id ); 
  323. } else { 
  324.  
  325. /** 
  326. * Filters the list of TinyMCE external plugins. 
  327. * The filter takes an associative array of external plugins for 
  328. * TinyMCE in the form 'plugin_name' => 'url'. 
  329. * The url should be absolute, and should include the js filename 
  330. * to be loaded. For example: 
  331. * 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'. 
  332. * If the external plugin adds a button, it should be added with 
  333. * one of the 'mce_buttons' filters. 
  334. * @since 2.5.0 
  335. * @param array $external_plugins An array of external TinyMCE plugins. 
  336. */ 
  337. $mce_external_plugins = apply_filters( 'mce_external_plugins', array() ); 
  338.  
  339. $plugins = array( 
  340. 'charmap',  
  341. 'colorpicker',  
  342. 'hr',  
  343. 'lists',  
  344. 'media',  
  345. 'paste',  
  346. 'tabfocus',  
  347. 'textcolor',  
  348. 'fullscreen',  
  349. 'wordpress',  
  350. 'wpautoresize',  
  351. 'wpeditimage',  
  352. 'wpemoji',  
  353. 'wpgallery',  
  354. 'wplink',  
  355. 'wpdialogs',  
  356. 'wptextpattern',  
  357. 'wpview',  
  358. 'wpembed',  
  359. ); 
  360.  
  361. if ( ! self::$has_medialib ) { 
  362. $plugins[] = 'image'; 
  363.  
  364. /** 
  365. * Filters the list of default TinyMCE plugins. 
  366. * The filter specifies which of the default plugins included 
  367. * in WordPress should be added to the TinyMCE instance. 
  368. * @since 3.3.0 
  369. * @param array $plugins An array of default TinyMCE plugins. 
  370. */ 
  371. $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) ); 
  372.  
  373. if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { 
  374. // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. 
  375. // It can be added with 'mce_external_plugins'. 
  376. unset( $plugins[$key] ); 
  377.  
  378. if ( ! empty( $mce_external_plugins ) ) { 
  379.  
  380. /** 
  381. * Filters the translations loaded for external TinyMCE 3.x plugins. 
  382. * The filter takes an associative array ('plugin_name' => 'path') 
  383. * where 'path' is the include path to the file. 
  384. * The language file should follow the same format as wp_mce_translation(),  
  385. * and should define a variable ($strings) that holds all translated strings. 
  386. * @since 2.5.0 
  387. * @param array $translations Translations for external TinyMCE plugins. 
  388. */ 
  389. $mce_external_languages = apply_filters( 'mce_external_languages', array() ); 
  390.  
  391. $loaded_langs = array(); 
  392. $strings = ''; 
  393.  
  394. if ( ! empty( $mce_external_languages ) ) { 
  395. foreach ( $mce_external_languages as $name => $path ) { 
  396. if ( @is_file( $path ) && @is_readable( $path ) ) { 
  397. include_once( $path ); 
  398. $ext_plugins .= $strings . "\n"; 
  399. $loaded_langs[] = $name; 
  400.  
  401. foreach ( $mce_external_plugins as $name => $url ) { 
  402. if ( in_array( $name, $plugins, true ) ) { 
  403. unset( $mce_external_plugins[ $name ] ); 
  404. continue; 
  405.  
  406. $url = set_url_scheme( $url ); 
  407. $mce_external_plugins[ $name ] = $url; 
  408. $plugurl = dirname( $url ); 
  409. $strings = ''; 
  410.  
  411. // Try to load langs/[locale].js and langs/[locale]_dlg.js 
  412. if ( ! in_array( $name, $loaded_langs, true ) ) { 
  413. $path = str_replace( content_url(), '', $plugurl ); 
  414. $path = WP_CONTENT_DIR . $path . '/langs/'; 
  415.  
  416. if ( function_exists('realpath') ) 
  417. $path = trailingslashit( realpath($path) ); 
  418.  
  419. if ( @is_file( $path . $mce_locale . '.js' ) ) 
  420. $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; 
  421.  
  422. if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) 
  423. $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; 
  424.  
  425. if ( 'en' != $mce_locale && empty( $strings ) ) { 
  426. if ( @is_file( $path . 'en.js' ) ) { 
  427. $str1 = @file_get_contents( $path . 'en.js' ); 
  428. $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; 
  429.  
  430. if ( @is_file( $path . 'en_dlg.js' ) ) { 
  431. $str2 = @file_get_contents( $path . 'en_dlg.js' ); 
  432. $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; 
  433.  
  434. if ( ! empty( $strings ) ) 
  435. $ext_plugins .= "\n" . $strings . "\n"; 
  436.  
  437. $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; 
  438. $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; 
  439.  
  440. self::$plugins = $plugins; 
  441. self::$ext_plugins = $ext_plugins; 
  442.  
  443. self::$first_init = array( 
  444. 'theme' => 'modern',  
  445. 'skin' => 'lightgray',  
  446. 'language' => self::$mce_locale,  
  447. 'formats' => '{' . 
  448. 'alignleft: [' . 
  449. '{selector: "p, h1, h2, h3, h4, h5, h6, td, th, div, ul, ol, li", styles: {textAlign:"left"}}, ' . 
  450. '{selector: "img, table, dl.wp-caption", classes: "alignleft"}' . 
  451. '], ' . 
  452. 'aligncenter: [' . 
  453. '{selector: "p, h1, h2, h3, h4, h5, h6, td, th, div, ul, ol, li", styles: {textAlign:"center"}}, ' . 
  454. '{selector: "img, table, dl.wp-caption", classes: "aligncenter"}' . 
  455. '], ' . 
  456. 'alignright: [' . 
  457. '{selector: "p, h1, h2, h3, h4, h5, h6, td, th, div, ul, ol, li", styles: {textAlign:"right"}}, ' . 
  458. '{selector: "img, table, dl.wp-caption", classes: "alignright"}' . 
  459. '], ' . 
  460. 'strikethrough: {inline: "del"}' . 
  461. '}',  
  462. 'relative_urls' => false,  
  463. 'remove_script_host' => false,  
  464. 'convert_urls' => false,  
  465. 'browser_spellcheck' => true,  
  466. 'fix_list_elements' => true,  
  467. 'entities' => '38, amp, 60, lt, 62, gt',  
  468. 'entity_encoding' => 'raw',  
  469. 'keep_styles' => false,  
  470. 'cache_suffix' => 'wp-mce-' . $tinymce_version,  
  471.  
  472. // Limit the preview styles in the menu/toolbar 
  473. 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',  
  474.  
  475. 'end_container_on_empty_block' => true,  
  476. 'wpeditimage_disable_captions' => $no_captions,  
  477. 'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ),  
  478. 'plugins' => implode( ', ', $plugins ),  
  479. 'wp_lang_attr' => get_bloginfo( 'language' ),  
  480. 'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ),  
  481. ); 
  482.  
  483. if ( ! empty( $mce_external_plugins ) ) { 
  484. self::$first_init['external_plugins'] = wp_json_encode( $mce_external_plugins ); 
  485.  
  486. $suffix = SCRIPT_DEBUG ? '' : '.min'; 
  487. $version = 'ver=' . get_bloginfo( 'version' ); 
  488. $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); 
  489.  
  490. // WordPress default stylesheet and dashicons 
  491. $mce_css = array( 
  492. $dashicons,  
  493. self::$baseurl . '/skins/wordpress/wp-content.css?' . $version 
  494. ); 
  495.  
  496. $editor_styles = get_editor_stylesheets(); 
  497. if ( ! empty( $editor_styles ) ) { 
  498. foreach ( $editor_styles as $style ) { 
  499. $mce_css[] = $style; 
  500.  
  501. /** 
  502. * Filters the comma-delimited list of stylesheets to load in TinyMCE. 
  503. * @since 2.1.0 
  504. * @param string $stylesheets Comma-delimited list of stylesheets. 
  505. */ 
  506. $mce_css = trim( apply_filters( 'mce_css', implode( ', ', $mce_css ) ), ' , ' ); 
  507.  
  508. if ( ! empty($mce_css) ) 
  509. self::$first_init['content_css'] = $mce_css; 
  510.  
  511. if ( $set['teeny'] ) { 
  512.  
  513. /** 
  514. * Filters the list of teenyMCE buttons (Text tab). 
  515. * @since 2.7.0 
  516. * @param array $buttons An array of teenyMCE buttons. 
  517. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  518. */ 
  519. $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ); 
  520. $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); 
  521. } else { 
  522. $mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker' ); 
  523.  
  524. if ( ! wp_is_mobile() ) { 
  525. if ( $set['_content_editor_dfw'] ) { 
  526. $mce_buttons[] = 'dfw'; 
  527. } else { 
  528. $mce_buttons[] = 'fullscreen'; 
  529.  
  530. $mce_buttons[] = 'wp_adv'; 
  531.  
  532. /** 
  533. * Filters the first-row list of TinyMCE buttons (Visual tab). 
  534. * @since 2.0.0 
  535. * @param array $buttons First-row list of buttons. 
  536. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  537. */ 
  538. $mce_buttons = apply_filters( 'mce_buttons', $mce_buttons, $editor_id ); 
  539.  
  540. $mce_buttons_2 = array( 'strikethrough', 'hr', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo' ); 
  541.  
  542. if ( ! wp_is_mobile() ) { 
  543. $mce_buttons_2[] = 'wp_help'; 
  544.  
  545. /** 
  546. * Filters the second-row list of TinyMCE buttons (Visual tab). 
  547. * @since 2.0.0 
  548. * @param array $buttons Second-row list of buttons. 
  549. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  550. */ 
  551. $mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id ); 
  552.  
  553. /** 
  554. * Filters the third-row list of TinyMCE buttons (Visual tab). 
  555. * @since 2.0.0 
  556. * @param array $buttons Third-row list of buttons. 
  557. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  558. */ 
  559. $mce_buttons_3 = apply_filters( 'mce_buttons_3', array(), $editor_id ); 
  560.  
  561. /** 
  562. * Filters the fourth-row list of TinyMCE buttons (Visual tab). 
  563. * @since 2.5.0 
  564. * @param array $buttons Fourth-row list of buttons. 
  565. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  566. */ 
  567. $mce_buttons_4 = apply_filters( 'mce_buttons_4', array(), $editor_id ); 
  568.  
  569. $body_class = $editor_id; 
  570.  
  571. if ( $post = get_post() ) { 
  572. $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); 
  573.  
  574. if ( post_type_supports( $post->post_type, 'post-formats' ) ) { 
  575. $post_format = get_post_format( $post ); 
  576. if ( $post_format && ! is_wp_error( $post_format ) ) 
  577. $body_class .= ' post-format-' . sanitize_html_class( $post_format ); 
  578. else 
  579. $body_class .= ' post-format-standard'; 
  580.  
  581. $page_template = get_page_template_slug( $post ); 
  582.  
  583. if ( $page_template !== false ) { 
  584. $page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) ); 
  585. $body_class .= ' page-template-' . sanitize_html_class( $page_template ); 
  586.  
  587. $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); 
  588.  
  589. if ( !empty($set['tinymce']['body_class']) ) { 
  590. $body_class .= ' ' . $set['tinymce']['body_class']; 
  591. unset($set['tinymce']['body_class']); 
  592.  
  593. $mceInit = array ( 
  594. 'selector' => "#$editor_id",  
  595. 'resize' => 'vertical',  
  596. 'menubar' => false,  
  597. 'wpautop' => (bool) $set['wpautop'],  
  598. 'indent' => ! $set['wpautop'],  
  599. 'toolbar1' => implode($mce_buttons, ', '),  
  600. 'toolbar2' => implode($mce_buttons_2, ', '),  
  601. 'toolbar3' => implode($mce_buttons_3, ', '),  
  602. 'toolbar4' => implode($mce_buttons_4, ', '),  
  603. 'tabfocus_elements' => $set['tabfocus_elements'],  
  604. 'body_class' => $body_class 
  605. ); 
  606.  
  607. // Merge with the first part of the init array 
  608. $mceInit = array_merge( self::$first_init, $mceInit ); 
  609.  
  610. if ( is_array( $set['tinymce'] ) ) 
  611. $mceInit = array_merge( $mceInit, $set['tinymce'] ); 
  612.  
  613. /** 
  614. * For people who really REALLY know what they're doing with TinyMCE 
  615. * You can modify $mceInit to add, remove, change elements of the config 
  616. * before tinyMCE.init. Setting "valid_elements", "invalid_elements" 
  617. * and "extended_valid_elements" can be done through this filter. Best 
  618. * is to use the default cleanup by not specifying valid_elements,  
  619. * as TinyMCE checks against the full set of HTML 5.0 elements and attributes. 
  620. */ 
  621. if ( $set['teeny'] ) { 
  622.  
  623. /** 
  624. * Filters the teenyMCE config before init. 
  625. * @since 2.7.0 
  626. * @param array $mceInit An array with teenyMCE config. 
  627. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  628. */ 
  629. $mceInit = apply_filters( 'teeny_mce_before_init', $mceInit, $editor_id ); 
  630. } else { 
  631.  
  632. /** 
  633. * Filters the TinyMCE config before init. 
  634. * @since 2.5.0 
  635. * @param array $mceInit An array with TinyMCE config. 
  636. * @param string $editor_id Unique editor identifier, e.g. 'content'. 
  637. */ 
  638. $mceInit = apply_filters( 'tiny_mce_before_init', $mceInit, $editor_id ); 
  639.  
  640. if ( empty( $mceInit['toolbar3'] ) && ! empty( $mceInit['toolbar4'] ) ) { 
  641. $mceInit['toolbar3'] = $mceInit['toolbar4']; 
  642. $mceInit['toolbar4'] = ''; 
  643.  
  644. self::$mce_settings[$editor_id] = $mceInit; 
  645. } // end if self::$this_tinymce 
  646.  
  647. /** 
  648. * @static 
  649. * @param array $init 
  650. * @return string 
  651. */ 
  652. private static function _parse_init($init) { 
  653. $options = ''; 
  654.  
  655. foreach ( $init as $k => $v ) { 
  656. if ( is_bool($v) ) { 
  657. $val = $v ? 'true' : 'false'; 
  658. $options .= $k . ':' . $val . ', '; 
  659. continue; 
  660. } elseif ( !empty($v) && is_string($v) && ( ('{' == $v{0} && '}' == $v{strlen($v) - 1}) || ('[' == $v{0} && ']' == $v{strlen($v) - 1}) || preg_match('/^\(?function ?\(/', $v) ) ) { 
  661. $options .= $k . ':' . $v . ', '; 
  662. continue; 
  663. $options .= $k . ':"' . $v . '", '; 
  664.  
  665. return '{' . trim( $options, ' , ' ) . '}'; 
  666.  
  667. /** 
  668. * @static 
  669. */ 
  670. public static function enqueue_scripts() { 
  671. if ( self::$has_tinymce ) 
  672. wp_enqueue_script('editor'); 
  673.  
  674. if ( self::$has_quicktags ) { 
  675. wp_enqueue_script( 'quicktags' ); 
  676. wp_enqueue_style( 'buttons' ); 
  677.  
  678. if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { 
  679. wp_enqueue_script('wplink'); 
  680. wp_enqueue_script( 'jquery-ui-autocomplete' ); 
  681.  
  682. if ( self::$old_dfw_compat ) { 
  683. wp_enqueue_script('wp-fullscreen-stub'); 
  684.  
  685. if ( self::$has_medialib ) { 
  686. add_thickbox(); 
  687. wp_enqueue_script( 'media-upload' ); 
  688. wp_enqueue_script( 'wp-embed' ); 
  689.  
  690. /** 
  691. * Fires when scripts and styles are enqueued for the editor. 
  692. * @since 3.9.0 
  693. * @param array $to_load An array containing boolean values whether TinyMCE 
  694. * and Quicktags are being loaded. 
  695. */ 
  696. do_action( 'wp_enqueue_editor', array( 
  697. 'tinymce' => self::$has_tinymce,  
  698. 'quicktags' => self::$has_quicktags,  
  699. ) ); 
  700.  
  701. private static function get_translation() { 
  702. if ( empty( self::$translation ) ) { 
  703. self::$translation = array( 
  704. // Default TinyMCE strings 
  705. 'New document' => __( 'New document' ),  
  706. 'Formats' => _x( 'Formats', 'TinyMCE' ),  
  707.  
  708. 'Headings' => _x( 'Headings', 'TinyMCE' ),  
  709. 'Heading 1' => array( __( 'Heading 1' ), 'access1' ),  
  710. 'Heading 2' => array( __( 'Heading 2' ), 'access2' ),  
  711. 'Heading 3' => array( __( 'Heading 3' ), 'access3' ),  
  712. 'Heading 4' => array( __( 'Heading 4' ), 'access4' ),  
  713. 'Heading 5' => array( __( 'Heading 5' ), 'access5' ),  
  714. 'Heading 6' => array( __( 'Heading 6' ), 'access6' ),  
  715.  
  716. /** translators: block tags */ 
  717. 'Blocks' => _x( 'Blocks', 'TinyMCE' ),  
  718. 'Paragraph' => array( __( 'Paragraph' ), 'access7' ),  
  719. 'Blockquote' => array( __( 'Blockquote' ), 'accessQ' ),  
  720. 'Div' => _x( 'Div', 'HTML tag' ),  
  721. 'Pre' => _x( 'Pre', 'HTML tag' ),  
  722. 'Preformatted' => _x( 'Preformatted', 'HTML tag' ),  
  723. 'Address' => _x( 'Address', 'HTML tag' ),  
  724.  
  725. 'Inline' => _x( 'Inline', 'HTML elements' ),  
  726. 'Underline' => array( __( 'Underline' ), 'metaU' ),  
  727. 'Strikethrough' => array( __( 'Strikethrough' ), 'accessD' ),  
  728. 'Subscript' => __( 'Subscript' ),  
  729. 'Superscript' => __( 'Superscript' ),  
  730. 'Clear formatting' => __( 'Clear formatting' ),  
  731. 'Bold' => array( __( 'Bold' ), 'metaB' ),  
  732. 'Italic' => array( __( 'Italic' ), 'metaI' ),  
  733. 'Code' => array( __( 'Code' ), 'accessX' ),  
  734. 'Source code' => __( 'Source code' ),  
  735. 'Font Family' => __( 'Font Family' ),  
  736. 'Font Sizes' => __( 'Font Sizes' ),  
  737.  
  738. 'Align center' => array( __( 'Align center' ), 'accessC' ),  
  739. 'Align right' => array( __( 'Align right' ), 'accessR' ),  
  740. 'Align left' => array( __( 'Align left' ), 'accessL' ),  
  741. 'Justify' => array( __( 'Justify' ), 'accessJ' ),  
  742. 'Increase indent' => __( 'Increase indent' ),  
  743. 'Decrease indent' => __( 'Decrease indent' ),  
  744.  
  745. 'Cut' => array( __( 'Cut' ), 'metaX' ),  
  746. 'Copy' => array( __( 'Copy' ), 'metaC' ),  
  747. 'Paste' => array( __( 'Paste' ), 'metaV' ),  
  748. 'Select all' => array( __( 'Select all' ), 'metaA' ),  
  749. 'Undo' => array( __( 'Undo' ), 'metaZ' ),  
  750. 'Redo' => array( __( 'Redo' ), 'metaY' ),  
  751.  
  752. 'Ok' => __( 'OK' ),  
  753. 'Cancel' => __( 'Cancel' ),  
  754. 'Close' => __( 'Close' ),  
  755. 'Visual aids' => __( 'Visual aids' ),  
  756.  
  757. 'Bullet list' => array( __( 'Bulleted list' ), 'accessU' ),  
  758. 'Numbered list' => array( __( 'Numbered list' ), 'accessO' ),  
  759. 'Square' => _x( 'Square', 'list style' ),  
  760. 'Default' => _x( 'Default', 'list style' ),  
  761. 'Circle' => _x( 'Circle', 'list style' ),  
  762. 'Disc' => _x('Disc', 'list style' ),  
  763. 'Lower Greek' => _x( 'Lower Greek', 'list style' ),  
  764. 'Lower Alpha' => _x( 'Lower Alpha', 'list style' ),  
  765. 'Upper Alpha' => _x( 'Upper Alpha', 'list style' ),  
  766. 'Upper Roman' => _x( 'Upper Roman', 'list style' ),  
  767. 'Lower Roman' => _x( 'Lower Roman', 'list style' ),  
  768.  
  769. // Anchor plugin 
  770. 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ),  
  771. 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ),  
  772. 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ),  
  773.  
  774. // Fullpage plugin 
  775. 'Document properties' => __( 'Document properties' ),  
  776. 'Robots' => __( 'Robots' ),  
  777. 'Title' => __( 'Title' ),  
  778. 'Keywords' => __( 'Keywords' ),  
  779. 'Encoding' => __( 'Encoding' ),  
  780. 'Description' => __( 'Description' ),  
  781. 'Author' => __( 'Author' ),  
  782.  
  783. // Media, image plugins 
  784. 'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ),  
  785. 'General' => __( 'General' ),  
  786. 'Advanced' => __( 'Advanced' ),  
  787. 'Source' => __( 'Source' ),  
  788. 'Border' => __( 'Border' ),  
  789. 'Constrain proportions' => __( 'Constrain proportions' ),  
  790. 'Vertical space' => __( 'Vertical space' ),  
  791. 'Image description' => __( 'Image description' ),  
  792. 'Style' => __( 'Style' ),  
  793. 'Dimensions' => __( 'Dimensions' ),  
  794. 'Insert image' => __( 'Insert image' ),  
  795. 'Insert date/time' => __( 'Insert date/time' ),  
  796. 'Insert/edit video' => __( 'Insert/edit video' ),  
  797. 'Poster' => __( 'Poster' ),  
  798. 'Alternative source' => __( 'Alternative source' ),  
  799. 'Paste your embed code below:' => __( 'Paste your embed code below:' ),  
  800. 'Insert video' => __( 'Insert video' ),  
  801. 'Embed' => __( 'Embed' ),  
  802.  
  803. // Each of these have a corresponding plugin 
  804. 'Special character' => __( 'Special character' ),  
  805. 'Right to left' => _x( 'Right to left', 'editor button' ),  
  806. 'Left to right' => _x( 'Left to right', 'editor button' ),  
  807. 'Emoticons' => __( 'Emoticons' ),  
  808. 'Nonbreaking space' => __( 'Nonbreaking space' ),  
  809. 'Page break' => __( 'Page break' ),  
  810. 'Paste as text' => __( 'Paste as text' ),  
  811. 'Preview' => __( 'Preview' ),  
  812. 'Print' => __( 'Print' ),  
  813. 'Save' => __( 'Save' ),  
  814. 'Fullscreen' => __( 'Fullscreen' ),  
  815. 'Horizontal line' => __( 'Horizontal line' ),  
  816. 'Horizontal space' => __( 'Horizontal space' ),  
  817. 'Restore last draft' => __( 'Restore last draft' ),  
  818. 'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ),  
  819. 'Remove link' => array( __( 'Remove link' ), 'accessS' ),  
  820.  
  821. 'Color' => __( 'Color' ),  
  822. 'Custom color' => __( 'Custom color' ),  
  823. 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis 
  824. 'No color' => __( 'No color' ),  
  825.  
  826. // Spelling, search/replace plugins 
  827. 'Could not find the specified string.' => __( 'Could not find the specified string.' ),  
  828. 'Replace' => _x( 'Replace', 'find/replace' ),  
  829. 'Next' => _x( 'Next', 'find/replace' ),  
  830. /** translators: previous */ 
  831. 'Prev' => _x( 'Prev', 'find/replace' ),  
  832. 'Whole words' => _x( 'Whole words', 'find/replace' ),  
  833. 'Find and replace' => __( 'Find and replace' ),  
  834. 'Replace with' => _x('Replace with', 'find/replace' ),  
  835. 'Find' => _x( 'Find', 'find/replace' ),  
  836. 'Replace all' => _x( 'Replace all', 'find/replace' ),  
  837. 'Match case' => __( 'Match case' ),  
  838. 'Spellcheck' => __( 'Check Spelling' ),  
  839. 'Finish' => _x( 'Finish', 'spellcheck' ),  
  840. 'Ignore all' => _x( 'Ignore all', 'spellcheck' ),  
  841. 'Ignore' => _x( 'Ignore', 'spellcheck' ),  
  842. 'Add to Dictionary' => __( 'Add to Dictionary' ),  
  843.  
  844. // TinyMCE tables 
  845. 'Insert table' => __( 'Insert table' ),  
  846. 'Delete table' => __( 'Delete table' ),  
  847. 'Table properties' => __( 'Table properties' ),  
  848. 'Row properties' => __( 'Table row properties' ),  
  849. 'Cell properties' => __( 'Table cell properties' ),  
  850. 'Border color' => __( 'Border color' ),  
  851.  
  852. 'Row' => __( 'Row' ),  
  853. 'Rows' => __( 'Rows' ),  
  854. 'Column' => _x( 'Column', 'table column' ),  
  855. 'Cols' => _x( 'Cols', 'table columns' ),  
  856. 'Cell' => _x( 'Cell', 'table cell' ),  
  857. 'Header cell' => __( 'Header cell' ),  
  858. 'Header' => _x( 'Header', 'table header' ),  
  859. 'Body' => _x( 'Body', 'table body' ),  
  860. 'Footer' => _x( 'Footer', 'table footer' ),  
  861.  
  862. 'Insert row before' => __( 'Insert row before' ),  
  863. 'Insert row after' => __( 'Insert row after' ),  
  864. 'Insert column before' => __( 'Insert column before' ),  
  865. 'Insert column after' => __( 'Insert column after' ),  
  866. 'Paste row before' => __( 'Paste table row before' ),  
  867. 'Paste row after' => __( 'Paste table row after' ),  
  868. 'Delete row' => __( 'Delete row' ),  
  869. 'Delete column' => __( 'Delete column' ),  
  870. 'Cut row' => __( 'Cut table row' ),  
  871. 'Copy row' => __( 'Copy table row' ),  
  872. 'Merge cells' => __( 'Merge table cells' ),  
  873. 'Split cell' => __( 'Split table cell' ),  
  874.  
  875. 'Height' => __( 'Height' ),  
  876. 'Width' => __( 'Width' ),  
  877. 'Caption' => __( 'Caption' ),  
  878. 'Alignment' => __( 'Alignment' ),  
  879. 'H Align' => _x( 'H Align', 'horizontal table cell alignment' ),  
  880. 'Left' => __( 'Left' ),  
  881. 'Center' => __( 'Center' ),  
  882. 'Right' => __( 'Right' ),  
  883. 'None' => _x( 'None', 'table cell alignment attribute' ),  
  884. 'V Align' => _x( 'V Align', 'vertical table cell alignment' ),  
  885. 'Top' => __( 'Top' ),  
  886. 'Middle' => __( 'Middle' ),  
  887. 'Bottom' => __( 'Bottom' ),  
  888.  
  889. 'Row group' => __( 'Row group' ),  
  890. 'Column group' => __( 'Column group' ),  
  891. 'Row type' => __( 'Row type' ),  
  892. 'Cell type' => __( 'Cell type' ),  
  893. 'Cell padding' => __( 'Cell padding' ),  
  894. 'Cell spacing' => __( 'Cell spacing' ),  
  895. 'Scope' => _x( 'Scope', 'table cell scope attribute' ),  
  896.  
  897. 'Insert template' => _x( 'Insert template', 'TinyMCE' ),  
  898. 'Templates' => _x( 'Templates', 'TinyMCE' ),  
  899.  
  900. 'Background color' => __( 'Background color' ),  
  901. 'Text color' => __( 'Text color' ),  
  902. 'Show blocks' => _x( 'Show blocks', 'editor button' ),  
  903. 'Show invisible characters' => __( 'Show invisible characters' ),  
  904.  
  905. /** translators: word count */ 
  906. 'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ),  
  907. 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . __( 'If you’re looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ),  
  908. 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => __( 'Rich Text Area. Press Alt-Shift-H for help.' ),  
  909. 'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ),  
  910. 'You have unsaved changes are you sure you want to navigate away?' => __( 'The changes you made will be lost if you navigate away from this page.' ),  
  911. 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ),  
  912.  
  913. // TinyMCE menus 
  914. 'Insert' => _x( 'Insert', 'TinyMCE menu' ),  
  915. 'File' => _x( 'File', 'TinyMCE menu' ),  
  916. 'Edit' => _x( 'Edit', 'TinyMCE menu' ),  
  917. 'Tools' => _x( 'Tools', 'TinyMCE menu' ),  
  918. 'View' => _x( 'View', 'TinyMCE menu' ),  
  919. 'Table' => _x( 'Table', 'TinyMCE menu' ),  
  920. 'Format' => _x( 'Format', 'TinyMCE menu' ),  
  921.  
  922. // WordPress strings 
  923. 'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ),  
  924. 'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ),  
  925. 'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ),  
  926. 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) 
  927. 'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ),  
  928. 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar 
  929. 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar 
  930. 'Edit ' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar 
  931. 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog 
  932. 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog 
  933. 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog 
  934.  
  935. // Shortcuts help modal 
  936. 'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ),  
  937. 'Default shortcuts, ' => __( 'Default shortcuts, ' ),  
  938. 'Additional shortcuts, ' => __( 'Additional shortcuts, ' ),  
  939. 'Focus shortcuts:' => __( 'Focus shortcuts:' ),  
  940. 'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ),  
  941. 'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ),  
  942. 'Editor toolbar' => __( 'Editor toolbar' ),  
  943. 'Elements path' => __( 'Elements path' ),  
  944. 'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ),  
  945. 'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ),  
  946. 'Cmd + letter:' => __( 'Cmd + letter:' ),  
  947. 'Ctrl + letter:' => __( 'Ctrl + letter:' ),  
  948. 'Letter' => __( 'Letter' ),  
  949. 'Action' => __( 'Action' ),  
  950. 'Warning: the link has been inserted but may have errors. Please test it.' => __( 'Warning: the link has been inserted but may have errors. Please test it.' ),  
  951. 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' => 
  952. __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ),  
  953. 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' => 
  954. __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ),  
  955. 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => 
  956. __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ),  
  957. 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' => 
  958. __( 'The next group of formatting shortcuts are applied as you type or when you insert them around plain text in the same paragraph. Press Escape or the Undo button to undo.' ),  
  959. ); 
  960.  
  961. /** 
  962. * Link plugin (not included): 
  963. * Insert link 
  964. * Target 
  965. * New window 
  966. * Text to display 
  967. * The URL you entered seems to be an email address. Do you want to add the required mailto: prefix? 
  968. * The URL you entered seems to be an external link. Do you want to add the required http:\/\/ prefix? 
  969. * Url 
  970. */ 
  971.  
  972. return self::$translation; 
  973.  
  974. /** 
  975. * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(). 
  976. * Can be used directly (_WP_Editors::wp_mce_translation()) by passing the same locale as set in the TinyMCE init object. 
  977. * @static 
  978. * @param string $mce_locale The locale used for the editor. 
  979. * @param bool $json_only optional Whether to include the JavaScript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone(). 
  980. * @return string Translation object, JSON encoded. 
  981. */ 
  982. public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { 
  983. if ( ! $mce_locale ) { 
  984. $mce_locale = self::$mce_locale; 
  985.  
  986. $mce_translation = self::get_translation(); 
  987.  
  988. foreach ( $mce_translation as $name => $value ) { 
  989. if ( is_array( $value ) ) { 
  990. $mce_translation[$name] = $value[0]; 
  991.  
  992. /** 
  993. * Filters translated strings prepared for TinyMCE. 
  994. * @since 3.9.0 
  995. * @param array $mce_translation Key/value pairs of strings. 
  996. * @param string $mce_locale Locale. 
  997. */ 
  998. $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); 
  999.  
  1000. foreach ( $mce_translation as $key => $value ) { 
  1001. // Remove strings that are not translated. 
  1002. if ( $key === $value ) { 
  1003. unset( $mce_translation[$key] ); 
  1004. continue; 
  1005.  
  1006. if ( false !== strpos( $value, '&' ) ) { 
  1007. $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); 
  1008.  
  1009. // Set direction 
  1010. if ( is_rtl() ) { 
  1011. $mce_translation['_dir'] = 'rtl'; 
  1012.  
  1013. if ( $json_only ) { 
  1014. return wp_json_encode( $mce_translation ); 
  1015.  
  1016. $baseurl = self::$baseurl ? self::$baseurl : includes_url( 'js/tinymce' ); 
  1017.  
  1018. return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . 
  1019. "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; 
  1020.  
  1021. /** 
  1022. * @static 
  1023. * @global string $tinymce_version 
  1024. * @global bool $concatenate_scripts 
  1025. * @global bool $compress_scripts 
  1026. */ 
  1027. public static function editor_js() { 
  1028. global $tinymce_version, $concatenate_scripts, $compress_scripts; 
  1029.  
  1030. /** 
  1031. * Filters "tiny_mce_version" is deprecated 
  1032. * The tiny_mce_version filter is not needed since external plugins are loaded directly by TinyMCE. 
  1033. * These plugins can be refreshed by appending query string to the URL passed to "mce_external_plugins" filter. 
  1034. * 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). 
  1035. */ 
  1036. $version = 'ver=' . $tinymce_version; 
  1037. $tmce_on = !empty(self::$mce_settings); 
  1038.  
  1039. if ( ! isset($concatenate_scripts) ) 
  1040. script_concat_settings(); 
  1041.  
  1042. $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) 
  1043. && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); 
  1044.  
  1045. $mceInit = $qtInit = ''; 
  1046. if ( $tmce_on ) { 
  1047. foreach ( self::$mce_settings as $editor_id => $init ) { 
  1048. $options = self::_parse_init( $init ); 
  1049. $mceInit .= "'$editor_id':{$options}, "; 
  1050. $mceInit = '{' . trim($mceInit, ', ') . '}'; 
  1051. } else { 
  1052. $mceInit = '{}'; 
  1053.  
  1054. if ( !empty(self::$qt_settings) ) { 
  1055. foreach ( self::$qt_settings as $editor_id => $init ) { 
  1056. $options = self::_parse_init( $init ); 
  1057. $qtInit .= "'$editor_id':{$options}, "; 
  1058. $qtInit = '{' . trim($qtInit, ', ') . '}'; 
  1059. } else { 
  1060. $qtInit = '{}'; 
  1061.  
  1062. $ref = array( 
  1063. 'plugins' => implode( ', ', self::$plugins ),  
  1064. 'theme' => 'modern',  
  1065. 'language' => self::$mce_locale 
  1066. ); 
  1067.  
  1068. $suffix = SCRIPT_DEBUG ? '' : '.min'; 
  1069.  
  1070. /** 
  1071. * Fires immediately before the TinyMCE settings are printed. 
  1072. * @since 3.2.0 
  1073. * @param array $mce_settings TinyMCE settings array. 
  1074. */ 
  1075. do_action( 'before_wp_tiny_mce', self::$mce_settings ); 
  1076. ?> 
  1077.  
  1078. <script type="text/javascript"> 
  1079. tinyMCEPreInit = { 
  1080. baseURL: "<?php echo self::$baseurl; ?>",  
  1081. suffix: "<?php echo $suffix; ?>",  
  1082. <?php 
  1083.  
  1084. if ( self::$drag_drop_upload ) { 
  1085. echo 'dragDropUpload: true, '; 
  1086.  
  1087. ?> 
  1088. mceInit: <?php echo $mceInit; ?>,  
  1089. qtInit: <?php echo $qtInit; ?>,  
  1090. ref: <?php echo self::_parse_init( $ref ); ?>,  
  1091. load_ext: function(url, lang) {var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} 
  1092. }; 
  1093. </script> 
  1094. <?php 
  1095.  
  1096. $baseurl = self::$baseurl; 
  1097. // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG) 
  1098. $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min'; 
  1099.  
  1100. if ( $tmce_on ) { 
  1101. if ( $compressed ) { 
  1102. echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n"; 
  1103. } else { 
  1104. echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n"; 
  1105. echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n"; 
  1106.  
  1107. echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; 
  1108.  
  1109. if ( self::$ext_plugins ) { 
  1110. // Load the old-format English strings to prevent unsightly labels in old style popups 
  1111. echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; 
  1112.  
  1113. /** 
  1114. * Fires after tinymce.js is loaded, but before any TinyMCE editor 
  1115. * instances are created. 
  1116. * @since 3.9.0 
  1117. * @param array $mce_settings TinyMCE settings array. 
  1118. */ 
  1119. do_action( 'wp_tiny_mce_init', self::$mce_settings ); 
  1120.  
  1121. ?> 
  1122. <script type="text/javascript"> 
  1123. <?php 
  1124.  
  1125. if ( self::$ext_plugins ) 
  1126. echo self::$ext_plugins . "\n"; 
  1127.  
  1128. if ( ! is_admin() ) 
  1129. echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; 
  1130.  
  1131. ?> 
  1132.  
  1133. ( function() { 
  1134. var init, id, $wrap; 
  1135.  
  1136. if ( typeof tinymce !== 'undefined' ) { 
  1137. for ( id in tinyMCEPreInit.mceInit ) { 
  1138. init = tinyMCEPreInit.mceInit[id]; 
  1139. $wrap = tinymce.$( '#wp-' + id + '-wrap' ); 
  1140.  
  1141. if ( ( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && ! init.wp_skip_init ) { 
  1142. tinymce.init( init ); 
  1143.  
  1144. if ( ! window.wpActiveEditor ) { 
  1145. window.wpActiveEditor = id; 
  1146.  
  1147. if ( typeof quicktags !== 'undefined' ) { 
  1148. for ( id in tinyMCEPreInit.qtInit ) { 
  1149. quicktags( tinyMCEPreInit.qtInit[id] ); 
  1150.  
  1151. if ( ! window.wpActiveEditor ) { 
  1152. window.wpActiveEditor = id; 
  1153. }()); 
  1154. </script> 
  1155. <?php 
  1156.  
  1157. if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { 
  1158. self::wp_link_dialog(); 
  1159.  
  1160. /** 
  1161. * Fires after any core TinyMCE editor instances are created. 
  1162. * @since 3.2.0 
  1163. * @param array $mce_settings TinyMCE settings array. 
  1164. */ 
  1165. do_action( 'after_wp_tiny_mce', self::$mce_settings ); 
  1166.  
  1167. /** 
  1168. * @static 
  1169. * @global int $content_width 
  1170. */ 
  1171. public static function wp_fullscreen_html() { 
  1172. _deprecated_function( __FUNCTION__, '4.3.0' ); 
  1173.  
  1174. /** 
  1175. * Performs post queries for internal linking. 
  1176. * @since 3.1.0 
  1177. * @static 
  1178. * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. 
  1179. * @return false|array Results. 
  1180. */ 
  1181. public static function wp_link_query( $args = array() ) { 
  1182. $pts = get_post_types( array( 'public' => true ), 'objects' ); 
  1183. $pt_names = array_keys( $pts ); 
  1184.  
  1185. $query = array( 
  1186. 'post_type' => $pt_names,  
  1187. 'suppress_filters' => true,  
  1188. 'update_post_term_cache' => false,  
  1189. 'update_post_meta_cache' => false,  
  1190. 'post_status' => 'publish',  
  1191. 'posts_per_page' => 20,  
  1192. ); 
  1193.  
  1194. $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; 
  1195.  
  1196. if ( isset( $args['s'] ) ) 
  1197. $query['s'] = $args['s']; 
  1198.  
  1199. $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; 
  1200.  
  1201. /** 
  1202. * Filters the link query arguments. 
  1203. * Allows modification of the link query arguments before querying. 
  1204. * @see WP_Query for a full list of arguments 
  1205. * @since 3.7.0 
  1206. * @param array $query An array of WP_Query arguments. 
  1207. */ 
  1208. $query = apply_filters( 'wp_link_query_args', $query ); 
  1209.  
  1210. // Do main query. 
  1211. $get_posts = new WP_Query; 
  1212. $posts = $get_posts->query( $query ); 
  1213. // Check if any posts were found. 
  1214. if ( ! $get_posts->post_count ) 
  1215. return false; 
  1216.  
  1217. // Build results. 
  1218. $results = array(); 
  1219. foreach ( $posts as $post ) { 
  1220. if ( 'post' == $post->post_type ) 
  1221. $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); 
  1222. else 
  1223. $info = $pts[ $post->post_type ]->labels->singular_name; 
  1224.  
  1225. $results[] = array( 
  1226. 'ID' => $post->ID,  
  1227. 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ),  
  1228. 'permalink' => get_permalink( $post->ID ),  
  1229. 'info' => $info,  
  1230. ); 
  1231.  
  1232. /** 
  1233. * Filters the link query results. 
  1234. * Allows modification of the returned link query results. 
  1235. * @since 3.7.0 
  1236. * @see 'wp_link_query_args' filter 
  1237. * @param array $results { 
  1238. * An associative array of query results. 
  1239. * @type array { 
  1240. * @type int $ID Post ID. 
  1241. * @type string $title The trimmed, escaped post title. 
  1242. * @type string $permalink Post permalink. 
  1243. * @type string $info A 'Y/m/d'-formatted date for 'post' post type,  
  1244. * the 'singular_name' post type label otherwise. 
  1245. * } 
  1246. * } 
  1247. * @param array $query An array of WP_Query arguments. 
  1248. */ 
  1249. return apply_filters( 'wp_link_query', $results, $query ); 
  1250.  
  1251. /** 
  1252. * Dialog for internal linking. 
  1253. * @since 3.1.0 
  1254. * @static 
  1255. */ 
  1256. public static function wp_link_dialog() { 
  1257. // display: none is required here, see #WP27605 
  1258. ?> 
  1259. <div id="wp-link-backdrop" style="display: none"></div> 
  1260. <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> 
  1261. <form id="wp-link" tabindex="-1"> 
  1262. <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> 
  1263. <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> 
  1264. <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 
  1265. <div id="link-selector"> 
  1266. <div id="link-options"> 
  1267. <p class="howto" id="wplink-enter-url"><?php _e( 'Enter the destination URL' ); ?></p> 
  1268. <div> 
  1269. <label><span><?php _e( 'URL' ); ?></span> 
  1270. <input id="wp-link-url" type="text" aria-describedby="wplink-enter-url" /></label> 
  1271. </div> 
  1272. <div class="wp-link-text-field"> 
  1273. <label><span><?php _e( 'Link Text' ); ?></span> 
  1274. <input id="wp-link-text" type="text" /></label> 
  1275. </div> 
  1276. <div class="link-target"> 
  1277. <label><span></span> 
  1278. <input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new tab' ); ?></label> 
  1279. </div> 
  1280. </div> 
  1281. <p class="howto" id="wplink-link-existing-content"><?php _e( 'Or link to existing content' ); ?></p> 
  1282. <div id="search-panel"> 
  1283. <div class="link-search-wrapper"> 
  1284. <label> 
  1285. <span class="search-label"><?php _e( 'Search' ); ?></span> 
  1286. <input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" aria-describedby="wplink-link-existing-content" /> 
  1287. <span class="spinner"></span> 
  1288. </label> 
  1289. </div> 
  1290. <div id="search-results" class="query-results" tabindex="0"> 
  1291. <ul></ul> 
  1292. <div class="river-waiting"> 
  1293. <span class="spinner"></span> 
  1294. </div> 
  1295. </div> 
  1296. <div id="most-recent-results" class="query-results" tabindex="0"> 
  1297. <div class="query-notice" id="query-notice-message"> 
  1298. <em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> 
  1299. <em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em> 
  1300. </div> 
  1301. <ul></ul> 
  1302. <div class="river-waiting"> 
  1303. <span class="spinner"></span> 
  1304. </div> 
  1305. </div> 
  1306. </div> 
  1307. </div> 
  1308. <div class="submitbox"> 
  1309. <div id="wp-link-cancel"> 
  1310. <button type="button" class="button"><?php _e( 'Cancel' ); ?></button> 
  1311. </div> 
  1312. <div id="wp-link-update"> 
  1313. <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> 
  1314. </div> 
  1315. </div> 
  1316. </form> 
  1317. </div> 
  1318. <?php