PluginProbe
Wp-Insert / 1.7.5
Wp-Insert v1.7.5
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / includes / syntax-highlighter.php

syntax-highlighter.php in Wp-Insert 1.7.5, at includes/syntax-highlighter.php

105 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function wp_insert_syntax_highlighter_page() {
3 global $screen_layout_columns;
4 wp_insert_update_page_order();
5 add_meta_box('wp_insert_syntax_highlighter_editor', 'Theme & Plugin Editor Syntax Highlighting', 'wp_insert_syntax_highlighter_editor_HTML', 'col_1');
6 add_meta_box('wp_insert_syntax_highlighter_posts', 'Syntax Highlighting for Code in Posts & Pages', 'wp_insert_syntax_highlighter_posts_HTML', 'col_1');
7
8 $parameters = 'wp_insert_sh_editor_enable, wp_insert_sh_posts_enable';
9 wp_insert_settings_page_layout($parameters, 'WP-INSERT : Syntax Highlighting', 'syntax');
10 }
11
12 function wp_insert_syntax_highlighter_editor_HTML() { ?>
13 <div>
14 <?php if(get_option('wp_insert_sh_editor_enable')) { ?><input type="button" id="wp_insert_sh_editor_enable_button" value="Click to Deactivate" class="button" style="font-weight:bold;color:red;" onclick="wpInsertToggleAdWidget('#wp_insert_sh_editor_enable_button', '#wp_insert_sh_enable')"/>
15 <?php } else { ?><input type="button" id="wp_insert_sh_editor_enable_button" value="Click to Activate" class="button" style="font-weight:bold;color:#2f9303;" onclick="wpInsertToggleAdWidget('#wp_insert_sh_editor_enable_button', '#wp_insert_sh_editor_enable')"/><?php } ?>
16 <input style="display:none;" id="wp_insert_sh_editor_enable" name="wp_insert_sh_editor_enable" type="checkbox" value="1"<?php if(get_option('wp_insert_sh_editor_enable')) echo ' checked="checked"'; ?> />
17 <p><small>Syntax Highlighting support using Editarea 0.8.2 by <a target="_blank" href="http://www.cdolivet.com/index.php?page=editArea">Christophe Dolivet</a></small></p>
18 </div>
19 <?php }
20
21 function wp_insert_syntax_highlighter_posts_HTML() { ?>
22 <div>
23 <?php if(get_option('wp_insert_sh_posts_enable')) { ?><input type="button" id="wp_insert_sh_posts_enable_button" value="Click to Deactivate" class="button" style="font-weight:bold;color:red;" onclick="wpInsertToggleAdWidget('#wp_insert_sh_posts_enable_button', '#wp_insert_sh_posts_enable')"/>
24 <?php } else { ?><input type="button" id="wp_insert_sh_posts_enable_button" value="Click to Activate" class="button" style="font-weight:bold;color:#2f9303;" onclick="wpInsertToggleAdWidget('#wp_insert_sh_posts_enable_button', '#wp_insert_sh_posts_enable')"/><?php } ?>
25 <input style="display:none;" id="wp_insert_sh_posts_enable" name="wp_insert_sh_posts_enable" type="checkbox" value="1"<?php if(get_option('wp_insert_sh_posts_enable')) echo ' checked="checked"'; ?> />
26 <p><small>Enclose CODE snippets between [code] and [/code].<br/>Visit <a href="http://wp-insert.smartlogix.co.in/">Wp-Insert Tutorial Site</a> for advanced options.</a></small></p>
27 </div>
28 <?php }
29
30 add_action("plugins_loaded", "wp_insert_syntaxhighlighting_init");
31 function wp_insert_syntaxhighlighting_init() {
32 if(get_option('wp_insert_sh_editor_enable')) {
33 add_action('admin_footer', 'wp_insert_editor_syntaxhighlighting');
34 }
35 if(get_option('wp_insert_sh_posts_enable')) {
36 add_action('wp_footer', 'wp_insert_posts_syntaxhighlighting');
37 add_shortcode('code', 'wp_insert_posts_shortcode');
38 }
39 }
40 function wp_insert_editor_syntaxhighlighting() {
41 if(basename($_SERVER['SCRIPT_NAME']) == 'plugin-editor.php' || basename($_SERVER['SCRIPT_NAME']) == 'theme-editor.php') {
42 global $file;
43 $ext=strstr(basename($file),'.');
44 if($ext == '.php') {
45 $ext = 'php';
46 } else if($ext == '.css') {
47 $ext = 'css';
48 } else if($ext == '.js') {
49 $ext = 'javascript';
50 } else if($ext == '.html' ||$ext == '.htm') {
51 $ext = 'html';
52 } else {
53 $ext = '';
54 } ?>
55 <script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/editarea/edit_area_full.js"></script>
56 <script type="text/javascript">
57 try {
58 editAreaLoader.init({
59 id: "newcontent"
60 ,start_highlight: true
61 ,allow_resize: "y"
62 ,allow_toggle: true
63 ,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, word_wrap, help"
64 ,syntax_selection_allow: "css,html,js,php,xml"
65 ,word_wrap: true
66 ,syntax: "<?php echo $ext; ?>"
67 });
68 }
69 catch (e) { void(0); }
70 </script>
71 <?php
72 }
73 }
74
75 function wp_insert_posts_syntaxhighlighting() { ?>
76 <script type="text/javascript" src="<?php echo WP_PLUGIN_URL; ?>/wp-insert/editarea/edit_area_full.js"></script>
77 <script type="text/javascript">
78 try {
79 var codeBlocks = document.getElementsByName("codeSnippet");
80 for(var i = 0; i < codeBlocks.length; i++) {
81 editAreaLoader.init({
82 id: codeBlocks[i].id
83 ,start_highlight: true
84 ,allow_resize: "y"
85 ,allow_toggle: false
86 ,toolbar: "go_to_line, |, select_font, |, syntax_selection, |, highlight, reset_highlight, |, word_wrap"
87 ,is_editable: true
88 ,word_wrap: true
89 ,syntax: codeBlocks[i].title
90 });
91 }
92 }
93 catch (e) { void(0); }
94 </script>
95 <?php }
96 function wp_insert_posts_shortcode($atts, $content = null, $code = "" ) {
97 $attributes = shortcode_atts(array('language' => 'php', 'custom' => ''), $atts);
98 if($attributes['custom'] != '') {
99 global $post;
100 return '<textarea title="'.$attributes['language'].'" class="codeSnippet" name="codeSnippet" id="codeSnippet_'.rand(0,999999).'_'.rand(0,999999).'">'.get_post_meta($post->ID, $attributes['custom'], true).'</textarea>';
101 } else {
102 return '<textarea title="'.$attributes['language'].'" class="codeSnippet" name="codeSnippet" id="codeSnippet_'.rand(0,999999).'_'.rand(0,999999).'">'.$content.'</textarea>';
103 }
104 }
105 ?>