PluginProbe
Code Snippets / 3.2.1
Code Snippets v3.2.1
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.2.1, at php/views/edit.php

141 lines 3.6 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(
37 ' <a href="%1$s" class="page-title-action add-new-h2">%2$s</a>',
38 esc_url( add_query_arg( 'type', $snippet->type, code_snippets()->get_menu_url( 'add' ) ) ),
39 esc_html_x( 'Add New', 'snippet', 'code-snippets' )
40 );
41 } else {
42 esc_html_e( 'Add New Snippet', 'code-snippets' );
43 }
44
45 if ( code_snippets()->is_compact_menu() ) {
46 $this->page_title_actions( [ 'manage', 'import', 'settings' ] );
47 }
48
49 ?>
50 </h1>
51
52 <?php $this->print_messages(); ?>
53
54 <form method="post" id="snippet-form" action="" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
55 data-snippet-type="<?php echo esc_attr( $snippet->type ); ?>">
56 <?php
57 /* Output the hidden fields */
58
59 if ( 0 !== $snippet->id ) {
60 printf( '<input type="hidden" name="snippet_id" value="%d">', esc_attr( $snippet->id ) );
61 }
62
63 printf( '<input type="hidden" name="snippet_active" value="%d">', esc_attr( $snippet->active ) );
64
65 printf( '<input type="hidden" name="current_snippet_scope" value="%s">', esc_attr( $snippet->scope ) );
66
67 do_action( 'code_snippets/admin/before_title_input', $snippet );
68 ?>
69
70 <div id="titlediv">
71 <div id="titlewrap">
72 <label for="title" style="display: none;"><?php esc_html_e( 'Name', 'code-snippets' ); ?></label>
73 <input id="title" type="text" autocomplete="off" name="snippet_name"
74 value="<?php echo esc_attr( $snippet->name ); ?>"
75 placeholder="<?php esc_attr_e( 'Enter title here', 'code-snippets' ); ?>">
76 </div>
77 </div>
78
79 <?php do_action( 'code_snippets/admin/after_title_input', $snippet ); ?>
80
81 <p class="submit-inline"><?php do_action( 'code_snippets/admin/code_editor_toolbar', $snippet ); ?></p>
82
83 <h2>
84 <label for="snippet_code">
85 <?php
86 esc_html_e( 'Code', 'code-snippets' );
87
88 if ( $snippet->id ) {
89 printf(
90 ' <span class="snippet-type-badge" data-type="%s">%s</span>',
91 esc_attr( $snippet->type ),
92 esc_html( $snippet->type )
93 );
94 }
95
96 ?>
97 </label>
98 </h2>
99
100 <?php
101
102 if ( ! $snippet->id && ! isset( $_REQUEST['preview'] ) ) {
103 echo '<h2 class="nav-tab-wrapper" id="snippet-type-tabs">';
104
105 foreach ( Plugin::get_types() as $type_name => $label ) {
106 Admin::render_snippet_type_tab( $type_name, $label, $snippet->type );
107 }
108
109 echo '</h2>';
110 }
111
112 ?>
113
114 <div class="snippet-editor">
115 <textarea id="snippet_code" name="snippet_code" rows="200" spellcheck="false"
116 style="font-family: monospace; width: 100%;"><?php echo esc_textarea( $snippet->code ); ?></textarea>
117
118 <?php $this->render_view( 'partials/editor-shortcuts' ); ?>
119 </div>
120
121 <div class="below-editor">
122 <?php
123 $this->render_view( 'partials/edit-scopes' );
124 do_action( 'code_snippets_below_editor', $snippet );
125 ?>
126 </div>
127
128 <?php
129
130 /* Allow plugins to add fields and content to this page */
131 do_action( 'code_snippets_edit_snippet', $snippet );
132
133 /* Add a nonce for security */
134 wp_nonce_field( 'save_snippet' );
135
136 ?>
137
138 <p class="submit"><?php $this->render_submit_buttons( $snippet ); ?></p>
139 </form>
140 </div>
141