PluginProbe
Code Snippets / 3.6.3
Code Snippets v3.6.3
3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 3.0.1 All 64 releases
code-snippets / php / front-end / mce-strings.php

mce-strings.php in Code Snippets 3.6.3, at php/front-end/mce-strings.php

56 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * For some reason, WordPress requires that TinyMCE translations be hosted in an external file. So that's what this is.
4 *
5 * @package Code_Snippets
6 */
7
8 namespace Code_Snippets;
9
10 use _WP_Editors;
11
12 /**
13 * Variable types.
14 *
15 * @var array<string, string|array<string, Snippet[]>> $strings
16 */
17
18 $strings = [
19 'insert_content_menu' => __( 'Content Snippet', 'code-snippets' ),
20 'insert_content_title' => __( 'Insert Content Snippet', 'code-snippets' ),
21 'snippet_label' => __( 'Snippet', 'code-snippets' ),
22 'php_att_label' => __( 'Run PHP code', 'code-snippets' ),
23 'format_att_label' => __( 'Apply formatting', 'code-snippets' ),
24 'shortcodes_att_label' => __( 'Enable shortcodes', 'code-snippets' ),
25
26 'insert_source_menu' => __( 'Snippet Source Code', 'code-snippets' ),
27 'insert_source_title' => __( 'Insert Snippet Source', 'code-snippets' ),
28 'show_line_numbers_label' => __( 'Show line numbers', 'code-snippets' ),
29 ];
30
31 $strings = array_map( 'esc_js', $strings );
32
33 $snippets = get_snippets();
34
35 $strings['all_snippets'] = [];
36 $strings['content_snippets'] = [];
37
38 foreach ( $snippets as $snippet ) {
39 if ( 'content' === $snippet->scope ) {
40 $strings['content_snippets'][ $snippet->id ] = $snippet->display_name;
41 }
42
43 $strings['all_snippets'][ $snippet->id ] = sprintf(
44 '%s (%s)',
45 $snippet->display_name,
46 strtoupper( $snippet->type )
47 );
48 }
49
50 asort( $strings['all_snippets'], SORT_STRING | SORT_FLAG_CASE );
51 asort( $strings['content_snippets'], SORT_STRING | SORT_FLAG_CASE );
52
53 $strings = [ _WP_Editors::$mce_locale => [ 'code_snippets' => $strings ] ];
54 /** $strings is used by outer file. @noinspection PhpUnusedLocalVariableInspection */
55 $strings = 'tinyMCE.addI18n(' . wp_json_encode( $strings ) . ');';
56