Changeset 43867
- Timestamp:
- 11/05/2018 08:38:47 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/src/wp-includes/script-loader.php
r43861 r43867 464 464 ); 465 465 466 // TinyMCE init. 467 $tinymce_plugins = array( 468 'charmap', 469 'colorpicker', 470 'hr', 471 'lists', 472 'media', 473 'paste', 474 'tabfocus', 475 'textcolor', 476 'fullscreen', 477 'wordpress', 478 'wpautoresize', 479 'wpeditimage', 480 'wpemoji', 481 'wpgallery', 482 'wplink', 483 'wpdialogs', 484 'wptextpattern', 485 'wpview', 486 ); 487 466 488 /* This filter is documented in wp-includes/class-wp-editor.php */ 467 $tinymce_settings = apply_filters( 468 'tiny_mce_before_init', 469 array( 470 'plugins' => implode( 471 ',', 472 array_unique( 473 /* This filter is documented in wp-includes/class-wp-editor.php */ 474 apply_filters( 475 'tiny_mce_plugins', 476 array( 477 'charmap', 478 'colorpicker', 479 'hr', 480 'lists', 481 'media', 482 'paste', 483 'tabfocus', 484 'textcolor', 485 'fullscreen', 486 'wordpress', 487 'wpautoresize', 488 'wpeditimage', 489 'wpemoji', 490 'wpgallery', 491 'wplink', 492 'wpdialogs', 493 'wptextpattern', 494 'wpview', 495 ) 496 ) 497 ) 498 ), 499 'toolbar1' => implode( 500 ',', 501 array_merge( 502 /* This filter is documented in wp-includes/class-wp-editor.php */ 503 apply_filters( 504 'mce_buttons', 505 array( 506 'formatselect', 507 'bold', 508 'italic', 509 'bullist', 510 'numlist', 511 'blockquote', 512 'alignleft', 513 'aligncenter', 514 'alignright', 515 'link', 516 'unlink', 517 'wp_more', 518 'spellchecker', 519 'wp_add_media', 520 ), 521 'editor' 522 ), 523 array( 'kitchensink' ) 524 ) 525 ), 526 'toolbar2' => implode( 527 ',', 528 /* This filter is documented in wp-includes/class-wp-editor.php */ 529 apply_filters( 530 'mce_buttons_2', 531 array( 532 'strikethrough', 533 'hr', 534 'forecolor', 535 'pastetext', 536 'removeformat', 537 'charmap', 538 'outdent', 539 'indent', 540 'undo', 541 'redo', 542 'wp_help', 543 ), 544 'editor' 545 ) 546 ), 547 /* This filter is documented in wp-includes/class-wp-editor.php */ 548 'toolbar3' => implode( ',', apply_filters( 'mce_buttons_3', array(), 'editor' ) ), 549 /* This filter is documented in wp-includes/class-wp-editor.php */ 550 'toolbar4' => implode( ',', apply_filters( 'mce_buttons_4', array(), 'editor' ) ), 551 /* This filter is documented in wp-includes/class-wp-editor.php */ 552 'external_plugins' => apply_filters( 'mce_external_plugins', array() ), 553 ), 554 'editor' 489 $tinymce_plugins = apply_filters( 'tiny_mce_plugins', $tinymce_plugins, 'classic-block' ); 490 $tinymce_plugins = array_unique( $tinymce_plugins ); 491 492 $toolbar1 = array( 493 'formatselect', 494 'bold', 495 'italic', 496 'bullist', 497 'numlist', 498 'blockquote', 499 'alignleft', 500 'aligncenter', 501 'alignright', 502 'link', 503 'unlink', 504 'wp_more', 505 'spellchecker', 506 'wp_add_media', 507 'kitchensink', 555 508 ); 556 509 557 if ( isset( $tinymce_settings['style_formats'] ) && is_string( $tinymce_settings['style_formats'] ) ) {558 // Decode the options as we used to recommende json_encoding the TinyMCE settings.559 $tinymce_settings['style_formats'] = json_decode( $tinymce_settings['style_formats'] ); 560 }561 562 $scripts->localize(563 ' wp-block-library',564 ' wpEditorL10n',565 array(566 'tinymce' => array(567 'baseURL' => includes_url( 'js/tinymce' ),568 'suffix' => SCRIPT_DEBUG ? '' : '.min',569 'settings' => $tinymce_settings,570 ),571 )510 /* This filter is documented in wp-includes/class-wp-editor.php */ 511 $toolbar1 = apply_filters( 'mce_buttons', $toolbar1, 'classic-block' ); 512 513 $toolbar2 = array( 514 'strikethrough', 515 'hr', 516 'forecolor', 517 'pastetext', 518 'removeformat', 519 'charmap', 520 'outdent', 521 'indent', 522 'undo', 523 'redo', 524 'wp_help', 572 525 ); 526 527 /* This filter is documented in wp-includes/class-wp-editor.php */ 528 $toolbar2 = apply_filters( 'mce_buttons_2', $toolbar2, 'classic-block' ); 529 /* This filter is documented in wp-includes/class-wp-editor.php */ 530 $toolbar3 = apply_filters( 'mce_buttons_3', array(), 'classic-block' ); 531 /* This filter is documented in wp-includes/class-wp-editor.php */ 532 $toolbar4 = apply_filters( 'mce_buttons_4', array(), 'classic-block' ); 533 /* This filter is documented in wp-includes/class-wp-editor.php */ 534 $external_plugins = apply_filters( 'mce_external_plugins', array(), 'classic-block' ); 535 536 $tinymce_settings = array( 537 'plugins' => implode( ',', $tinymce_plugins ), 538 'toolbar1' => implode( ',', $toolbar1 ), 539 'toolbar2' => implode( ',', $toolbar2 ), 540 'toolbar3' => implode( ',', $toolbar3 ), 541 'toolbar4' => implode( ',', $toolbar4 ), 542 'external_plugins' => wp_json_encode( $external_plugins ), 543 'classic_block_editor' => true, 544 ); 545 546 /* This filter is documented in wp-includes/class-wp-editor.php */ 547 $tinymce_settings = apply_filters( 'tiny_mce_before_init', $tinymce_settings, 'classic-block' ); 548 549 // Do "by hand" translation from PHP array to js object. 550 // Prevents breakage in some custom settings. 551 $init_obj = ''; 552 foreach ( $tinymce_settings as $key => $value ) { 553 if ( is_bool( $value ) ) { 554 $val = $value ? 'true' : 'false'; 555 $init_obj .= $key . ':' . $val . ','; 556 continue; 557 } elseif ( ! empty( $value ) && is_string( $value ) && ( 558 ( '{' == $value{0} && '}' == $value{strlen( $value ) - 1} ) || 559 ( '[' == $value{0} && ']' == $value{strlen( $value ) - 1} ) || 560 preg_match( '/^\(?function ?\(/', $value ) ) ) { 561 $init_obj .= $key . ':' . $value . ','; 562 continue; 563 } 564 $init_obj .= $key . ':"' . $value . '",'; 565 } 566 567 $init_obj = '{' . trim( $init_obj, ' ,' ) . '}'; 568 569 $script = 'window.wpEditorL10n = { 570 tinymce: { 571 baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ', 572 suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ', 573 settings: ' . $init_obj . ', 574 } 575 }'; 576 577 $scripts->add_inline_script( 'wp-block-library', $script, 'before' ); 573 578 } 574 579
Note: See TracChangeset
for help on using the changeset viewer.