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