forked from boliquan/wp-code-highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp_code_highlight_admin.php
148 lines (137 loc) · 7 KB
/
wp_code_highlight_admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
function wp_code_highlight_admin() {
add_options_page('WP Code Highlight Options', 'WP Code Highlight','manage_options', __FILE__, 'wp_code_highlight_options');
add_action('admin_init','wp_code_highlight_register');
}
function wp_code_highlight_register(){
register_setting('wch-settings','wp_code_highlight_button');
register_setting('wch-settings','wp_code_highlight_themes');
register_setting('wch-settings','wp_code_highlight_line_numbers');
register_setting('wch-settings','wp_code_highlight_deactivate');
}
function wp_code_highlight_options(){
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>WP Code Highlight</h2>
<form action="options.php" method="post" enctype="multipart/form-data" name="wp_code_highlight_form">
<?php settings_fields('wch-settings'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php _e('Code Button','WP-Code-Highlight'); ?>
</th>
<td>
<label>
<input name="wp_code_highlight_button" type="radio" value="enable"<?php if (get_option('wp_code_highlight_button') == 'enable') { ?> checked="checked"<?php } ?> />
<?php _e('enable','WP-Code-Highlight'); ?>
</label>
<label>
<input name="wp_code_highlight_button" type="radio" value="disable"<?php if (get_option('wp_code_highlight_button') == 'disable') { ?> checked="checked"<?php } ?> />
<?php _e('disable','WP-Code-Highlight'); ?>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Highlight Themes','WP-Code-Highlight'); ?>
</th>
<td>
<label>
<input name="wp_code_highlight_themes" type="radio" value="wp-code-highlight"<?php if (get_option('wp_code_highlight_themes') == 'wp-code-highlight') { ?> checked="checked"<?php } ?> />
wp-code-highlight
</label>
<label>
<input name="wp_code_highlight_themes" type="radio" value="dawn"<?php if (get_option('wp_code_highlight_themes') == 'dawn') { ?> checked="checked"<?php } ?> />
dawn
</label>
<label>
<input name="wp_code_highlight_themes" type="radio" value="desert"<?php if (get_option('wp_code_highlight_themes') == 'desert') { ?> checked="checked"<?php } ?> />
desert
</label>
<label>
<input name="wp_code_highlight_themes" type="radio" value="sunburst"<?php if (get_option('wp_code_highlight_themes') == 'sunburst') { ?> checked="checked"<?php } ?> />
sunburst
</label>
<label>
<input name="wp_code_highlight_themes" type="radio" value="sons-of-obsidian"<?php if (get_option('wp_code_highlight_themes') == 'sons-of-obsidian') { ?> checked="checked"<?php } ?> />
sons-of-obsidian
</label>
<label>
<input name="wp_code_highlight_themes" type="radio" value="random"<?php if (get_option('wp_code_highlight_themes') == 'random') { ?> checked="checked"<?php } ?> />
random
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Line Numbers','WP-Code-Highlight'); ?>
</th>
<td>
<label>
<input name="wp_code_highlight_line_numbers" type="radio" value="enable"<?php if (get_option('wp_code_highlight_line_numbers') == 'enable') { ?> checked="checked"<?php } ?> />
<?php _e('enable','WP-Code-Highlight'); ?>
</label>
<label>
<input name="wp_code_highlight_line_numbers" type="radio" value="disable"<?php if (get_option('wp_code_highlight_line_numbers') == 'disable') { ?> checked="checked"<?php } ?> />
<?php _e('disable','WP-Code-Highlight'); ?>
<code>Notice: Be careful to enable Line Numbers, you may need to adjust your wordpress theme style.</code>
</label>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Delete Options','WP-Code-Highlight'); ?>
</th>
<td>
<label>
<input type="checkbox" name="wp_code_highlight_deactivate" value="yes" <?php if(get_option("wp_code_highlight_deactivate")=='yes') echo 'checked="checked"'; ?> />
<?php _e('Delete options while deactivate this plugin.','WP-Code-Highlight'); ?>
</label>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" name="Submit" value="<?php _e('Save Changes'); ?>" />
</p>
</form>
<h3>Basic Usage</h3>
1. "Dashboard"->"Users"->"Your Profile"->"Disable the visual editor when writing"<br />
2. "Dashboard"->"Settings"->"WP Code Highlight"<br />
3. Wrap code blocks with <code><pre></code> and <code></pre></code> (It provides a code button in the HTML editor)<br />
4. You don't need to specify the language since WP Code Highlight will guess, all languages are supported<br />
5. It can also load <code>wp-code-highlight.css</code> from current wordpress theme directory<br />
6. For more information, please visit: <a href="http://boliquan.com/wp-code-highlight/" target="_blank">WP Code Highlight</a> | <a href="http://boliquan.com/wp-code-highlight/" title="WP Code Highlight" target="_blank">FAQ</a> | <a href="http://boliquan.com/wp-code-highlight/" target="_blank">Submit Translations</a> | <a href="http://wordpress.org/plugins/wp-code-highlight/" target="_blank">Download</a>
<h3>Example</h3>
<code><pre></code><br />
<?php<br />
echo "Hello World";<br />
?><br />
<code></pre></code>
<h3>Other Plugins</h3>
1. <a href="http://boliquan.com/wp-clean-up/" target="_blank">WP Clean Up</a> | <a href="http://wordpress.org/plugins/wp-clean-up/" target="_blank">Download</a><br />
2. <a href="http://boliquan.com/wp-smtp/" target="_blank">WP SMTP</a> | <a href="http://wordpress.org/plugins/wp-smtp/" target="_blank">Download</a><br />
3. <a href="http://boliquan.com/wp-slug-translate/" target="_blank">WP Slug Translate</a> | <a href="http://wordpress.org/plugins/wp-slug-translate/" target="_blank">Download</a><br />
4. <a href="http://boliquan.com/wp-anti-spam/" target="_blank">WP Anti Spam</a> | <a href="http://wordpress.org/plugins/wp-anti-spam/" target="_blank">Download</a><br />
5. <a href="http://boliquan.com/yg-share/" target="_blank">YG Share</a> | <a href="http://wordpress.org/plugins/yg-share/" target="_blank">Download</a>
<br /><br />
<?php $donate_url = plugins_url('/img/paypal_32_32.jpg', __FILE__);?>
<?php $paypal_donate_url = plugins_url('/img/paypal_donate_email.jpg', __FILE__);?>
<?php $ali_donate_url = plugins_url('/img/alipay_donate_email.jpg', __FILE__);?>
<div class="icon32"><img src="<?php echo $donate_url; ?>" alt="Donate" /></div>
<h2>Donate</h2>
<p>
If you find my work useful and you want to encourage the development of more free resources, you can do it by donating.
</p>
<p>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SCWY6NPFRR8EY" target="_blank"><img src="<?php echo $paypal_donate_url; ?>" alt="Paypal Donate" title="Paypal" /></a>
<a href="https://www.alipay.com/" target="_blank"><img src="<?php echo $ali_donate_url; ?>" alt="Alipay Donate" title="Alipay" /></a>
</p>
<br />
<div style="text-align:center; margin:60px 0 10px 0;">© <?php echo date("Y"); ?> BoLiQuan.COM</div>
</div>
<?php
}
add_action('admin_menu', 'wp_code_highlight_admin');
?>