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 / views / edit.php

edit.php in Code Snippets 3.0.0, at php/views/edit.php

138 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * HTML for the Add New/Edit Snippet page.
4 *
5 * @package Code_Snippets
6 * @subpackage Views
7 *
8 * @var Edit_Menu $this
9 */
10
11 namespace Code_Snippets;
12
13 /* Bail if accessed directly */
14 if ( ! defined( 'ABSPATH' ) ) {
15 return;
16 }
17
18 $snippet = $this->snippet;
19 $classes = array();
20
21 if ( ! $snippet->id ) {
22 $classes[] = 'new-snippet';
23 } elseif ( 'single-use' === $snippet->scope ) {
24 $classes[] = 'single-use-snippet';
25 } elseif ( 'html' !== $snippet->type ) {
26 $classes[] = ( $snippet->active ? '' : 'in' ) . 'active-snippet';
27 }
28
29 ?>
30 <div class="wrap">
31 <h1>
32 <?php
33
34 if ( $snippet->id ) {
35 esc_html_e( 'Edit Snippet', 'code-snippets' );
36 printf( ' <a href="%1$s" class="page-title-action add-new-h2">%2$s</a>',
37 esc_url( add_query_arg( 'type', $snippet->type, code_snippets()->get_menu_url( 'add' ) ) ),
38 esc_html_x( 'Add New', 'snippet', 'code-snippets' )
39 );
40 } else {
41 esc_html_e( 'Add New Snippet', 'code-snippets' );
42 }
43
44 if ( code_snippets()->is_compact_menu() ) {
45 $this->page_title_actions( [ 'manage', 'import', 'settings' ] );
46 }
47
48 ?>
49 </h1>
50
51 <?php $this->print_messages(); ?>
52
53 <form method="post" id="snippet-form" action="" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
54 data-snippet-type="<?php echo esc_attr( $snippet->type ); ?>">
55 <?php
56 /* Output the hidden fields */
57
58 if ( 0 !== $snippet->id ) {
59 printf( '<input type="hidden" name="snippet_id" value="%d">', esc_attr( $snippet->id ) );
60 }
61
62 printf( '<input type="hidden" name="snippet_active" value="%d">', esc_attr( $snippet->active ) );
63
64 printf( '<input type="hidden" name="current_snippet_scope" value="%s">', esc_attr( $snippet->scope ) );
65
66 do_action( 'code_snippets/admin/before_title_input', $snippet );
67 ?>
68
69 <div id="titlediv">
70 <div id="titlewrap">
71 <label for="title" style="display: none;"><?php esc_html_e( 'Name', 'code-snippets' ); ?></label>
72 <input id="title" type="text" autocomplete="off" name="snippet_name"
73 value="<?php echo esc_attr( $snippet->name ); ?>"
74 placeholder="<?php esc_attr_e( 'Enter title here', 'code-snippets' ); ?>">
75 </div>
76 </div>
77
78 <?php do_action( 'code_snippets/admin/after_title_input', $snippet ); ?>
79
80 <p class="submit-inline"><?php do_action( 'code_snippets/admin/code_editor_toolbar', $snippet ); ?></p>
81
82 <h2>
83 <label for="snippet_code">
84 <?php esc_html_e( 'Code', 'code-snippets' );
85
86 if ( $snippet->id ) {
87 printf( ' <span class="snippet-type-badge" data-type="%s">%s</span>', esc_attr( $snippet->type ), esc_html( $snippet->type ) );
88 }
89
90 ?>
91 </label>
92 </h2>
93
94 <?php if ( ! $snippet->id ) { ?>
95 <h2 class="nav-tab-wrapper" id="snippet-type-tabs">
96 <?php
97
98 foreach ( code_snippets()->get_types() as $type_name => $label ) {
99
100 if ( $snippet->type === $type_name ) {
101 echo '<a class="nav-tab nav-tab-active"';
102 } else {
103 printf( '<a class="nav-tab" href="%s"', esc_url( add_query_arg( 'type', $type_name ) ) );
104 }
105
106 printf( ' data-type="%s">%s <span>%s</span></a>', esc_attr( $type_name ), esc_html( $label ), esc_html( $type_name ) );
107 } ?>
108 </h2>
109 <?php } ?>
110
111 <div class="snippet-editor">
112 <textarea id="snippet_code" name="snippet_code" rows="200" spellcheck="false"
113 style="font-family: monospace; width: 100%;"><?php echo esc_textarea( $snippet->code ); ?></textarea>
114
115 <?php $this->render_view( 'partials/editor-shortcuts' ); ?>
116 </div>
117
118 <div class="below-editor">
119 <?php
120 $this->render_view( 'partials/edit-scopes' );
121 do_action( 'code_snippets_below_editor', $snippet );
122 ?>
123 </div>
124
125 <?php
126
127 /* Allow plugins to add fields and content to this page */
128 do_action( 'code_snippets_edit_snippet', $snippet );
129
130 /* Add a nonce for security */
131 wp_nonce_field( 'save_snippet' );
132
133 ?>
134
135 <p class="submit"><?php $this->render_submit_buttons( $snippet ); ?></p>
136 </form>
137 </div>
138