changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
8:c7c34916027a | 9:177826044cd9 |
---|---|
10 |
10 |
11 final class _WP_Editors { |
11 final class _WP_Editors { |
12 public static $mce_locale; |
12 public static $mce_locale; |
13 |
13 |
14 private static $mce_settings = array(); |
14 private static $mce_settings = array(); |
15 private static $qt_settings = array(); |
15 private static $qt_settings = array(); |
16 private static $plugins = array(); |
16 private static $plugins = array(); |
17 private static $qt_buttons = array(); |
17 private static $qt_buttons = array(); |
18 private static $ext_plugins; |
18 private static $ext_plugins; |
19 private static $baseurl; |
19 private static $baseurl; |
20 private static $first_init; |
20 private static $first_init; |
21 private static $this_tinymce = false; |
21 private static $this_tinymce = false; |
22 private static $this_quicktags = false; |
22 private static $this_quicktags = false; |
23 private static $has_tinymce = false; |
23 private static $has_tinymce = false; |
24 private static $has_quicktags = false; |
24 private static $has_quicktags = false; |
25 private static $has_medialib = false; |
25 private static $has_medialib = false; |
26 private static $editor_buttons_css = true; |
26 private static $editor_buttons_css = true; |
27 private static $drag_drop_upload = false; |
27 private static $drag_drop_upload = false; |
28 private static $old_dfw_compat = false; |
28 private static $old_dfw_compat = false; |
29 private static $translation; |
29 private static $translation; |
30 private static $tinymce_scripts_printed = false; |
30 private static $tinymce_scripts_printed = false; |
31 private static $link_dialog_printed = false; |
31 private static $link_dialog_printed = false; |
32 |
32 |
33 private function __construct() {} |
33 private function __construct() {} |
34 |
34 |
35 /** |
35 /** |
36 * Parse default arguments for the editor instance. |
36 * Parse default arguments for the editor instance. |
37 * |
37 * |
38 * @static |
|
39 * @param string $editor_id ID for the current editor instance. |
38 * @param string $editor_id ID for the current editor instance. |
40 * @param array $settings { |
39 * @param array $settings { |
41 * Array of editor arguments. |
40 * Array of editor arguments. |
42 * |
41 * |
43 * @type bool $wpautop Whether to use wpautop(). Default true. |
42 * @type bool $wpautop Whether to use wpautop(). Default true. |
71 /** |
70 /** |
72 * Filters the wp_editor() settings. |
71 * Filters the wp_editor() settings. |
73 * |
72 * |
74 * @since 4.0.0 |
73 * @since 4.0.0 |
75 * |
74 * |
76 * @see _WP_Editors()::parse_settings() |
75 * @see _WP_Editors::parse_settings() |
77 * |
76 * |
78 * @param array $settings Array of editor arguments. |
77 * @param array $settings Array of editor arguments. |
79 * @param string $editor_id ID for the current editor instance. |
78 * @param string $editor_id ID for the current editor instance. |
80 */ |
79 */ |
81 $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); |
80 $settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); |
82 |
81 |
83 $set = wp_parse_args( $settings, array( |
82 $set = wp_parse_args( |
84 'wpautop' => true, |
83 $settings, |
85 'media_buttons' => true, |
84 array( |
86 'default_editor' => '', |
85 // Disable autop if the current post has blocks in it. |
87 'drag_drop_upload' => false, |
86 'wpautop' => ! has_blocks(), |
88 'textarea_name' => $editor_id, |
87 'media_buttons' => true, |
89 'textarea_rows' => 20, |
88 'default_editor' => '', |
90 'tabindex' => '', |
89 'drag_drop_upload' => false, |
91 'tabfocus_elements' => ':prev,:next', |
90 'textarea_name' => $editor_id, |
92 'editor_css' => '', |
91 'textarea_rows' => 20, |
93 'editor_class' => '', |
92 'tabindex' => '', |
94 'teeny' => false, |
93 'tabfocus_elements' => ':prev,:next', |
95 'dfw' => false, |
94 'editor_css' => '', |
96 '_content_editor_dfw' => false, |
95 'editor_class' => '', |
97 'tinymce' => true, |
96 'teeny' => false, |
98 'quicktags' => true |
97 'dfw' => false, |
99 ) ); |
98 '_content_editor_dfw' => false, |
99 'tinymce' => true, |
|
100 'quicktags' => true, |
|
101 ) |
|
102 ); |
|
100 |
103 |
101 self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); |
104 self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); |
102 |
105 |
103 if ( self::$this_tinymce ) { |
106 if ( self::$this_tinymce ) { |
104 if ( false !== strpos( $editor_id, '[' ) ) { |
107 if ( false !== strpos( $editor_id, '[' ) ) { |
107 } |
110 } |
108 } |
111 } |
109 |
112 |
110 self::$this_quicktags = (bool) $set['quicktags']; |
113 self::$this_quicktags = (bool) $set['quicktags']; |
111 |
114 |
112 if ( self::$this_tinymce ) |
115 if ( self::$this_tinymce ) { |
113 self::$has_tinymce = true; |
116 self::$has_tinymce = true; |
114 |
117 } |
115 if ( self::$this_quicktags ) |
118 |
119 if ( self::$this_quicktags ) { |
|
116 self::$has_quicktags = true; |
120 self::$has_quicktags = true; |
121 } |
|
117 |
122 |
118 if ( $set['dfw'] ) { |
123 if ( $set['dfw'] ) { |
119 self::$old_dfw_compat = true; |
124 self::$old_dfw_compat = true; |
120 } |
125 } |
121 |
126 |
122 if ( empty( $set['editor_height'] ) ) |
127 if ( empty( $set['editor_height'] ) ) { |
123 return $set; |
128 return $set; |
129 } |
|
124 |
130 |
125 if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { |
131 if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { |
126 // A cookie (set when a user resizes the editor) overrides the height. |
132 // A cookie (set when a user resizes the editor) overrides the height. |
127 $cookie = (int) get_user_setting( 'ed_size' ); |
133 $cookie = (int) get_user_setting( 'ed_size' ); |
128 |
134 |
129 if ( $cookie ) |
135 if ( $cookie ) { |
130 $set['editor_height'] = $cookie; |
136 $set['editor_height'] = $cookie; |
131 } |
137 } |
132 |
138 } |
133 if ( $set['editor_height'] < 50 ) |
139 |
140 if ( $set['editor_height'] < 50 ) { |
|
134 $set['editor_height'] = 50; |
141 $set['editor_height'] = 50; |
135 elseif ( $set['editor_height'] > 5000 ) |
142 } elseif ( $set['editor_height'] > 5000 ) { |
136 $set['editor_height'] = 5000; |
143 $set['editor_height'] = 5000; |
144 } |
|
137 |
145 |
138 return $set; |
146 return $set; |
139 } |
147 } |
140 |
148 |
141 /** |
149 /** |
142 * Outputs the HTML for a single instance of the editor. |
150 * Outputs the HTML for a single instance of the editor. |
143 * |
151 * |
144 * @static |
|
145 * @param string $content The initial content of the editor. |
152 * @param string $content The initial content of the editor. |
146 * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). |
153 * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). |
147 * @param array $settings See _WP_Editors()::parse_settings() for description. |
154 * @param array $settings See _WP_Editors::parse_settings() for description. |
148 */ |
155 */ |
149 public static function editor( $content, $editor_id, $settings = array() ) { |
156 public static function editor( $content, $editor_id, $settings = array() ) { |
150 $set = self::parse_settings( $editor_id, $settings ); |
157 $set = self::parse_settings( $editor_id, $settings ); |
151 $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; |
158 $editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; |
152 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; |
159 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; |
153 $default_editor = 'html'; |
160 $default_editor = 'html'; |
154 $buttons = $autocomplete = ''; |
161 $buttons = $autocomplete = ''; |
155 $editor_id_attr = esc_attr( $editor_id ); |
162 $editor_id_attr = esc_attr( $editor_id ); |
156 |
163 |
157 if ( $set['drag_drop_upload'] ) { |
164 if ( $set['drag_drop_upload'] ) { |
158 self::$drag_drop_upload = true; |
165 self::$drag_drop_upload = true; |
159 } |
166 } |
186 $default_editor = 'tinymce'; |
193 $default_editor = 'tinymce'; |
187 } |
194 } |
188 } |
195 } |
189 |
196 |
190 $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; |
197 $switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; |
191 $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; |
198 $wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; |
192 |
199 |
193 if ( $set['_content_editor_dfw'] ) { |
200 if ( $set['_content_editor_dfw'] ) { |
194 $wrap_class .= ' has-dfw'; |
201 $wrap_class .= ' has-dfw'; |
195 } |
202 } |
196 |
203 |
209 echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; |
216 echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; |
210 |
217 |
211 if ( $set['media_buttons'] ) { |
218 if ( $set['media_buttons'] ) { |
212 self::$has_medialib = true; |
219 self::$has_medialib = true; |
213 |
220 |
214 if ( ! function_exists( 'media_buttons' ) ) |
221 if ( ! function_exists( 'media_buttons' ) ) { |
215 include( ABSPATH . 'wp-admin/includes/media.php' ); |
222 include( ABSPATH . 'wp-admin/includes/media.php' ); |
223 } |
|
216 |
224 |
217 echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; |
225 echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; |
218 |
226 |
219 /** |
227 /** |
220 * Fires after the default media button(s) are displayed. |
228 * Fires after the default media button(s) are displayed. |
248 * |
256 * |
249 * @since 2.1.0 |
257 * @since 2.1.0 |
250 * |
258 * |
251 * @param string $output Editor's HTML markup. |
259 * @param string $output Editor's HTML markup. |
252 */ |
260 */ |
253 $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . |
261 $the_editor = apply_filters( |
262 'the_editor', |
|
263 '<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . |
|
254 $quicktags_toolbar . |
264 $quicktags_toolbar . |
255 '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . |
265 '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . |
256 'id="' . $editor_id_attr . '">%s</textarea></div>' ); |
266 'id="' . $editor_id_attr . '">%s</textarea></div>' |
267 ); |
|
257 |
268 |
258 // Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat). |
269 // Prepare the content for the Visual or Text editor, only when TinyMCE is used (back-compat). |
259 if ( self::$this_tinymce ) { |
270 if ( self::$this_tinymce ) { |
260 add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); |
271 add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); |
261 } |
272 } |
294 |
305 |
295 self::editor_settings( $editor_id, $set ); |
306 self::editor_settings( $editor_id, $set ); |
296 } |
307 } |
297 |
308 |
298 /** |
309 /** |
299 * @static |
|
300 * |
|
301 * @global string $tinymce_version |
310 * @global string $tinymce_version |
302 * |
311 * |
303 * @param string $editor_id |
312 * @param string $editor_id |
304 * @param array $set |
313 * @param array $set |
305 */ |
314 */ |
306 public static function editor_settings($editor_id, $set) { |
315 public static function editor_settings( $editor_id, $set ) { |
307 global $tinymce_version; |
316 global $tinymce_version; |
308 |
317 |
309 if ( empty(self::$first_init) ) { |
318 if ( empty( self::$first_init ) ) { |
310 if ( is_admin() ) { |
319 if ( is_admin() ) { |
311 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
320 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
321 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
|
312 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
322 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
313 } else { |
323 } else { |
314 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
324 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
325 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
|
315 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
326 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
316 } |
327 } |
317 } |
328 } |
318 |
329 |
319 if ( self::$this_quicktags ) { |
330 if ( self::$this_quicktags ) { |
320 |
331 |
321 $qtInit = array( |
332 $qtInit = array( |
322 'id' => $editor_id, |
333 'id' => $editor_id, |
323 'buttons' => '' |
334 'buttons' => '', |
324 ); |
335 ); |
325 |
336 |
326 if ( is_array($set['quicktags']) ) |
337 if ( is_array( $set['quicktags'] ) ) { |
327 $qtInit = array_merge($qtInit, $set['quicktags']); |
338 $qtInit = array_merge( $qtInit, $set['quicktags'] ); |
328 |
339 } |
329 if ( empty($qtInit['buttons']) ) |
340 |
341 if ( empty( $qtInit['buttons'] ) ) { |
|
330 $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; |
342 $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; |
343 } |
|
331 |
344 |
332 if ( $set['_content_editor_dfw'] ) { |
345 if ( $set['_content_editor_dfw'] ) { |
333 $qtInit['buttons'] .= ',dfw'; |
346 $qtInit['buttons'] .= ',dfw'; |
334 } |
347 } |
335 |
348 |
341 * @param array $qtInit Quicktags settings. |
354 * @param array $qtInit Quicktags settings. |
342 * @param string $editor_id The unique editor ID, e.g. 'content'. |
355 * @param string $editor_id The unique editor ID, e.g. 'content'. |
343 */ |
356 */ |
344 $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); |
357 $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); |
345 |
358 |
346 self::$qt_settings[$editor_id] = $qtInit; |
359 self::$qt_settings[ $editor_id ] = $qtInit; |
347 |
360 |
348 self::$qt_buttons = array_merge( self::$qt_buttons, explode(',', $qtInit['buttons']) ); |
361 self::$qt_buttons = array_merge( self::$qt_buttons, explode( ',', $qtInit['buttons'] ) ); |
349 } |
362 } |
350 |
363 |
351 if ( self::$this_tinymce ) { |
364 if ( self::$this_tinymce ) { |
352 |
365 |
353 if ( empty( self::$first_init ) ) { |
366 if ( empty( self::$first_init ) ) { |
354 $baseurl = self::get_baseurl(); |
367 $baseurl = self::get_baseurl(); |
355 $mce_locale = self::get_mce_locale(); |
368 $mce_locale = self::get_mce_locale(); |
356 $ext_plugins = ''; |
369 $ext_plugins = ''; |
357 |
370 |
358 if ( $set['teeny'] ) { |
371 if ( $set['teeny'] ) { |
359 |
372 |
360 /** |
373 /** |
425 $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) ); |
438 $plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) ); |
426 |
439 |
427 if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { |
440 if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) { |
428 // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. |
441 // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. |
429 // It can be added with 'mce_external_plugins'. |
442 // It can be added with 'mce_external_plugins'. |
430 unset( $plugins[$key] ); |
443 unset( $plugins[ $key ] ); |
431 } |
444 } |
432 |
445 |
433 if ( ! empty( $mce_external_plugins ) ) { |
446 if ( ! empty( $mce_external_plugins ) ) { |
434 |
447 |
435 /** |
448 /** |
446 * @param array $translations Translations for external TinyMCE plugins. |
459 * @param array $translations Translations for external TinyMCE plugins. |
447 */ |
460 */ |
448 $mce_external_languages = apply_filters( 'mce_external_languages', array() ); |
461 $mce_external_languages = apply_filters( 'mce_external_languages', array() ); |
449 |
462 |
450 $loaded_langs = array(); |
463 $loaded_langs = array(); |
451 $strings = ''; |
464 $strings = ''; |
452 |
465 |
453 if ( ! empty( $mce_external_languages ) ) { |
466 if ( ! empty( $mce_external_languages ) ) { |
454 foreach ( $mce_external_languages as $name => $path ) { |
467 foreach ( $mce_external_languages as $name => $path ) { |
455 if ( @is_file( $path ) && @is_readable( $path ) ) { |
468 if ( @is_file( $path ) && @is_readable( $path ) ) { |
456 include_once( $path ); |
469 include_once( $path ); |
457 $ext_plugins .= $strings . "\n"; |
470 $ext_plugins .= $strings . "\n"; |
458 $loaded_langs[] = $name; |
471 $loaded_langs[] = $name; |
459 } |
472 } |
460 } |
473 } |
461 } |
474 } |
462 |
475 |
464 if ( in_array( $name, $plugins, true ) ) { |
477 if ( in_array( $name, $plugins, true ) ) { |
465 unset( $mce_external_plugins[ $name ] ); |
478 unset( $mce_external_plugins[ $name ] ); |
466 continue; |
479 continue; |
467 } |
480 } |
468 |
481 |
469 $url = set_url_scheme( $url ); |
482 $url = set_url_scheme( $url ); |
470 $mce_external_plugins[ $name ] = $url; |
483 $mce_external_plugins[ $name ] = $url; |
471 $plugurl = dirname( $url ); |
484 $plugurl = dirname( $url ); |
472 $strings = ''; |
485 $strings = ''; |
473 |
486 |
474 // Try to load langs/[locale].js and langs/[locale]_dlg.js |
487 // Try to load langs/[locale].js and langs/[locale]_dlg.js |
475 if ( ! in_array( $name, $loaded_langs, true ) ) { |
488 if ( ! in_array( $name, $loaded_langs, true ) ) { |
476 $path = str_replace( content_url(), '', $plugurl ); |
489 $path = str_replace( content_url(), '', $plugurl ); |
477 $path = WP_CONTENT_DIR . $path . '/langs/'; |
490 $path = WP_CONTENT_DIR . $path . '/langs/'; |
478 |
491 |
479 if ( function_exists('realpath') ) |
492 if ( function_exists( 'realpath' ) ) { |
480 $path = trailingslashit( realpath($path) ); |
493 $path = trailingslashit( realpath( $path ) ); |
481 |
494 } |
482 if ( @is_file( $path . $mce_locale . '.js' ) ) |
495 |
496 if ( @is_file( $path . $mce_locale . '.js' ) ) { |
|
483 $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; |
497 $strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; |
484 |
498 } |
485 if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) |
499 |
500 if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) { |
|
486 $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; |
501 $strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; |
502 } |
|
487 |
503 |
488 if ( 'en' != $mce_locale && empty( $strings ) ) { |
504 if ( 'en' != $mce_locale && empty( $strings ) ) { |
489 if ( @is_file( $path . 'en.js' ) ) { |
505 if ( @is_file( $path . 'en.js' ) ) { |
490 $str1 = @file_get_contents( $path . 'en.js' ); |
506 $str1 = @file_get_contents( $path . 'en.js' ); |
491 $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; |
507 $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; |
492 } |
508 } |
493 |
509 |
494 if ( @is_file( $path . 'en_dlg.js' ) ) { |
510 if ( @is_file( $path . 'en_dlg.js' ) ) { |
495 $str2 = @file_get_contents( $path . 'en_dlg.js' ); |
511 $str2 = @file_get_contents( $path . 'en_dlg.js' ); |
496 $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; |
512 $strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; |
497 } |
513 } |
498 } |
514 } |
499 |
515 |
500 if ( ! empty( $strings ) ) |
516 if ( ! empty( $strings ) ) { |
501 $ext_plugins .= "\n" . $strings . "\n"; |
517 $ext_plugins .= "\n" . $strings . "\n"; |
518 } |
|
502 } |
519 } |
503 |
520 |
504 $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; |
521 $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; |
505 } |
522 } |
506 } |
523 } |
507 } |
524 } |
508 |
525 |
509 self::$plugins = $plugins; |
526 self::$plugins = $plugins; |
510 self::$ext_plugins = $ext_plugins; |
527 self::$ext_plugins = $ext_plugins; |
511 |
528 |
512 $settings = self::default_settings(); |
529 $settings = self::default_settings(); |
513 $settings['plugins'] = implode( ',', $plugins ); |
530 $settings['plugins'] = implode( ',', $plugins ); |
514 |
531 |
515 if ( ! empty( $mce_external_plugins ) ) { |
532 if ( ! empty( $mce_external_plugins ) ) { |
516 $settings['external_plugins'] = wp_json_encode( $mce_external_plugins ); |
533 $settings['external_plugins'] = wp_json_encode( $mce_external_plugins ); |
517 } |
534 } |
519 /** This filter is documented in wp-admin/includes/media.php */ |
536 /** This filter is documented in wp-admin/includes/media.php */ |
520 if ( apply_filters( 'disable_captions', '' ) ) { |
537 if ( apply_filters( 'disable_captions', '' ) ) { |
521 $settings['wpeditimage_disable_captions'] = true; |
538 $settings['wpeditimage_disable_captions'] = true; |
522 } |
539 } |
523 |
540 |
524 $mce_css = $settings['content_css']; |
541 $mce_css = $settings['content_css']; |
525 $editor_styles = get_editor_stylesheets(); |
542 $editor_styles = get_editor_stylesheets(); |
526 |
543 |
527 if ( ! empty( $editor_styles ) ) { |
544 if ( ! empty( $editor_styles ) ) { |
528 // Force urlencoding of commas. |
545 // Force urlencoding of commas. |
529 foreach ( $editor_styles as $key => $url ) { |
546 foreach ( $editor_styles as $key => $url ) { |
561 * @since 2.7.0 |
578 * @since 2.7.0 |
562 * |
579 * |
563 * @param array $buttons An array of teenyMCE buttons. |
580 * @param array $buttons An array of teenyMCE buttons. |
564 * @param string $editor_id Unique editor identifier, e.g. 'content'. |
581 * @param string $editor_id Unique editor identifier, e.g. 'content'. |
565 */ |
582 */ |
566 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'fullscreen'), $editor_id ); |
583 $mce_buttons = apply_filters( 'teeny_mce_buttons', array( 'bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'fullscreen' ), $editor_id ); |
567 $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); |
584 $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); |
568 } else { |
585 } else { |
569 $mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'wp_more', 'spellchecker' ); |
586 $mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'wp_more', 'spellchecker' ); |
570 |
587 |
571 if ( ! wp_is_mobile() ) { |
588 if ( ! wp_is_mobile() ) { |
572 if ( $set['_content_editor_dfw'] ) { |
589 if ( $set['_content_editor_dfw'] ) { |
590 $mce_buttons[] = 'wp_adv'; |
|
573 $mce_buttons[] = 'dfw'; |
591 $mce_buttons[] = 'dfw'; |
574 } else { |
592 } else { |
575 $mce_buttons[] = 'fullscreen'; |
593 $mce_buttons[] = 'fullscreen'; |
594 $mce_buttons[] = 'wp_adv'; |
|
576 } |
595 } |
596 } else { |
|
597 $mce_buttons[] = 'wp_adv'; |
|
577 } |
598 } |
578 |
|
579 $mce_buttons[] = 'wp_adv'; |
|
580 |
599 |
581 /** |
600 /** |
582 * Filters the first-row list of TinyMCE buttons (Visual tab). |
601 * Filters the first-row list of TinyMCE buttons (Visual tab). |
583 * |
602 * |
584 * @since 2.0.0 |
603 * @since 2.0.0 |
630 if ( $post = get_post() ) { |
649 if ( $post = get_post() ) { |
631 $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); |
650 $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); |
632 |
651 |
633 if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
652 if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
634 $post_format = get_post_format( $post ); |
653 $post_format = get_post_format( $post ); |
635 if ( $post_format && ! is_wp_error( $post_format ) ) |
654 if ( $post_format && ! is_wp_error( $post_format ) ) { |
636 $body_class .= ' post-format-' . sanitize_html_class( $post_format ); |
655 $body_class .= ' post-format-' . sanitize_html_class( $post_format ); |
637 else |
656 } else { |
638 $body_class .= ' post-format-standard'; |
657 $body_class .= ' post-format-standard'; |
658 } |
|
639 } |
659 } |
640 |
660 |
641 $page_template = get_page_template_slug( $post ); |
661 $page_template = get_page_template_slug( $post ); |
642 |
662 |
643 if ( $page_template !== false ) { |
663 if ( $page_template !== false ) { |
644 $page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) ); |
664 $page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) ); |
645 $body_class .= ' page-template-' . sanitize_html_class( $page_template ); |
665 $body_class .= ' page-template-' . sanitize_html_class( $page_template ); |
646 } |
666 } |
647 } |
667 } |
648 |
668 |
649 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
669 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
650 |
670 |
651 if ( ! empty( $set['tinymce']['body_class'] ) ) { |
671 if ( ! empty( $set['tinymce']['body_class'] ) ) { |
652 $body_class .= ' ' . $set['tinymce']['body_class']; |
672 $body_class .= ' ' . $set['tinymce']['body_class']; |
653 unset( $set['tinymce']['body_class'] ); |
673 unset( $set['tinymce']['body_class'] ); |
654 } |
674 } |
655 |
675 |
656 $mceInit = array ( |
676 $mceInit = array( |
657 'selector' => "#$editor_id", |
677 'selector' => "#$editor_id", |
658 'wpautop' => (bool) $set['wpautop'], |
678 'wpautop' => (bool) $set['wpautop'], |
659 'indent' => ! $set['wpautop'], |
679 'indent' => ! $set['wpautop'], |
660 'toolbar1' => implode( ',', $mce_buttons ), |
680 'toolbar1' => implode( ',', $mce_buttons ), |
661 'toolbar2' => implode( ',', $mce_buttons_2 ), |
681 'toolbar2' => implode( ',', $mce_buttons_2 ), |
662 'toolbar3' => implode( ',', $mce_buttons_3 ), |
682 'toolbar3' => implode( ',', $mce_buttons_3 ), |
663 'toolbar4' => implode( ',', $mce_buttons_4 ), |
683 'toolbar4' => implode( ',', $mce_buttons_4 ), |
664 'tabfocus_elements' => $set['tabfocus_elements'], |
684 'tabfocus_elements' => $set['tabfocus_elements'], |
665 'body_class' => $body_class |
685 'body_class' => $body_class, |
666 ); |
686 ); |
667 |
687 |
668 // Merge with the first part of the init array |
688 // Merge with the first part of the init array |
669 $mceInit = array_merge( self::$first_init, $mceInit ); |
689 $mceInit = array_merge( self::$first_init, $mceInit ); |
670 |
690 |
671 if ( is_array( $set['tinymce'] ) ) |
691 if ( is_array( $set['tinymce'] ) ) { |
672 $mceInit = array_merge( $mceInit, $set['tinymce'] ); |
692 $mceInit = array_merge( $mceInit, $set['tinymce'] ); |
693 } |
|
673 |
694 |
674 /* |
695 /* |
675 * For people who really REALLY know what they're doing with TinyMCE |
696 * For people who really REALLY know what they're doing with TinyMCE |
676 * You can modify $mceInit to add, remove, change elements of the config |
697 * You can modify $mceInit to add, remove, change elements of the config |
677 * before tinyMCE.init. Setting "valid_elements", "invalid_elements" |
698 * before tinyMCE.init. Setting "valid_elements", "invalid_elements" |
706 if ( empty( $mceInit['toolbar3'] ) && ! empty( $mceInit['toolbar4'] ) ) { |
727 if ( empty( $mceInit['toolbar3'] ) && ! empty( $mceInit['toolbar4'] ) ) { |
707 $mceInit['toolbar3'] = $mceInit['toolbar4']; |
728 $mceInit['toolbar3'] = $mceInit['toolbar4']; |
708 $mceInit['toolbar4'] = ''; |
729 $mceInit['toolbar4'] = ''; |
709 } |
730 } |
710 |
731 |
711 self::$mce_settings[$editor_id] = $mceInit; |
732 self::$mce_settings[ $editor_id ] = $mceInit; |
712 } // end if self::$this_tinymce |
733 } // end if self::$this_tinymce |
713 } |
734 } |
714 |
735 |
715 /** |
736 /** |
716 * |
|
717 * @static |
|
718 * @param array $init |
737 * @param array $init |
719 * @return string |
738 * @return string |
720 */ |
739 */ |
721 private static function _parse_init( $init ) { |
740 private static function _parse_init( $init ) { |
722 $options = ''; |
741 $options = ''; |
723 |
742 |
724 foreach ( $init as $key => $value ) { |
743 foreach ( $init as $key => $value ) { |
725 if ( is_bool( $value ) ) { |
744 if ( is_bool( $value ) ) { |
726 $val = $value ? 'true' : 'false'; |
745 $val = $value ? 'true' : 'false'; |
727 $options .= $key . ':' . $val . ','; |
746 $options .= $key . ':' . $val . ','; |
728 continue; |
747 continue; |
729 } elseif ( ! empty( $value ) && is_string( $value ) && ( |
748 } elseif ( ! empty( $value ) && is_string( $value ) && ( |
730 ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) || |
749 ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) || |
731 ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) || |
750 ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) || |
741 } |
760 } |
742 |
761 |
743 /** |
762 /** |
744 * |
763 * |
745 * @static |
764 * @static |
746 * |
765 * |
747 * @param bool $default_scripts Optional. Whether default scripts should be enqueued. Default false. |
766 * @param bool $default_scripts Optional. Whether default scripts should be enqueued. Default false. |
748 */ |
767 */ |
749 public static function enqueue_scripts( $default_scripts = false ) { |
768 public static function enqueue_scripts( $default_scripts = false ) { |
750 if ( $default_scripts || self::$has_tinymce ) { |
769 if ( $default_scripts || self::$has_tinymce ) { |
751 wp_enqueue_script( 'editor' ); |
770 wp_enqueue_script( 'editor' ); |
779 * @since 3.9.0 |
798 * @since 3.9.0 |
780 * |
799 * |
781 * @param array $to_load An array containing boolean values whether TinyMCE |
800 * @param array $to_load An array containing boolean values whether TinyMCE |
782 * and Quicktags are being loaded. |
801 * and Quicktags are being loaded. |
783 */ |
802 */ |
784 do_action( 'wp_enqueue_editor', array( |
803 do_action( |
785 'tinymce' => ( $default_scripts || self::$has_tinymce ), |
804 'wp_enqueue_editor', |
786 'quicktags' => ( $default_scripts || self::$has_quicktags ), |
805 array( |
787 ) ); |
806 'tinymce' => ( $default_scripts || self::$has_tinymce ), |
807 'quicktags' => ( $default_scripts || self::$has_quicktags ), |
|
808 ) |
|
809 ); |
|
788 } |
810 } |
789 |
811 |
790 /** |
812 /** |
791 * Enqueue all editor scripts. |
813 * Enqueue all editor scripts. |
792 * For use when the editor is going to be initialized after page load. |
814 * For use when the editor is going to be initialized after page load. |
803 |
825 |
804 // Also add wp-includes/css/editor.css |
826 // Also add wp-includes/css/editor.css |
805 wp_enqueue_style( 'editor-buttons' ); |
827 wp_enqueue_style( 'editor-buttons' ); |
806 |
828 |
807 if ( is_admin() ) { |
829 if ( is_admin() ) { |
830 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
|
808 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
831 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
809 } else { |
832 } else { |
833 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
|
810 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
834 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
811 } |
835 } |
812 } |
836 } |
813 |
837 |
814 /** |
838 /** |
815 * Print (output) all editor scripts and default settings. |
839 * Print (output) all editor scripts and default settings. |
816 * For use when the editor is going to be initialized after page load. |
840 * For use when the editor is going to be initialized after page load. |
817 * |
841 * |
818 * @since 4.8.0 |
842 * @since 4.8.0 |
819 * |
|
820 */ |
843 */ |
821 public static function print_default_editor_scripts() { |
844 public static function print_default_editor_scripts() { |
822 $user_can_richedit = user_can_richedit(); |
845 $user_can_richedit = user_can_richedit(); |
823 |
846 |
824 if ( $user_can_richedit ) { |
847 if ( $user_can_richedit ) { |
825 $settings = self::default_settings(); |
848 $settings = self::default_settings(); |
826 |
849 |
827 $settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; |
850 $settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; |
828 $settings['wpautop'] = false; |
851 $settings['wpautop'] = false; |
829 $settings['indent'] = true; |
852 $settings['indent'] = true; |
830 $settings['elementpath'] = false; |
853 $settings['elementpath'] = false; |
831 |
854 |
832 if ( is_rtl() ) { |
855 if ( is_rtl() ) { |
833 $settings['directionality'] = 'rtl'; |
856 $settings['directionality'] = 'rtl'; |
834 } |
857 } |
835 |
858 |
836 // In production all plugins are loaded (they are in wp-editor.js.gz). |
859 // In production all plugins are loaded (they are in wp-editor.js.gz). |
837 // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. |
860 // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. |
838 // Can be added from js by using the 'wp-before-tinymce-init' event. |
861 // Can be added from js by using the 'wp-before-tinymce-init' event. |
839 $settings['plugins'] = implode( ',', array( |
862 $settings['plugins'] = implode( |
840 'charmap', |
863 ',', |
841 'colorpicker', |
864 array( |
842 'hr', |
865 'charmap', |
843 'lists', |
866 'colorpicker', |
844 'paste', |
867 'hr', |
845 'tabfocus', |
868 'lists', |
846 'textcolor', |
869 'paste', |
847 'fullscreen', |
870 'tabfocus', |
848 'wordpress', |
871 'textcolor', |
849 'wpautoresize', |
872 'fullscreen', |
850 'wpeditimage', |
873 'wordpress', |
851 'wpemoji', |
874 'wpautoresize', |
852 'wpgallery', |
875 'wpeditimage', |
853 'wplink', |
876 'wpemoji', |
854 'wptextpattern', |
877 'wpgallery', |
855 ) ); |
878 'wplink', |
879 'wptextpattern', |
|
880 ) |
|
881 ); |
|
856 |
882 |
857 $settings = self::_parse_init( $settings ); |
883 $settings = self::_parse_init( $settings ); |
858 } else { |
884 } else { |
859 $settings = '{}'; |
885 $settings = '{}'; |
860 } |
886 } |
873 }; |
899 }; |
874 |
900 |
875 <?php |
901 <?php |
876 |
902 |
877 if ( $user_can_richedit ) { |
903 if ( $user_can_richedit ) { |
878 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
904 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
879 $baseurl = self::get_baseurl(); |
905 $baseurl = self::get_baseurl(); |
880 |
906 |
881 ?> |
907 ?> |
882 var tinyMCEPreInit = { |
908 var tinyMCEPreInit = { |
883 baseURL: "<?php echo $baseurl; ?>", |
909 baseURL: "<?php echo $baseurl; ?>", |
907 self::wp_link_dialog(); |
933 self::wp_link_dialog(); |
908 } |
934 } |
909 |
935 |
910 public static function get_mce_locale() { |
936 public static function get_mce_locale() { |
911 if ( empty( self::$mce_locale ) ) { |
937 if ( empty( self::$mce_locale ) ) { |
912 $mce_locale = get_user_locale(); |
938 $mce_locale = get_user_locale(); |
913 self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 |
939 self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 |
914 } |
940 } |
915 |
941 |
916 return self::$mce_locale; |
942 return self::$mce_locale; |
917 } |
943 } |
937 |
963 |
938 $shortcut_labels = array(); |
964 $shortcut_labels = array(); |
939 |
965 |
940 foreach ( self::get_translation() as $name => $value ) { |
966 foreach ( self::get_translation() as $name => $value ) { |
941 if ( is_array( $value ) ) { |
967 if ( is_array( $value ) ) { |
942 $shortcut_labels[$name] = $value[1]; |
968 $shortcut_labels[ $name ] = $value[1]; |
943 } |
969 } |
944 } |
970 } |
945 |
971 |
946 $settings = array( |
972 $settings = array( |
947 'theme' => 'modern', |
973 'theme' => 'modern', |
948 'skin' => 'lightgray', |
974 'skin' => 'lightgray', |
949 'language' => self::get_mce_locale(), |
975 'language' => self::get_mce_locale(), |
950 'formats' => '{' . |
976 'formats' => '{' . |
951 'alignleft: [' . |
977 'alignleft: [' . |
952 '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . |
978 '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . |
953 '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . |
979 '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . |
954 '],' . |
980 '],' . |
955 'aligncenter: [' . |
981 'aligncenter: [' . |
960 '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . |
986 '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . |
961 '{selector: "img,table,dl.wp-caption", classes: "alignright"}' . |
987 '{selector: "img,table,dl.wp-caption", classes: "alignright"}' . |
962 '],' . |
988 '],' . |
963 'strikethrough: {inline: "del"}' . |
989 'strikethrough: {inline: "del"}' . |
964 '}', |
990 '}', |
965 'relative_urls' => false, |
991 'relative_urls' => false, |
966 'remove_script_host' => false, |
992 'remove_script_host' => false, |
967 'convert_urls' => false, |
993 'convert_urls' => false, |
968 'browser_spellcheck' => true, |
994 'browser_spellcheck' => true, |
969 'fix_list_elements' => true, |
995 'fix_list_elements' => true, |
970 'entities' => '38,amp,60,lt,62,gt', |
996 'entities' => '38,amp,60,lt,62,gt', |
971 'entity_encoding' => 'raw', |
997 'entity_encoding' => 'raw', |
972 'keep_styles' => false, |
998 'keep_styles' => false, |
973 'cache_suffix' => 'wp-mce-' . $tinymce_version, |
999 'cache_suffix' => 'wp-mce-' . $tinymce_version, |
974 'resize' => 'vertical', |
1000 'resize' => 'vertical', |
975 'menubar' => false, |
1001 'menubar' => false, |
976 'branding' => false, |
1002 'branding' => false, |
977 |
1003 |
978 // Limit the preview styles in the menu/toolbar |
1004 // Limit the preview styles in the menu/toolbar |
979 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', |
1005 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', |
980 |
1006 |
981 'end_container_on_empty_block' => true, |
1007 'end_container_on_empty_block' => true, |
982 'wpeditimage_html5_captions' => true, |
1008 'wpeditimage_html5_captions' => true, |
983 'wp_lang_attr' => get_bloginfo( 'language' ), |
1009 'wp_lang_attr' => get_bloginfo( 'language' ), |
984 'wp_keep_scroll_position' => false, |
1010 'wp_keep_scroll_position' => false, |
985 'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ), |
1011 'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ), |
986 ); |
1012 ); |
987 |
1013 |
988 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
1014 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
989 $version = 'ver=' . get_bloginfo( 'version' ); |
1015 $version = 'ver=' . get_bloginfo( 'version' ); |
990 |
1016 |
991 // Default stylesheets |
1017 // Default stylesheets |
992 $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' . |
1018 $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' . |
993 includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" ); |
1019 includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" ); |
996 } |
1022 } |
997 |
1023 |
998 private static function get_translation() { |
1024 private static function get_translation() { |
999 if ( empty( self::$translation ) ) { |
1025 if ( empty( self::$translation ) ) { |
1000 self::$translation = array( |
1026 self::$translation = array( |
1001 // Default TinyMCE strings |
1027 // Default TinyMCE strings |
1002 'New document' => __( 'New document' ), |
1028 'New document' => __( 'New document' ), |
1003 'Formats' => _x( 'Formats', 'TinyMCE' ), |
1029 'Formats' => _x( 'Formats', 'TinyMCE' ), |
1004 |
1030 |
1005 'Headings' => _x( 'Headings', 'TinyMCE' ), |
1031 'Headings' => _x( 'Headings', 'TinyMCE' ), |
1006 'Heading 1' => array( __( 'Heading 1' ), 'access1' ), |
1032 'Heading 1' => array( __( 'Heading 1' ), 'access1' ), |
1007 'Heading 2' => array( __( 'Heading 2' ), 'access2' ), |
1033 'Heading 2' => array( __( 'Heading 2' ), 'access2' ), |
1008 'Heading 3' => array( __( 'Heading 3' ), 'access3' ), |
1034 'Heading 3' => array( __( 'Heading 3' ), 'access3' ), |
1009 'Heading 4' => array( __( 'Heading 4' ), 'access4' ), |
1035 'Heading 4' => array( __( 'Heading 4' ), 'access4' ), |
1010 'Heading 5' => array( __( 'Heading 5' ), 'access5' ), |
1036 'Heading 5' => array( __( 'Heading 5' ), 'access5' ), |
1011 'Heading 6' => array( __( 'Heading 6' ), 'access6' ), |
1037 'Heading 6' => array( __( 'Heading 6' ), 'access6' ), |
1012 |
1038 |
1013 /* translators: block tags */ |
1039 /* translators: block tags */ |
1014 'Blocks' => _x( 'Blocks', 'TinyMCE' ), |
1040 'Blocks' => _x( 'Blocks', 'TinyMCE' ), |
1015 'Paragraph' => array( __( 'Paragraph' ), 'access7' ), |
1041 'Paragraph' => array( __( 'Paragraph' ), 'access7' ), |
1016 'Blockquote' => array( __( 'Blockquote' ), 'accessQ' ), |
1042 'Blockquote' => array( __( 'Blockquote' ), 'accessQ' ), |
1017 'Div' => _x( 'Div', 'HTML tag' ), |
1043 'Div' => _x( 'Div', 'HTML tag' ), |
1018 'Pre' => _x( 'Pre', 'HTML tag' ), |
1044 'Pre' => _x( 'Pre', 'HTML tag' ), |
1019 'Preformatted' => _x( 'Preformatted', 'HTML tag' ), |
1045 'Preformatted' => _x( 'Preformatted', 'HTML tag' ), |
1020 'Address' => _x( 'Address', 'HTML tag' ), |
1046 'Address' => _x( 'Address', 'HTML tag' ), |
1021 |
1047 |
1022 'Inline' => _x( 'Inline', 'HTML elements' ), |
1048 'Inline' => _x( 'Inline', 'HTML elements' ), |
1023 'Underline' => array( __( 'Underline' ), 'metaU' ), |
1049 'Underline' => array( __( 'Underline' ), 'metaU' ), |
1024 'Strikethrough' => array( __( 'Strikethrough' ), 'accessD' ), |
1050 'Strikethrough' => array( __( 'Strikethrough' ), 'accessD' ), |
1025 'Subscript' => __( 'Subscript' ), |
1051 'Subscript' => __( 'Subscript' ), |
1026 'Superscript' => __( 'Superscript' ), |
1052 'Superscript' => __( 'Superscript' ), |
1027 'Clear formatting' => __( 'Clear formatting' ), |
1053 'Clear formatting' => __( 'Clear formatting' ), |
1028 'Bold' => array( __( 'Bold' ), 'metaB' ), |
1054 'Bold' => array( __( 'Bold' ), 'metaB' ), |
1029 'Italic' => array( __( 'Italic' ), 'metaI' ), |
1055 'Italic' => array( __( 'Italic' ), 'metaI' ), |
1030 'Code' => array( __( 'Code' ), 'accessX' ), |
1056 'Code' => array( __( 'Code' ), 'accessX' ), |
1031 'Source code' => __( 'Source code' ), |
1057 'Source code' => __( 'Source code' ), |
1032 'Font Family' => __( 'Font Family' ), |
1058 'Font Family' => __( 'Font Family' ), |
1033 'Font Sizes' => __( 'Font Sizes' ), |
1059 'Font Sizes' => __( 'Font Sizes' ), |
1034 |
1060 |
1035 'Align center' => array( __( 'Align center' ), 'accessC' ), |
1061 'Align center' => array( __( 'Align center' ), 'accessC' ), |
1036 'Align right' => array( __( 'Align right' ), 'accessR' ), |
1062 'Align right' => array( __( 'Align right' ), 'accessR' ), |
1037 'Align left' => array( __( 'Align left' ), 'accessL' ), |
1063 'Align left' => array( __( 'Align left' ), 'accessL' ), |
1038 'Justify' => array( __( 'Justify' ), 'accessJ' ), |
1064 'Justify' => array( __( 'Justify' ), 'accessJ' ), |
1039 'Increase indent' => __( 'Increase indent' ), |
1065 'Increase indent' => __( 'Increase indent' ), |
1040 'Decrease indent' => __( 'Decrease indent' ), |
1066 'Decrease indent' => __( 'Decrease indent' ), |
1041 |
1067 |
1042 'Cut' => array( __( 'Cut' ), 'metaX' ), |
1068 'Cut' => array( __( 'Cut' ), 'metaX' ), |
1043 'Copy' => array( __( 'Copy' ), 'metaC' ), |
1069 'Copy' => array( __( 'Copy' ), 'metaC' ), |
1044 'Paste' => array( __( 'Paste' ), 'metaV' ), |
1070 'Paste' => array( __( 'Paste' ), 'metaV' ), |
1045 'Select all' => array( __( 'Select all' ), 'metaA' ), |
1071 'Select all' => array( __( 'Select all' ), 'metaA' ), |
1046 'Undo' => array( __( 'Undo' ), 'metaZ' ), |
1072 'Undo' => array( __( 'Undo' ), 'metaZ' ), |
1047 'Redo' => array( __( 'Redo' ), 'metaY' ), |
1073 'Redo' => array( __( 'Redo' ), 'metaY' ), |
1048 |
1074 |
1049 'Ok' => __( 'OK' ), |
1075 'Ok' => __( 'OK' ), |
1050 'Cancel' => __( 'Cancel' ), |
1076 'Cancel' => __( 'Cancel' ), |
1051 'Close' => __( 'Close' ), |
1077 'Close' => __( 'Close' ), |
1052 'Visual aids' => __( 'Visual aids' ), |
1078 'Visual aids' => __( 'Visual aids' ), |
1053 |
1079 |
1054 'Bullet list' => array( __( 'Bulleted list' ), 'accessU' ), |
1080 'Bullet list' => array( __( 'Bulleted list' ), 'accessU' ), |
1055 'Numbered list' => array( __( 'Numbered list' ), 'accessO' ), |
1081 'Numbered list' => array( __( 'Numbered list' ), 'accessO' ), |
1056 'Square' => _x( 'Square', 'list style' ), |
1082 'Square' => _x( 'Square', 'list style' ), |
1057 'Default' => _x( 'Default', 'list style' ), |
1083 'Default' => _x( 'Default', 'list style' ), |
1058 'Circle' => _x( 'Circle', 'list style' ), |
1084 'Circle' => _x( 'Circle', 'list style' ), |
1059 'Disc' => _x('Disc', 'list style' ), |
1085 'Disc' => _x( 'Disc', 'list style' ), |
1060 'Lower Greek' => _x( 'Lower Greek', 'list style' ), |
1086 'Lower Greek' => _x( 'Lower Greek', 'list style' ), |
1061 'Lower Alpha' => _x( 'Lower Alpha', 'list style' ), |
1087 'Lower Alpha' => _x( 'Lower Alpha', 'list style' ), |
1062 'Upper Alpha' => _x( 'Upper Alpha', 'list style' ), |
1088 'Upper Alpha' => _x( 'Upper Alpha', 'list style' ), |
1063 'Upper Roman' => _x( 'Upper Roman', 'list style' ), |
1089 'Upper Roman' => _x( 'Upper Roman', 'list style' ), |
1064 'Lower Roman' => _x( 'Lower Roman', 'list style' ), |
1090 'Lower Roman' => _x( 'Lower Roman', 'list style' ), |
1065 |
1091 |
1066 // Anchor plugin |
1092 // Anchor plugin |
1067 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), |
1093 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), |
1068 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), |
1094 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), |
1069 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), |
1095 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), |
1070 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' => |
1096 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' => |
1071 __( 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' ), |
1097 __( 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' ), |
1072 'Id' => _x( 'Id', 'Id for link anchor (TinyMCE)' ), |
1098 'Id' => _x( 'Id', 'Id for link anchor (TinyMCE)' ), |
1073 |
1099 |
1074 // Fullpage plugin |
1100 // Fullpage plugin |
1075 'Document properties' => __( 'Document properties' ), |
1101 'Document properties' => __( 'Document properties' ), |
1076 'Robots' => __( 'Robots' ), |
1102 'Robots' => __( 'Robots' ), |
1077 'Title' => __( 'Title' ), |
1103 'Title' => __( 'Title' ), |
1078 'Keywords' => __( 'Keywords' ), |
1104 'Keywords' => __( 'Keywords' ), |
1079 'Encoding' => __( 'Encoding' ), |
1105 'Encoding' => __( 'Encoding' ), |
1080 'Description' => __( 'Description' ), |
1106 'Description' => __( 'Description' ), |
1081 'Author' => __( 'Author' ), |
1107 'Author' => __( 'Author' ), |
1082 |
1108 |
1083 // Media, image plugins |
1109 // Media, image plugins |
1084 'Image' => __( 'Image' ), |
1110 'Image' => __( 'Image' ), |
1085 'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ), |
1111 'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ), |
1086 'General' => __( 'General' ), |
1112 'General' => __( 'General' ), |
1087 'Advanced' => __( 'Advanced' ), |
1113 'Advanced' => __( 'Advanced' ), |
1088 'Source' => __( 'Source' ), |
1114 'Source' => __( 'Source' ), |
1089 'Border' => __( 'Border' ), |
1115 'Border' => __( 'Border' ), |
1090 'Constrain proportions' => __( 'Constrain proportions' ), |
1116 'Constrain proportions' => __( 'Constrain proportions' ), |
1091 'Vertical space' => __( 'Vertical space' ), |
1117 'Vertical space' => __( 'Vertical space' ), |
1092 'Image description' => __( 'Image description' ), |
1118 'Image description' => __( 'Image description' ), |
1093 'Style' => __( 'Style' ), |
1119 'Style' => __( 'Style' ), |
1094 'Dimensions' => __( 'Dimensions' ), |
1120 'Dimensions' => __( 'Dimensions' ), |
1095 'Insert image' => __( 'Insert image' ), |
1121 'Insert image' => __( 'Insert image' ), |
1096 'Date/time' => __( 'Date/time' ), |
1122 'Date/time' => __( 'Date/time' ), |
1097 'Insert date/time' => __( 'Insert date/time' ), |
1123 'Insert date/time' => __( 'Insert date/time' ), |
1098 'Table of Contents' => __( 'Table of Contents' ), |
1124 'Table of Contents' => __( 'Table of Contents' ), |
1099 'Insert/Edit code sample' => __( 'Insert/edit code sample' ), |
1125 'Insert/Edit code sample' => __( 'Insert/edit code sample' ), |
1100 'Language' => __( 'Language' ), |
1126 'Language' => __( 'Language' ), |
1101 'Media' => __( 'Media' ), |
1127 'Media' => __( 'Media' ), |
1102 'Insert/edit media' => __( 'Insert/edit media' ), |
1128 'Insert/edit media' => __( 'Insert/edit media' ), |
1103 'Poster' => __( 'Poster' ), |
1129 'Poster' => __( 'Poster' ), |
1104 'Alternative source' => __( 'Alternative source' ), |
1130 'Alternative source' => __( 'Alternative source' ), |
1105 'Paste your embed code below:' => __( 'Paste your embed code below:' ), |
1131 'Paste your embed code below:' => __( 'Paste your embed code below:' ), |
1106 'Insert video' => __( 'Insert video' ), |
1132 'Insert video' => __( 'Insert video' ), |
1107 'Embed' => __( 'Embed' ), |
1133 'Embed' => __( 'Embed' ), |
1108 |
1134 |
1109 // Each of these have a corresponding plugin |
1135 // Each of these have a corresponding plugin |
1110 'Special character' => __( 'Special character' ), |
1136 'Special character' => __( 'Special character' ), |
1111 'Right to left' => _x( 'Right to left', 'editor button' ), |
1137 'Right to left' => _x( 'Right to left', 'editor button' ), |
1112 'Left to right' => _x( 'Left to right', 'editor button' ), |
1138 'Left to right' => _x( 'Left to right', 'editor button' ), |
1113 'Emoticons' => __( 'Emoticons' ), |
1139 'Emoticons' => __( 'Emoticons' ), |
1114 'Nonbreaking space' => __( 'Nonbreaking space' ), |
1140 'Nonbreaking space' => __( 'Nonbreaking space' ), |
1115 'Page break' => __( 'Page break' ), |
1141 'Page break' => __( 'Page break' ), |
1116 'Paste as text' => __( 'Paste as text' ), |
1142 'Paste as text' => __( 'Paste as text' ), |
1117 'Preview' => __( 'Preview' ), |
1143 'Preview' => __( 'Preview' ), |
1118 'Print' => __( 'Print' ), |
1144 'Print' => __( 'Print' ), |
1119 'Save' => __( 'Save' ), |
1145 'Save' => __( 'Save' ), |
1120 'Fullscreen' => __( 'Fullscreen' ), |
1146 'Fullscreen' => __( 'Fullscreen' ), |
1121 'Horizontal line' => __( 'Horizontal line' ), |
1147 'Horizontal line' => __( 'Horizontal line' ), |
1122 'Horizontal space' => __( 'Horizontal space' ), |
1148 'Horizontal space' => __( 'Horizontal space' ), |
1123 'Restore last draft' => __( 'Restore last draft' ), |
1149 'Restore last draft' => __( 'Restore last draft' ), |
1124 'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ), |
1150 'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ), |
1125 'Remove link' => array( __( 'Remove link' ), 'accessS' ), |
1151 'Remove link' => array( __( 'Remove link' ), 'accessS' ), |
1126 |
1152 |
1127 // Link plugin |
1153 // Link plugin |
1128 'Link' => __( 'Link' ), |
1154 'Link' => __( 'Link' ), |
1129 'Insert link' => __( 'Insert link' ), |
1155 'Insert link' => __( 'Insert link' ), |
1130 'Insert/edit link' => __( 'Insert/edit link' ), |
1156 'Target' => __( 'Target' ), |
1131 'Target' => __( 'Target' ), |
1157 'New window' => __( 'New window' ), |
1132 'New window' => __( 'New window' ), |
1158 'Text to display' => __( 'Text to display' ), |
1133 'Text to display' => __( 'Text to display' ), |
1159 'Url' => __( 'URL' ), |
1134 'Url' => __( 'URL' ), |
1160 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' => |
1135 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' => |
1161 __( 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' ), |
1136 __( 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' ), |
1162 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' => |
1137 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' => |
1163 __( 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' ), |
1138 __( 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' ), |
1164 |
1139 |
1165 'Color' => __( 'Color' ), |
1140 'Color' => __( 'Color' ), |
1166 'Custom color' => __( 'Custom color' ), |
1141 'Custom color' => __( 'Custom color' ), |
1167 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis |
1142 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis |
1168 'No color' => __( 'No color' ), |
1143 'No color' => __( 'No color' ), |
1169 'R' => _x( 'R', 'Short for red in RGB' ), |
1144 'R' => _x( 'R', 'Short for red in RGB' ), |
1170 'G' => _x( 'G', 'Short for green in RGB' ), |
1145 'G' => _x( 'G', 'Short for green in RGB' ), |
1171 'B' => _x( 'B', 'Short for blue in RGB' ), |
1146 'B' => _x( 'B', 'Short for blue in RGB' ), |
1172 |
1147 |
1173 // Spelling, search/replace plugins |
1148 // Spelling, search/replace plugins |
1174 'Could not find the specified string.' => __( 'Could not find the specified string.' ), |
1149 'Could not find the specified string.' => __( 'Could not find the specified string.' ), |
1175 'Replace' => _x( 'Replace', 'find/replace' ), |
1150 'Replace' => _x( 'Replace', 'find/replace' ), |
1176 'Next' => _x( 'Next', 'find/replace' ), |
1151 'Next' => _x( 'Next', 'find/replace' ), |
1177 /* translators: previous */ |
1152 /* translators: previous */ |
1178 'Prev' => _x( 'Prev', 'find/replace' ), |
1153 'Prev' => _x( 'Prev', 'find/replace' ), |
1179 'Whole words' => _x( 'Whole words', 'find/replace' ), |
1154 'Whole words' => _x( 'Whole words', 'find/replace' ), |
1180 'Find and replace' => __( 'Find and replace' ), |
1155 'Find and replace' => __( 'Find and replace' ), |
1181 'Replace with' => _x( 'Replace with', 'find/replace' ), |
1156 'Replace with' => _x('Replace with', 'find/replace' ), |
1182 'Find' => _x( 'Find', 'find/replace' ), |
1157 'Find' => _x( 'Find', 'find/replace' ), |
1183 'Replace all' => _x( 'Replace all', 'find/replace' ), |
1158 'Replace all' => _x( 'Replace all', 'find/replace' ), |
1184 'Match case' => __( 'Match case' ), |
1159 'Match case' => __( 'Match case' ), |
1185 'Spellcheck' => __( 'Check Spelling' ), |
1160 'Spellcheck' => __( 'Check Spelling' ), |
1186 'Finish' => _x( 'Finish', 'spellcheck' ), |
1161 'Finish' => _x( 'Finish', 'spellcheck' ), |
1187 'Ignore all' => _x( 'Ignore all', 'spellcheck' ), |
1162 'Ignore all' => _x( 'Ignore all', 'spellcheck' ), |
1188 'Ignore' => _x( 'Ignore', 'spellcheck' ), |
1163 'Ignore' => _x( 'Ignore', 'spellcheck' ), |
1189 'Add to Dictionary' => __( 'Add to Dictionary' ), |
1164 'Add to Dictionary' => __( 'Add to Dictionary' ), |
1190 |
1165 |
1191 // TinyMCE tables |
1166 // TinyMCE tables |
1192 'Insert table' => __( 'Insert table' ), |
1167 'Insert table' => __( 'Insert table' ), |
1193 'Delete table' => __( 'Delete table' ), |
1168 'Delete table' => __( 'Delete table' ), |
1194 'Table properties' => __( 'Table properties' ), |
1169 'Table properties' => __( 'Table properties' ), |
1195 'Row properties' => __( 'Table row properties' ), |
1170 'Row properties' => __( 'Table row properties' ), |
1196 'Cell properties' => __( 'Table cell properties' ), |
1171 'Cell properties' => __( 'Table cell properties' ), |
1197 'Border color' => __( 'Border color' ), |
1172 'Border color' => __( 'Border color' ), |
1198 |
1173 |
1199 'Row' => __( 'Row' ), |
1174 'Row' => __( 'Row' ), |
1200 'Rows' => __( 'Rows' ), |
1175 'Rows' => __( 'Rows' ), |
1201 'Column' => _x( 'Column', 'table column' ), |
1176 'Column' => _x( 'Column', 'table column' ), |
1202 'Cols' => _x( 'Cols', 'table columns' ), |
1177 'Cols' => _x( 'Cols', 'table columns' ), |
1203 'Cell' => _x( 'Cell', 'table cell' ), |
1178 'Cell' => _x( 'Cell', 'table cell' ), |
1204 'Header cell' => __( 'Header cell' ), |
1179 'Header cell' => __( 'Header cell' ), |
1205 'Header' => _x( 'Header', 'table header' ), |
1180 'Header' => _x( 'Header', 'table header' ), |
1206 'Body' => _x( 'Body', 'table body' ), |
1181 'Body' => _x( 'Body', 'table body' ), |
1207 'Footer' => _x( 'Footer', 'table footer' ), |
1182 'Footer' => _x( 'Footer', 'table footer' ), |
1208 |
1183 |
1209 'Insert row before' => __( 'Insert row before' ), |
1184 'Insert row before' => __( 'Insert row before' ), |
1210 'Insert row after' => __( 'Insert row after' ), |
1185 'Insert row after' => __( 'Insert row after' ), |
1211 'Insert column before' => __( 'Insert column before' ), |
1186 'Insert column before' => __( 'Insert column before' ), |
1212 'Insert column after' => __( 'Insert column after' ), |
1187 'Insert column after' => __( 'Insert column after' ), |
1213 'Paste row before' => __( 'Paste table row before' ), |
1188 'Paste row before' => __( 'Paste table row before' ), |
1214 'Paste row after' => __( 'Paste table row after' ), |
1189 'Paste row after' => __( 'Paste table row after' ), |
1215 'Delete row' => __( 'Delete row' ), |
1190 'Delete row' => __( 'Delete row' ), |
1216 'Delete column' => __( 'Delete column' ), |
1191 'Delete column' => __( 'Delete column' ), |
1217 'Cut row' => __( 'Cut table row' ), |
1192 'Cut row' => __( 'Cut table row' ), |
1218 'Copy row' => __( 'Copy table row' ), |
1193 'Copy row' => __( 'Copy table row' ), |
1219 'Merge cells' => __( 'Merge table cells' ), |
1194 'Merge cells' => __( 'Merge table cells' ), |
1220 'Split cell' => __( 'Split table cell' ), |
1195 'Split cell' => __( 'Split table cell' ), |
1221 |
1196 |
1222 'Height' => __( 'Height' ), |
1197 'Height' => __( 'Height' ), |
1223 'Width' => __( 'Width' ), |
1198 'Width' => __( 'Width' ), |
1224 'Caption' => __( 'Caption' ), |
1199 'Caption' => __( 'Caption' ), |
1225 'Alignment' => __( 'Alignment' ), |
1200 'Alignment' => __( 'Alignment' ), |
1226 'H Align' => _x( 'H Align', 'horizontal table cell alignment' ), |
1201 'H Align' => _x( 'H Align', 'horizontal table cell alignment' ), |
1227 'Left' => __( 'Left' ), |
1202 'Left' => __( 'Left' ), |
1228 'Center' => __( 'Center' ), |
1203 'Center' => __( 'Center' ), |
1229 'Right' => __( 'Right' ), |
1204 'Right' => __( 'Right' ), |
1230 'None' => _x( 'None', 'table cell alignment attribute' ), |
1205 'None' => _x( 'None', 'table cell alignment attribute' ), |
1231 'V Align' => _x( 'V Align', 'vertical table cell alignment' ), |
1206 'V Align' => _x( 'V Align', 'vertical table cell alignment' ), |
1232 'Top' => __( 'Top' ), |
1207 'Top' => __( 'Top' ), |
1233 'Middle' => __( 'Middle' ), |
1208 'Middle' => __( 'Middle' ), |
1234 'Bottom' => __( 'Bottom' ), |
1209 'Bottom' => __( 'Bottom' ), |
1235 |
1210 |
1236 'Row group' => __( 'Row group' ), |
1211 'Row group' => __( 'Row group' ), |
1237 'Column group' => __( 'Column group' ), |
1212 'Column group' => __( 'Column group' ), |
1238 'Row type' => __( 'Row type' ), |
1213 'Row type' => __( 'Row type' ), |
1239 'Cell type' => __( 'Cell type' ), |
1214 'Cell type' => __( 'Cell type' ), |
1240 'Cell padding' => __( 'Cell padding' ), |
1215 'Cell padding' => __( 'Cell padding' ), |
1241 'Cell spacing' => __( 'Cell spacing' ), |
1216 'Cell spacing' => __( 'Cell spacing' ), |
1242 'Scope' => _x( 'Scope', 'table cell scope attribute' ), |
1217 'Scope' => _x( 'Scope', 'table cell scope attribute' ), |
1243 |
1218 |
1244 'Insert template' => _x( 'Insert template', 'TinyMCE' ), |
1219 'Insert template' => _x( 'Insert template', 'TinyMCE' ), |
1245 'Templates' => _x( 'Templates', 'TinyMCE' ), |
1220 'Templates' => _x( 'Templates', 'TinyMCE' ), |
1246 |
1221 |
1247 'Background color' => __( 'Background color' ), |
1222 'Background color' => __( 'Background color' ), |
1248 'Text color' => __( 'Text color' ), |
1223 'Text color' => __( 'Text color' ), |
1249 'Show blocks' => _x( 'Show blocks', 'editor button' ), |
1224 'Show blocks' => _x( 'Show blocks', 'editor button' ), |
1250 'Show invisible characters' => __( 'Show invisible characters' ), |
1225 'Show invisible characters' => __( 'Show invisible characters' ), |
1251 |
1226 |
1252 /* translators: word count */ |
1227 /* translators: word count */ |
1253 'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ), |
1228 'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ), |
1254 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => |
1229 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => |
1255 __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . |
1230 __( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . |
1256 __( '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.' ), |
1231 __( '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.' ), |
1257 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => |
1232 'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => |
1258 __( 'Rich Text Area. Press Alt-Shift-H for help.' ), |
1233 __( 'Rich Text Area. Press Alt-Shift-H for help.' ), |
1259 'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ), |
1234 'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ), |
1260 'You have unsaved changes are you sure you want to navigate away?' => |
1235 'You have unsaved changes are you sure you want to navigate away?' => |
1261 __( 'The changes you made will be lost if you navigate away from this page.' ), |
1236 __( 'The changes you made will be lost if you navigate away from this page.' ), |
1262 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => |
1237 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => |
1263 __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), |
1238 __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), |
1264 |
1239 |
1265 // TinyMCE menus |
1240 // TinyMCE menus |
1266 'Insert' => _x( 'Insert', 'TinyMCE menu' ), |
1241 'Insert' => _x( 'Insert', 'TinyMCE menu' ), |
1267 'File' => _x( 'File', 'TinyMCE menu' ), |
1242 'File' => _x( 'File', 'TinyMCE menu' ), |
1268 'Edit' => _x( 'Edit', 'TinyMCE menu' ), |
1243 'Edit' => _x( 'Edit', 'TinyMCE menu' ), |
1269 'Tools' => _x( 'Tools', 'TinyMCE menu' ), |
1244 'Tools' => _x( 'Tools', 'TinyMCE menu' ), |
1270 'View' => _x( 'View', 'TinyMCE menu' ), |
1245 'View' => _x( 'View', 'TinyMCE menu' ), |
1271 'Table' => _x( 'Table', 'TinyMCE menu' ), |
1246 'Table' => _x( 'Table', 'TinyMCE menu' ), |
1272 'Format' => _x( 'Format', 'TinyMCE menu' ), |
1247 'Format' => _x( 'Format', 'TinyMCE menu' ), |
1273 |
1248 |
1274 // WordPress strings |
1249 // WordPress strings |
1275 'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ), |
1250 'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ), |
1276 'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ), |
1251 'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ), |
1277 'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ), |
1252 'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ), |
1278 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) |
1253 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) |
1279 'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ), |
1254 'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ), |
1280 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar |
1255 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar |
1281 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar |
1256 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar |
1282 'Edit|button' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar |
1257 'Edit ' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar |
1283 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog |
1258 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog |
1284 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog |
1259 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog |
1285 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog |
1260 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog |
1286 'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label |
1261 'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label |
1287 'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label |
1262 'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label |
1288 'Add Media' => array( __( 'Add Media' ), 'accessM' ), // Tooltip for the 'Add Media' button in the Block Editor Classic block |
1263 |
1289 |
1264 // Shortcuts help modal |
1290 // Shortcuts help modal |
1265 'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ), |
1291 'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ), |
1266 'Default shortcuts,' => __( 'Default shortcuts,' ), |
1292 'Classic Block Keyboard Shortcuts' => __( 'Classic Block Keyboard Shortcuts' ), |
1267 'Additional shortcuts,' => __( 'Additional shortcuts,' ), |
1293 'Default shortcuts,' => __( 'Default shortcuts,' ), |
1268 'Focus shortcuts:' => __( 'Focus shortcuts:' ), |
1294 'Additional shortcuts,' => __( 'Additional shortcuts,' ), |
1269 'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ), |
1295 'Focus shortcuts:' => __( 'Focus shortcuts:' ), |
1270 'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ), |
1296 'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ), |
1271 'Editor toolbar' => __( 'Editor toolbar' ), |
1297 'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ), |
1272 'Elements path' => __( 'Elements path' ), |
1298 'Editor toolbar' => __( 'Editor toolbar' ), |
1273 'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ), |
1299 'Elements path' => __( 'Elements path' ), |
1274 'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ), |
1300 'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ), |
1275 'Cmd + letter:' => __( 'Cmd + letter:' ), |
1301 'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ), |
1276 'Ctrl + letter:' => __( 'Ctrl + letter:' ), |
1302 'Cmd + letter:' => __( 'Cmd + letter:' ), |
1277 'Letter' => __( 'Letter' ), |
1303 'Ctrl + letter:' => __( 'Ctrl + letter:' ), |
1278 'Action' => __( 'Action' ), |
1304 'Letter' => __( 'Letter' ), |
1279 '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.' ), |
1305 'Action' => __( 'Action' ), |
1280 '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.' => |
1306 '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.' ), |
1281 __( '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.' ), |
1307 '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.' => |
1282 '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.' => |
1308 __( '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.' ), |
1283 __( '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.' ), |
1309 '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.' => |
1284 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => |
1310 __( '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.' ), |
1285 __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ), |
1311 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => |
1286 '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.' => |
1312 __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ), |
1287 __( '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.' ), |
1313 '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.' => |
1314 __( '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.' ), |
|
1288 ); |
1315 ); |
1289 } |
1316 } |
1290 |
1317 |
1291 /* |
1318 /* |
1292 Imagetools plugin (not included): |
1319 Imagetools plugin (not included): |
1315 |
1342 |
1316 /** |
1343 /** |
1317 * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), |
1344 * Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), |
1318 * or as JS snippet that should run after tinymce.js is loaded. |
1345 * or as JS snippet that should run after tinymce.js is loaded. |
1319 * |
1346 * |
1320 * @static |
|
1321 * @param string $mce_locale The locale used for the editor. |
1347 * @param string $mce_locale The locale used for the editor. |
1322 * @param bool $json_only optional Whether to include the JavaScript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone(). |
1348 * @param bool $json_only optional Whether to include the JavaScript calls to tinymce.addI18n() and tinymce.ScriptLoader.markDone(). |
1323 * @return string Translation object, JSON encoded. |
1349 * @return string Translation object, JSON encoded. |
1324 */ |
1350 */ |
1325 public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { |
1351 public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { |
1329 |
1355 |
1330 $mce_translation = self::get_translation(); |
1356 $mce_translation = self::get_translation(); |
1331 |
1357 |
1332 foreach ( $mce_translation as $name => $value ) { |
1358 foreach ( $mce_translation as $name => $value ) { |
1333 if ( is_array( $value ) ) { |
1359 if ( is_array( $value ) ) { |
1334 $mce_translation[$name] = $value[0]; |
1360 $mce_translation[ $name ] = $value[0]; |
1335 } |
1361 } |
1336 } |
1362 } |
1337 |
1363 |
1338 /** |
1364 /** |
1339 * Filters translated strings prepared for TinyMCE. |
1365 * Filters translated strings prepared for TinyMCE. |
1346 $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); |
1372 $mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); |
1347 |
1373 |
1348 foreach ( $mce_translation as $key => $value ) { |
1374 foreach ( $mce_translation as $key => $value ) { |
1349 // Remove strings that are not translated. |
1375 // Remove strings that are not translated. |
1350 if ( $key === $value ) { |
1376 if ( $key === $value ) { |
1351 unset( $mce_translation[$key] ); |
1377 unset( $mce_translation[ $key ] ); |
1352 continue; |
1378 continue; |
1353 } |
1379 } |
1354 |
1380 |
1355 if ( false !== strpos( $value, '&' ) ) { |
1381 if ( false !== strpos( $value, '&' ) ) { |
1356 $mce_translation[$key] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); |
1382 $mce_translation[ $key ] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); |
1357 } |
1383 } |
1358 } |
1384 } |
1359 |
1385 |
1360 // Set direction |
1386 // Set direction |
1361 if ( is_rtl() ) { |
1387 if ( is_rtl() ) { |
1371 return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . |
1397 return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . |
1372 "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; |
1398 "tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; |
1373 } |
1399 } |
1374 |
1400 |
1375 /** |
1401 /** |
1402 * Force uncompressed TinyMCE when a custom theme has been defined. |
|
1403 * |
|
1404 * The compressed TinyMCE file cannot deal with custom themes, so this makes |
|
1405 * sure that we use the uncompressed TinyMCE file if a theme is defined. |
|
1406 * Even if we are on a production environment. |
|
1407 */ |
|
1408 public static function force_uncompressed_tinymce() { |
|
1409 $has_custom_theme = false; |
|
1410 foreach ( self::$mce_settings as $init ) { |
|
1411 if ( ! empty( $init['theme_url'] ) ) { |
|
1412 $has_custom_theme = true; |
|
1413 break; |
|
1414 } |
|
1415 } |
|
1416 |
|
1417 if ( ! $has_custom_theme ) { |
|
1418 return; |
|
1419 } |
|
1420 |
|
1421 $wp_scripts = wp_scripts(); |
|
1422 |
|
1423 $wp_scripts->remove( 'wp-tinymce' ); |
|
1424 wp_register_tinymce_scripts( $wp_scripts, true ); |
|
1425 } |
|
1426 |
|
1427 /** |
|
1376 * Print (output) the main TinyMCE scripts. |
1428 * Print (output) the main TinyMCE scripts. |
1377 * |
1429 * |
1378 * @since 4.8.0 |
1430 * @since 4.8.0 |
1379 * |
1431 * |
1380 * @static |
|
1381 * @global string $tinymce_version |
1432 * @global string $tinymce_version |
1382 * @global bool $concatenate_scripts |
1433 * @global bool $concatenate_scripts |
1383 * @global bool $compress_scripts |
1434 * @global bool $compress_scripts |
1384 */ |
1435 */ |
1385 public static function print_tinymce_scripts() { |
1436 public static function print_tinymce_scripts() { |
1386 global $tinymce_version, $concatenate_scripts, $compress_scripts; |
1437 global $concatenate_scripts; |
1387 |
1438 |
1388 if ( self::$tinymce_scripts_printed ) { |
1439 if ( self::$tinymce_scripts_printed ) { |
1389 return; |
1440 return; |
1390 } |
1441 } |
1391 |
1442 |
1393 |
1444 |
1394 if ( ! isset( $concatenate_scripts ) ) { |
1445 if ( ! isset( $concatenate_scripts ) ) { |
1395 script_concat_settings(); |
1446 script_concat_settings(); |
1396 } |
1447 } |
1397 |
1448 |
1398 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
1449 wp_print_scripts( array( 'wp-tinymce' ) ); |
1399 $version = 'ver=' . $tinymce_version; |
|
1400 $baseurl = self::get_baseurl(); |
|
1401 |
|
1402 $has_custom_theme = false; |
|
1403 foreach ( self::$mce_settings as $init ) { |
|
1404 if ( ! empty( $init['theme_url'] ) ) { |
|
1405 $has_custom_theme = true; |
|
1406 break; |
|
1407 } |
|
1408 } |
|
1409 |
|
1410 $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) |
|
1411 && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $has_custom_theme; |
|
1412 |
|
1413 // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG) |
|
1414 $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min'; |
|
1415 |
|
1416 if ( $compressed ) { |
|
1417 echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n"; |
|
1418 } else { |
|
1419 echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n"; |
|
1420 echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n"; |
|
1421 } |
|
1422 |
1450 |
1423 echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; |
1451 echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; |
1424 } |
1452 } |
1425 |
1453 |
1426 /** |
1454 /** |
1427 * Print (output) the TinyMCE configuration and initialization scripts. |
1455 * Print (output) the TinyMCE configuration and initialization scripts. |
1428 * |
1456 * |
1429 * @static |
|
1430 * @global string $tinymce_version |
1457 * @global string $tinymce_version |
1431 */ |
1458 */ |
1432 public static function editor_js() { |
1459 public static function editor_js() { |
1433 global $tinymce_version; |
1460 global $tinymce_version; |
1434 |
1461 |
1435 $tmce_on = ! empty( self::$mce_settings ); |
1462 $tmce_on = ! empty( self::$mce_settings ); |
1436 $mceInit = $qtInit = ''; |
1463 $mceInit = $qtInit = ''; |
1437 |
1464 |
1438 if ( $tmce_on ) { |
1465 if ( $tmce_on ) { |
1439 foreach ( self::$mce_settings as $editor_id => $init ) { |
1466 foreach ( self::$mce_settings as $editor_id => $init ) { |
1440 $options = self::_parse_init( $init ); |
1467 $options = self::_parse_init( $init ); |
1441 $mceInit .= "'$editor_id':{$options},"; |
1468 $mceInit .= "'$editor_id':{$options},"; |
1442 } |
1469 } |
1443 $mceInit = '{' . trim( $mceInit, ',' ) . '}'; |
1470 $mceInit = '{' . trim( $mceInit, ',' ) . '}'; |
1444 } else { |
1471 } else { |
1445 $mceInit = '{}'; |
1472 $mceInit = '{}'; |
1454 } else { |
1481 } else { |
1455 $qtInit = '{}'; |
1482 $qtInit = '{}'; |
1456 } |
1483 } |
1457 |
1484 |
1458 $ref = array( |
1485 $ref = array( |
1459 'plugins' => implode( ',', self::$plugins ), |
1486 'plugins' => implode( ',', self::$plugins ), |
1460 'theme' => 'modern', |
1487 'theme' => 'modern', |
1461 'language' => self::$mce_locale |
1488 'language' => self::$mce_locale, |
1462 ); |
1489 ); |
1463 |
1490 |
1464 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
1491 $suffix = SCRIPT_DEBUG ? '' : '.min'; |
1465 $baseurl = self::get_baseurl(); |
1492 $baseurl = self::get_baseurl(); |
1466 $version = 'ver=' . $tinymce_version; |
1493 $version = 'ver=' . $tinymce_version; |
1467 |
1494 |
1468 /** |
1495 /** |
1469 * Fires immediately before the TinyMCE settings are printed. |
1496 * Fires immediately before the TinyMCE settings are printed. |
1515 |
1542 |
1516 ?> |
1543 ?> |
1517 <script type="text/javascript"> |
1544 <script type="text/javascript"> |
1518 <?php |
1545 <?php |
1519 |
1546 |
1520 if ( self::$ext_plugins ) |
1547 if ( self::$ext_plugins ) { |
1521 echo self::$ext_plugins . "\n"; |
1548 echo self::$ext_plugins . "\n"; |
1522 |
1549 } |
1523 if ( ! is_admin() ) |
1550 |
1551 if ( ! is_admin() ) { |
|
1524 echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; |
1552 echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; |
1553 } |
|
1525 |
1554 |
1526 ?> |
1555 ?> |
1527 |
1556 |
1528 ( function() { |
1557 ( function() { |
1529 var init, id, $wrap; |
1558 var init, id, $wrap; |
1578 /** |
1607 /** |
1579 * Outputs the HTML for distraction-free writing mode. |
1608 * Outputs the HTML for distraction-free writing mode. |
1580 * |
1609 * |
1581 * @since 3.2.0 |
1610 * @since 3.2.0 |
1582 * @deprecated 4.3.0 |
1611 * @deprecated 4.3.0 |
1583 * |
|
1584 * @static |
|
1585 */ |
1612 */ |
1586 public static function wp_fullscreen_html() { |
1613 public static function wp_fullscreen_html() { |
1587 _deprecated_function( __FUNCTION__, '4.3.0' ); |
1614 _deprecated_function( __FUNCTION__, '4.3.0' ); |
1588 } |
1615 } |
1589 |
1616 |
1590 /** |
1617 /** |
1591 * Performs post queries for internal linking. |
1618 * Performs post queries for internal linking. |
1592 * |
1619 * |
1593 * @since 3.1.0 |
1620 * @since 3.1.0 |
1594 * |
1621 * |
1595 * @static |
|
1596 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. |
1622 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. |
1597 * @return false|array Results. |
1623 * @return false|array Results. |
1598 */ |
1624 */ |
1599 public static function wp_link_query( $args = array() ) { |
1625 public static function wp_link_query( $args = array() ) { |
1600 $pts = get_post_types( array( 'public' => true ), 'objects' ); |
1626 $pts = get_post_types( array( 'public' => true ), 'objects' ); |
1601 $pt_names = array_keys( $pts ); |
1627 $pt_names = array_keys( $pts ); |
1602 |
1628 |
1603 $query = array( |
1629 $query = array( |
1604 'post_type' => $pt_names, |
1630 'post_type' => $pt_names, |
1605 'suppress_filters' => true, |
1631 'suppress_filters' => true, |
1606 'update_post_term_cache' => false, |
1632 'update_post_term_cache' => false, |
1607 'update_post_meta_cache' => false, |
1633 'update_post_meta_cache' => false, |
1608 'post_status' => 'publish', |
1634 'post_status' => 'publish', |
1609 'posts_per_page' => 20, |
1635 'posts_per_page' => 20, |
1610 ); |
1636 ); |
1611 |
1637 |
1612 $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; |
1638 $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; |
1613 |
1639 |
1614 if ( isset( $args['s'] ) ) |
1640 if ( isset( $args['s'] ) ) { |
1615 $query['s'] = $args['s']; |
1641 $query['s'] = $args['s']; |
1642 } |
|
1616 |
1643 |
1617 $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; |
1644 $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; |
1618 |
1645 |
1619 /** |
1646 /** |
1620 * Filters the link query arguments. |
1647 * Filters the link query arguments. |
1629 */ |
1656 */ |
1630 $query = apply_filters( 'wp_link_query_args', $query ); |
1657 $query = apply_filters( 'wp_link_query_args', $query ); |
1631 |
1658 |
1632 // Do main query. |
1659 // Do main query. |
1633 $get_posts = new WP_Query; |
1660 $get_posts = new WP_Query; |
1634 $posts = $get_posts->query( $query ); |
1661 $posts = $get_posts->query( $query ); |
1635 |
1662 |
1636 // Build results. |
1663 // Build results. |
1637 $results = array(); |
1664 $results = array(); |
1638 foreach ( $posts as $post ) { |
1665 foreach ( $posts as $post ) { |
1639 if ( 'post' == $post->post_type ) |
1666 if ( 'post' == $post->post_type ) { |
1640 $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
1667 $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
1641 else |
1668 } else { |
1642 $info = $pts[ $post->post_type ]->labels->singular_name; |
1669 $info = $pts[ $post->post_type ]->labels->singular_name; |
1670 } |
|
1643 |
1671 |
1644 $results[] = array( |
1672 $results[] = array( |
1645 'ID' => $post->ID, |
1673 'ID' => $post->ID, |
1646 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
1674 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
1647 'permalink' => get_permalink( $post->ID ), |
1675 'permalink' => get_permalink( $post->ID ), |
1648 'info' => $info, |
1676 'info' => $info, |
1649 ); |
1677 ); |
1650 } |
1678 } |
1651 |
1679 |
1652 /** |
1680 /** |
1653 * Filters the link query results. |
1681 * Filters the link query results. |
1678 |
1706 |
1679 /** |
1707 /** |
1680 * Dialog for internal linking. |
1708 * Dialog for internal linking. |
1681 * |
1709 * |
1682 * @since 3.1.0 |
1710 * @since 3.1.0 |
1683 * |
|
1684 * @static |
|
1685 */ |
1711 */ |
1686 public static function wp_link_dialog() { |
1712 public static function wp_link_dialog() { |
1687 // Run once |
1713 // Run once |
1688 if ( self::$link_dialog_printed ) { |
1714 if ( self::$link_dialog_printed ) { |
1689 return; |
1715 return; |
1695 ?> |
1721 ?> |
1696 <div id="wp-link-backdrop" style="display: none"></div> |
1722 <div id="wp-link-backdrop" style="display: none"></div> |
1697 <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> |
1723 <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> |
1698 <form id="wp-link" tabindex="-1"> |
1724 <form id="wp-link" tabindex="-1"> |
1699 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> |
1725 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> |
1700 <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> |
1726 <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ); ?></h1> |
1701 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> |
1727 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> |
1702 <div id="link-selector"> |
1728 <div id="link-selector"> |
1703 <div id="link-options"> |
1729 <div id="link-options"> |
1704 <p class="howto" id="wplink-enter-url"><?php _e( 'Enter the destination URL' ); ?></p> |
1730 <p class="howto" id="wplink-enter-url"><?php _e( 'Enter the destination URL' ); ?></p> |
1705 <div> |
1731 <div> |
1737 </div> |
1763 </div> |
1738 <ul></ul> |
1764 <ul></ul> |
1739 <div class="river-waiting"> |
1765 <div class="river-waiting"> |
1740 <span class="spinner"></span> |
1766 <span class="spinner"></span> |
1741 </div> |
1767 </div> |
1742 </div> |
1768 </div> |
1743 </div> |
1769 </div> |
1744 </div> |
1770 </div> |
1745 <div class="submitbox"> |
1771 <div class="submitbox"> |
1746 <div id="wp-link-cancel"> |
1772 <div id="wp-link-cancel"> |
1747 <button type="button" class="button"><?php _e( 'Cancel' ); ?></button> |
1773 <button type="button" class="button"><?php _e( 'Cancel' ); ?></button> |
1748 </div> |
1774 </div> |