PluginProbe
Post Snippets – Custom WordPress Code Snippets Customizer / 1.9
Post Snippets – Custom WordPress Code Snippets Customizer v1.9
4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.1 1.7.2 1.7.3 1.8 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.8.9.1 1.8.9.2 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 All 115 releases
post-snippets / classes / settings.php

settings.php in Post Snippets – Custom WordPress Code Snippets Customizer 1.9, at classes/settings.php

121 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post Snippets Settings.
4 *
5 * Class that renders out the HTML for the settings screen and contains helpful
6 * methods to simply the maintainance of the admin screen.
7 *
8 * @package Post Snippets
9 * @author Johan Steen <artstorm at gmail dot com>
10 * @since Post Snippets 1.8.8
11 */
12 class Post_Snippets_Settings
13 {
14
15 private $plugin_options;
16
17 public function set_options( $options )
18 {
19 $this->plugin_options = $options;
20 }
21
22 public function render()
23 {
24 ?>
25 <div class=wrap>
26 <h2>Post Snippets</h2>
27
28 <form method="post" action="">
29 <?php wp_nonce_field('update-options'); ?>
30
31 <div class="tablenav">
32 <div class="alignleft actions">
33 <input type="submit" name="add-snippet" value="<?php _e( 'Add New Snippet', 'post-snippets' ) ?>" class="button-secondary" />
34 <input type="submit" name="delete-selected" value="<?php _e( 'Delete Selected', 'post-snippets' ) ?>" class="button-secondary" />
35 <span class="description"><?php _e( '(Use the help dropdown button above for additional information.)', 'post-snippets' ); ?></span>
36 </div>
37 </div>
38 <div class="clear"></div>
39
40 <table class="widefat fixed" cellspacing="0">
41 <thead>
42 <tr>
43 <th scope="col" class="check-column"><input type="checkbox" /></th>
44 <th scope="col" style="width: 180px;"><?php _e( 'Title', 'post-snippets' ) ?></th>
45 <th scope="col" style="width: 180px;"><?php _e( 'Variables', 'post-snippets' ) ?></th>
46 <th scope="col"><?php _e( 'Snippet', 'post-snippets' ) ?></th>
47 </tr>
48 </thead>
49
50 <tfoot>
51 <tr>
52 <th scope="col" class="check-column"><input type="checkbox" /></th>
53 <th scope="col"><?php _e( 'Title', 'post-snippets' ) ?></th>
54 <th scope="col"><?php _e( 'Variables', 'post-snippets' ) ?></th>
55 <th scope="col"><?php _e( 'Snippet', 'post-snippets' ) ?></th>
56 </tr>
57 </tfoot>
58
59 <tbody>
60 <?php
61 // $snippets = get_option($this->plugin_options);
62 $snippets = $this->plugin_options;
63 if (!empty($snippets)) {
64 foreach ($snippets as $key => $snippet) {
65 ?>
66 <tr class='recent'>
67 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='<?php echo $key; ?>' /></th>
68 <td class='row-title'>
69 <input type='text' name='<?php echo $key; ?>_title' value='<?php echo $snippet['title']; ?>' />
70 </td>
71 <td class='name'>
72 <input type='text' name='<?php echo $key; ?>_vars' value='<?php echo $snippet['vars']; ?>' /><br/>
73 <?php
74 $this->checkbox(__('Shortcode', 'post-snippets'), $key.'_shortcode',
75 $snippet['shortcode']);
76
77 $this->checkbox(__('PHP Code', 'post-snippets'), $key.'_php',
78 $snippet['php']);
79 ?>
80 </td>
81 <td class='desc'>
82 <textarea name="<?php echo $key; ?>_snippet" class="large-text" style='width: 100%;' rows="5"><?php echo htmlspecialchars($snippet['snippet'], ENT_NOQUOTES); ?></textarea>
83 <?php _e( 'Description', 'post-snippets' ) ?>:
84 <input type='text' style='width: 100%;' name='<?php echo $key; ?>_description' value='<?php if (isset( $snippet['description'] ) ) echo esc_html($snippet['description']); ?>' /><br/>
85 </td>
86 </tr>
87 <?php
88 }
89 }
90 ?>
91 </tbody>
92 </table>
93 <div class="submit">
94 <input type="submit" name="update-post-snippets" value="<?php _e( 'Update Snippets', 'post-snippets' ) ?>" class="button-primary" /></div>
95 </form>
96 </div>
97 <?php
98 }
99
100 // -------------------------------------------------------------------------
101 // HTML and Form element methods
102 // -------------------------------------------------------------------------
103
104 /**
105 * Checkbox.
106 * Renders the HTML for an input checkbox.
107 *
108 * @param string $label The label rendered to screen
109 * @param string $name The unique name to identify the input
110 * @param boolean $checked If the input is checked or not
111 */
112 private function checkbox( $label, $name, $checked )
113 {
114 printf( '<input type="checkbox" name="%s" value="true"', $name );
115 if ($checked)
116 echo ' checked';
117 echo ' />';
118 echo ' '.$label.'<br/>';
119 }
120 }
121