PluginProbe
Code Snippets / 3.0.0
Code Snippets v3.0.0
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.0.0, at php/front-end/mce-strings.php

52 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 $strings = [
13 'insert_content_menu' => __( 'Content Snippet', 'code-snippets' ),
14 'insert_content_title' => __( 'Insert Content Snippet', 'code-snippets' ),
15 'snippet_label' => __( 'Snippet', 'code-snippets' ),
16 'php_att_label' => __( 'Run PHP code', 'code-snippets' ),
17 'format_att_label' => __( 'Apply formatting', 'code-snippets' ),
18 'shortcodes_att_label' => __( 'Enable shortcodes', 'code-snippets' ),
19
20 'insert_source_menu' => __( 'Snippet Source Code', 'code-snippets' ),
21 'insert_source_title' => __( 'Insert Snippet Source', 'code-snippets' ),
22 'show_line_numbers_label' => __( 'Show line numbers', 'code-snippets' ),
23 ];
24
25 $strings = array_map( 'esc_js', $strings );
26
27 $snippets = get_snippets();
28
29 $strings['all_snippets'] = [];
30 $strings['content_snippets'] = [];
31
32 /** Snippet @var Snippet $snippet */
33 foreach ( $snippets as $snippet ) {
34
35 if ( 'content' === $snippet->scope ) {
36 $strings['content_snippets'][ $snippet->id ] = $snippet->display_name;
37 }
38
39 $strings['all_snippets'][ $snippet->id ] = sprintf(
40 '%s (%s)',
41 $snippet->display_name,
42 strtoupper( $snippet->type )
43 );
44 }
45
46 asort( $strings['all_snippets'], SORT_STRING | SORT_FLAG_CASE );
47 asort( $strings['content_snippets'], SORT_STRING | SORT_FLAG_CASE );
48
49 $strings = [ _WP_Editors::$mce_locale => [ 'code_snippets' => $strings ] ];
50 /** $strings is used by outer file. @noinspection PhpUnusedLocalVariableInspection */
51 $strings = 'tinyMCE.addI18n(' . wp_json_encode( $strings ) . ');';
52