|
1 | 1 | <?php
|
2 |
| -if( !class_exists( 'Code_Snippets' ) ) exit; |
| 2 | +if( ! class_exists( 'Code_Snippets' ) ) exit; |
3 | 3 | 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 | +} |
4 | 14 | ?>
|
5 | 15 | <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→</a></p></div> |
| 19 | + <?php endif; ?> |
7 | 20 | <?php if ( isset( $msg ) ) : ?>
|
8 | 21 | <div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
|
9 | 22 | <?php endif; ?>
|
10 | 23 | <?php $snippets = $wpdb->get_results( 'select * from ' . $this->table ); ?>
|
11 | 24 | <form action="" method="post">
|
12 | 25 | <div class="tablenav top">
|
13 | 26 | <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> |
20 | 33 | </select>
|
21 | 34 | <input type="submit" id="doaction" class="button-secondary" value="Apply" />
|
22 | 35 | </div>
|
23 | 36 | </div>
|
24 |
| - <table class="widefat manage-snippets" style="margin-top: .5em"> |
| 37 | + <table class="widefat snippets" style="margin-top: .5em"> |
25 | 38 | <thead>
|
26 | 39 | <tr>
|
27 | 40 | <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> |
29 | 42 | <th scope="col" id="description">Description</th>
|
30 | 43 | </tr>
|
31 | 44 | </thead>
|
32 |
| - <?php if( count( $snippets ) ): ?> |
| 45 | + <?php if( count( $snippets ) ) : ?> |
33 | 46 | <?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' ); ?>"> |
40 | 48 | <th scope="row" class="check-column"><input class="snippets" type="checkbox" name="ids[]" value="<?php echo $snippet->id; ?>" /></th>
|
41 | 49 | <td class="snippet-title"><strong><?php echo stripslashes( $snippet->name );?></strong>
|
42 | 50 | <div class="row-actions-visible">
|
43 | 51 | <?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> |
45 | 53 | <?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> |
47 | 55 | <?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> |
51 | 59 | </div>
|
52 | 60 | </td>
|
53 | 61 | <td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
|
54 | 62 | </tr>
|
55 | 63 | <?php endforeach; ?>
|
56 | 64 | <?php else: ?>
|
57 |
| - <tr id='no-groups'> |
| 65 | + <tr id="no-groups"> |
58 | 66 | <th scope="row" class="check-column"> </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→</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→</a></td> |
60 | 68 | </tr>
|
61 | 69 | <?php endif;?>
|
62 | 70 | <tfoot>
|
|
69 | 77 | </table>
|
70 | 78 | <div class="tablenav bottom">
|
71 | 79 | <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> |
78 | 86 | </select>
|
79 | 87 | <input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
|
80 | 88 | </div>
|
|
0 commit comments