Skip to content

Commit 6bff801

Browse files
committed
Updated to version 1.4
1 parent 917d610 commit 6bff801

File tree

150 files changed

+5296
-10367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+5296
-10367
lines changed

code-snippets.php

Lines changed: 219 additions & 78 deletions
Large diffs are not rendered by default.

css/codemirror.css

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
.CodeMirror {
2+
line-height: 1em;
3+
font-family: monospace;
4+
5+
/* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */
6+
position: relative;
7+
/* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */
8+
overflow: hidden;
9+
}
10+
11+
.CodeMirror-scroll {
12+
overflow-x: auto;
13+
overflow-y: hidden;
14+
height: 300px;
15+
/* This is needed to prevent an IE[67] bug where the scrolled content
16+
is visible outside of the scrolling box. */
17+
position: relative;
18+
outline: none;
19+
}
20+
21+
/* Vertical scrollbar */
22+
.CodeMirror-scrollbar {
23+
float: right;
24+
overflow-x: hidden;
25+
overflow-y: scroll;
26+
27+
/* This corrects for the 1px gap introduced to the left of the scrollbar
28+
by the rule for .CodeMirror-scrollbar-inner. */
29+
margin-left: -1px;
30+
}
31+
.CodeMirror-scrollbar-inner {
32+
/* This needs to have a nonzero width in order for the scrollbar to appear
33+
in Firefox and IE9. */
34+
width: 1px;
35+
}
36+
.CodeMirror-scrollbar.cm-sb-overlap {
37+
/* Ensure that the scrollbar appears in Lion, and that it overlaps the content
38+
rather than sitting to the right of it. */
39+
position: absolute;
40+
z-index: 1;
41+
float: none;
42+
right: 0;
43+
min-width: 12px;
44+
}
45+
.CodeMirror-scrollbar.cm-sb-nonoverlap {
46+
min-width: 12px;
47+
}
48+
.CodeMirror-scrollbar.cm-sb-ie7 {
49+
min-width: 18px;
50+
}
51+
52+
.CodeMirror-gutter {
53+
position: absolute; left: 0; top: 0;
54+
z-index: 10;
55+
background-color: #f7f7f7;
56+
border-right: 1px solid #eee;
57+
min-width: 2em;
58+
height: 100%;
59+
}
60+
.CodeMirror-gutter-text {
61+
color: #aaa;
62+
text-align: right;
63+
padding: .4em .2em .4em .4em;
64+
white-space: pre !important;
65+
cursor: default;
66+
}
67+
.CodeMirror-lines {
68+
padding: .4em;
69+
white-space: pre;
70+
cursor: text;
71+
}
72+
.CodeMirror-lines * {
73+
/* Necessary for throw-scrolling to decelerate properly on Safari. */
74+
pointer-events: none;
75+
}
76+
77+
.CodeMirror pre {
78+
-moz-border-radius: 0;
79+
-webkit-border-radius: 0;
80+
-o-border-radius: 0;
81+
border-radius: 0;
82+
border-width: 0; margin: 0; padding: 0; background: transparent;
83+
font-family: inherit;
84+
font-size: inherit;
85+
padding: 0; margin: 0;
86+
white-space: pre;
87+
word-wrap: normal;
88+
line-height: inherit;
89+
color: inherit;
90+
}
91+
92+
.CodeMirror-wrap pre {
93+
word-wrap: break-word;
94+
white-space: pre-wrap;
95+
word-break: normal;
96+
}
97+
.CodeMirror-wrap .CodeMirror-scroll {
98+
overflow-x: hidden;
99+
}
100+
101+
.CodeMirror textarea {
102+
outline: none !important;
103+
}
104+
105+
.CodeMirror pre.CodeMirror-cursor {
106+
z-index: 10;
107+
position: absolute;
108+
visibility: hidden;
109+
border-left: 1px solid black;
110+
border-right: none;
111+
width: 0;
112+
}
113+
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
114+
width: auto;
115+
border: 0;
116+
background: transparent;
117+
background: rgba(0, 200, 0, .4);
118+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
119+
}
120+
/* Kludge to turn off filter in ie9+, which also accepts rgba */
121+
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
122+
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
123+
}
124+
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
125+
.CodeMirror-focused pre.CodeMirror-cursor {
126+
visibility: visible;
127+
}
128+
129+
div.CodeMirror-selected { background: #d9d9d9; }
130+
.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
131+
132+
.CodeMirror-searching {
133+
background: #ffa;
134+
background: rgba(255, 255, 0, .4);
135+
}
136+
137+
/* Default theme */
138+
139+
.cm-s-default span.cm-keyword {color: #708;}
140+
.cm-s-default span.cm-atom {color: #219;}
141+
.cm-s-default span.cm-number {color: #164;}
142+
.cm-s-default span.cm-def {color: #00f;}
143+
.cm-s-default span.cm-variable {color: black;}
144+
.cm-s-default span.cm-variable-2 {color: #05a;}
145+
.cm-s-default span.cm-variable-3 {color: #085;}
146+
.cm-s-default span.cm-property {color: black;}
147+
.cm-s-default span.cm-operator {color: black;}
148+
.cm-s-default span.cm-comment {color: #a50;}
149+
.cm-s-default span.cm-string {color: #a11;}
150+
.cm-s-default span.cm-string-2 {color: #f50;}
151+
.cm-s-default span.cm-meta {color: #555;}
152+
.cm-s-default span.cm-error {color: #f00;}
153+
.cm-s-default span.cm-qualifier {color: #555;}
154+
.cm-s-default span.cm-builtin {color: #30a;}
155+
.cm-s-default span.cm-bracket {color: #cc7;}
156+
.cm-s-default span.cm-tag {color: #170;}
157+
.cm-s-default span.cm-attribute {color: #00c;}
158+
.cm-s-default span.cm-header {color: blue;}
159+
.cm-s-default span.cm-quote {color: #090;}
160+
.cm-s-default span.cm-hr {color: #999;}
161+
.cm-s-default span.cm-link {color: #00c;}
162+
163+
span.cm-header, span.cm-strong {font-weight: bold;}
164+
span.cm-em {font-style: italic;}
165+
span.cm-emstrong {font-style: italic; font-weight: bold;}
166+
span.cm-link {text-decoration: underline;}
167+
168+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
169+
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}

css/dialog.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.CodeMirror-dialog {
2+
position: relative;
3+
}
4+
5+
.CodeMirror-dialog > div {
6+
position: absolute;
7+
top: 0; left: 0; right: 0;
8+
background: white;
9+
border-bottom: 1px solid #eee;
10+
z-index: 15;
11+
padding: .1em .8em;
12+
overflow: hidden;
13+
color: #333;
14+
}
15+
16+
.CodeMirror-dialog input {
17+
border: none;
18+
outline: none;
19+
background: transparent;
20+
width: 20em;
21+
color: inherit;
22+
font-family: monospace;
23+
}
24+
25+
.CodeMirror-dialog button {
26+
font-size: 70%;
27+
}

css/index.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

css/style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,21 @@ tr {
3535

3636
.inactive a {
3737
color: #557799;
38+
}
39+
40+
/* Snippets > Add New */
41+
42+
.CodeMirror {
43+
border: 1px solid #ccc;
44+
-o-border-radius: 3px;
45+
-moz-border-radius: 3px;
46+
-webkit-border-radius: 3px;
47+
border-radius: 3px;
48+
}
3849

50+
.CodeMirror-scroll {
51+
height: auto;
52+
overflow-y: hidden;
53+
overflow-x: auto;
54+
min-height: 242px;
3955
}

images/index.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

includes/admin/admin-manage.php

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,70 @@
11
<?php
2-
if( !class_exists( 'Code_Snippets' ) ) exit;
2+
if( ! class_exists( 'Code_Snippets' ) ) exit;
33
global $wpdb;
4+
$screen = get_current_screen();
5+
if( $screen->is_network ) {
6+
$activate_label = __( 'Network Activate' );
7+
$deactivate_label = __( 'Network Deactivate' );
8+
$activate_title = __( 'Activate this snippet for all sites on the network' );
9+
} else {
10+
$activate_label = __( 'Activate' );
11+
$deactivate_label = __( 'Deactivate' );
12+
$activate_title = __( 'Activate this snippet' );
13+
}
414
?>
515
<div class="wrap">
6-
<div id="icon-snippets" class="icon32"><br /></div><h2>Snippets <a href="<?php echo $this->admin_edit_url; ?>" class="add-new-h2">Add New</a></h2>
16+
<div id="icon-snippets" class="icon32"><br /></div><h2>Snippets <a href="<?php echo $this->admin_single_url; ?>&action=new" class="add-new-h2">Add New</a></h2>
17+
<?php if ( defined( 'CS_SAFE_MODE' ) ) if( CS_SAFE_MODE ) : ?>
18+
<div class="error"><p><strong>Warning:</strong> Safe mode is active and snippets will not execute! Remove the <code>CS_SAFE_MODE</code> constant from wp-config.php to turn off safe mode. <a href="http://cs.bungeshea.com/docs/safe-mode" target="_blank">More info&rarr;</a></p></div>
19+
<?php endif; ?>
720
<?php if ( isset( $msg ) ) : ?>
821
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
922
<?php endif; ?>
1023
<?php $snippets = $wpdb->get_results( 'select * from ' . $this->table ); ?>
1124
<form action="" method="post">
1225
<div class="tablenav top">
1326
<div class="alignleft actions">
14-
<select name='action' class="bulk-actions">
15-
<option value='-1' selected='selected'>Bulk Actions</option>
16-
<option value='activate'>Activate</option>
17-
<option value='deactivate'>Deactivate</option>
18-
<option value='export'>Export</option>
19-
<option value='delete'>Delete</option>
27+
<select name="action" class="bulk-actions">
28+
<option value="-1" selected="selected">Bulk Actions</option>
29+
<option value="activate"><?php echo $activate_label; ?></option>
30+
<option value="deactivate"><?php echo $deactivate_label; ?></option>
31+
<option value="export">Export</option>
32+
<option value="delete">Delete</option>
2033
</select>
2134
<input type="submit" id="doaction" class="button-secondary" value="Apply" />
2235
</div>
2336
</div>
24-
<table class="widefat manage-snippets" style="margin-top: .5em">
37+
<table class="widefat snippets" style="margin-top: .5em">
2538
<thead>
2639
<tr>
2740
<th scope="col" class="check-column"><input type="checkbox" name="toggle" id="toggle" /></th>
28-
<th scope="col" id="name" style="min-width:180px">Name</th>
41+
<th scope="col" id="name" style="width:36ex">Name</th>
2942
<th scope="col" id="description">Description</th>
3043
</tr>
3144
</thead>
32-
<?php if( count( $snippets ) ): ?>
45+
<?php if( count( $snippets ) ) : ?>
3346
<?php foreach( $snippets as $snippet ) : ?>
34-
<tr class='<?php
35-
if($snippet->active == false)
36-
echo 'inactive';
37-
else
38-
echo 'active';
39-
?>'>
47+
<tr class="<?php echo ( $snippet->active ? 'active' : 'inactive' ); ?>">
4048
<th scope="row" class="check-column"><input class="snippets" type="checkbox" name="ids[]" value="<?php echo $snippet->id; ?>" /></th>
4149
<td class="snippet-title"><strong><?php echo stripslashes( $snippet->name );?></strong>
4250
<div class="row-actions-visible">
4351
<?php if( $snippet->active == 0 ) : ?>
44-
<span class='activate'><a href="<?php echo $this->admin_manage_url . '&action=activate&id=' . $snippet->id; ?>" title="Activate this snippet" class="edit">Activate</a> | </span>
52+
<span class="activate"><a href="<?php echo $this->admin_manage_url . '&action=activate&id=' . $snippet->id; ?>" title="<?php echo $activate_title; ?>" class="edit"><?php echo $activate_label; ?></a> | </span>
4553
<?php else : ?>
46-
<span class='deactivate'><a href="<?php echo $this->admin_manage_url . '&action=deactivate&id=' . $snippet->id; ?>" title="Deactivate this snippet" class="edit">Deactivate</a> | </span>
54+
<span class="deactivate"><a href="<?php echo $this->admin_manage_url . '&action=deactivate&id=' . $snippet->id; ?>" title="Deactivate this snippet" class="edit"><?php echo $deactivate_label; ?></a> | </span>
4755
<?php endif; ?>
48-
<span class='edit'><a href="<?php echo $this->admin_edit_url . '&action=edit&id=' . $snippet->id; ?>" title="Edit this snippet" class="edit">Edit</a> | </span>
49-
<span class='edit'><a href="<?php echo $this->admin_manage_url . '&action=export&id=' . $snippet->id; ?>" title="Export this snippet" class="edit">Export</a> | </span>
50-
<span class='delete'><a href="<?php echo $this->admin_manage_url . '&action=delete&id=' . $snippet->id; ?>" title="Delete this snippet" class="delete" onclick="return confirm('Are you sure? This action is non-reversable');">Delete</a></span>
56+
<span class="edit"><a href="<?php echo $this->admin_single_url . '&action=edit&id=' . $snippet->id; ?>" title="Edit this snippet" class="edit">Edit</a> | </span>
57+
<span class="edit"><a href="<?php echo $this->admin_manage_url . '&action=export&id=' . $snippet->id; ?>" title="Export this snippet" class="edit">Export</a> | </span>
58+
<span class="delete"><a href="<?php echo $this->admin_manage_url . '&action=delete&id=' . $snippet->id; ?>" title="Delete this snippet" class="delete" onclick="return confirm('Are you sure? This action is non-reversable');">Delete</a></span>
5159
</div>
5260
</td>
5361
<td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
5462
</tr>
5563
<?php endforeach; ?>
5664
<?php else: ?>
57-
<tr id='no-groups'>
65+
<tr id="no-groups">
5866
<th scope="row" class="check-column">&nbsp;</th>
59-
<td colspan="4">You do not appear to have any snippets available at this time. <a href="<?php echo $this->admin_edit_url; ?>">Add New&rarr;</a></td>
67+
<td colspan="4">You do not appear to have any snippets available at this time. <a href="<?php echo $this->admin_single_url; ?>&action=new">Add New&rarr;</a></td>
6068
</tr>
6169
<?php endif;?>
6270
<tfoot>
@@ -69,12 +77,12 @@
6977
</table>
7078
<div class="tablenav bottom">
7179
<div class="alignleft actions">
72-
<select name='action2' class="bulk-actions">
73-
<option value='-1' selected='selected'>Bulk Actions</option>
74-
<option value='activate'>Activate</option>
75-
<option value='deactivate'>Dectivate</option>
76-
<option value='export'>Export</option>
77-
<option value='delete'>Delete</option>
80+
<select name="action2" class="bulk-actions">
81+
<option value="-1" selected="selected">Bulk Actions</option>
82+
<option value="activate"><?php echo $activate_label; ?></option>
83+
<option value="deactivate"><?php echo $deactivate_label; ?></option>
84+
<option value="export">Export</option>
85+
<option value="delete">Delete</option>
7886
</select>
7987
<input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
8088
</div>

includes/admin/admin-edit.php renamed to includes/admin/admin-single.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
if( !class_exists( 'Code_Snippets' ) ) exit;
2+
if( ! class_exists( 'Code_Snippets' ) ) exit;
33
$edit = isset( $_GET['id'] ) && intval( @$_GET['id'] );
44

55
if( $edit )
@@ -8,7 +8,7 @@
88
<div class="wrap">
99
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
1010
if( $edit ) :
11-
?>Edit Snippet<a href="<?php echo $this->admin_edit_url; ?>" class="add-new-h2">Add New</a></h2><?php
11+
?>Edit Snippet<a href="<?php echo $this->admin_single_url; ?>&action=new" class="add-new-h2">Add New</a></h2><?php
1212
else:
1313
?>Add New Snippet</h2>
1414
<?php endif; ?>
@@ -40,7 +40,7 @@
4040

4141
<label for="snippet_code"><h3 style="display:inline">Code</h3>
4242
<span style="float:right">Enter or paste the snippet code without the <code>&lt;?php</code> and <code>?&gt;</code> tags.</span></label><br />
43-
<textarea id="snippet_code" name="snippet_code" rows="20" spellcheck="false" style="font-family:monospace;width:100%"><?php echo stripslashes( $snippet->code ); ?></textarea>
43+
<textarea id="snippet_code" name="snippet_code" spellcheck="false" style="font-family:monospace;width:100%"><?php echo stripslashes( $snippet->code ); ?></textarea>
4444
<br style="margin: 20px;" />
4545
<div id="desclabel">
4646
<label for="description" style="text-align:center; margin: 10px auto"><h3 style="display:inline">Description</h3> (Optional)</label><br />
@@ -53,9 +53,14 @@
5353
</form>
5454
</div>
5555
<script type="text/javascript">
56-
editAreaLoader.init({
57-
id : "snippet_code"
58-
,syntax: "php"
59-
,start_highlight: true
60-
});
56+
var editor = CodeMirror.fromTextArea(document.getElementById("snippet_code"), {
57+
mode: "application/x-httpd-php-open",
58+
lineNumbers: true,
59+
lineWrapping: true,
60+
matchBrackets: true,
61+
indentUnit: 4,
62+
indentWithTabs: true,
63+
enterMode: "keep",
64+
tabMode: "shift"
65+
});
6166
</script>

0 commit comments

Comments
 (0)