Changeset 32677 for trunk/src/wp-includes/class-wp-editor.php
- Timestamp:
- 06/01/2015 05:37:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-editor.php
r32543 r32677 26 26 private static $editor_buttons_css = true; 27 27 private static $drag_drop_upload = false; 28 private static $old_dfw_compat = false; 28 29 29 30 private function __construct() {} … … 54 55 * @type bool $teeny Whether to output the minimal editor config. Examples include 55 56 * Press This and the Comment editor. Default false. 56 * @type bool $dfw Whether to replace the default fullscreen with "Distraction Free 57 * Writing". DFW requires specific DOM elements and css). Default false. 57 * @type bool $dfw Deprecated in 4.1. Since 4.3 used only to enqueue wp-fullscreen-stub.js for backwards compatibility. 58 58 * @type bool|array $tinymce Whether to load TinyMCE. Can be used to pass settings directly to 59 59 * TinyMCE using an array. Default true. … … 112 112 self::$has_quicktags = true; 113 113 114 if ( $set['dfw'] ) { 115 self::$old_dfw_compat = true; 116 } 117 114 118 if ( empty( $set['editor_height'] ) ) 115 119 return $set; … … 283 287 if ( empty($qtInit['buttons']) ) 284 288 $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'; 285 286 if ( $set['dfw'] )287 $qtInit['buttons'] .= ',fullscreen';288 289 289 290 if ( $set['_content_editor_dfw'] ) { … … 469 470 } 470 471 } 471 472 if ( $set['dfw'] )473 $plugins[] = 'wpfullscreen';474 472 475 473 self::$plugins = $plugins; … … 638 636 } 639 637 640 if ( $set['dfw'] ) {641 // replace the first 'fullscreen' with 'wp_fullscreen'642 if ( ($key = array_search('fullscreen', $mce_buttons)) !== false )643 $mce_buttons[$key] = 'wp_fullscreen';644 elseif ( ($key = array_search('fullscreen', $mce_buttons_2)) !== false )645 $mce_buttons_2[$key] = 'wp_fullscreen';646 elseif ( ($key = array_search('fullscreen', $mce_buttons_3)) !== false )647 $mce_buttons_3[$key] = 'wp_fullscreen';648 elseif ( ($key = array_search('fullscreen', $mce_buttons_4)) !== false )649 $mce_buttons_4[$key] = 'wp_fullscreen';650 }651 652 638 $mceInit = array ( 653 639 'selector' => "#$editor_id", … … 754 740 } 755 741 756 if ( in_array('wpfullscreen', self::$plugins, true) || in_array('fullscreen', self::$qt_buttons, true) ) 757 wp_enqueue_script('wp-fullscreen'); 742 if ( self::$old_dfw_compat ) { 743 wp_enqueue_script('wp-fullscreen-stub'); 744 } 758 745 759 746 if ( self::$has_medialib ) { … … 1253 1240 self::wp_link_dialog(); 1254 1241 1255 if ( in_array( 'wpfullscreen', self::$plugins, true ) || in_array( 'fullscreen', self::$qt_buttons, true ) )1256 self::wp_fullscreen_html();1257 1258 1242 /** 1259 1243 * Fires after any core TinyMCE editor instances are created. … … 1272 1256 */ 1273 1257 public static function wp_fullscreen_html() { 1274 global $content_width; 1275 $post = get_post(); 1276 1277 $width = isset( $content_width ) && 800 > $content_width ? $content_width : 800; 1278 $width = $width + 22; // compensate for the padding and border 1279 $dfw_width = get_user_setting( 'dfw_width', $width ); 1280 $save = $post && $post->post_status == 'publish' ? __('Update') : __('Save'); 1281 1282 ?> 1283 <div id="wp-fullscreen-body" class="wp-core-ui<?php if ( is_rtl() ) echo ' rtl'; ?>" data-theme-width="<?php echo (int) $width; ?>" data-dfw-width="<?php echo (int) $dfw_width; ?>"> 1284 <div id="fullscreen-topbar"> 1285 <div id="wp-fullscreen-toolbar"> 1286 <div id="wp-fullscreen-close"><a href="#" onclick="wp.editor.fullscreen.off();return false;"><?php _e('Exit fullscreen'); ?></a></div> 1287 <div id="wp-fullscreen-central-toolbar" style="width:<?php echo $width; ?>px;"> 1288 1289 <div id="wp-fullscreen-mode-bar"> 1290 <div id="wp-fullscreen-modes" class="button-group"> 1291 <a class="button wp-fullscreen-mode-tinymce" href="#" onclick="wp.editor.fullscreen.switchmode( 'tinymce' ); return false;"><?php _e( 'Visual' ); ?></a> 1292 <a class="button wp-fullscreen-mode-html" href="#" onclick="wp.editor.fullscreen.switchmode( 'html' ); return false;"><?php _ex( 'Text', 'Name for the Text editor tab (formerly HTML)' ); ?></a> 1293 </div> 1294 </div> 1295 1296 <div id="wp-fullscreen-button-bar"><div id="wp-fullscreen-buttons" class="mce-toolbar"> 1297 <?php 1298 1299 $buttons = array( 1300 // format: title, onclick, show in both editors 1301 'bold' => array( 'title' => __('Bold (Ctrl + B)'), 'both' => false ), 1302 'italic' => array( 'title' => __('Italic (Ctrl + I)'), 'both' => false ), 1303 'bullist' => array( 'title' => __('Unordered list (Alt + Shift + U)'), 'both' => false ), 1304 'numlist' => array( 'title' => __('Ordered list (Alt + Shift + O)'), 'both' => false ), 1305 'blockquote' => array( 'title' => __('Blockquote (Alt + Shift + Q)'), 'both' => false ), 1306 'wp-media-library' => array( 'title' => __('Media library (Alt + Shift + M)'), 'both' => true ), 1307 'link' => array( 'title' => __('Insert/edit link (Alt + Shift + A)'), 'both' => true ), 1308 'unlink' => array( 'title' => __('Unlink (Alt + Shift + S)'), 'both' => false ), 1309 'help' => array( 'title' => __('Help (Alt + Shift + H)'), 'both' => false ), 1310 ); 1311 1312 /** 1313 * Filter the list of TinyMCE buttons for the fullscreen 1314 * 'Distraction-Free Writing' editor. 1315 * 1316 * @since 3.2.0 1317 * 1318 * @param array $buttons An array of TinyMCE buttons for the DFW editor. 1319 */ 1320 $buttons = apply_filters( 'wp_fullscreen_buttons', $buttons ); 1321 1322 foreach ( $buttons as $button => $args ) { 1323 if ( 'separator' == $args ) { 1324 continue; 1325 } 1326 1327 $onclick = ! empty( $args['onclick'] ) ? ' onclick="' . $args['onclick'] . '"' : ''; 1328 $title = esc_attr( $args['title'] ); 1329 ?> 1330 1331 <div class="mce-widget mce-btn<?php if ( $args['both'] ) { ?> wp-fullscreen-both<?php } ?>"> 1332 <button type="button" aria-label="<?php echo $title; ?>" title="<?php echo $title; ?>"<?php echo $onclick; ?> id="wp_fs_<?php echo $button; ?>"> 1333 <i class="mce-ico mce-i-<?php echo $button; ?>"></i> 1334 </button> 1335 </div> 1336 <?php 1337 } 1338 1339 ?> 1340 1341 </div></div> 1342 1343 <div id="wp-fullscreen-save"> 1344 <input type="button" class="button button-primary right" value="<?php echo $save; ?>" onclick="wp.editor.fullscreen.save();" /> 1345 <span class="wp-fullscreen-saved-message"><?php if ( $post && $post->post_status == 'publish' ) _e('Updated.'); else _e('Saved.'); ?></span> 1346 <span class="wp-fullscreen-error-message"><?php _e('Save failed.'); ?></span> 1347 <span class="spinner"></span> 1348 </div> 1349 1350 </div> 1351 </div> 1352 </div> 1353 <div id="wp-fullscreen-statusbar"> 1354 <div id="wp-fullscreen-status"> 1355 <div id="wp-fullscreen-count"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></div> 1356 <div id="wp-fullscreen-tagline"><?php _e('Just write.'); ?></div> 1357 </div> 1358 </div> 1359 </div> 1360 1361 <div class="fullscreen-overlay" id="fullscreen-overlay"></div> 1362 <div class="fullscreen-overlay fullscreen-fader fade-300" id="fullscreen-fader"></div> 1363 <?php 1258 _deprecated_function( __FUNCTION__, '4.3' ); 1364 1259 } 1365 1260
Note: See TracChangeset
for help on using the changeset viewer.