Skip to content

Commit c1438e5

Browse files
committed
Initial commit
0 parents  commit c1438e5

21 files changed

+1631
-0
lines changed

code-snippets.php

+368
Large diffs are not rendered by default.

css/style.css

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#icon-snippets.icon32{
2+
background: url('../img/icon32.png') no-repeat scroll transparent;
3+
}
4+
5+
/* Snippets > Manage Snippets */
6+
7+
.inactive a:hover{
8+
color: #d54e21;
9+
}
10+
11+
a.delete:hover {
12+
color: #f00;
13+
border-bottom-color: #f00;
14+
}
15+
16+
a.delete{
17+
color: #21759b;
18+
}
19+
20+
tr{
21+
background-color: #fcfcfc;
22+
}
23+
24+
.inactive,
25+
.inactive th,
26+
.inactive td{
27+
background-color: #f4f4f4;
28+
}
29+
30+
.active,
31+
.active th,
32+
.active td {
33+
color: #000;
34+
}
35+
36+
.inactive a {
37+
color: #557799;
38+
39+
}

img/icon-big.png

33.9 KB
Loading

img/icon-horiz.png

13.3 KB
Loading

img/icon-med.png

15.4 KB
Loading

img/icon-small.png

4.43 KB
Loading

img/icon.odg

3.12 KB
Binary file not shown.

img/icon.svg

+58
Loading

img/icon16.png

730 Bytes
Loading

img/icon32.png

1.47 KB
Loading

inc/edit-snippets.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php $id = intval( @$_GET['id'] ); ?>
2+
<div class="wrap">
3+
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
4+
if( $_GET['action'] == 'edit' ) :
5+
?>Edit Snippet<a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2><?php
6+
else:
7+
?>Add New Snippet</h2>
8+
<?php endif; ?>
9+
<?php if ( strlen($msg) ) : ?>
10+
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
11+
<?php else: ?>
12+
<br />
13+
<?php endif; ?>
14+
<form method="post" action="">
15+
<?php if( $_GET['action'] == 'edit' ) : ?>
16+
<?php $record = $wpdb->get_row( "SELECT * FROM `$this->table_name` WHERE `id` = '$id';" ); ?>
17+
<input type="hidden" name="edit_id" value="<?php echo $id;?>" />
18+
<?php else: ?>
19+
<?php
20+
// define a empty object (or one with default values)
21+
$record = new stdClass();
22+
$record->name = '';
23+
$record->description = '';
24+
$record->code = '';
25+
?>
26+
<?php endif; ?>
27+
28+
<div id="titlediv">
29+
<div id="titlewrap">
30+
<label for="title" style="display:none">Name (short title)</label>
31+
<input id="title" type="text" autocomplete="off" size="30" name="snippet_name" value="<?php echo stripslashes( $record->name ); ?>" placeholder="Name (short title)">
32+
</div>
33+
</div>
34+
35+
<label for="snippet_code"><h3 style="display:inline">Code</h3>
36+
<span style="float:right">Enter or paste the snippet code without the <code>&lt;?php</code> and <code>?&gt;</code> tags.</span></label><br />
37+
<textarea id="snippet_code" name="snippet_code" rows="20" spellcheck="false" style="font-family:monospace;width:100%"><?php echo htmlspecialchars_decode( stripslashes( $record->code ) );?></textarea>
38+
<br style="margin: 20px;" />
39+
<div id="desclabel">
40+
<label for="description" style="text-align:center; margin: 10px auto"><h3 style="display:inline">Description</h3> (Optional)</label><br />
41+
</div>
42+
<?php wp_editor( htmlspecialchars_decode( stripslashes( $record->description ) ), 'description', array( 'textarea_name' => 'snippet_description', 'textarea_rows' => 10 ) ); ?>
43+
<p class="submit">
44+
<input tabindex="15" type="submit" name="save_snippet" class="button-primary" value="Save" />
45+
<a href="<?php echo $this->manage_snippets_url; ?>" class="button">Cancel</a>
46+
</p>
47+
</form>
48+
</div>
49+
<script type="text/javascript">
50+
//<![CDATA[
51+
jQuery(document).ready(function() {
52+
53+
jQuery('textarea').tabby();
54+
55+
});
56+
//]]>
57+
</script>

inc/manage-snippets.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php global $wpdb; ?>
2+
<div class="wrap">
3+
<div id="icon-snippets" class="icon32"><br /></div><h2>Snippets <a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2>
4+
<?php if ( strlen( $msg ) ) : ?>
5+
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
6+
<?php endif; ?>
7+
<?php $snippets = $wpdb->get_results( 'select * from ' . $this->table_name ); ?>
8+
<form action="" method="post">
9+
<div class="tablenav top">
10+
<div class="alignleft actions">
11+
<select name='action' class="bulk-actions">
12+
<option value='-1' selected='selected'>Bulk Actions</option>
13+
<option value='activate'>Activate</option>
14+
<option value='deactivate'>Deactivate</option>
15+
<option value='delete'>Delete</option>
16+
</select>
17+
<input type="submit" id="doaction" class="button-secondary" value="Apply" />
18+
</div>
19+
</div>
20+
<table class="widefat manage-snippets" style="margin-top: .5em">
21+
<thead>
22+
<tr>
23+
<th scope="col" class="check-column"><input type="checkbox" name="toggle" id="toggle" /></th>
24+
<th scope="col" id="name">Name</th>
25+
<th scope="col" id="description">Description</th>
26+
</tr>
27+
</thead>
28+
<?php if( count( $snippets ) ): ?>
29+
<?php foreach( $snippets as $snippet ) : ?>
30+
<tr class='<?php
31+
if($snippet->active == false)
32+
echo 'inactive';
33+
else
34+
echo 'active';
35+
?>'>
36+
<th scope="row" class="check-column"><input class="snippets" type="checkbox" name="snippets[]" value="<?php echo $snippet->id; ?>" /></th>
37+
<td class="snippet-title"><strong><?php echo stripslashes($snippet->name);?></strong>
38+
<div class="row-actions-visible">
39+
<?php if( $snippet->active == 0 ) : ?>
40+
<span class='activate'><a href="<?php echo $this->manage_snippets_url . '&action=activate&id=' . $snippet->id; ?>" title="Activate this plugin" class="edit">Activate</a> | </span>
41+
<?php else : ?>
42+
<span class='deactivate'><a href="<?php echo $this->manage_snippets_url . '&action=deactivate&id=' . $snippet->id; ?>" title="Deactivate this plugin" class="edit">Deactivate</a> | </span>
43+
<?php endif; ?>
44+
<span class='edit'><a href="<?php echo $this->edit_snippets_url . '&action=edit&id=' . $snippet->id; ?>" title="Edit this Snippet" class="edit">Edit</a> | </span>
45+
<span class='delete'><a href="<?php echo $this->manage_snippets_url . '&action=delete&id=' . $snippet->id; ?>" title="Delete this plugin" class="delete" onclick="return confirm('Are you sure? This action is non-reversable');">Delete</a></span>
46+
</div>
47+
</td>
48+
<td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
49+
</tr>
50+
<?php endforeach; ?>
51+
<?php else: ?>
52+
<tr id='no-groups'>
53+
<th scope="row" class="check-column">&nbsp;</th>
54+
<td colspan="4">You do not appear to have any snippets available at this time.</td>
55+
</tr>
56+
<?php endif;?>
57+
</table>
58+
<div class="tablenav bottom">
59+
<div class="alignleft actions">
60+
<select name='action2' class="bulk-actions">
61+
<option value='-1' selected='selected'>Bulk Actions</option>
62+
<option value='activate'>Activate</option>
63+
<option value='deactivate'>Deactivate</option>
64+
<option value='delete'>Delete</option>
65+
</select>
66+
<input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
67+
</div>
68+
</div>
69+
</form>
70+
</div>

inc/uninstall-plugin.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div class="wrap">
2+
<div id="icon-snippets" class="icon32"><br /></div><h2>Uninstall Code Snippets</h2>
3+
<?php if ( strlen($msg) ) : ?>
4+
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
5+
<?php endif; ?>
6+
<p>Checking this box will remove all snippets and the table from the database when the plugin is deactivated.</p>
7+
<p>Only use if permanently uninstalling the Code Snippets plugin.</p>
8+
<p>You can come back here before deactivating the plugin and change your choice.</p>
9+
<form action="" method="post">
10+
<?php $check_uninstall = ( get_option( 'cs_complete_uninstall',0 ) == 1 ) ? 'checked' : 'id="unin"'; ?>
11+
<input type="checkbox" name="ch_unin" <?php echo $check_uninstall; ?> style="margin-right: 5px" />
12+
<input tabindex="15" type="submit" name="uninstall" class="button-primary" value="Submit"/>
13+
</form>
14+
<script type="text/javascript">
15+
//<![CDATA[
16+
var cb = jQuery('#unin');
17+
if(cb.length) {
18+
cb.click(function() {
19+
if(confirm('Are you sure? \nYou will permanently lose your snippets when the plugin is deactivated.')) {
20+
cb.unbind('click');
21+
return true;
22+
}
23+
else {
24+
return false;
25+
}
26+
});
27+
}
28+
//]]>
29+
</script>
30+
</div>

0 commit comments

Comments
 (0)