Skip to content

Commit

Permalink
Updated to version 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jun 17, 2013
1 parent 917d610 commit 6bff801
Show file tree
Hide file tree
Showing 150 changed files with 5,296 additions and 10,367 deletions.
297 changes: 219 additions & 78 deletions code-snippets.php

Large diffs are not rendered by default.

169 changes: 169 additions & 0 deletions css/codemirror.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
.CodeMirror {
line-height: 1em;
font-family: monospace;

/* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */
position: relative;
/* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */
overflow: hidden;
}

.CodeMirror-scroll {
overflow-x: auto;
overflow-y: hidden;
height: 300px;
/* This is needed to prevent an IE[67] bug where the scrolled content
is visible outside of the scrolling box. */
position: relative;
outline: none;
}

/* Vertical scrollbar */
.CodeMirror-scrollbar {
float: right;
overflow-x: hidden;
overflow-y: scroll;

/* This corrects for the 1px gap introduced to the left of the scrollbar
by the rule for .CodeMirror-scrollbar-inner. */
margin-left: -1px;
}
.CodeMirror-scrollbar-inner {
/* This needs to have a nonzero width in order for the scrollbar to appear
in Firefox and IE9. */
width: 1px;
}
.CodeMirror-scrollbar.cm-sb-overlap {
/* Ensure that the scrollbar appears in Lion, and that it overlaps the content
rather than sitting to the right of it. */
position: absolute;
z-index: 1;
float: none;
right: 0;
min-width: 12px;
}
.CodeMirror-scrollbar.cm-sb-nonoverlap {
min-width: 12px;
}
.CodeMirror-scrollbar.cm-sb-ie7 {
min-width: 18px;
}

.CodeMirror-gutter {
position: absolute; left: 0; top: 0;
z-index: 10;
background-color: #f7f7f7;
border-right: 1px solid #eee;
min-width: 2em;
height: 100%;
}
.CodeMirror-gutter-text {
color: #aaa;
text-align: right;
padding: .4em .2em .4em .4em;
white-space: pre !important;
cursor: default;
}
.CodeMirror-lines {
padding: .4em;
white-space: pre;
cursor: text;
}
.CodeMirror-lines * {
/* Necessary for throw-scrolling to decelerate properly on Safari. */
pointer-events: none;
}

.CodeMirror pre {
-moz-border-radius: 0;
-webkit-border-radius: 0;
-o-border-radius: 0;
border-radius: 0;
border-width: 0; margin: 0; padding: 0; background: transparent;
font-family: inherit;
font-size: inherit;
padding: 0; margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
}

.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-wrap .CodeMirror-scroll {
overflow-x: hidden;
}

.CodeMirror textarea {
outline: none !important;
}

.CodeMirror pre.CodeMirror-cursor {
z-index: 10;
position: absolute;
visibility: hidden;
border-left: 1px solid black;
border-right: none;
width: 0;
}
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
width: auto;
border: 0;
background: transparent;
background: rgba(0, 200, 0, .4);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
}
/* Kludge to turn off filter in ie9+, which also accepts rgba */
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
.CodeMirror-focused pre.CodeMirror-cursor {
visibility: visible;
}

div.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }

.CodeMirror-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}

/* Default theme */

.cm-s-default span.cm-keyword {color: #708;}
.cm-s-default span.cm-atom {color: #219;}
.cm-s-default span.cm-number {color: #164;}
.cm-s-default span.cm-def {color: #00f;}
.cm-s-default span.cm-variable {color: black;}
.cm-s-default span.cm-variable-2 {color: #05a;}
.cm-s-default span.cm-variable-3 {color: #085;}
.cm-s-default span.cm-property {color: black;}
.cm-s-default span.cm-operator {color: black;}
.cm-s-default span.cm-comment {color: #a50;}
.cm-s-default span.cm-string {color: #a11;}
.cm-s-default span.cm-string-2 {color: #f50;}
.cm-s-default span.cm-meta {color: #555;}
.cm-s-default span.cm-error {color: #f00;}
.cm-s-default span.cm-qualifier {color: #555;}
.cm-s-default span.cm-builtin {color: #30a;}
.cm-s-default span.cm-bracket {color: #cc7;}
.cm-s-default span.cm-tag {color: #170;}
.cm-s-default span.cm-attribute {color: #00c;}
.cm-s-default span.cm-header {color: blue;}
.cm-s-default span.cm-quote {color: #090;}
.cm-s-default span.cm-hr {color: #999;}
.cm-s-default span.cm-link {color: #00c;}

span.cm-header, span.cm-strong {font-weight: bold;}
span.cm-em {font-style: italic;}
span.cm-emstrong {font-style: italic; font-weight: bold;}
span.cm-link {text-decoration: underline;}

div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
27 changes: 27 additions & 0 deletions css/dialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.CodeMirror-dialog {
position: relative;
}

.CodeMirror-dialog > div {
position: absolute;
top: 0; left: 0; right: 0;
background: white;
border-bottom: 1px solid #eee;
z-index: 15;
padding: .1em .8em;
overflow: hidden;
color: #333;
}

.CodeMirror-dialog input {
border: none;
outline: none;
background: transparent;
width: 20em;
color: inherit;
font-family: monospace;
}

.CodeMirror-dialog button {
font-size: 70%;
}
7 changes: 0 additions & 7 deletions css/index.php

This file was deleted.

16 changes: 16 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,21 @@ tr {

.inactive a {
color: #557799;
}

/* Snippets > Add New */

.CodeMirror {
border: 1px solid #ccc;
-o-border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}

.CodeMirror-scroll {
height: auto;
overflow-y: hidden;
overflow-x: auto;
min-height: 242px;
}
7 changes: 0 additions & 7 deletions images/index.php

This file was deleted.

68 changes: 38 additions & 30 deletions includes/admin/admin-manage.php
Original file line number Diff line number Diff line change
@@ -1,62 +1,70 @@
<?php
if( !class_exists( 'Code_Snippets' ) ) exit;
if( ! class_exists( 'Code_Snippets' ) ) exit;
global $wpdb;
$screen = get_current_screen();
if( $screen->is_network ) {
$activate_label = __( 'Network Activate' );
$deactivate_label = __( 'Network Deactivate' );
$activate_title = __( 'Activate this snippet for all sites on the network' );
} else {
$activate_label = __( 'Activate' );
$deactivate_label = __( 'Deactivate' );
$activate_title = __( 'Activate this snippet' );
}
?>
<div class="wrap">
<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>
<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>
<?php if ( defined( 'CS_SAFE_MODE' ) ) if( CS_SAFE_MODE ) : ?>
<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>
<?php endif; ?>
<?php if ( isset( $msg ) ) : ?>
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
<?php endif; ?>
<?php $snippets = $wpdb->get_results( 'select * from ' . $this->table ); ?>
<form action="" method="post">
<div class="tablenav top">
<div class="alignleft actions">
<select name='action' class="bulk-actions">
<option value='-1' selected='selected'>Bulk Actions</option>
<option value='activate'>Activate</option>
<option value='deactivate'>Deactivate</option>
<option value='export'>Export</option>
<option value='delete'>Delete</option>
<select name="action" class="bulk-actions">
<option value="-1" selected="selected">Bulk Actions</option>
<option value="activate"><?php echo $activate_label; ?></option>
<option value="deactivate"><?php echo $deactivate_label; ?></option>
<option value="export">Export</option>
<option value="delete">Delete</option>
</select>
<input type="submit" id="doaction" class="button-secondary" value="Apply" />
</div>
</div>
<table class="widefat manage-snippets" style="margin-top: .5em">
<table class="widefat snippets" style="margin-top: .5em">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" name="toggle" id="toggle" /></th>
<th scope="col" id="name" style="min-width:180px">Name</th>
<th scope="col" id="name" style="width:36ex">Name</th>
<th scope="col" id="description">Description</th>
</tr>
</thead>
<?php if( count( $snippets ) ): ?>
<?php if( count( $snippets ) ) : ?>
<?php foreach( $snippets as $snippet ) : ?>
<tr class='<?php
if($snippet->active == false)
echo 'inactive';
else
echo 'active';
?>'>
<tr class="<?php echo ( $snippet->active ? 'active' : 'inactive' ); ?>">
<th scope="row" class="check-column"><input class="snippets" type="checkbox" name="ids[]" value="<?php echo $snippet->id; ?>" /></th>
<td class="snippet-title"><strong><?php echo stripslashes( $snippet->name );?></strong>
<div class="row-actions-visible">
<?php if( $snippet->active == 0 ) : ?>
<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>
<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>
<?php else : ?>
<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>
<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>
<?php endif; ?>
<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>
<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>
<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>
<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>
<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>
<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>
</div>
</td>
<td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr id='no-groups'>
<tr id="no-groups">
<th scope="row" class="check-column">&nbsp;</th>
<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>
<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>
</tr>
<?php endif;?>
<tfoot>
Expand All @@ -69,12 +77,12 @@
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<select name='action2' class="bulk-actions">
<option value='-1' selected='selected'>Bulk Actions</option>
<option value='activate'>Activate</option>
<option value='deactivate'>Dectivate</option>
<option value='export'>Export</option>
<option value='delete'>Delete</option>
<select name="action2" class="bulk-actions">
<option value="-1" selected="selected">Bulk Actions</option>
<option value="activate"><?php echo $activate_label; ?></option>
<option value="deactivate"><?php echo $deactivate_label; ?></option>
<option value="export">Export</option>
<option value="delete">Delete</option>
</select>
<input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
</div>
Expand Down
21 changes: 13 additions & 8 deletions includes/admin/admin-edit.php → includes/admin/admin-single.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if( !class_exists( 'Code_Snippets' ) ) exit;
if( ! class_exists( 'Code_Snippets' ) ) exit;
$edit = isset( $_GET['id'] ) && intval( @$_GET['id'] );

if( $edit )
Expand All @@ -8,7 +8,7 @@
<div class="wrap">
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
if( $edit ) :
?>Edit Snippet<a href="<?php echo $this->admin_edit_url; ?>" class="add-new-h2">Add New</a></h2><?php
?>Edit Snippet<a href="<?php echo $this->admin_single_url; ?>&action=new" class="add-new-h2">Add New</a></h2><?php
else:
?>Add New Snippet</h2>
<?php endif; ?>
Expand Down Expand Up @@ -40,7 +40,7 @@

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

0 comments on commit 6bff801

Please sign in to comment.