Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jun 17, 2013
0 parents commit c1438e5
Show file tree
Hide file tree
Showing 21 changed files with 1,631 additions and 0 deletions.
368 changes: 368 additions & 0 deletions code-snippets.php

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#icon-snippets.icon32{
background: url('../img/icon32.png') no-repeat scroll transparent;
}

/* Snippets > Manage Snippets */

.inactive a:hover{
color: #d54e21;
}

a.delete:hover {
color: #f00;
border-bottom-color: #f00;
}

a.delete{
color: #21759b;
}

tr{
background-color: #fcfcfc;
}

.inactive,
.inactive th,
.inactive td{
background-color: #f4f4f4;
}

.active,
.active th,
.active td {
color: #000;
}

.inactive a {
color: #557799;

}
Binary file added img/icon-big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-horiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-med.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon.odg
Binary file not shown.
58 changes: 58 additions & 0 deletions img/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions inc/edit-snippets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php $id = intval( @$_GET['id'] ); ?>
<div class="wrap">
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
if( $_GET['action'] == 'edit' ) :
?>Edit Snippet<a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2><?php
else:
?>Add New Snippet</h2>
<?php endif; ?>
<?php if ( strlen($msg) ) : ?>
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
<?php else: ?>
<br />
<?php endif; ?>
<form method="post" action="">
<?php if( $_GET['action'] == 'edit' ) : ?>
<?php $record = $wpdb->get_row( "SELECT * FROM `$this->table_name` WHERE `id` = '$id';" ); ?>
<input type="hidden" name="edit_id" value="<?php echo $id;?>" />
<?php else: ?>
<?php
// define a empty object (or one with default values)
$record = new stdClass();
$record->name = '';
$record->description = '';
$record->code = '';
?>
<?php endif; ?>

<div id="titlediv">
<div id="titlewrap">
<label for="title" style="display:none">Name (short title)</label>
<input id="title" type="text" autocomplete="off" size="30" name="snippet_name" value="<?php echo stripslashes( $record->name ); ?>" placeholder="Name (short title)">
</div>
</div>

<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 htmlspecialchars_decode( stripslashes( $record->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 />
</div>
<?php wp_editor( htmlspecialchars_decode( stripslashes( $record->description ) ), 'description', array( 'textarea_name' => 'snippet_description', 'textarea_rows' => 10 ) ); ?>
<p class="submit">
<input tabindex="15" type="submit" name="save_snippet" class="button-primary" value="Save" />
<a href="<?php echo $this->manage_snippets_url; ?>" class="button">Cancel</a>
</p>
</form>
</div>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {

jQuery('textarea').tabby();

});
//]]>
</script>
70 changes: 70 additions & 0 deletions inc/manage-snippets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php global $wpdb; ?>
<div class="wrap">
<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>
<?php if ( strlen( $msg ) ) : ?>
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
<?php endif; ?>
<?php $snippets = $wpdb->get_results( 'select * from ' . $this->table_name ); ?>
<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='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">
<thead>
<tr>
<th scope="col" class="check-column"><input type="checkbox" name="toggle" id="toggle" /></th>
<th scope="col" id="name">Name</th>
<th scope="col" id="description">Description</th>
</tr>
</thead>
<?php if( count( $snippets ) ): ?>
<?php foreach( $snippets as $snippet ) : ?>
<tr class='<?php
if($snippet->active == false)
echo 'inactive';
else
echo 'active';
?>'>
<th scope="row" class="check-column"><input class="snippets" type="checkbox" name="snippets[]" 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->manage_snippets_url . '&action=activate&id=' . $snippet->id; ?>" title="Activate this plugin" class="edit">Activate</a> | </span>
<?php else : ?>
<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>
<?php endif; ?>
<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>
<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>
</div>
</td>
<td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<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.</td>
</tr>
<?php endif;?>
</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'>Deactivate</option>
<option value='delete'>Delete</option>
</select>
<input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
</div>
</div>
</form>
</div>
30 changes: 30 additions & 0 deletions inc/uninstall-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div class="wrap">
<div id="icon-snippets" class="icon32"><br /></div><h2>Uninstall Code Snippets</h2>
<?php if ( strlen($msg) ) : ?>
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
<?php endif; ?>
<p>Checking this box will remove all snippets and the table from the database when the plugin is deactivated.</p>
<p>Only use if permanently uninstalling the Code Snippets plugin.</p>
<p>You can come back here before deactivating the plugin and change your choice.</p>
<form action="" method="post">
<?php $check_uninstall = ( get_option( 'cs_complete_uninstall',0 ) == 1 ) ? 'checked' : 'id="unin"'; ?>
<input type="checkbox" name="ch_unin" <?php echo $check_uninstall; ?> style="margin-right: 5px" />
<input tabindex="15" type="submit" name="uninstall" class="button-primary" value="Submit"/>
</form>
<script type="text/javascript">
//<![CDATA[
var cb = jQuery('#unin');
if(cb.length) {
cb.click(function() {
if(confirm('Are you sure? \nYou will permanently lose your snippets when the plugin is deactivated.')) {
cb.unbind('click');
return true;
}
else {
return false;
}
});
}
//]]>
</script>
</div>
Loading

0 comments on commit c1438e5

Please sign in to comment.