author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
parent 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Facilitates adding of the WordPress editor as used on the Write and Edit screens. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @since 3.3.0 |
|
7 |
* |
|
8 |
* Private, not included by default. See wp_editor() in wp-includes/general-template.php. |
|
9 |
*/ |
|
10 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
11 |
#[AllowDynamicProperties] |
0 | 12 |
final class _WP_Editors { |
13 |
public static $mce_locale; |
|
14 |
||
15 |
private static $mce_settings = array(); |
|
9 | 16 |
private static $qt_settings = array(); |
17 |
private static $plugins = array(); |
|
18 |
private static $qt_buttons = array(); |
|
0 | 19 |
private static $ext_plugins; |
20 |
private static $baseurl; |
|
21 |
private static $first_init; |
|
9 | 22 |
private static $this_tinymce = false; |
23 |
private static $this_quicktags = false; |
|
24 |
private static $has_tinymce = false; |
|
25 |
private static $has_quicktags = false; |
|
26 |
private static $has_medialib = false; |
|
0 | 27 |
private static $editor_buttons_css = true; |
9 | 28 |
private static $drag_drop_upload = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
private static $translation; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
private static $tinymce_scripts_printed = false; |
9 | 31 |
private static $link_dialog_printed = false; |
0 | 32 |
|
33 |
private function __construct() {} |
|
34 |
||
5 | 35 |
/** |
36 |
* Parse default arguments for the editor instance. |
|
37 |
* |
|
16 | 38 |
* @since 3.3.0 |
39 |
* |
|
40 |
* @param string $editor_id HTML ID for the textarea and TinyMCE and Quicktags instances. |
|
41 |
* Should not contain square brackets. |
|
5 | 42 |
* @param array $settings { |
43 |
* Array of editor arguments. |
|
44 |
* |
|
45 |
* @type bool $wpautop Whether to use wpautop(). Default true. |
|
46 |
* @type bool $media_buttons Whether to show the Add Media/other media buttons. |
|
47 |
* @type string $default_editor When both TinyMCE and Quicktags are used, set which |
|
48 |
* editor is shown on page load. Default empty. |
|
49 |
* @type bool $drag_drop_upload Whether to enable drag & drop on the editor uploading. Default false. |
|
50 |
* Requires the media modal. |
|
51 |
* @type string $textarea_name Give the textarea a unique name here. Square brackets |
|
52 |
* can be used here. Default $editor_id. |
|
53 |
* @type int $textarea_rows Number rows in the editor textarea. Default 20. |
|
54 |
* @type string|int $tabindex Tabindex value to use. Default empty. |
|
55 |
* @type string $tabfocus_elements The previous and next element ID to move the focus to |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* when pressing the Tab key in TinyMCE. Default ':prev,:next'. |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
57 |
* @type string $editor_css Intended for extra styles for both Visual and Code editors. |
5 | 58 |
* Should include `<style>` tags, and can use "scoped". Default empty. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
* @type string $editor_class Extra classes to add to the editor textarea element. Default empty. |
5 | 60 |
* @type bool $teeny Whether to output the minimal editor config. Examples include |
61 |
* Press This and the Comment editor. Default false. |
|
16 | 62 |
* @type bool $dfw Deprecated in 4.1. Unused. |
5 | 63 |
* @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to |
64 |
* TinyMCE using an array. Default true. |
|
65 |
* @type bool|array $quicktags Whether to load Quicktags. Can be used to pass settings directly to |
|
66 |
* Quicktags using an array. Default true. |
|
67 |
* } |
|
68 |
* @return array Parsed arguments array. |
|
69 |
*/ |
|
70 |
public static function parse_settings( $editor_id, $settings ) { |
|
71 |
||
72 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
* Filters the wp_editor() settings. |
5 | 74 |
* |
75 |
* @since 4.0.0 |
|
76 |
* |
|
9 | 77 |
* @see _WP_Editors::parse_settings() |
5 | 78 |
* |
79 |
* @param array $settings Array of editor arguments. |
|
16 | 80 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
81 |
* when called from block editor's Classic block. |
|
5 | 82 |
*/ |
83 |
$settings = apply_filters( 'wp_editor_settings', $settings, $editor_id ); |
|
84 |
||
9 | 85 |
$set = wp_parse_args( |
86 |
$settings, |
|
87 |
array( |
|
88 |
// Disable autop if the current post has blocks in it. |
|
89 |
'wpautop' => ! has_blocks(), |
|
90 |
'media_buttons' => true, |
|
91 |
'default_editor' => '', |
|
92 |
'drag_drop_upload' => false, |
|
93 |
'textarea_name' => $editor_id, |
|
94 |
'textarea_rows' => 20, |
|
95 |
'tabindex' => '', |
|
96 |
'tabfocus_elements' => ':prev,:next', |
|
97 |
'editor_css' => '', |
|
98 |
'editor_class' => '', |
|
99 |
'teeny' => false, |
|
100 |
'_content_editor_dfw' => false, |
|
101 |
'tinymce' => true, |
|
102 |
'quicktags' => true, |
|
103 |
) |
|
104 |
); |
|
0 | 105 |
|
106 |
self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() ); |
|
5 | 107 |
|
108 |
if ( self::$this_tinymce ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
if ( str_contains( $editor_id, '[' ) ) { |
5 | 110 |
self::$this_tinymce = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
_deprecated_argument( 'wp_editor()', '3.9.0', 'TinyMCE editor IDs cannot have brackets.' ); |
5 | 112 |
} |
113 |
} |
|
114 |
||
0 | 115 |
self::$this_quicktags = (bool) $set['quicktags']; |
116 |
||
9 | 117 |
if ( self::$this_tinymce ) { |
0 | 118 |
self::$has_tinymce = true; |
9 | 119 |
} |
0 | 120 |
|
9 | 121 |
if ( self::$this_quicktags ) { |
0 | 122 |
self::$has_quicktags = true; |
9 | 123 |
} |
0 | 124 |
|
9 | 125 |
if ( empty( $set['editor_height'] ) ) { |
0 | 126 |
return $set; |
9 | 127 |
} |
0 | 128 |
|
5 | 129 |
if ( 'content' === $editor_id && empty( $set['tinymce']['wp_autoresize_on'] ) ) { |
0 | 130 |
// A cookie (set when a user resizes the editor) overrides the height. |
131 |
$cookie = (int) get_user_setting( 'ed_size' ); |
|
132 |
||
9 | 133 |
if ( $cookie ) { |
0 | 134 |
$set['editor_height'] = $cookie; |
9 | 135 |
} |
0 | 136 |
} |
137 |
||
9 | 138 |
if ( $set['editor_height'] < 50 ) { |
0 | 139 |
$set['editor_height'] = 50; |
9 | 140 |
} elseif ( $set['editor_height'] > 5000 ) { |
0 | 141 |
$set['editor_height'] = 5000; |
9 | 142 |
} |
0 | 143 |
|
144 |
return $set; |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* Outputs the HTML for a single instance of the editor. |
|
149 |
* |
|
16 | 150 |
* @since 3.3.0 |
151 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
152 |
* @global WP_Screen $current_screen WordPress current screen object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
153 |
* |
16 | 154 |
* @param string $content Initial content for the editor. |
155 |
* @param string $editor_id HTML ID for the textarea and TinyMCE and Quicktags instances. |
|
156 |
* Should not contain square brackets. |
|
157 |
* @param array $settings See _WP_Editors::parse_settings() for description. |
|
0 | 158 |
*/ |
159 |
public static function editor( $content, $editor_id, $settings = array() ) { |
|
9 | 160 |
$set = self::parse_settings( $editor_id, $settings ); |
161 |
$editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"'; |
|
162 |
$tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
$default_editor = 'html'; |
16 | 164 |
$buttons = ''; |
165 |
$autocomplete = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
$editor_id_attr = esc_attr( $editor_id ); |
5 | 167 |
|
168 |
if ( $set['drag_drop_upload'] ) { |
|
169 |
self::$drag_drop_upload = true; |
|
170 |
} |
|
0 | 171 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
if ( ! empty( $set['editor_height'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
$height = ' style="height: ' . (int) $set['editor_height'] . 'px"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
$height = ' rows="' . (int) $set['textarea_rows'] . '"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
} |
0 | 177 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
if ( ! current_user_can( 'upload_files' ) ) { |
0 | 179 |
$set['media_buttons'] = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
} |
0 | 181 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
if ( self::$this_tinymce ) { |
5 | 183 |
$autocomplete = ' autocomplete="off"'; |
0 | 184 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
if ( self::$this_quicktags ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
$default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor(); |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
187 |
// 'html' is used for the "Code" editor tab. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
if ( 'html' !== $default_editor ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
$default_editor = 'tinymce'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
} |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
191 |
$tmce_active = ( 'html' === $default_editor ) ? ' aria-pressed="true"' : ''; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
192 |
$html_active = ( 'html' === $default_editor ) ? '' : ' aria-pressed="true"'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
194 |
$buttons .= '<button type="button" id="' . $editor_id_attr . '-tmce"' . $html_active . ' class="wp-switch-editor switch-tmce"' . |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Visual', 'Name for the Visual editor tab' ) . "</button>\n"; |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
196 |
$buttons .= '<button type="button" id="' . $editor_id_attr . '-html"' . $tmce_active . ' class="wp-switch-editor switch-html"' . |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
197 |
' data-wp-editor-id="' . $editor_id_attr . '">' . _x( 'Code', 'Name for the Code editor tab (formerly Text)' ) . "</button>\n"; |
0 | 198 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
$default_editor = 'tinymce'; |
0 | 200 |
} |
201 |
} |
|
202 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
$switch_class = 'html' === $default_editor ? 'html-active' : 'tmce-active'; |
9 | 204 |
$wrap_class = 'wp-core-ui wp-editor-wrap ' . $switch_class; |
5 | 205 |
|
206 |
if ( $set['_content_editor_dfw'] ) { |
|
207 |
$wrap_class .= ' has-dfw'; |
|
208 |
} |
|
209 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
echo '<div id="wp-' . $editor_id_attr . '-wrap" class="' . $wrap_class . '">'; |
0 | 211 |
|
212 |
if ( self::$editor_buttons_css ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
wp_print_styles( 'editor-buttons' ); |
0 | 214 |
self::$editor_buttons_css = false; |
215 |
} |
|
216 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
if ( ! empty( $set['editor_css'] ) ) { |
0 | 218 |
echo $set['editor_css'] . "\n"; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
} |
0 | 220 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
221 |
if ( ! empty( $buttons ) || $set['media_buttons'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
echo '<div id="wp-' . $editor_id_attr . '-editor-tools" class="wp-editor-tools hide-if-no-js">'; |
0 | 223 |
|
224 |
if ( $set['media_buttons'] ) { |
|
225 |
self::$has_medialib = true; |
|
226 |
||
9 | 227 |
if ( ! function_exists( 'media_buttons' ) ) { |
16 | 228 |
require ABSPATH . 'wp-admin/includes/media.php'; |
9 | 229 |
} |
0 | 230 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
echo '<div id="wp-' . $editor_id_attr . '-media-buttons" class="wp-media-buttons">'; |
5 | 232 |
|
233 |
/** |
|
234 |
* Fires after the default media button(s) are displayed. |
|
235 |
* |
|
236 |
* @since 2.5.0 |
|
237 |
* |
|
238 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
|
239 |
*/ |
|
240 |
do_action( 'media_buttons', $editor_id ); |
|
0 | 241 |
echo "</div>\n"; |
242 |
} |
|
5 | 243 |
|
244 |
echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n"; |
|
0 | 245 |
echo "</div>\n"; |
246 |
} |
|
247 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
$quicktags_toolbar = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
if ( self::$this_quicktags ) { |
16 | 251 |
if ( 'content' === $editor_id && ! empty( $GLOBALS['current_screen'] ) && 'post' === $GLOBALS['current_screen']->base ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
$toolbar_id = 'ed_toolbar'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
$toolbar_id = 'qt_' . $editor_id_attr . '_toolbar'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
|
18 | 257 |
$quicktags_toolbar = '<div id="' . $toolbar_id . '" class="quicktags-toolbar hide-if-no-js"></div>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
|
5 | 260 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
* Filters the HTML markup output that displays the editor. |
5 | 262 |
* |
263 |
* @since 2.1.0 |
|
264 |
* |
|
265 |
* @param string $output Editor's HTML markup. |
|
266 |
*/ |
|
9 | 267 |
$the_editor = apply_filters( |
268 |
'the_editor', |
|
269 |
'<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
$quicktags_toolbar . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
'<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' . |
9 | 272 |
'id="' . $editor_id_attr . '">%s</textarea></div>' |
273 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
275 |
// Prepare the content for the Visual or Code editor, only when TinyMCE is used (back-compat). |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
if ( self::$this_tinymce ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
add_filter( 'the_editor_content', 'format_for_editor', 10, 2 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
} |
0 | 279 |
|
5 | 280 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
* Filters the default editor content. |
5 | 282 |
* |
283 |
* @since 2.1.0 |
|
284 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @param string $content Default editor content. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
* @param string $default_editor The default editor for the current user. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* Either 'html' or 'tinymce'. |
5 | 288 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
$content = apply_filters( 'the_editor_content', $content, $default_editor ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
// Remove the filter as the next editor on the same page may not need it. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
if ( self::$this_tinymce ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
remove_filter( 'the_editor_content', 'format_for_editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
|
16 | 296 |
// Back-compat for the `htmledit_pre` and `richedit_pre` filters. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
/** This filter is documented in wp-includes/deprecated.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
$content = apply_filters_deprecated( 'htmledit_pre', array( $content ), '4.3.0', 'format_for_editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
} elseif ( 'tinymce' === $default_editor && has_filter( 'richedit_pre' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
/** This filter is documented in wp-includes/deprecated.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
$content = apply_filters_deprecated( 'richedit_pre', array( $content ), '4.3.0', 'format_for_editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
if ( false !== stripos( $content, 'textarea' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
$content = preg_replace( '%</textarea%i', '</textarea', $content ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
} |
5 | 308 |
|
309 |
printf( $the_editor, $content ); |
|
0 | 310 |
echo "\n</div>\n\n"; |
311 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
self::editor_settings( $editor_id, $set ); |
0 | 313 |
} |
314 |
||
5 | 315 |
/** |
16 | 316 |
* @since 3.3.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
* |
16 | 318 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
319 |
* @param array $set Array of editor arguments. |
|
5 | 320 |
*/ |
9 | 321 |
public static function editor_settings( $editor_id, $set ) { |
322 |
if ( empty( self::$first_init ) ) { |
|
0 | 323 |
if ( is_admin() ) { |
5 | 324 |
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
9 | 325 |
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
5 | 326 |
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
0 | 327 |
} else { |
5 | 328 |
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); |
9 | 329 |
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
5 | 330 |
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); |
0 | 331 |
} |
332 |
} |
|
333 |
||
334 |
if ( self::$this_quicktags ) { |
|
335 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
$qt_init = array( |
9 | 337 |
'id' => $editor_id, |
338 |
'buttons' => '', |
|
0 | 339 |
); |
340 |
||
9 | 341 |
if ( is_array( $set['quicktags'] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
342 |
$qt_init = array_merge( $qt_init, $set['quicktags'] ); |
9 | 343 |
} |
0 | 344 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
345 |
if ( empty( $qt_init['buttons'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
346 |
$qt_init['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; |
9 | 347 |
} |
0 | 348 |
|
5 | 349 |
if ( $set['_content_editor_dfw'] ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
350 |
$qt_init['buttons'] .= ',dfw'; |
5 | 351 |
} |
352 |
||
353 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
* Filters the Quicktags settings. |
5 | 355 |
* |
356 |
* @since 3.3.0 |
|
357 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
358 |
* @param array $qt_init Quicktags settings. |
16 | 359 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
5 | 360 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
361 |
$qt_init = apply_filters( 'quicktags_settings', $qt_init, $editor_id ); |
5 | 362 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
363 |
self::$qt_settings[ $editor_id ] = $qt_init; |
0 | 364 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
365 |
self::$qt_buttons = array_merge( self::$qt_buttons, explode( ',', $qt_init['buttons'] ) ); |
0 | 366 |
} |
367 |
||
368 |
if ( self::$this_tinymce ) { |
|
369 |
||
5 | 370 |
if ( empty( self::$first_init ) ) { |
9 | 371 |
$baseurl = self::get_baseurl(); |
372 |
$mce_locale = self::get_mce_locale(); |
|
0 | 373 |
$ext_plugins = ''; |
374 |
||
375 |
if ( $set['teeny'] ) { |
|
5 | 376 |
|
377 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
* Filters the list of teenyMCE plugins. |
5 | 379 |
* |
380 |
* @since 2.7.0 |
|
16 | 381 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 382 |
* |
383 |
* @param array $plugins An array of teenyMCE plugins. |
|
384 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
|
385 |
*/ |
|
16 | 386 |
$plugins = apply_filters( |
387 |
'teeny_mce_plugins', |
|
388 |
array( |
|
389 |
'colorpicker', |
|
390 |
'lists', |
|
391 |
'fullscreen', |
|
392 |
'image', |
|
393 |
'wordpress', |
|
394 |
'wpeditimage', |
|
395 |
'wplink', |
|
396 |
), |
|
397 |
$editor_id |
|
398 |
); |
|
0 | 399 |
} else { |
5 | 400 |
|
401 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
* Filters the list of TinyMCE external plugins. |
5 | 403 |
* |
404 |
* The filter takes an associative array of external plugins for |
|
405 |
* TinyMCE in the form 'plugin_name' => 'url'. |
|
406 |
* |
|
407 |
* The url should be absolute, and should include the js filename |
|
408 |
* to be loaded. For example: |
|
409 |
* 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'. |
|
410 |
* |
|
411 |
* If the external plugin adds a button, it should be added with |
|
412 |
* one of the 'mce_buttons' filters. |
|
413 |
* |
|
414 |
* @since 2.5.0 |
|
16 | 415 |
* @since 5.3.0 The `$editor_id` parameter was added. |
5 | 416 |
* |
16 | 417 |
* @param array $external_plugins An array of external TinyMCE plugins. |
418 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
419 |
* when called from block editor's Classic block. |
|
5 | 420 |
*/ |
16 | 421 |
$mce_external_plugins = apply_filters( 'mce_external_plugins', array(), $editor_id ); |
0 | 422 |
|
5 | 423 |
$plugins = array( |
424 |
'charmap', |
|
425 |
'colorpicker', |
|
426 |
'hr', |
|
427 |
'lists', |
|
428 |
'media', |
|
429 |
'paste', |
|
430 |
'tabfocus', |
|
431 |
'textcolor', |
|
432 |
'fullscreen', |
|
433 |
'wordpress', |
|
434 |
'wpautoresize', |
|
435 |
'wpeditimage', |
|
436 |
'wpemoji', |
|
437 |
'wpgallery', |
|
438 |
'wplink', |
|
439 |
'wpdialogs', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
'wptextpattern', |
5 | 441 |
'wpview', |
442 |
); |
|
443 |
||
444 |
if ( ! self::$has_medialib ) { |
|
445 |
$plugins[] = 'image'; |
|
446 |
} |
|
0 | 447 |
|
5 | 448 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
* Filters the list of default TinyMCE plugins. |
5 | 450 |
* |
451 |
* The filter specifies which of the default plugins included |
|
452 |
* in WordPress should be added to the TinyMCE instance. |
|
453 |
* |
|
454 |
* @since 3.3.0 |
|
16 | 455 |
* @since 5.3.0 The `$editor_id` parameter was added. |
5 | 456 |
* |
16 | 457 |
* @param array $plugins An array of default TinyMCE plugins. |
458 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
459 |
* when called from block editor's Classic block. |
|
5 | 460 |
*/ |
16 | 461 |
$plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins, $editor_id ) ); |
5 | 462 |
|
16 | 463 |
$key = array_search( 'spellchecker', $plugins, true ); |
464 |
if ( false !== $key ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
465 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
466 |
* Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
467 |
* It can be added with 'mce_external_plugins'. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
468 |
*/ |
9 | 469 |
unset( $plugins[ $key ] ); |
5 | 470 |
} |
471 |
||
472 |
if ( ! empty( $mce_external_plugins ) ) { |
|
473 |
||
474 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
* Filters the translations loaded for external TinyMCE 3.x plugins. |
5 | 476 |
* |
477 |
* The filter takes an associative array ('plugin_name' => 'path') |
|
478 |
* where 'path' is the include path to the file. |
|
479 |
* |
|
480 |
* The language file should follow the same format as wp_mce_translation(), |
|
481 |
* and should define a variable ($strings) that holds all translated strings. |
|
482 |
* |
|
483 |
* @since 2.5.0 |
|
16 | 484 |
* @since 5.3.0 The `$editor_id` parameter was added. |
5 | 485 |
* |
16 | 486 |
* @param array $translations Translations for external TinyMCE plugins. |
487 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
|
5 | 488 |
*/ |
16 | 489 |
$mce_external_languages = apply_filters( 'mce_external_languages', array(), $editor_id ); |
0 | 490 |
|
491 |
$loaded_langs = array(); |
|
9 | 492 |
$strings = ''; |
0 | 493 |
|
5 | 494 |
if ( ! empty( $mce_external_languages ) ) { |
0 | 495 |
foreach ( $mce_external_languages as $name => $path ) { |
5 | 496 |
if ( @is_file( $path ) && @is_readable( $path ) ) { |
16 | 497 |
include_once $path; |
9 | 498 |
$ext_plugins .= $strings . "\n"; |
0 | 499 |
$loaded_langs[] = $name; |
500 |
} |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
foreach ( $mce_external_plugins as $name => $url ) { |
|
5 | 505 |
if ( in_array( $name, $plugins, true ) ) { |
506 |
unset( $mce_external_plugins[ $name ] ); |
|
507 |
continue; |
|
508 |
} |
|
0 | 509 |
|
9 | 510 |
$url = set_url_scheme( $url ); |
5 | 511 |
$mce_external_plugins[ $name ] = $url; |
9 | 512 |
$plugurl = dirname( $url ); |
513 |
$strings = ''; |
|
0 | 514 |
|
16 | 515 |
// Try to load langs/[locale].js and langs/[locale]_dlg.js. |
5 | 516 |
if ( ! in_array( $name, $loaded_langs, true ) ) { |
0 | 517 |
$path = str_replace( content_url(), '', $plugurl ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
$path = realpath( WP_CONTENT_DIR . $path . '/langs/' ); |
0 | 519 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
520 |
if ( ! $path ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
521 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
522 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
523 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
524 |
$path = trailingslashit( $path ); |
0 | 525 |
|
9 | 526 |
if ( @is_file( $path . $mce_locale . '.js' ) ) { |
5 | 527 |
$strings .= @file_get_contents( $path . $mce_locale . '.js' ) . "\n"; |
9 | 528 |
} |
0 | 529 |
|
9 | 530 |
if ( @is_file( $path . $mce_locale . '_dlg.js' ) ) { |
5 | 531 |
$strings .= @file_get_contents( $path . $mce_locale . '_dlg.js' ) . "\n"; |
9 | 532 |
} |
0 | 533 |
|
16 | 534 |
if ( 'en' !== $mce_locale && empty( $strings ) ) { |
5 | 535 |
if ( @is_file( $path . 'en.js' ) ) { |
9 | 536 |
$str1 = @file_get_contents( $path . 'en.js' ); |
0 | 537 |
$strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str1, 1 ) . "\n"; |
538 |
} |
|
539 |
||
5 | 540 |
if ( @is_file( $path . 'en_dlg.js' ) ) { |
9 | 541 |
$str2 = @file_get_contents( $path . 'en_dlg.js' ); |
0 | 542 |
$strings .= preg_replace( '/([\'"])en\./', '$1' . $mce_locale . '.', $str2, 1 ) . "\n"; |
543 |
} |
|
544 |
} |
|
545 |
||
9 | 546 |
if ( ! empty( $strings ) ) { |
0 | 547 |
$ext_plugins .= "\n" . $strings . "\n"; |
9 | 548 |
} |
0 | 549 |
} |
550 |
||
551 |
$ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; |
|
552 |
} |
|
553 |
} |
|
554 |
} |
|
555 |
||
9 | 556 |
self::$plugins = $plugins; |
0 | 557 |
self::$ext_plugins = $ext_plugins; |
558 |
||
9 | 559 |
$settings = self::default_settings(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
$settings['plugins'] = implode( ',', $plugins ); |
0 | 561 |
|
5 | 562 |
if ( ! empty( $mce_external_plugins ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
$settings['external_plugins'] = wp_json_encode( $mce_external_plugins ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
/** This filter is documented in wp-admin/includes/media.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
if ( apply_filters( 'disable_captions', '' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
$settings['wpeditimage_disable_captions'] = true; |
0 | 569 |
} |
570 |
||
16 | 571 |
$mce_css = $settings['content_css']; |
572 |
||
573 |
/* |
|
574 |
* The `editor-style.css` added by the theme is generally intended for the editor instance on the Edit Post screen. |
|
575 |
* Plugins that use wp_editor() on the front-end can decide whether to add the theme stylesheet |
|
576 |
* by using `get_editor_stylesheets()` and the `mce_css` or `tiny_mce_before_init` filters, see below. |
|
577 |
*/ |
|
578 |
if ( is_admin() ) { |
|
579 |
$editor_styles = get_editor_stylesheets(); |
|
0 | 580 |
|
16 | 581 |
if ( ! empty( $editor_styles ) ) { |
582 |
// Force urlencoding of commas. |
|
583 |
foreach ( $editor_styles as $key => $url ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
584 |
if ( str_contains( $url, ',' ) ) { |
16 | 585 |
$editor_styles[ $key ] = str_replace( ',', '%2C', $url ); |
586 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
} |
16 | 588 |
|
589 |
$mce_css .= ',' . implode( ',', $editor_styles ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
} |
0 | 591 |
} |
592 |
||
5 | 593 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
* Filters the comma-delimited list of stylesheets to load in TinyMCE. |
5 | 595 |
* |
596 |
* @since 2.1.0 |
|
597 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
* @param string $stylesheets Comma-delimited list of stylesheets. |
5 | 599 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
$mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' ); |
0 | 601 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
if ( ! empty( $mce_css ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
$settings['content_css'] = $mce_css; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
unset( $settings['content_css'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
self::$first_init = $settings; |
0 | 609 |
} |
610 |
||
611 |
if ( $set['teeny'] ) { |
|
16 | 612 |
$mce_buttons = array( |
613 |
'bold', |
|
614 |
'italic', |
|
615 |
'underline', |
|
616 |
'blockquote', |
|
617 |
'strikethrough', |
|
618 |
'bullist', |
|
619 |
'numlist', |
|
620 |
'alignleft', |
|
621 |
'aligncenter', |
|
622 |
'alignright', |
|
623 |
'undo', |
|
624 |
'redo', |
|
625 |
'link', |
|
626 |
'fullscreen', |
|
627 |
); |
|
5 | 628 |
|
629 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
630 |
* Filters the list of teenyMCE buttons (Code tab). |
5 | 631 |
* |
632 |
* @since 2.7.0 |
|
16 | 633 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 634 |
* |
16 | 635 |
* @param array $mce_buttons An array of teenyMCE buttons. |
636 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
|
5 | 637 |
*/ |
16 | 638 |
$mce_buttons = apply_filters( 'teeny_mce_buttons', $mce_buttons, $editor_id ); |
639 |
$mce_buttons_2 = array(); |
|
640 |
$mce_buttons_3 = array(); |
|
641 |
$mce_buttons_4 = array(); |
|
0 | 642 |
} else { |
16 | 643 |
$mce_buttons = array( |
644 |
'formatselect', |
|
645 |
'bold', |
|
646 |
'italic', |
|
647 |
'bullist', |
|
648 |
'numlist', |
|
649 |
'blockquote', |
|
650 |
'alignleft', |
|
651 |
'aligncenter', |
|
652 |
'alignright', |
|
653 |
'link', |
|
654 |
'wp_more', |
|
655 |
'spellchecker', |
|
656 |
); |
|
5 | 657 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
if ( ! wp_is_mobile() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
if ( $set['_content_editor_dfw'] ) { |
9 | 660 |
$mce_buttons[] = 'wp_adv'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
$mce_buttons[] = 'dfw'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
$mce_buttons[] = 'fullscreen'; |
9 | 664 |
$mce_buttons[] = 'wp_adv'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
} |
9 | 666 |
} else { |
667 |
$mce_buttons[] = 'wp_adv'; |
|
5 | 668 |
} |
669 |
||
670 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
* Filters the first-row list of TinyMCE buttons (Visual tab). |
5 | 672 |
* |
673 |
* @since 2.0.0 |
|
16 | 674 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 675 |
* |
16 | 676 |
* @param array $mce_buttons First-row list of buttons. |
677 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
678 |
* when called from block editor's Classic block. |
|
5 | 679 |
*/ |
680 |
$mce_buttons = apply_filters( 'mce_buttons', $mce_buttons, $editor_id ); |
|
681 |
||
16 | 682 |
$mce_buttons_2 = array( |
683 |
'strikethrough', |
|
684 |
'hr', |
|
685 |
'forecolor', |
|
686 |
'pastetext', |
|
687 |
'removeformat', |
|
688 |
'charmap', |
|
689 |
'outdent', |
|
690 |
'indent', |
|
691 |
'undo', |
|
692 |
'redo', |
|
693 |
); |
|
5 | 694 |
|
695 |
if ( ! wp_is_mobile() ) { |
|
696 |
$mce_buttons_2[] = 'wp_help'; |
|
697 |
} |
|
698 |
||
699 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* Filters the second-row list of TinyMCE buttons (Visual tab). |
5 | 701 |
* |
702 |
* @since 2.0.0 |
|
16 | 703 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 704 |
* |
16 | 705 |
* @param array $mce_buttons_2 Second-row list of buttons. |
706 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
707 |
* when called from block editor's Classic block. |
|
5 | 708 |
*/ |
709 |
$mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id ); |
|
710 |
||
711 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
* Filters the third-row list of TinyMCE buttons (Visual tab). |
5 | 713 |
* |
714 |
* @since 2.0.0 |
|
16 | 715 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 716 |
* |
16 | 717 |
* @param array $mce_buttons_3 Third-row list of buttons. |
718 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
719 |
* when called from block editor's Classic block. |
|
5 | 720 |
*/ |
721 |
$mce_buttons_3 = apply_filters( 'mce_buttons_3', array(), $editor_id ); |
|
722 |
||
723 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
724 |
* Filters the fourth-row list of TinyMCE buttons (Visual tab). |
5 | 725 |
* |
726 |
* @since 2.5.0 |
|
16 | 727 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 728 |
* |
16 | 729 |
* @param array $mce_buttons_4 Fourth-row list of buttons. |
730 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
|
731 |
* when called from block editor's Classic block. |
|
5 | 732 |
*/ |
733 |
$mce_buttons_4 = apply_filters( 'mce_buttons_4', array(), $editor_id ); |
|
0 | 734 |
} |
735 |
||
736 |
$body_class = $editor_id; |
|
737 |
||
16 | 738 |
$post = get_post(); |
739 |
if ( $post ) { |
|
0 | 740 |
$body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
|
0 | 742 |
if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
743 |
$post_format = get_post_format( $post ); |
|
9 | 744 |
if ( $post_format && ! is_wp_error( $post_format ) ) { |
0 | 745 |
$body_class .= ' post-format-' . sanitize_html_class( $post_format ); |
9 | 746 |
} else { |
0 | 747 |
$body_class .= ' post-format-standard'; |
9 | 748 |
} |
0 | 749 |
} |
750 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
$page_template = get_page_template_slug( $post ); |
5 | 752 |
|
16 | 753 |
if ( false !== $page_template ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
754 |
$page_template = empty( $page_template ) ? 'default' : str_replace( '.', '-', basename( $page_template, '.php' ) ); |
9 | 755 |
$body_class .= ' page-template-' . sanitize_html_class( $page_template ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
} |
0 | 757 |
} |
758 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
if ( ! empty( $set['tinymce']['body_class'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
$body_class .= ' ' . $set['tinymce']['body_class']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
unset( $set['tinymce']['body_class'] ); |
0 | 764 |
} |
765 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
766 |
$mce_init = array( |
9 | 767 |
'selector' => "#$editor_id", |
768 |
'wpautop' => (bool) $set['wpautop'], |
|
769 |
'indent' => ! $set['wpautop'], |
|
770 |
'toolbar1' => implode( ',', $mce_buttons ), |
|
771 |
'toolbar2' => implode( ',', $mce_buttons_2 ), |
|
772 |
'toolbar3' => implode( ',', $mce_buttons_3 ), |
|
773 |
'toolbar4' => implode( ',', $mce_buttons_4 ), |
|
0 | 774 |
'tabfocus_elements' => $set['tabfocus_elements'], |
9 | 775 |
'body_class' => $body_class, |
0 | 776 |
); |
777 |
||
16 | 778 |
// Merge with the first part of the init array. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
779 |
$mce_init = array_merge( self::$first_init, $mce_init ); |
5 | 780 |
|
9 | 781 |
if ( is_array( $set['tinymce'] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
782 |
$mce_init = array_merge( $mce_init, $set['tinymce'] ); |
9 | 783 |
} |
0 | 784 |
|
5 | 785 |
/* |
786 |
* For people who really REALLY know what they're doing with TinyMCE |
|
787 |
* You can modify $mceInit to add, remove, change elements of the config |
|
788 |
* before tinyMCE.init. Setting "valid_elements", "invalid_elements" |
|
789 |
* and "extended_valid_elements" can be done through this filter. Best |
|
790 |
* is to use the default cleanup by not specifying valid_elements, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
791 |
* as TinyMCE checks against the full set of HTML 5.0 elements and attributes. |
5 | 792 |
*/ |
793 |
if ( $set['teeny'] ) { |
|
0 | 794 |
|
5 | 795 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
* Filters the teenyMCE config before init. |
5 | 797 |
* |
798 |
* @since 2.7.0 |
|
16 | 799 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 800 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
801 |
* @param array $mce_init An array with teenyMCE config. |
5 | 802 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. |
803 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
804 |
$mce_init = apply_filters( 'teeny_mce_before_init', $mce_init, $editor_id ); |
0 | 805 |
} else { |
5 | 806 |
|
807 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
808 |
* Filters the TinyMCE config before init. |
5 | 809 |
* |
810 |
* @since 2.5.0 |
|
16 | 811 |
* @since 3.3.0 The `$editor_id` parameter was added. |
5 | 812 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
813 |
* @param array $mce_init An array with TinyMCE config. |
16 | 814 |
* @param string $editor_id Unique editor identifier, e.g. 'content'. Accepts 'classic-block' |
815 |
* when called from block editor's Classic block. |
|
5 | 816 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
817 |
$mce_init = apply_filters( 'tiny_mce_before_init', $mce_init, $editor_id ); |
0 | 818 |
} |
819 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
820 |
if ( empty( $mce_init['toolbar3'] ) && ! empty( $mce_init['toolbar4'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
821 |
$mce_init['toolbar3'] = $mce_init['toolbar4']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
822 |
$mce_init['toolbar4'] = ''; |
0 | 823 |
} |
824 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
825 |
self::$mce_settings[ $editor_id ] = $mce_init; |
16 | 826 |
} // End if self::$this_tinymce. |
0 | 827 |
} |
828 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
829 |
/** |
16 | 830 |
* @since 3.3.0 |
831 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
* @param array $init |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
private static function _parse_init( $init ) { |
0 | 836 |
$options = ''; |
837 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
foreach ( $init as $key => $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
if ( is_bool( $value ) ) { |
9 | 840 |
$val = $value ? 'true' : 'false'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
841 |
$options .= $key . ':' . $val . ','; |
0 | 842 |
continue; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
843 |
} elseif ( ! empty( $value ) && is_string( $value ) && ( |
16 | 844 |
( '{' === $value[0] && '}' === $value[ strlen( $value ) - 1 ] ) || |
845 |
( '[' === $value[0] && ']' === $value[ strlen( $value ) - 1 ] ) || |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
846 |
preg_match( '/^\(?function ?\(/', $value ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
$options .= $key . ':' . $value . ','; |
0 | 849 |
continue; |
850 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
$options .= $key . ':"' . $value . '",'; |
0 | 852 |
} |
853 |
||
854 |
return '{' . trim( $options, ' ,' ) . '}'; |
|
855 |
} |
|
856 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
857 |
/** |
16 | 858 |
* @since 3.3.0 |
9 | 859 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
* @param bool $default_scripts Optional. Whether default scripts should be enqueued. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
public static function enqueue_scripts( $default_scripts = false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
if ( $default_scripts || self::$has_tinymce ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
wp_enqueue_script( 'editor' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
} |
0 | 866 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
if ( $default_scripts || self::$has_quicktags ) { |
5 | 868 |
wp_enqueue_script( 'quicktags' ); |
869 |
wp_enqueue_style( 'buttons' ); |
|
870 |
} |
|
0 | 871 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
872 |
if ( $default_scripts || in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
873 |
wp_enqueue_script( 'wplink' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
874 |
wp_enqueue_script( 'jquery-ui-autocomplete' ); |
0 | 875 |
} |
876 |
||
877 |
if ( self::$has_medialib ) { |
|
878 |
add_thickbox(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
wp_enqueue_script( 'media-upload' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
wp_enqueue_script( 'wp-embed' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
} elseif ( $default_scripts ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
wp_enqueue_script( 'media-upload' ); |
0 | 883 |
} |
5 | 884 |
|
885 |
/** |
|
886 |
* Fires when scripts and styles are enqueued for the editor. |
|
887 |
* |
|
888 |
* @since 3.9.0 |
|
889 |
* |
|
890 |
* @param array $to_load An array containing boolean values whether TinyMCE |
|
891 |
* and Quicktags are being loaded. |
|
892 |
*/ |
|
9 | 893 |
do_action( |
894 |
'wp_enqueue_editor', |
|
895 |
array( |
|
896 |
'tinymce' => ( $default_scripts || self::$has_tinymce ), |
|
897 |
'quicktags' => ( $default_scripts || self::$has_quicktags ), |
|
898 |
) |
|
899 |
); |
|
5 | 900 |
} |
901 |
||
902 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
* Enqueue all editor scripts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
* For use when the editor is going to be initialized after page load. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
public static function enqueue_default_editor() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
// We are past the point where scripts can be enqueued properly. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
if ( did_action( 'wp_enqueue_editor' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
self::enqueue_scripts( true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
|
16 | 916 |
// Also add wp-includes/css/editor.css. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
wp_enqueue_style( 'editor-buttons' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
918 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
if ( is_admin() ) { |
9 | 920 |
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
922 |
} else { |
9 | 923 |
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
925 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
926 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
927 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
* Print (output) all editor scripts and default settings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
* For use when the editor is going to be initialized after page load. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
* @since 4.8.0 |
5 | 933 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
public static function print_default_editor_scripts() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
$user_can_richedit = user_can_richedit(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
if ( $user_can_richedit ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
$settings = self::default_settings(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
|
9 | 940 |
$settings['toolbar1'] = 'bold,italic,bullist,numlist,link'; |
941 |
$settings['wpautop'] = false; |
|
942 |
$settings['indent'] = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
$settings['elementpath'] = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
944 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
if ( is_rtl() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
$settings['directionality'] = 'rtl'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
|
16 | 949 |
/* |
950 |
* In production all plugins are loaded (they are in wp-editor.js.gz). |
|
951 |
* The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. |
|
952 |
* Can be added from js by using the 'wp-before-tinymce-init' event. |
|
953 |
*/ |
|
9 | 954 |
$settings['plugins'] = implode( |
955 |
',', |
|
956 |
array( |
|
957 |
'charmap', |
|
958 |
'colorpicker', |
|
959 |
'hr', |
|
960 |
'lists', |
|
961 |
'paste', |
|
962 |
'tabfocus', |
|
963 |
'textcolor', |
|
964 |
'fullscreen', |
|
965 |
'wordpress', |
|
966 |
'wpautoresize', |
|
967 |
'wpeditimage', |
|
968 |
'wpemoji', |
|
969 |
'wpgallery', |
|
970 |
'wplink', |
|
971 |
'wptextpattern', |
|
972 |
) |
|
973 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
974 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
$settings = self::_parse_init( $settings ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
$settings = '{}'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
981 |
<script type="text/javascript"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
window.wp = window.wp || {}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
983 |
window.wp.editor = window.wp.editor || {}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
window.wp.editor.getDefaultSettings = function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
return { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
tinymce: <?php echo $settings; ?>, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
quicktags: { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
buttons: 'strong,em,link,ul,ol,li,code' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
991 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
if ( $user_can_richedit ) { |
9 | 996 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
$baseurl = self::get_baseurl(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
var tinyMCEPreInit = { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
baseURL: "<?php echo $baseurl; ?>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
suffix: "<?php echo $suffix; ?>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
mceInit: {}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
qtInit: {}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
</script> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
if ( $user_can_richedit ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
self::print_tinymce_scripts(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
* Fires when the editor scripts are loaded for later initialization, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
* after all scripts and settings are printed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
do_action( 'print_default_editor_scripts' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1025 |
self::wp_link_dialog(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
} |
5 | 1027 |
|
16 | 1028 |
/** |
1029 |
* Returns the TinyMCE locale. |
|
1030 |
* |
|
1031 |
* @since 4.8.0 |
|
1032 |
* |
|
1033 |
* @return string |
|
1034 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
public static function get_mce_locale() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
if ( empty( self::$mce_locale ) ) { |
9 | 1037 |
$mce_locale = get_user_locale(); |
16 | 1038 |
self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
return self::$mce_locale; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
|
16 | 1044 |
/** |
1045 |
* Returns the TinyMCE base URL. |
|
1046 |
* |
|
1047 |
* @since 4.8.0 |
|
1048 |
* |
|
1049 |
* @return string |
|
1050 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1051 |
public static function get_baseurl() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1052 |
if ( empty( self::$baseurl ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1053 |
self::$baseurl = includes_url( 'js/tinymce' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
return self::$baseurl; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1059 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
* Returns the default TinyMCE settings. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
* Doesn't include plugins, buttons, editor selector. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1062 |
* |
16 | 1063 |
* @since 4.8.0 |
1064 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
* @global string $tinymce_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1069 |
private static function default_settings() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
global $tinymce_version; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1072 |
$shortcut_labels = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
foreach ( self::get_translation() as $name => $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
if ( is_array( $value ) ) { |
9 | 1076 |
$shortcut_labels[ $name ] = $value[1]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
$settings = array( |
9 | 1081 |
'theme' => 'modern', |
1082 |
'skin' => 'lightgray', |
|
1083 |
'language' => self::get_mce_locale(), |
|
1084 |
'formats' => '{' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
'alignleft: [' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
'{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
'{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
'],' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
'aligncenter: [' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
'{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
'{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1092 |
'],' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
'alignright: [' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
'{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
'{selector: "img,table,dl.wp-caption", classes: "alignright"}' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
'],' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
'strikethrough: {inline: "del"}' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
'}', |
9 | 1099 |
'relative_urls' => false, |
1100 |
'remove_script_host' => false, |
|
1101 |
'convert_urls' => false, |
|
1102 |
'browser_spellcheck' => true, |
|
1103 |
'fix_list_elements' => true, |
|
1104 |
'entities' => '38,amp,60,lt,62,gt', |
|
1105 |
'entity_encoding' => 'raw', |
|
1106 |
'keep_styles' => false, |
|
1107 |
'cache_suffix' => 'wp-mce-' . $tinymce_version, |
|
1108 |
'resize' => 'vertical', |
|
1109 |
'menubar' => false, |
|
1110 |
'branding' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
|
16 | 1112 |
// Limit the preview styles in the menu/toolbar. |
9 | 1113 |
'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
'end_container_on_empty_block' => true, |
9 | 1116 |
'wpeditimage_html5_captions' => true, |
1117 |
'wp_lang_attr' => get_bloginfo( 'language' ), |
|
1118 |
'wp_shortcut_labels' => wp_json_encode( $shortcut_labels ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1120 |
|
9 | 1121 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
$version = 'ver=' . get_bloginfo( 'version' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
|
16 | 1124 |
// Default stylesheets. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
$settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
return $settings; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
|
16 | 1131 |
/** |
1132 |
* @since 4.7.0 |
|
1133 |
* |
|
1134 |
* @return array |
|
1135 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
private static function get_translation() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
if ( empty( self::$translation ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
self::$translation = array( |
16 | 1139 |
// Default TinyMCE strings. |
9 | 1140 |
'New document' => __( 'New document' ), |
1141 |
'Formats' => _x( 'Formats', 'TinyMCE' ), |
|
5 | 1142 |
|
9 | 1143 |
'Headings' => _x( 'Headings', 'TinyMCE' ), |
1144 |
'Heading 1' => array( __( 'Heading 1' ), 'access1' ), |
|
1145 |
'Heading 2' => array( __( 'Heading 2' ), 'access2' ), |
|
1146 |
'Heading 3' => array( __( 'Heading 3' ), 'access3' ), |
|
1147 |
'Heading 4' => array( __( 'Heading 4' ), 'access4' ), |
|
1148 |
'Heading 5' => array( __( 'Heading 5' ), 'access5' ), |
|
1149 |
'Heading 6' => array( __( 'Heading 6' ), 'access6' ), |
|
5 | 1150 |
|
16 | 1151 |
/* translators: Block tags. */ |
9 | 1152 |
'Blocks' => _x( 'Blocks', 'TinyMCE' ), |
1153 |
'Paragraph' => array( __( 'Paragraph' ), 'access7' ), |
|
1154 |
'Blockquote' => array( __( 'Blockquote' ), 'accessQ' ), |
|
1155 |
'Div' => _x( 'Div', 'HTML tag' ), |
|
1156 |
'Pre' => _x( 'Pre', 'HTML tag' ), |
|
1157 |
'Preformatted' => _x( 'Preformatted', 'HTML tag' ), |
|
1158 |
'Address' => _x( 'Address', 'HTML tag' ), |
|
5 | 1159 |
|
9 | 1160 |
'Inline' => _x( 'Inline', 'HTML elements' ), |
1161 |
'Underline' => array( __( 'Underline' ), 'metaU' ), |
|
1162 |
'Strikethrough' => array( __( 'Strikethrough' ), 'accessD' ), |
|
1163 |
'Subscript' => __( 'Subscript' ), |
|
1164 |
'Superscript' => __( 'Superscript' ), |
|
1165 |
'Clear formatting' => __( 'Clear formatting' ), |
|
1166 |
'Bold' => array( __( 'Bold' ), 'metaB' ), |
|
1167 |
'Italic' => array( __( 'Italic' ), 'metaI' ), |
|
1168 |
'Code' => array( __( 'Code' ), 'accessX' ), |
|
1169 |
'Source code' => __( 'Source code' ), |
|
1170 |
'Font Family' => __( 'Font Family' ), |
|
1171 |
'Font Sizes' => __( 'Font Sizes' ), |
|
5 | 1172 |
|
9 | 1173 |
'Align center' => array( __( 'Align center' ), 'accessC' ), |
1174 |
'Align right' => array( __( 'Align right' ), 'accessR' ), |
|
1175 |
'Align left' => array( __( 'Align left' ), 'accessL' ), |
|
1176 |
'Justify' => array( __( 'Justify' ), 'accessJ' ), |
|
1177 |
'Increase indent' => __( 'Increase indent' ), |
|
1178 |
'Decrease indent' => __( 'Decrease indent' ), |
|
5 | 1179 |
|
9 | 1180 |
'Cut' => array( __( 'Cut' ), 'metaX' ), |
1181 |
'Copy' => array( __( 'Copy' ), 'metaC' ), |
|
1182 |
'Paste' => array( __( 'Paste' ), 'metaV' ), |
|
1183 |
'Select all' => array( __( 'Select all' ), 'metaA' ), |
|
1184 |
'Undo' => array( __( 'Undo' ), 'metaZ' ), |
|
1185 |
'Redo' => array( __( 'Redo' ), 'metaY' ), |
|
5 | 1186 |
|
9 | 1187 |
'Ok' => __( 'OK' ), |
1188 |
'Cancel' => __( 'Cancel' ), |
|
1189 |
'Close' => __( 'Close' ), |
|
1190 |
'Visual aids' => __( 'Visual aids' ), |
|
5 | 1191 |
|
9 | 1192 |
'Bullet list' => array( __( 'Bulleted list' ), 'accessU' ), |
1193 |
'Numbered list' => array( __( 'Numbered list' ), 'accessO' ), |
|
1194 |
'Square' => _x( 'Square', 'list style' ), |
|
1195 |
'Default' => _x( 'Default', 'list style' ), |
|
1196 |
'Circle' => _x( 'Circle', 'list style' ), |
|
1197 |
'Disc' => _x( 'Disc', 'list style' ), |
|
1198 |
'Lower Greek' => _x( 'Lower Greek', 'list style' ), |
|
1199 |
'Lower Alpha' => _x( 'Lower Alpha', 'list style' ), |
|
1200 |
'Upper Alpha' => _x( 'Upper Alpha', 'list style' ), |
|
1201 |
'Upper Roman' => _x( 'Upper Roman', 'list style' ), |
|
1202 |
'Lower Roman' => _x( 'Lower Roman', 'list style' ), |
|
5 | 1203 |
|
16 | 1204 |
// Anchor plugin. |
9 | 1205 |
'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), |
1206 |
'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), |
|
1207 |
'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), |
|
1208 |
'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' => |
|
1209 |
__( 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' ), |
|
1210 |
'Id' => _x( 'Id', 'Id for link anchor (TinyMCE)' ), |
|
5 | 1211 |
|
16 | 1212 |
// Fullpage plugin. |
9 | 1213 |
'Document properties' => __( 'Document properties' ), |
1214 |
'Robots' => __( 'Robots' ), |
|
1215 |
'Title' => __( 'Title' ), |
|
1216 |
'Keywords' => __( 'Keywords' ), |
|
1217 |
'Encoding' => __( 'Encoding' ), |
|
1218 |
'Description' => __( 'Description' ), |
|
1219 |
'Author' => __( 'Author' ), |
|
5 | 1220 |
|
16 | 1221 |
// Media, image plugins. |
9 | 1222 |
'Image' => __( 'Image' ), |
1223 |
'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ), |
|
1224 |
'General' => __( 'General' ), |
|
1225 |
'Advanced' => __( 'Advanced' ), |
|
1226 |
'Source' => __( 'Source' ), |
|
1227 |
'Border' => __( 'Border' ), |
|
1228 |
'Constrain proportions' => __( 'Constrain proportions' ), |
|
1229 |
'Vertical space' => __( 'Vertical space' ), |
|
1230 |
'Image description' => __( 'Image description' ), |
|
1231 |
'Style' => __( 'Style' ), |
|
1232 |
'Dimensions' => __( 'Dimensions' ), |
|
1233 |
'Insert image' => __( 'Insert image' ), |
|
1234 |
'Date/time' => __( 'Date/time' ), |
|
1235 |
'Insert date/time' => __( 'Insert date/time' ), |
|
1236 |
'Table of Contents' => __( 'Table of Contents' ), |
|
1237 |
'Insert/Edit code sample' => __( 'Insert/edit code sample' ), |
|
1238 |
'Language' => __( 'Language' ), |
|
1239 |
'Media' => __( 'Media' ), |
|
1240 |
'Insert/edit media' => __( 'Insert/edit media' ), |
|
1241 |
'Poster' => __( 'Poster' ), |
|
1242 |
'Alternative source' => __( 'Alternative source' ), |
|
1243 |
'Paste your embed code below:' => __( 'Paste your embed code below:' ), |
|
1244 |
'Insert video' => __( 'Insert video' ), |
|
1245 |
'Embed' => __( 'Embed' ), |
|
5 | 1246 |
|
16 | 1247 |
// Each of these have a corresponding plugin. |
9 | 1248 |
'Special character' => __( 'Special character' ), |
1249 |
'Right to left' => _x( 'Right to left', 'editor button' ), |
|
1250 |
'Left to right' => _x( 'Left to right', 'editor button' ), |
|
1251 |
'Emoticons' => __( 'Emoticons' ), |
|
1252 |
'Nonbreaking space' => __( 'Nonbreaking space' ), |
|
1253 |
'Page break' => __( 'Page break' ), |
|
1254 |
'Paste as text' => __( 'Paste as text' ), |
|
1255 |
'Preview' => __( 'Preview' ), |
|
1256 |
'Print' => __( 'Print' ), |
|
1257 |
'Save' => __( 'Save' ), |
|
1258 |
'Fullscreen' => __( 'Fullscreen' ), |
|
1259 |
'Horizontal line' => __( 'Horizontal line' ), |
|
1260 |
'Horizontal space' => __( 'Horizontal space' ), |
|
1261 |
'Restore last draft' => __( 'Restore last draft' ), |
|
1262 |
'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ), |
|
1263 |
'Remove link' => array( __( 'Remove link' ), 'accessS' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
|
16 | 1265 |
// Link plugin. |
9 | 1266 |
'Link' => __( 'Link' ), |
1267 |
'Insert link' => __( 'Insert link' ), |
|
1268 |
'Target' => __( 'Target' ), |
|
1269 |
'New window' => __( 'New window' ), |
|
1270 |
'Text to display' => __( 'Text to display' ), |
|
1271 |
'Url' => __( 'URL' ), |
|
1272 |
'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' => |
|
1273 |
__( 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?' ), |
|
1274 |
'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' => |
|
1275 |
__( 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?' ), |
|
5 | 1276 |
|
9 | 1277 |
'Color' => __( 'Color' ), |
1278 |
'Custom color' => __( 'Custom color' ), |
|
16 | 1279 |
'Custom...' => _x( 'Custom...', 'label for custom color' ), // No ellipsis. |
9 | 1280 |
'No color' => __( 'No color' ), |
1281 |
'R' => _x( 'R', 'Short for red in RGB' ), |
|
1282 |
'G' => _x( 'G', 'Short for green in RGB' ), |
|
1283 |
'B' => _x( 'B', 'Short for blue in RGB' ), |
|
5 | 1284 |
|
16 | 1285 |
// Spelling, search/replace plugins. |
9 | 1286 |
'Could not find the specified string.' => __( 'Could not find the specified string.' ), |
1287 |
'Replace' => _x( 'Replace', 'find/replace' ), |
|
1288 |
'Next' => _x( 'Next', 'find/replace' ), |
|
16 | 1289 |
/* translators: Previous. */ |
9 | 1290 |
'Prev' => _x( 'Prev', 'find/replace' ), |
1291 |
'Whole words' => _x( 'Whole words', 'find/replace' ), |
|
1292 |
'Find and replace' => __( 'Find and replace' ), |
|
1293 |
'Replace with' => _x( 'Replace with', 'find/replace' ), |
|
1294 |
'Find' => _x( 'Find', 'find/replace' ), |
|
1295 |
'Replace all' => _x( 'Replace all', 'find/replace' ), |
|
1296 |
'Match case' => __( 'Match case' ), |
|
1297 |
'Spellcheck' => __( 'Check Spelling' ), |
|
1298 |
'Finish' => _x( 'Finish', 'spellcheck' ), |
|
1299 |
'Ignore all' => _x( 'Ignore all', 'spellcheck' ), |
|
1300 |
'Ignore' => _x( 'Ignore', 'spellcheck' ), |
|
1301 |
'Add to Dictionary' => __( 'Add to Dictionary' ), |
|
5 | 1302 |
|
16 | 1303 |
// TinyMCE tables. |
9 | 1304 |
'Insert table' => __( 'Insert table' ), |
1305 |
'Delete table' => __( 'Delete table' ), |
|
1306 |
'Table properties' => __( 'Table properties' ), |
|
1307 |
'Row properties' => __( 'Table row properties' ), |
|
1308 |
'Cell properties' => __( 'Table cell properties' ), |
|
1309 |
'Border color' => __( 'Border color' ), |
|
5 | 1310 |
|
9 | 1311 |
'Row' => __( 'Row' ), |
1312 |
'Rows' => __( 'Rows' ), |
|
18 | 1313 |
'Column' => __( 'Column' ), |
1314 |
'Cols' => __( 'Columns' ), |
|
9 | 1315 |
'Cell' => _x( 'Cell', 'table cell' ), |
1316 |
'Header cell' => __( 'Header cell' ), |
|
1317 |
'Header' => _x( 'Header', 'table header' ), |
|
1318 |
'Body' => _x( 'Body', 'table body' ), |
|
1319 |
'Footer' => _x( 'Footer', 'table footer' ), |
|
5 | 1320 |
|
9 | 1321 |
'Insert row before' => __( 'Insert row before' ), |
1322 |
'Insert row after' => __( 'Insert row after' ), |
|
1323 |
'Insert column before' => __( 'Insert column before' ), |
|
1324 |
'Insert column after' => __( 'Insert column after' ), |
|
1325 |
'Paste row before' => __( 'Paste table row before' ), |
|
1326 |
'Paste row after' => __( 'Paste table row after' ), |
|
1327 |
'Delete row' => __( 'Delete row' ), |
|
1328 |
'Delete column' => __( 'Delete column' ), |
|
1329 |
'Cut row' => __( 'Cut table row' ), |
|
1330 |
'Copy row' => __( 'Copy table row' ), |
|
1331 |
'Merge cells' => __( 'Merge table cells' ), |
|
1332 |
'Split cell' => __( 'Split table cell' ), |
|
5 | 1333 |
|
9 | 1334 |
'Height' => __( 'Height' ), |
1335 |
'Width' => __( 'Width' ), |
|
1336 |
'Caption' => __( 'Caption' ), |
|
1337 |
'Alignment' => __( 'Alignment' ), |
|
1338 |
'H Align' => _x( 'H Align', 'horizontal table cell alignment' ), |
|
1339 |
'Left' => __( 'Left' ), |
|
1340 |
'Center' => __( 'Center' ), |
|
1341 |
'Right' => __( 'Right' ), |
|
1342 |
'None' => _x( 'None', 'table cell alignment attribute' ), |
|
1343 |
'V Align' => _x( 'V Align', 'vertical table cell alignment' ), |
|
1344 |
'Top' => __( 'Top' ), |
|
1345 |
'Middle' => __( 'Middle' ), |
|
1346 |
'Bottom' => __( 'Bottom' ), |
|
5 | 1347 |
|
9 | 1348 |
'Row group' => __( 'Row group' ), |
1349 |
'Column group' => __( 'Column group' ), |
|
1350 |
'Row type' => __( 'Row type' ), |
|
1351 |
'Cell type' => __( 'Cell type' ), |
|
1352 |
'Cell padding' => __( 'Cell padding' ), |
|
1353 |
'Cell spacing' => __( 'Cell spacing' ), |
|
1354 |
'Scope' => _x( 'Scope', 'table cell scope attribute' ), |
|
5 | 1355 |
|
9 | 1356 |
'Insert template' => _x( 'Insert template', 'TinyMCE' ), |
1357 |
'Templates' => _x( 'Templates', 'TinyMCE' ), |
|
5 | 1358 |
|
9 | 1359 |
'Background color' => __( 'Background color' ), |
1360 |
'Text color' => __( 'Text color' ), |
|
1361 |
'Show blocks' => _x( 'Show blocks', 'editor button' ), |
|
1362 |
'Show invisible characters' => __( 'Show invisible characters' ), |
|
5 | 1363 |
|
16 | 1364 |
/* translators: Word count. */ |
9 | 1365 |
'Words: {0}' => sprintf( __( 'Words: %s' ), '{0}' ), |
1366 |
'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' => |
|
1367 |
__( 'Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.' ) . "\n\n" . |
|
19 | 1368 |
__( 'If you are looking to paste rich content from Microsoft Word, try turning this option off. The editor will clean up text pasted from Word automatically.' ), |
9 | 1369 |
'Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help' => |
1370 |
__( 'Rich Text Area. Press Alt-Shift-H for help.' ), |
|
1371 |
'Rich Text Area. Press Control-Option-H for help.' => __( 'Rich Text Area. Press Control-Option-H for help.' ), |
|
1372 |
'You have unsaved changes are you sure you want to navigate away?' => |
|
1373 |
__( 'The changes you made will be lost if you navigate away from this page.' ), |
|
1374 |
'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => |
|
1375 |
__( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), |
|
5 | 1376 |
|
16 | 1377 |
// TinyMCE menus. |
9 | 1378 |
'Insert' => _x( 'Insert', 'TinyMCE menu' ), |
1379 |
'File' => _x( 'File', 'TinyMCE menu' ), |
|
1380 |
'Edit' => _x( 'Edit', 'TinyMCE menu' ), |
|
1381 |
'Tools' => _x( 'Tools', 'TinyMCE menu' ), |
|
1382 |
'View' => _x( 'View', 'TinyMCE menu' ), |
|
1383 |
'Table' => _x( 'Table', 'TinyMCE menu' ), |
|
1384 |
'Format' => _x( 'Format', 'TinyMCE menu' ), |
|
5 | 1385 |
|
16 | 1386 |
// WordPress strings. |
9 | 1387 |
'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ), |
1388 |
'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ), |
|
1389 |
'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ), |
|
16 | 1390 |
'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis). |
9 | 1391 |
'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ), |
16 | 1392 |
'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar. |
1393 |
'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar. |
|
1394 |
'Edit|button' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar. |
|
1395 |
'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog. |
|
1396 |
'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog. |
|
1397 |
'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog. |
|
1398 |
'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label. |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1399 |
'Code|tab' => _x( 'Code', 'Name for the Code editor tab (formerly Text)' ), // Editor switch tab label. |
16 | 1400 |
'Add Media' => array( __( 'Add Media' ), 'accessM' ), // Tooltip for the 'Add Media' button in the block editor Classic block. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
|
16 | 1402 |
// Shortcuts help modal. |
9 | 1403 |
'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ), |
1404 |
'Classic Block Keyboard Shortcuts' => __( 'Classic Block Keyboard Shortcuts' ), |
|
1405 |
'Default shortcuts,' => __( 'Default shortcuts,' ), |
|
1406 |
'Additional shortcuts,' => __( 'Additional shortcuts,' ), |
|
1407 |
'Focus shortcuts:' => __( 'Focus shortcuts:' ), |
|
1408 |
'Inline toolbar (when an image, link or preview is selected)' => __( 'Inline toolbar (when an image, link or preview is selected)' ), |
|
1409 |
'Editor menu (when enabled)' => __( 'Editor menu (when enabled)' ), |
|
1410 |
'Editor toolbar' => __( 'Editor toolbar' ), |
|
1411 |
'Elements path' => __( 'Elements path' ), |
|
1412 |
'Ctrl + Alt + letter:' => __( 'Ctrl + Alt + letter:' ), |
|
1413 |
'Shift + Alt + letter:' => __( 'Shift + Alt + letter:' ), |
|
1414 |
'Cmd + letter:' => __( 'Cmd + letter:' ), |
|
1415 |
'Ctrl + letter:' => __( 'Ctrl + letter:' ), |
|
1416 |
'Letter' => __( 'Letter' ), |
|
1417 |
'Action' => __( 'Action' ), |
|
1418 |
'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.' ), |
|
1419 |
'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.' => |
|
1420 |
__( '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.' ), |
|
1421 |
'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.' => |
|
1422 |
__( '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.' ), |
|
1423 |
'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' => |
|
1424 |
__( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ), |
|
1425 |
'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.' => |
|
1426 |
__( '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.' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1428 |
} |
5 | 1429 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
Imagetools plugin (not included): |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
'Edit image' => __( 'Edit image' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1433 |
'Image options' => __( 'Image options' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1434 |
'Back' => __( 'Back' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1435 |
'Invert' => __( 'Invert' ), |
16 | 1436 |
'Flip horizontally' => __( 'Flip horizontal' ), |
1437 |
'Flip vertically' => __( 'Flip vertical' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1438 |
'Crop' => __( 'Crop' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
'Orientation' => __( 'Orientation' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
'Resize' => __( 'Resize' ), |
16 | 1441 |
'Rotate clockwise' => __( 'Rotate right' ), |
1442 |
'Rotate counterclockwise' => __( 'Rotate left' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
'Sharpen' => __( 'Sharpen' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
'Brightness' => __( 'Brightness' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
'Color levels' => __( 'Color levels' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
'Contrast' => __( 'Contrast' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
'Gamma' => __( 'Gamma' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
'Zoom in' => __( 'Zoom in' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
'Zoom out' => __( 'Zoom out' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
*/ |
5 | 1451 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
return self::$translation; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1456 |
* Translates the default TinyMCE strings and returns them as JSON encoded object ready to be loaded with tinymce.addI18n(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
* or as JS snippet that should run after tinymce.js is loaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
* |
16 | 1459 |
* @since 3.9.0 |
1460 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
* @param string $mce_locale The locale used for the editor. |
16 | 1462 |
* @param bool $json_only Optional. Whether to include the JavaScript calls to tinymce.addI18n() and |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1463 |
* tinymce.ScriptLoader.markDone(). Default false. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
* @return string Translation object, JSON encoded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
public static function wp_mce_translation( $mce_locale = '', $json_only = false ) { |
5 | 1467 |
if ( ! $mce_locale ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
$mce_locale = self::get_mce_locale(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1471 |
$mce_translation = self::get_translation(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
foreach ( $mce_translation as $name => $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1474 |
if ( is_array( $value ) ) { |
9 | 1475 |
$mce_translation[ $name ] = $value[0]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
} |
5 | 1477 |
} |
1478 |
||
1479 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
* Filters translated strings prepared for TinyMCE. |
5 | 1481 |
* |
1482 |
* @since 3.9.0 |
|
1483 |
* |
|
1484 |
* @param array $mce_translation Key/value pairs of strings. |
|
1485 |
* @param string $mce_locale Locale. |
|
1486 |
*/ |
|
1487 |
$mce_translation = apply_filters( 'wp_mce_translation', $mce_translation, $mce_locale ); |
|
1488 |
||
1489 |
foreach ( $mce_translation as $key => $value ) { |
|
1490 |
// Remove strings that are not translated. |
|
1491 |
if ( $key === $value ) { |
|
9 | 1492 |
unset( $mce_translation[ $key ] ); |
5 | 1493 |
continue; |
1494 |
} |
|
1495 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1496 |
if ( str_contains( $value, '&' ) ) { |
9 | 1497 |
$mce_translation[ $key ] = html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); |
5 | 1498 |
} |
1499 |
} |
|
1500 |
||
16 | 1501 |
// Set direction. |
5 | 1502 |
if ( is_rtl() ) { |
1503 |
$mce_translation['_dir'] = 'rtl'; |
|
1504 |
} |
|
1505 |
||
1506 |
if ( $json_only ) { |
|
1507 |
return wp_json_encode( $mce_translation ); |
|
1508 |
} |
|
1509 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
$baseurl = self::get_baseurl(); |
5 | 1511 |
|
1512 |
return "tinymce.addI18n( '$mce_locale', " . wp_json_encode( $mce_translation ) . ");\n" . |
|
1513 |
"tinymce.ScriptLoader.markDone( '$baseurl/langs/$mce_locale.js' );\n"; |
|
0 | 1514 |
} |
1515 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1516 |
/** |
9 | 1517 |
* Force uncompressed TinyMCE when a custom theme has been defined. |
1518 |
* |
|
1519 |
* The compressed TinyMCE file cannot deal with custom themes, so this makes |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1520 |
* sure that WordPress uses the uncompressed TinyMCE file if a theme is defined. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1521 |
* Even if the website is running on a production environment. |
16 | 1522 |
* |
1523 |
* @since 5.0.0 |
|
9 | 1524 |
*/ |
1525 |
public static function force_uncompressed_tinymce() { |
|
1526 |
$has_custom_theme = false; |
|
1527 |
foreach ( self::$mce_settings as $init ) { |
|
1528 |
if ( ! empty( $init['theme_url'] ) ) { |
|
1529 |
$has_custom_theme = true; |
|
1530 |
break; |
|
1531 |
} |
|
1532 |
} |
|
1533 |
||
1534 |
if ( ! $has_custom_theme ) { |
|
1535 |
return; |
|
1536 |
} |
|
1537 |
||
1538 |
$wp_scripts = wp_scripts(); |
|
1539 |
||
1540 |
$wp_scripts->remove( 'wp-tinymce' ); |
|
1541 |
wp_register_tinymce_scripts( $wp_scripts, true ); |
|
1542 |
} |
|
1543 |
||
1544 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1545 |
* Print (output) the main TinyMCE scripts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1548 |
* |
16 | 1549 |
* @global bool $concatenate_scripts |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
public static function print_tinymce_scripts() { |
9 | 1552 |
global $concatenate_scripts; |
0 | 1553 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
if ( self::$tinymce_scripts_printed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1555 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1556 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1557 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1558 |
self::$tinymce_scripts_printed = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1559 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1560 |
if ( ! isset( $concatenate_scripts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1561 |
script_concat_settings(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1562 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1563 |
|
9 | 1564 |
wp_print_scripts( array( 'wp-tinymce' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1565 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
echo "<script type='text/javascript'>\n" . self::wp_mce_translation() . "</script>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
} |
0 | 1568 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* Print (output) the TinyMCE configuration and initialization scripts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* |
16 | 1572 |
* @since 3.3.0 |
1573 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* @global string $tinymce_version |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1575 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
public static function editor_js() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
global $tinymce_version; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1579 |
$tmce_on = ! empty( self::$mce_settings ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1580 |
$mce_init = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1581 |
$qt_init = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
|
0 | 1583 |
if ( $tmce_on ) { |
1584 |
foreach ( self::$mce_settings as $editor_id => $init ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1585 |
$options = self::_parse_init( $init ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1586 |
$mce_init .= "'$editor_id':{$options},"; |
0 | 1587 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1588 |
$mce_init = '{' . trim( $mce_init, ',' ) . '}'; |
0 | 1589 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1590 |
$mce_init = '{}'; |
0 | 1591 |
} |
1592 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1593 |
if ( ! empty( self::$qt_settings ) ) { |
0 | 1594 |
foreach ( self::$qt_settings as $editor_id => $init ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1595 |
$options = self::_parse_init( $init ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1596 |
$qt_init .= "'$editor_id':{$options},"; |
0 | 1597 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1598 |
$qt_init = '{' . trim( $qt_init, ',' ) . '}'; |
0 | 1599 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1600 |
$qt_init = '{}'; |
0 | 1601 |
} |
1602 |
||
1603 |
$ref = array( |
|
9 | 1604 |
'plugins' => implode( ',', self::$plugins ), |
1605 |
'theme' => 'modern', |
|
1606 |
'language' => self::$mce_locale, |
|
0 | 1607 |
); |
1608 |
||
9 | 1609 |
$suffix = SCRIPT_DEBUG ? '' : '.min'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1610 |
$baseurl = self::get_baseurl(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1611 |
$version = 'ver=' . $tinymce_version; |
0 | 1612 |
|
5 | 1613 |
/** |
1614 |
* Fires immediately before the TinyMCE settings are printed. |
|
1615 |
* |
|
1616 |
* @since 3.2.0 |
|
1617 |
* |
|
1618 |
* @param array $mce_settings TinyMCE settings array. |
|
1619 |
*/ |
|
1620 |
do_action( 'before_wp_tiny_mce', self::$mce_settings ); |
|
1621 |
?> |
|
0 | 1622 |
|
5 | 1623 |
<script type="text/javascript"> |
0 | 1624 |
tinyMCEPreInit = { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1625 |
baseURL: "<?php echo $baseurl; ?>", |
5 | 1626 |
suffix: "<?php echo $suffix; ?>", |
1627 |
<?php |
|
1628 |
||
1629 |
if ( self::$drag_drop_upload ) { |
|
1630 |
echo 'dragDropUpload: true,'; |
|
1631 |
} |
|
1632 |
||
1633 |
?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1634 |
mceInit: <?php echo $mce_init; ?>, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1635 |
qtInit: <?php echo $qt_init; ?>, |
5 | 1636 |
ref: <?php echo self::_parse_init( $ref ); ?>, |
1637 |
load_ext: function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} |
|
0 | 1638 |
}; |
5 | 1639 |
</script> |
1640 |
<?php |
|
0 | 1641 |
|
1642 |
if ( $tmce_on ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1643 |
self::print_tinymce_scripts(); |
5 | 1644 |
|
1645 |
if ( self::$ext_plugins ) { |
|
16 | 1646 |
// Load the old-format English strings to prevent unsightly labels in old style popups. |
0 | 1647 |
echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; |
5 | 1648 |
} |
0 | 1649 |
} |
1650 |
||
5 | 1651 |
/** |
1652 |
* Fires after tinymce.js is loaded, but before any TinyMCE editor |
|
1653 |
* instances are created. |
|
1654 |
* |
|
1655 |
* @since 3.9.0 |
|
1656 |
* |
|
1657 |
* @param array $mce_settings TinyMCE settings array. |
|
1658 |
*/ |
|
1659 |
do_action( 'wp_tiny_mce_init', self::$mce_settings ); |
|
0 | 1660 |
|
5 | 1661 |
?> |
1662 |
<script type="text/javascript"> |
|
0 | 1663 |
<?php |
1664 |
||
9 | 1665 |
if ( self::$ext_plugins ) { |
0 | 1666 |
echo self::$ext_plugins . "\n"; |
9 | 1667 |
} |
0 | 1668 |
|
9 | 1669 |
if ( ! is_admin() ) { |
0 | 1670 |
echo 'var ajaxurl = "' . admin_url( 'admin-ajax.php', 'relative' ) . '";'; |
9 | 1671 |
} |
0 | 1672 |
|
1673 |
?> |
|
5 | 1674 |
|
1675 |
( function() { |
|
18 | 1676 |
var initialized = []; |
1677 |
var initialize = function() { |
|
1678 |
var init, id, inPostbox, $wrap; |
|
1679 |
var readyState = document.readyState; |
|
5 | 1680 |
|
18 | 1681 |
if ( readyState !== 'complete' && readyState !== 'interactive' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1682 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1683 |
} |
5 | 1684 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1685 |
for ( id in tinyMCEPreInit.mceInit ) { |
18 | 1686 |
if ( initialized.indexOf( id ) > -1 ) { |
1687 |
continue; |
|
1688 |
} |
|
1689 |
||
1690 |
init = tinyMCEPreInit.mceInit[id]; |
|
1691 |
$wrap = tinymce.$( '#wp-' + id + '-wrap' ); |
|
1692 |
inPostbox = $wrap.parents( '.postbox' ).length > 0; |
|
5 | 1693 |
|
18 | 1694 |
if ( |
1695 |
! init.wp_skip_init && |
|
1696 |
( $wrap.hasClass( 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( id ) ) && |
|
1697 |
( readyState === 'complete' || ( ! inPostbox && readyState === 'interactive' ) ) |
|
1698 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1699 |
tinymce.init( init ); |
18 | 1700 |
initialized.push( id ); |
5 | 1701 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1702 |
if ( ! window.wpActiveEditor ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1703 |
window.wpActiveEditor = id; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1704 |
} |
5 | 1705 |
} |
1706 |
} |
|
1707 |
} |
|
1708 |
||
18 | 1709 |
if ( typeof tinymce !== 'undefined' ) { |
1710 |
if ( tinymce.Env.ie && tinymce.Env.ie < 11 ) { |
|
1711 |
tinymce.$( '.wp-editor-wrap ' ).removeClass( 'tmce-active' ).addClass( 'html-active' ); |
|
1712 |
} else { |
|
1713 |
if ( document.readyState === 'complete' ) { |
|
1714 |
initialize(); |
|
1715 |
} else { |
|
1716 |
document.addEventListener( 'readystatechange', initialize ); |
|
1717 |
} |
|
1718 |
} |
|
1719 |
} |
|
1720 |
||
5 | 1721 |
if ( typeof quicktags !== 'undefined' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1722 |
for ( id in tinyMCEPreInit.qtInit ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1723 |
quicktags( tinyMCEPreInit.qtInit[id] ); |
5 | 1724 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1725 |
if ( ! window.wpActiveEditor ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1726 |
window.wpActiveEditor = id; |
5 | 1727 |
} |
1728 |
} |
|
1729 |
} |
|
1730 |
}()); |
|
0 | 1731 |
</script> |
1732 |
<?php |
|
1733 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1734 |
if ( in_array( 'wplink', self::$plugins, true ) || in_array( 'link', self::$qt_buttons, true ) ) { |
0 | 1735 |
self::wp_link_dialog(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1736 |
} |
0 | 1737 |
|
5 | 1738 |
/** |
1739 |
* Fires after any core TinyMCE editor instances are created. |
|
1740 |
* |
|
1741 |
* @since 3.2.0 |
|
1742 |
* |
|
1743 |
* @param array $mce_settings TinyMCE settings array. |
|
1744 |
*/ |
|
1745 |
do_action( 'after_wp_tiny_mce', self::$mce_settings ); |
|
0 | 1746 |
} |
1747 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1748 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1749 |
* Outputs the HTML for distraction-free writing mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1750 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1751 |
* @since 3.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1752 |
* @deprecated 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1753 |
*/ |
0 | 1754 |
public static function wp_fullscreen_html() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1755 |
_deprecated_function( __FUNCTION__, '4.3.0' ); |
0 | 1756 |
} |
1757 |
||
1758 |
/** |
|
1759 |
* Performs post queries for internal linking. |
|
1760 |
* |
|
1761 |
* @since 3.1.0 |
|
1762 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1763 |
* @param array $args { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1764 |
* Optional. Array of link query arguments. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1765 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1766 |
* @type int $pagenum Page number. Default 1. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1767 |
* @type string $s Search keywords. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1768 |
* } |
19 | 1769 |
* @return array|false $results { |
1770 |
* An array of associative arrays of query results, false if there are none. |
|
1771 |
* |
|
1772 |
* @type array ...$0 { |
|
1773 |
* @type int $ID Post ID. |
|
1774 |
* @type string $title The trimmed, escaped post title. |
|
1775 |
* @type string $permalink Post permalink. |
|
1776 |
* @type string $info A 'Y/m/d'-formatted date for 'post' post type, |
|
1777 |
* the 'singular_name' post type label otherwise. |
|
1778 |
* } |
|
1779 |
* } |
|
0 | 1780 |
*/ |
1781 |
public static function wp_link_query( $args = array() ) { |
|
9 | 1782 |
$pts = get_post_types( array( 'public' => true ), 'objects' ); |
0 | 1783 |
$pt_names = array_keys( $pts ); |
1784 |
||
1785 |
$query = array( |
|
9 | 1786 |
'post_type' => $pt_names, |
1787 |
'suppress_filters' => true, |
|
0 | 1788 |
'update_post_term_cache' => false, |
1789 |
'update_post_meta_cache' => false, |
|
9 | 1790 |
'post_status' => 'publish', |
1791 |
'posts_per_page' => 20, |
|
0 | 1792 |
); |
1793 |
||
1794 |
$args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; |
|
1795 |
||
9 | 1796 |
if ( isset( $args['s'] ) ) { |
0 | 1797 |
$query['s'] = $args['s']; |
9 | 1798 |
} |
0 | 1799 |
|
1800 |
$query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; |
|
1801 |
||
1802 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1803 |
* Filters the link query arguments. |
0 | 1804 |
* |
1805 |
* Allows modification of the link query arguments before querying. |
|
1806 |
* |
|
1807 |
* @see WP_Query for a full list of arguments |
|
1808 |
* |
|
1809 |
* @since 3.7.0 |
|
1810 |
* |
|
1811 |
* @param array $query An array of WP_Query arguments. |
|
1812 |
*/ |
|
1813 |
$query = apply_filters( 'wp_link_query_args', $query ); |
|
1814 |
||
1815 |
// Do main query. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1816 |
$get_posts = new WP_Query(); |
9 | 1817 |
$posts = $get_posts->query( $query ); |
0 | 1818 |
|
1819 |
// Build results. |
|
1820 |
$results = array(); |
|
1821 |
foreach ( $posts as $post ) { |
|
16 | 1822 |
if ( 'post' === $post->post_type ) { |
0 | 1823 |
$info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
9 | 1824 |
} else { |
0 | 1825 |
$info = $pts[ $post->post_type ]->labels->singular_name; |
9 | 1826 |
} |
0 | 1827 |
|
1828 |
$results[] = array( |
|
9 | 1829 |
'ID' => $post->ID, |
1830 |
'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
|
0 | 1831 |
'permalink' => get_permalink( $post->ID ), |
9 | 1832 |
'info' => $info, |
0 | 1833 |
); |
1834 |
} |
|
1835 |
||
1836 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1837 |
* Filters the link query results. |
0 | 1838 |
* |
1839 |
* Allows modification of the returned link query results. |
|
1840 |
* |
|
1841 |
* @since 3.7.0 |
|
1842 |
* |
|
5 | 1843 |
* @see 'wp_link_query_args' filter |
1844 |
* |
|
0 | 1845 |
* @param array $results { |
16 | 1846 |
* An array of associative arrays of query results. |
0 | 1847 |
* |
16 | 1848 |
* @type array ...$0 { |
5 | 1849 |
* @type int $ID Post ID. |
1850 |
* @type string $title The trimmed, escaped post title. |
|
1851 |
* @type string $permalink Post permalink. |
|
1852 |
* @type string $info A 'Y/m/d'-formatted date for 'post' post type, |
|
1853 |
* the 'singular_name' post type label otherwise. |
|
0 | 1854 |
* } |
1855 |
* } |
|
5 | 1856 |
* @param array $query An array of WP_Query arguments. |
0 | 1857 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1858 |
$results = apply_filters( 'wp_link_query', $results, $query ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1859 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1860 |
return ! empty( $results ) ? $results : false; |
0 | 1861 |
} |
1862 |
||
1863 |
/** |
|
1864 |
* Dialog for internal linking. |
|
1865 |
* |
|
1866 |
* @since 3.1.0 |
|
1867 |
*/ |
|
1868 |
public static function wp_link_dialog() { |
|
16 | 1869 |
// Run once. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1870 |
if ( self::$link_dialog_printed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1871 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1872 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1873 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1874 |
self::$link_dialog_printed = true; |
5 | 1875 |
|
16 | 1876 |
// `display: none` is required here, see #WP27605. |
5 | 1877 |
?> |
1878 |
<div id="wp-link-backdrop" style="display: none"></div> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1879 |
<div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-modal="true" aria-labelledby="link-modal-title"> |
5 | 1880 |
<form id="wp-link" tabindex="-1"> |
1881 |
<?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> |
|
9 | 1882 |
<h1 id="link-modal-title"><?php _e( 'Insert/edit link' ); ?></h1> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1883 |
<button type="button" id="wp-link-close"><span class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1884 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1885 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1886 |
_e( 'Close' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1887 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1888 |
</span></button> |
5 | 1889 |
<div id="link-selector"> |
1890 |
<div id="link-options"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1891 |
<p class="howto" id="wplink-enter-url"><?php _e( 'Enter the destination URL' ); ?></p> |
5 | 1892 |
<div> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1893 |
<label><span><?php _e( 'URL' ); ?></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1894 |
<input id="wp-link-url" type="text" aria-describedby="wplink-enter-url" /></label> |
5 | 1895 |
</div> |
1896 |
<div class="wp-link-text-field"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1897 |
<label><span><?php _e( 'Link Text' ); ?></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1898 |
<input id="wp-link-text" type="text" /></label> |
5 | 1899 |
</div> |
1900 |
<div class="link-target"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1901 |
<label><span></span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1902 |
<input type="checkbox" id="wp-link-target" /> <?php _e( 'Open link in a new tab' ); ?></label> |
0 | 1903 |
</div> |
1904 |
</div> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1905 |
<p class="howto" id="wplink-link-existing-content"><?php _e( 'Or link to existing content' ); ?></p> |
5 | 1906 |
<div id="search-panel"> |
1907 |
<div class="link-search-wrapper"> |
|
1908 |
<label> |
|
1909 |
<span class="search-label"><?php _e( 'Search' ); ?></span> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1910 |
<input type="search" id="wp-link-search" class="link-search-field" autocomplete="off" aria-describedby="wplink-link-existing-content" /> |
5 | 1911 |
<span class="spinner"></span> |
1912 |
</label> |
|
1913 |
</div> |
|
1914 |
<div id="search-results" class="query-results" tabindex="0"> |
|
1915 |
<ul></ul> |
|
1916 |
<div class="river-waiting"> |
|
1917 |
<span class="spinner"></span> |
|
1918 |
</div> |
|
1919 |
</div> |
|
1920 |
<div id="most-recent-results" class="query-results" tabindex="0"> |
|
1921 |
<div class="query-notice" id="query-notice-message"> |
|
1922 |
<em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1923 |
<em class="query-notice-hint screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1924 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1925 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1926 |
_e( 'Search or use up and down arrow keys to select an item.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1927 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1928 |
</em> |
5 | 1929 |
</div> |
1930 |
<ul></ul> |
|
1931 |
<div class="river-waiting"> |
|
1932 |
<span class="spinner"></span> |
|
1933 |
</div> |
|
16 | 1934 |
</div> |
1935 |
</div> |
|
0 | 1936 |
</div> |
5 | 1937 |
<div class="submitbox"> |
1938 |
<div id="wp-link-cancel"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1939 |
<button type="button" class="button"><?php _e( 'Cancel' ); ?></button> |
5 | 1940 |
</div> |
1941 |
<div id="wp-link-update"> |
|
1942 |
<input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> |
|
1943 |
</div> |
|
0 | 1944 |
</div> |
5 | 1945 |
</form> |
0 | 1946 |
</div> |
5 | 1947 |
<?php |
0 | 1948 |
} |
1949 |
} |