| 1 | Index: wp-includes/js/tinymce/langs/wp-langs.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/tinymce/langs/wp-langs.php (revision 19409) |
|---|
| 4 | +++ wp-includes/js/tinymce/langs/wp-langs.php (working copy) |
|---|
| 5 | @@ -1,16 +1,13 @@ |
|---|
| 6 | <?php |
|---|
| 7 | |
|---|
| 8 | -// escape text only if it needs translating |
|---|
| 9 | function mce_escape($text) { |
|---|
| 10 | - global $wp_editor; |
|---|
| 11 | - |
|---|
| 12 | - if ( 'en' == $wp_editor->mce_locale ) |
|---|
| 13 | - return $text; |
|---|
| 14 | - else |
|---|
| 15 | - return esc_js($text); |
|---|
| 16 | + return esc_js($text); |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | -$lang = 'tinyMCE.addI18n({' . $this->mce_locale . ':{ |
|---|
| 20 | +if ( ! class_exists( '_WP_Editors' ) ) |
|---|
| 21 | + require( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|---|
| 22 | + |
|---|
| 23 | +$lang = 'tinyMCE.addI18n({' . _WP_Editors::$mce_locale . ':{ |
|---|
| 24 | common:{ |
|---|
| 25 | edit_confirm:"' . mce_escape( __('Do you want to use the WYSIWYG mode for this textarea?') ) . '", |
|---|
| 26 | apply:"' . mce_escape( __('Apply') ) . '", |
|---|
| 27 | @@ -232,7 +229,7 @@ |
|---|
| 28 | } |
|---|
| 29 | }}); |
|---|
| 30 | |
|---|
| 31 | -tinyMCE.addI18n("' . $this->mce_locale . '.advanced",{ |
|---|
| 32 | +tinyMCE.addI18n("' . _WP_Editors::$mce_locale . '.advanced",{ |
|---|
| 33 | style_select:"' . mce_escape( /* translators: TinyMCE font styles */ _x('Styles', 'TinyMCE font styles') ) . '", |
|---|
| 34 | font_size:"' . mce_escape( __('Font size') ) . '", |
|---|
| 35 | fontdefault:"' . mce_escape( __('Font family') ) . '", |
|---|
| 36 | @@ -298,7 +295,7 @@ |
|---|
| 37 | toolbar:"' . mce_escape( __('Toolbar') ) . '" |
|---|
| 38 | }); |
|---|
| 39 | |
|---|
| 40 | -tinyMCE.addI18n("' . $this->mce_locale . '.advanced_dlg",{ |
|---|
| 41 | +tinyMCE.addI18n("' . _WP_Editors::$mce_locale . '.advanced_dlg",{ |
|---|
| 42 | about_title:"' . mce_escape( __('About TinyMCE') ) . '", |
|---|
| 43 | about_general:"' . mce_escape( __('About') ) . '", |
|---|
| 44 | about_help:"' . mce_escape( __('Help') ) . '", |
|---|
| 45 | @@ -352,7 +349,7 @@ |
|---|
| 46 | accessibility_usage_title:"' . mce_escape( __('General Usage') ) . '" |
|---|
| 47 | }); |
|---|
| 48 | |
|---|
| 49 | -tinyMCE.addI18n("' . $this->mce_locale . '.media_dlg",{ |
|---|
| 50 | +tinyMCE.addI18n("' . _WP_Editors::$mce_locale . '.media_dlg",{ |
|---|
| 51 | title:"' . mce_escape( __('Insert / edit embedded media') ) . '", |
|---|
| 52 | general:"' . mce_escape( __('General') ) . '", |
|---|
| 53 | advanced:"' . mce_escape( __('Advanced') ) . '", |
|---|
| 54 | @@ -462,7 +459,7 @@ |
|---|
| 55 | source:"' . mce_escape( __('Source') ) . '" |
|---|
| 56 | }); |
|---|
| 57 | |
|---|
| 58 | -tinyMCE.addI18n("' . $this->mce_locale . '.wordpress",{ |
|---|
| 59 | +tinyMCE.addI18n("' . _WP_Editors::$mce_locale . '.wordpress",{ |
|---|
| 60 | wp_adv_desc:"' . mce_escape( __('Show/Hide Kitchen Sink (Alt + Shift + Z)') ) . '", |
|---|
| 61 | wp_more_desc:"' . mce_escape( __('Insert More Tag (Alt + Shift + T)') ) . '", |
|---|
| 62 | wp_page_desc:"' . mce_escape( __('Insert Page break (Alt + Shift + P)') ) . '", |
|---|
| 63 | @@ -477,7 +474,7 @@ |
|---|
| 64 | delgallery:"' . mce_escape( __('Delete Gallery') ) . '" |
|---|
| 65 | }); |
|---|
| 66 | |
|---|
| 67 | -tinyMCE.addI18n("' . $this->mce_locale . '.wpeditimage",{ |
|---|
| 68 | +tinyMCE.addI18n("' . _WP_Editors::$mce_locale . '.wpeditimage",{ |
|---|
| 69 | edit_img:"' . mce_escape( __('Edit Image') ) . '", |
|---|
| 70 | del_img:"' . mce_escape( __('Delete Image') ) . '", |
|---|
| 71 | adv_settings:"' . mce_escape( __('Advanced Settings') ) . '", |
|---|
| 72 | Index: wp-includes/general-template.php |
|---|
| 73 | =================================================================== |
|---|
| 74 | --- wp-includes/general-template.php (revision 19409) |
|---|
| 75 | +++ wp-includes/general-template.php (working copy) |
|---|
| 76 | @@ -1766,11 +1766,29 @@ |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | /** |
|---|
| 80 | - * Loads and initializes WP_Editor class (if needed), passes the settings for an instance of the editor |
|---|
| 81 | + * Find out which editor should be displayed by default. |
|---|
| 82 | * |
|---|
| 83 | + * Works out which of the two editors to display as the current editor for a |
|---|
| 84 | + * user. |
|---|
| 85 | + * |
|---|
| 86 | + * @since 2.5.0 |
|---|
| 87 | + * |
|---|
| 88 | + * @return string Either 'tinymce', or 'html', or 'test' |
|---|
| 89 | + */ |
|---|
| 90 | +function wp_default_editor() { |
|---|
| 91 | + $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults |
|---|
| 92 | + if ( $user = wp_get_current_user() ) { // look for cookie |
|---|
| 93 | + $ed = get_user_setting('editor', 'tinymce'); |
|---|
| 94 | + $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; |
|---|
| 95 | + } |
|---|
| 96 | + return apply_filters( 'wp_default_editor', $r ); // filter |
|---|
| 97 | +} |
|---|
| 98 | + |
|---|
| 99 | +/** |
|---|
| 100 | + * Renders an editor. |
|---|
| 101 | + * |
|---|
| 102 | * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags. |
|---|
| 103 | - * WP_Editor shouldn't be instantiated separately as it keeps track of loaded scripts. |
|---|
| 104 | - * See http://core.trac.wordpress.org/ticket/17144. |
|---|
| 105 | + * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144. |
|---|
| 106 | * |
|---|
| 107 | * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason |
|---|
| 108 | * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used. |
|---|
| 109 | @@ -1783,17 +1801,13 @@ |
|---|
| 110 | * |
|---|
| 111 | * @param string $content Initial content for the editor. |
|---|
| 112 | * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/. |
|---|
| 113 | - * @param array $settings See WP_Editor::editor(). |
|---|
| 114 | + * @param array $settings See _WP_Editors::editor(). |
|---|
| 115 | */ |
|---|
| 116 | function wp_editor( $content, $editor_id, $settings = array() ) { |
|---|
| 117 | - global $wp_editor; |
|---|
| 118 | - |
|---|
| 119 | - if ( !is_a($wp_editor, 'WP_Editor') ) { |
|---|
| 120 | + if ( ! class_exists( '_WP_Editors' ) ) |
|---|
| 121 | require( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|---|
| 122 | - $wp_editor = new WP_Editor; |
|---|
| 123 | - } |
|---|
| 124 | |
|---|
| 125 | - $wp_editor->editor($content, $editor_id, $settings); |
|---|
| 126 | + _WP_Editors::editor($content, $editor_id, $settings); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | /** |
|---|
| 130 | Index: wp-includes/deprecated.php |
|---|
| 131 | =================================================================== |
|---|
| 132 | --- wp-includes/deprecated.php (revision 19409) |
|---|
| 133 | +++ wp-includes/deprecated.php (working copy) |
|---|
| 134 | @@ -2617,27 +2617,6 @@ |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | /** |
|---|
| 138 | - * Find out which editor should be displayed |
|---|
| 139 | - * |
|---|
| 140 | - * @see WP_Editor::wp_default_editor() |
|---|
| 141 | - * @since 2.5.0 |
|---|
| 142 | - * @deprecated 3.5 |
|---|
| 143 | - * |
|---|
| 144 | - * @return bool |
|---|
| 145 | - */ |
|---|
| 146 | -function wp_default_editor() { |
|---|
| 147 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|---|
| 148 | - |
|---|
| 149 | - global $wp_editor; |
|---|
| 150 | - if ( !is_a($wp_editor, 'WP_Editor') ) { |
|---|
| 151 | - require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|---|
| 152 | - $wp_editor = new WP_Editor; |
|---|
| 153 | - } |
|---|
| 154 | - |
|---|
| 155 | - return $wp_editor->wp_default_editor(); |
|---|
| 156 | -} |
|---|
| 157 | - |
|---|
| 158 | -/** |
|---|
| 159 | * Display editor: TinyMCE, HTML, or both. |
|---|
| 160 | * |
|---|
| 161 | * @since 2.1.0 |
|---|
| 162 | Index: wp-includes/class-wp-editor.php |
|---|
| 163 | =================================================================== |
|---|
| 164 | --- wp-includes/class-wp-editor.php (revision 19409) |
|---|
| 165 | +++ wp-includes/class-wp-editor.php (working copy) |
|---|
| 166 | @@ -8,31 +8,26 @@ |
|---|
| 167 | * Private, not included by default. See wp_editor() in wp-includes/general-template.php. |
|---|
| 168 | */ |
|---|
| 169 | |
|---|
| 170 | -class WP_Editor { |
|---|
| 171 | +final class _WP_Editors { |
|---|
| 172 | + public static $mce_locale; |
|---|
| 173 | |
|---|
| 174 | - var $mce_settings = array(); |
|---|
| 175 | - var $qt_settings = array(); |
|---|
| 176 | - var $plugins = array(); |
|---|
| 177 | - var $qt_buttons = array(); |
|---|
| 178 | - var $mce_locale; |
|---|
| 179 | - var $ext_plugins; |
|---|
| 180 | - var $baseurl; |
|---|
| 181 | - var $can_richedit; |
|---|
| 182 | - var $default_editor; |
|---|
| 183 | - var $first_init; |
|---|
| 184 | - var $this_tinymce = false; |
|---|
| 185 | - var $this_quicktags = false; |
|---|
| 186 | - var $has_tinymce = false; |
|---|
| 187 | - var $has_quicktags = false; |
|---|
| 188 | - var $has_medialib = false; |
|---|
| 189 | - var $editor_buttons_css = true; |
|---|
| 190 | + private static $mce_settings = array(); |
|---|
| 191 | + private static $qt_settings = array(); |
|---|
| 192 | + private static $plugins = array(); |
|---|
| 193 | + private static $qt_buttons = array(); |
|---|
| 194 | + private static $ext_plugins; |
|---|
| 195 | + private static $baseurl; |
|---|
| 196 | + private static $first_init; |
|---|
| 197 | + private static $this_tinymce = false; |
|---|
| 198 | + private static $this_quicktags = false; |
|---|
| 199 | + private static $has_tinymce = false; |
|---|
| 200 | + private static $has_quicktags = false; |
|---|
| 201 | + private static $has_medialib = false; |
|---|
| 202 | + private static $editor_buttons_css = true; |
|---|
| 203 | |
|---|
| 204 | - function __construct() { |
|---|
| 205 | - $this->can_richedit = user_can_richedit(); |
|---|
| 206 | - $this->default_editor = $this->wp_default_editor(); |
|---|
| 207 | - } |
|---|
| 208 | + private function __construct() {} |
|---|
| 209 | |
|---|
| 210 | - function parse_settings($editor_id, $settings) { |
|---|
| 211 | + public static function parse_settings($editor_id, $settings) { |
|---|
| 212 | $set = wp_parse_args( $settings, array( |
|---|
| 213 | 'wpautop' => true, // use wpautop? |
|---|
| 214 | 'media_buttons' => true, // show insert/upload button(s) |
|---|
| 215 | @@ -43,19 +38,23 @@ |
|---|
| 216 | 'editor_class' => '', // add extra class(es) to the editor textarea |
|---|
| 217 | 'teeny' => false, // output the minimal editor config used in Press This |
|---|
| 218 | 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css) |
|---|
| 219 | - 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() |
|---|
| 220 | + 'tinymce' => null, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() |
|---|
| 221 | 'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array() |
|---|
| 222 | ) ); |
|---|
| 223 | |
|---|
| 224 | - $this->this_tinymce = !empty($set['tinymce']) && $this->can_richedit; |
|---|
| 225 | - $this->this_quicktags = !empty($set['quicktags']); |
|---|
| 226 | + if ( null === $set['tinymce'] ) |
|---|
| 227 | + self::$this_tinymce = user_can_richedit(); |
|---|
| 228 | + else |
|---|
| 229 | + self::$this_tinymce = (bool) $set['tinymce']; |
|---|
| 230 | |
|---|
| 231 | - if ( $this->this_tinymce ) |
|---|
| 232 | - $this->has_tinymce = true; |
|---|
| 233 | + self::$this_quicktags = (bool) $set['quicktags']; |
|---|
| 234 | |
|---|
| 235 | - if ( $this->this_quicktags ) |
|---|
| 236 | - $this->has_quicktags = true; |
|---|
| 237 | + if ( self::$this_tinymce ) |
|---|
| 238 | + self::$has_tinymce = true; |
|---|
| 239 | |
|---|
| 240 | + if ( self::$this_quicktags ) |
|---|
| 241 | + self::$has_quicktags = true; |
|---|
| 242 | + |
|---|
| 243 | return $set; |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | @@ -64,11 +63,11 @@ |
|---|
| 247 | * |
|---|
| 248 | * @param string $content The initial content of the editor. |
|---|
| 249 | * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). |
|---|
| 250 | - * @param array $settings See WP_Editor::_parse_settings for description. |
|---|
| 251 | + * @param array $settings See the _parse_settings() method for description. |
|---|
| 252 | */ |
|---|
| 253 | - function editor( $content, $editor_id, $settings = array() ) { |
|---|
| 254 | + public static function editor( $content, $editor_id, $settings = array() ) { |
|---|
| 255 | |
|---|
| 256 | - $set = $this->parse_settings($editor_id, $settings); |
|---|
| 257 | + $set = self::parse_settings($editor_id, $settings); |
|---|
| 258 | $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"'; |
|---|
| 259 | $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; |
|---|
| 260 | $rows = ' rows="' . (int) $set['textarea_rows'] . '"'; |
|---|
| 261 | @@ -78,10 +77,10 @@ |
|---|
| 262 | if ( !current_user_can( 'upload_files' ) ) |
|---|
| 263 | $set['media_buttons'] = false; |
|---|
| 264 | |
|---|
| 265 | - if ( $this->this_quicktags && $this->this_tinymce ) { |
|---|
| 266 | + if ( self::$this_quicktags && self::$this_tinymce ) { |
|---|
| 267 | $switch_class = 'html-active'; |
|---|
| 268 | |
|---|
| 269 | - if ( 'html' == $this->default_editor ) { |
|---|
| 270 | + if ( 'html' == wp_default_editor() ) { |
|---|
| 271 | add_filter('the_editor_content', 'wp_htmledit_pre'); |
|---|
| 272 | } else { |
|---|
| 273 | add_filter('the_editor_content', 'wp_richedit_pre'); |
|---|
| 274 | @@ -94,9 +93,9 @@ |
|---|
| 275 | |
|---|
| 276 | echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">'; |
|---|
| 277 | |
|---|
| 278 | - if ( $this->editor_buttons_css ) { |
|---|
| 279 | + if ( self::$editor_buttons_css ) { |
|---|
| 280 | wp_print_styles('editor-buttons'); |
|---|
| 281 | - $this->editor_buttons_css = false; |
|---|
| 282 | + self::$editor_buttons_css = false; |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | if ( !empty($set['editor_css']) ) |
|---|
| 286 | @@ -107,7 +106,7 @@ |
|---|
| 287 | echo $buttons; |
|---|
| 288 | |
|---|
| 289 | if ( $set['media_buttons'] ) { |
|---|
| 290 | - $this->has_medialib = true; |
|---|
| 291 | + self::$has_medialib = true; |
|---|
| 292 | |
|---|
| 293 | if ( !function_exists('media_buttons') ) |
|---|
| 294 | include(ABSPATH . 'wp-admin/includes/media.php'); |
|---|
| 295 | @@ -125,24 +124,24 @@ |
|---|
| 296 | printf($the_editor, $content); |
|---|
| 297 | echo "\n</div>\n\n"; |
|---|
| 298 | |
|---|
| 299 | - $this->editor_settings($editor_id, $set); |
|---|
| 300 | + self::editor_settings($editor_id, $set); |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | - function editor_settings($editor_id, $set) { |
|---|
| 304 | + public static function editor_settings($editor_id, $set) { |
|---|
| 305 | global $editor_styles; |
|---|
| 306 | $first_run = false; |
|---|
| 307 | |
|---|
| 308 | - if ( empty($this->first_init) ) { |
|---|
| 309 | + if ( empty(self::$first_init) ) { |
|---|
| 310 | if ( is_admin() ) { |
|---|
| 311 | - add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 ); |
|---|
| 312 | - add_action( 'admin_footer', array($this, 'enqueue_scripts'), 1 ); |
|---|
| 313 | + add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js'), 50 ); |
|---|
| 314 | + add_action( 'admin_footer', array( __CLASS__, 'enqueue_scripts'), 1 ); |
|---|
| 315 | } else { |
|---|
| 316 | - add_action( 'wp_print_footer_scripts', array($this, 'editor_js'), 50 ); |
|---|
| 317 | - add_action( 'wp_footer', array($this, 'enqueue_scripts'), 1 ); |
|---|
| 318 | + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js'), 50 ); |
|---|
| 319 | + add_action( 'wp_footer', array( __CLASS__, 'enqueue_scripts'), 1 ); |
|---|
| 320 | } |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | - if ( $this->this_quicktags ) { |
|---|
| 324 | + if ( self::$this_quicktags ) { |
|---|
| 325 | |
|---|
| 326 | $qtInit = array( |
|---|
| 327 | 'id' => $editor_id, |
|---|
| 328 | @@ -159,22 +158,22 @@ |
|---|
| 329 | $qtInit['buttons'] .= ',fullscreen'; |
|---|
| 330 | |
|---|
| 331 | $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id); |
|---|
| 332 | - $this->qt_settings[$editor_id] = $qtInit; |
|---|
| 333 | + self::$qt_settings[$editor_id] = $qtInit; |
|---|
| 334 | |
|---|
| 335 | - $this->qt_buttons = array_merge( $this->qt_buttons, explode(',', $qtInit['buttons']) ); |
|---|
| 336 | + self::$qt_buttons = array_merge( self::$qt_buttons, explode(',', $qtInit['buttons']) ); |
|---|
| 337 | } |
|---|
| 338 | |
|---|
| 339 | - if ( $this->this_tinymce ) { |
|---|
| 340 | + if ( self::$this_tinymce ) { |
|---|
| 341 | |
|---|
| 342 | - if ( empty($this->first_init) ) { |
|---|
| 343 | - $this->baseurl = includes_url('js/tinymce'); |
|---|
| 344 | - $this->mce_locale = $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 |
|---|
| 345 | + if ( empty(self::$first_init) ) { |
|---|
| 346 | + self::$baseurl = includes_url('js/tinymce'); |
|---|
| 347 | + self::$mce_locale = $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 |
|---|
| 348 | $no_captions = (bool) apply_filters( 'disable_captions', '' ); |
|---|
| 349 | $plugins = array( 'inlinepopups', 'spellchecker', 'tabfocus', 'paste', 'media', 'fullscreen', 'wordpress', 'wpeditimage', 'wpgallery', 'wplink', 'wpdialogs' ); |
|---|
| 350 | $first_run = true; |
|---|
| 351 | |
|---|
| 352 | if ( $set['teeny'] ) { |
|---|
| 353 | - $this->plugins = $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs'), $editor_id ); |
|---|
| 354 | + self::$plugins = $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs'), $editor_id ); |
|---|
| 355 | $ext_plugins = ''; |
|---|
| 356 | } else { |
|---|
| 357 | /* |
|---|
| 358 | @@ -253,7 +252,7 @@ |
|---|
| 359 | $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n"; |
|---|
| 360 | $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; |
|---|
| 361 | |
|---|
| 362 | - $this->ext_plugins .= $ext_plugins; |
|---|
| 363 | + self::$ext_plugins .= $ext_plugins; |
|---|
| 364 | } |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | @@ -263,7 +262,7 @@ |
|---|
| 368 | if ( $set['dfw'] ) |
|---|
| 369 | $plugins[] = 'wpfullscreen'; |
|---|
| 370 | |
|---|
| 371 | - $this->plugins = $plugins; |
|---|
| 372 | + self::$plugins = $plugins; |
|---|
| 373 | |
|---|
| 374 | /* |
|---|
| 375 | The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu. |
|---|
| 376 | @@ -273,12 +272,12 @@ |
|---|
| 377 | */ |
|---|
| 378 | $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv'); |
|---|
| 379 | |
|---|
| 380 | - $this->first_init = array( |
|---|
| 381 | + self::$first_init = array( |
|---|
| 382 | 'mode' => 'exact', |
|---|
| 383 | 'width' => '100%', |
|---|
| 384 | 'theme' => 'advanced', |
|---|
| 385 | 'skin' => 'wp_theme', |
|---|
| 386 | - 'language' => $this->mce_locale, |
|---|
| 387 | + 'language' => self::$mce_locale, |
|---|
| 388 | 'spellchecker_languages' => $mce_spellchecker_languages, |
|---|
| 389 | 'theme_advanced_toolbar_location' => 'top', |
|---|
| 390 | 'theme_advanced_toolbar_align' => 'left', |
|---|
| 391 | @@ -317,7 +316,7 @@ |
|---|
| 392 | 'paste_text_use_dialog' => true, |
|---|
| 393 | 'extended_valid_elements' => 'article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr', |
|---|
| 394 | 'wpeditimage_disable_captions' => $no_captions, |
|---|
| 395 | - 'wp_fullscreen_content_css' => "$this->baseurl/plugins/wpfullscreen/css/wp-fullscreen.css", |
|---|
| 396 | + 'wp_fullscreen_content_css' => self::$baseurl . '/plugins/wpfullscreen/css/wp-fullscreen.css', |
|---|
| 397 | 'plugins' => implode( ',', $plugins ) |
|---|
| 398 | ); |
|---|
| 399 | |
|---|
| 400 | @@ -352,7 +351,7 @@ |
|---|
| 401 | $mce_css = trim( apply_filters( 'mce_css', $mce_css ), ' ,' ); |
|---|
| 402 | |
|---|
| 403 | if ( ! empty($mce_css) ) |
|---|
| 404 | - $this->first_init['content_css'] = $mce_css; |
|---|
| 405 | + self::$first_init['content_css'] = $mce_css; |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | if ( $set['teeny'] ) { |
|---|
| 409 | @@ -389,7 +388,7 @@ |
|---|
| 410 | ); |
|---|
| 411 | |
|---|
| 412 | if ( $first_run ) |
|---|
| 413 | - $mceInit = array_merge($this->first_init, $mceInit); |
|---|
| 414 | + $mceInit = array_merge(self::$first_init, $mceInit); |
|---|
| 415 | |
|---|
| 416 | if ( is_array($set['tinymce']) ) |
|---|
| 417 | $mceInit = array_merge($mceInit, $set['tinymce']); |
|---|
| 418 | @@ -409,11 +408,11 @@ |
|---|
| 419 | $mceInit['theme_advanced_buttons4'] = ''; |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | - $this->mce_settings[$editor_id] = $mceInit; |
|---|
| 423 | - } // end if $this->this_tinymce |
|---|
| 424 | + self::$mce_settings[$editor_id] = $mceInit; |
|---|
| 425 | + } // end if self::$this_tinymce |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | - function _parse_init($init) { |
|---|
| 429 | + private static function _parse_init($init) { |
|---|
| 430 | $options = ''; |
|---|
| 431 | |
|---|
| 432 | foreach ( $init as $k => $v ) { |
|---|
| 433 | @@ -431,50 +430,31 @@ |
|---|
| 434 | return '{' . trim( $options, ' ,' ) . '}'; |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | - /** |
|---|
| 438 | - * Find out which editor should be displayed by default. |
|---|
| 439 | - * |
|---|
| 440 | - * Works out which of the two editors to display as the current editor for a |
|---|
| 441 | - * user. |
|---|
| 442 | - * |
|---|
| 443 | - * @since 2.5.0 |
|---|
| 444 | - * |
|---|
| 445 | - * @return string Either 'tinymce', or 'html', or 'test' |
|---|
| 446 | - */ |
|---|
| 447 | - function wp_default_editor() { |
|---|
| 448 | - $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults |
|---|
| 449 | - if ( $user = wp_get_current_user() ) { // look for cookie |
|---|
| 450 | - $ed = get_user_setting('editor', 'tinymce'); |
|---|
| 451 | - $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; |
|---|
| 452 | - } |
|---|
| 453 | - return apply_filters( 'wp_default_editor', $r ); // filter |
|---|
| 454 | - } |
|---|
| 455 | - |
|---|
| 456 | - function enqueue_scripts() { |
|---|
| 457 | + public static function enqueue_scripts() { |
|---|
| 458 | wp_enqueue_script('word-count'); |
|---|
| 459 | |
|---|
| 460 | - if ( $this->has_tinymce ) |
|---|
| 461 | + if ( self::$has_tinymce ) |
|---|
| 462 | wp_enqueue_script('editor'); |
|---|
| 463 | |
|---|
| 464 | - if ( $this->has_quicktags ) |
|---|
| 465 | + if ( self::$has_quicktags ) |
|---|
| 466 | wp_enqueue_script('quicktags'); |
|---|
| 467 | |
|---|
| 468 | - if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) { |
|---|
| 469 | + if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) { |
|---|
| 470 | wp_enqueue_script('wplink'); |
|---|
| 471 | wp_enqueue_script('wpdialogs-popup'); |
|---|
| 472 | wp_enqueue_style('wp-jquery-ui-dialog'); |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | - if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) ) |
|---|
| 476 | + if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) ) |
|---|
| 477 | wp_enqueue_script('wp-fullscreen'); |
|---|
| 478 | |
|---|
| 479 | - if ( $this->has_medialib ) { |
|---|
| 480 | + if ( self::$has_medialib ) { |
|---|
| 481 | add_thickbox(); |
|---|
| 482 | wp_enqueue_script('media-upload'); |
|---|
| 483 | } |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | - function editor_js() { |
|---|
| 487 | + public static function editor_js() { |
|---|
| 488 | global $tinymce_version, $concatenate_scripts, $compress_scripts; |
|---|
| 489 | |
|---|
| 490 | /** |
|---|
| 491 | @@ -485,7 +465,7 @@ |
|---|
| 492 | * If the plugin has a popup dialog, a query string can be added to the button action that opens it (in the plugin's code). |
|---|
| 493 | */ |
|---|
| 494 | $version = 'ver=' . $tinymce_version; |
|---|
| 495 | - $tmce_on = !empty($this->mce_settings); |
|---|
| 496 | + $tmce_on = !empty(self::$mce_settings); |
|---|
| 497 | |
|---|
| 498 | if ( ! isset($concatenate_scripts) ) |
|---|
| 499 | script_concat_settings(); |
|---|
| 500 | @@ -493,13 +473,13 @@ |
|---|
| 501 | $compressed = $compress_scripts && $concatenate_scripts && isset($_SERVER['HTTP_ACCEPT_ENCODING']) |
|---|
| 502 | && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
|---|
| 503 | |
|---|
| 504 | - if ( $tmce_on && 'en' != $this->mce_locale ) |
|---|
| 505 | + if ( $tmce_on && 'en' != self::$mce_locale ) |
|---|
| 506 | include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php'); |
|---|
| 507 | |
|---|
| 508 | $mceInit = $qtInit = ''; |
|---|
| 509 | if ( $tmce_on ) { |
|---|
| 510 | - foreach ( $this->mce_settings as $editor_id => $init ) { |
|---|
| 511 | - $options = $this->_parse_init( $init ); |
|---|
| 512 | + foreach ( self::$mce_settings as $editor_id => $init ) { |
|---|
| 513 | + $options = self::_parse_init( $init ); |
|---|
| 514 | $mceInit .= "'$editor_id':{$options},"; |
|---|
| 515 | } |
|---|
| 516 | $mceInit = '{' . trim($mceInit, ',') . '}'; |
|---|
| 517 | @@ -507,9 +487,9 @@ |
|---|
| 518 | $mceInit = '{}'; |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | - if ( !empty($this->qt_settings) ) { |
|---|
| 522 | - foreach ( $this->qt_settings as $editor_id => $init ) { |
|---|
| 523 | - $options = $this->_parse_init( $init ); |
|---|
| 524 | + if ( !empty(self::$qt_settings) ) { |
|---|
| 525 | + foreach ( self::$qt_settings as $editor_id => $init ) { |
|---|
| 526 | + $options = self::_parse_init( $init ); |
|---|
| 527 | $qtInit .= "'$editor_id':{$options},"; |
|---|
| 528 | } |
|---|
| 529 | $qtInit = '{' . trim($qtInit, ',') . '}'; |
|---|
| 530 | @@ -518,43 +498,45 @@ |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | $ref = array( |
|---|
| 534 | - 'plugins' => implode( ',', $this->plugins ), |
|---|
| 535 | + 'plugins' => implode( ',', self::$plugins ), |
|---|
| 536 | 'theme' => 'advanced', |
|---|
| 537 | - 'language' => $this->mce_locale |
|---|
| 538 | + 'language' => self::$mce_locale |
|---|
| 539 | ); |
|---|
| 540 | |
|---|
| 541 | - do_action('before_wp_tiny_mce', $this->mce_settings); |
|---|
| 542 | + do_action('before_wp_tiny_mce', self::$mce_settings); |
|---|
| 543 | ?> |
|---|
| 544 | |
|---|
| 545 | <script type="text/javascript"> |
|---|
| 546 | tinyMCEPreInit = { |
|---|
| 547 | - base : "<?php echo $this->baseurl; ?>", |
|---|
| 548 | + base : "<?php echo self::$baseurl; ?>", |
|---|
| 549 | suffix : "", |
|---|
| 550 | query : "<?php echo $version; ?>", |
|---|
| 551 | mceInit : <?php echo $mceInit; ?>, |
|---|
| 552 | qtInit : <?php echo $qtInit; ?>, |
|---|
| 553 | - ref : <?php echo $this->_parse_init( $ref ); ?>, |
|---|
| 554 | + ref : <?php echo self::_parse_init( $ref ); ?>, |
|---|
| 555 | load_ext : function(url,lang){var sl=tinymce.ScriptLoader;sl.markDone(url+'/langs/'+lang+'.js');sl.markDone(url+'/langs/'+lang+'_dlg.js');} |
|---|
| 556 | }; |
|---|
| 557 | </script> |
|---|
| 558 | <?php |
|---|
| 559 | |
|---|
| 560 | + $baseurl = self::$baseurl; |
|---|
| 561 | + |
|---|
| 562 | if ( $tmce_on ) { |
|---|
| 563 | if ( $compressed ) |
|---|
| 564 | - echo "<script type='text/javascript' src='$this->baseurl/wp-tinymce.php?c=1&$version'></script>\n"; |
|---|
| 565 | + echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n"; |
|---|
| 566 | else |
|---|
| 567 | - echo "<script type='text/javascript' src='$this->baseurl/tiny_mce.js?$version'></script>\n"; |
|---|
| 568 | + echo "<script type='text/javascript' src='{$baseurl}/tiny_mce.js?$version'></script>\n"; |
|---|
| 569 | |
|---|
| 570 | - if ( 'en' != $this->mce_locale && isset($lang) ) |
|---|
| 571 | + if ( 'en' != self::$mce_locale && isset($lang) ) |
|---|
| 572 | echo "<script type='text/javascript'>\n$lang\n</script>\n"; |
|---|
| 573 | else |
|---|
| 574 | - echo "<script type='text/javascript' src='$this->baseurl/langs/wp-langs-en.js?$version'></script>\n"; |
|---|
| 575 | + echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; |
|---|
| 576 | } |
|---|
| 577 | ?> |
|---|
| 578 | |
|---|
| 579 | <script type="text/javascript"> |
|---|
| 580 | (function(){ |
|---|
| 581 | - var init, ed, qt, first_init, mce = <?php echo $this->default_editor == 'tinymce' ? 'true' : 'false'; ?>; |
|---|
| 582 | + var init, ed, qt, first_init, mce = <?php echo wp_default_editor() == 'tinymce' ? 'true' : 'false'; ?>; |
|---|
| 583 | |
|---|
| 584 | if ( typeof(tinymce) == 'object' ) { |
|---|
| 585 | for ( ed in tinyMCEPreInit.mceInit ) { |
|---|
| 586 | @@ -584,8 +566,8 @@ |
|---|
| 587 | |
|---|
| 588 | <?php |
|---|
| 589 | |
|---|
| 590 | - if ( $this->ext_plugins ) |
|---|
| 591 | - echo "$this->ext_plugins\n"; |
|---|
| 592 | + if ( self::$ext_plugins ) |
|---|
| 593 | + echo self::$ext_plugins . "\n"; |
|---|
| 594 | |
|---|
| 595 | if ( ! $compressed && $tmce_on ) { |
|---|
| 596 | ?> |
|---|
| 597 | @@ -599,16 +581,16 @@ |
|---|
| 598 | </script> |
|---|
| 599 | <?php |
|---|
| 600 | |
|---|
| 601 | - if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) |
|---|
| 602 | - $this->wp_link_dialog(); |
|---|
| 603 | + if ( in_array('wplink', self::$plugins, true) || in_array('link', self::$qt_buttons, true) ) |
|---|
| 604 | + self::wp_link_dialog(); |
|---|
| 605 | |
|---|
| 606 | - if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) ) |
|---|
| 607 | - $this->wp_fullscreen_html(); |
|---|
| 608 | + if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) ) |
|---|
| 609 | + self::wp_fullscreen_html(); |
|---|
| 610 | |
|---|
| 611 | - do_action('after_wp_tiny_mce', $this->mce_settings); |
|---|
| 612 | + do_action('after_wp_tiny_mce', self::$mce_settings); |
|---|
| 613 | } |
|---|
| 614 | |
|---|
| 615 | - function wp_fullscreen_html() { |
|---|
| 616 | + public static function wp_fullscreen_html() { |
|---|
| 617 | global $content_width, $post; |
|---|
| 618 | |
|---|
| 619 | $width = isset($content_width) && 800 > $content_width ? $content_width : 800; |
|---|
| 620 | @@ -705,7 +687,7 @@ |
|---|
| 621 | * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. |
|---|
| 622 | * @return array Results. |
|---|
| 623 | */ |
|---|
| 624 | - function wp_link_query( $args = array() ) { |
|---|
| 625 | + public static function wp_link_query( $args = array() ) { |
|---|
| 626 | $pts = get_post_types( array( 'public' => true ), 'objects' ); |
|---|
| 627 | $pt_names = array_keys( $pts ); |
|---|
| 628 | |
|---|
| 629 | @@ -758,7 +740,7 @@ |
|---|
| 630 | * |
|---|
| 631 | * @since 3.1.0 |
|---|
| 632 | */ |
|---|
| 633 | - function wp_link_dialog() { |
|---|
| 634 | + public static function wp_link_dialog() { |
|---|
| 635 | ?> |
|---|
| 636 | <div style="display:none;"> |
|---|
| 637 | <form id="wp-link" tabindex="-1"> |
|---|
| 638 | Index: wp-admin/admin-ajax.php |
|---|
| 639 | =================================================================== |
|---|
| 640 | --- wp-admin/admin-ajax.php (revision 19409) |
|---|
| 641 | +++ wp-admin/admin-ajax.php (working copy) |
|---|
| 642 | @@ -1130,7 +1130,7 @@ |
|---|
| 643 | $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; |
|---|
| 644 | |
|---|
| 645 | require(ABSPATH . WPINC . '/class-wp-editor.php'); |
|---|
| 646 | - $results = WP_Editor::wp_link_query( $args ); |
|---|
| 647 | + $results = _WP_Editors::wp_link_query( $args ); |
|---|
| 648 | |
|---|
| 649 | if ( ! isset( $results ) ) |
|---|
| 650 | die( '0' ); |
|---|
| 651 | Index: wp-admin/includes/deprecated.php |
|---|
| 652 | =================================================================== |
|---|
| 653 | --- wp-admin/includes/deprecated.php (revision 19409) |
|---|
| 654 | +++ wp-admin/includes/deprecated.php (working copy) |
|---|
| 655 | @@ -711,27 +711,21 @@ |
|---|
| 656 | function wp_tiny_mce( $teeny = false, $settings = false ) { |
|---|
| 657 | _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|---|
| 658 | |
|---|
| 659 | - global $wp_editor; |
|---|
| 660 | static $num = 1; |
|---|
| 661 | |
|---|
| 662 | - if ( !is_a($wp_editor, 'WP_Editor') ) { |
|---|
| 663 | - if ( !class_exists('WP_Editor') ) |
|---|
| 664 | - require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|---|
| 665 | + if ( ! class_exists('_WP_Editors' ) ) |
|---|
| 666 | + require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); |
|---|
| 667 | |
|---|
| 668 | - $wp_editor = new WP_Editor; |
|---|
| 669 | - } |
|---|
| 670 | + $editor_id = 'content' . $num++; |
|---|
| 671 | |
|---|
| 672 | - $editor_id = 'content' . $num; |
|---|
| 673 | - ++$num; |
|---|
| 674 | - |
|---|
| 675 | $set = array( |
|---|
| 676 | 'teeny' => $teeny, |
|---|
| 677 | 'tinymce' => $settings ? $settings : true, |
|---|
| 678 | 'quicktags' => false |
|---|
| 679 | ); |
|---|
| 680 | |
|---|
| 681 | - $set = $wp_editor->parse_settings($editor_id, $set); |
|---|
| 682 | - $wp_editor->editor_settings($editor_id, $set); |
|---|
| 683 | + $set = _WP_Editors::parse_settings($editor_id, $set); |
|---|
| 684 | + _WP_Editors::editor_settings($editor_id, $set); |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | /** |
|---|
| 688 | @@ -762,15 +756,6 @@ |
|---|
| 689 | } |
|---|
| 690 | |
|---|
| 691 | /** |
|---|
| 692 | - * @deprecated 3.3.0 |
|---|
| 693 | - * @deprecated Use wp_editor() |
|---|
| 694 | - * @see wp_editor() |
|---|
| 695 | - */ |
|---|
| 696 | -function wp_fullscreen_html() { |
|---|
| 697 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|---|
| 698 | -} |
|---|
| 699 | - |
|---|
| 700 | -/** |
|---|
| 701 | * Returns the screen layout options. |
|---|
| 702 | * |
|---|
| 703 | * @since 2.8.0 |
|---|