| 1 |
<?php |
| 2 |
add_action("plugins_loaded", "smart_syntaxhighlighting_init"); |
| 3 |
function smart_syntaxhighlighting_init() { |
| 4 |
if(get_option('smart_enable_sh')) { |
| 5 |
add_action('admin_footer', 'smart_init_syntaxhighlighting'); |
| 6 |
} |
| 7 |
} |
| 8 |
|
| 9 |
function smart_init_syntaxhighlighting() { |
| 10 |
if(basename($_SERVER['SCRIPT_NAME']) == 'plugin-editor.php' || basename($_SERVER['SCRIPT_NAME']) == 'theme-editor.php') { |
| 11 |
global $file; |
| 12 |
$ext=strstr(basename($file),'.'); |
| 13 |
if($ext == '.php') { |
| 14 |
$ext = 'php'; |
| 15 |
} |
| 16 |
else if($ext == '.css') { |
| 17 |
$ext = 'css'; |
| 18 |
} |
| 19 |
else if($ext == '.js') { |
| 20 |
$ext = 'javascript'; |
| 21 |
} |
| 22 |
else if($ext == '.html' ||$ext == '.htm') { |
| 23 |
$ext = 'html'; |
| 24 |
} |
| 25 |
else { |
| 26 |
$ext = ''; |
| 27 |
} ?> |
| 28 |
<script type="text/javascript" src="<?php echo get_bloginfo('url') ?>/wp-content/plugins/wp-insert/codepress/codepress.js"></script> |
| 29 |
<script type="text/javascript"> |
| 30 |
try { |
| 31 |
var smart_editor = document.getElementById('newcontent'); |
| 32 |
smart_editor.form.onsubmit=function() { |
| 33 |
var smart_input = document.createElement("input"); |
| 34 |
smart_input.setAttribute("type","hidden"); |
| 35 |
smart_input.setAttribute("name","newcontent"); |
| 36 |
smart_input.setAttribute("value",newcontent.getCode()); |
| 37 |
smart_editor.form.appendChild(smart_input); |
| 38 |
return true; |
| 39 |
} |
| 40 |
smart_editor.className="codepress <?php echo $ext ?> linenumbers-on autocomplete-off readonly-off"; |
| 41 |
var smart_options_content = "<table><tr><td colspan='6'><b><a title='WP-Insert by Smart Logix' href='http://www.smartlogix.co.in'>WP-insert</a> : Syntax Highlighter Options</b></td></tr><tr><td> </td></tr><tr><td><input type='checkbox' onclick='newcontent.toggleAutoComplete()' /> Turn on Autocomplete</td><td> </td><td><input type='checkbox' onclick='newcontent.toggleLineNumbers()' /> Turn off Linenumbers</td><td> </td><td><input type='checkbox' onclick='newcontent.toggleEditor()' /> Turn off Syntax Highlighting</td></tr></table>" |
| 42 |
var smart_options = document.createElement("div"); |
| 43 |
smart_options.innerHTML = smart_options_content; |
| 44 |
smart_editor.form.appendChild(smart_options); |
| 45 |
} |
| 46 |
catch (e) { void(0); } |
| 47 |
</script> |
| 48 |
<?php } |
| 49 |
} |
| 50 |
|
| 51 |
function smart_add_syntaxhighlighting_pages() { ?> |
| 52 |
<div class="wrap"> |
| 53 |
<h2>WP-INSERT : Syntax Highlighting</h2> |
| 54 |
<?php show_support_options(); ?> |
| 55 |
<form method="post" action="options.php"> |
| 56 |
<?php wp_nonce_field('update-options'); ?> |
| 57 |
<table class="form-table"> |
| 58 |
<tr valign="top"> |
| 59 |
<th scope="row"></th> |
| 60 |
<td><b style="color:red;">This section is irrelavent from wordpress 2.8</b></td> |
| 61 |
</tr> |
| 62 |
<tr valign="top"> |
| 63 |
<th scope="row"><input id="smart_enable_sh" name="smart_enable_sh" type="checkbox" value="1"<?php if(get_option('smart_enable_sh')) echo ' checked="checked"'; ?>/> <b>Plugin/Theme Editor</b></th> |
| 64 |
<td>( Syntax highlighting in plugin and theme editor )<br/> |
| 65 |
Syntax highlighting by codepress</td> |
| 66 |
</tr> |
| 67 |
<tr><th>Codepress Features</th> |
| 68 |
<td> |
| 69 |
<ul> |
| 70 |
<li>Real-time syntax highlighting</li> |
| 71 |
<li>Code snippets - on PHP pages just type "if" and press [tab]</li> |
| 72 |
<li>Auto completion - simple type single/double quotes or ( or [ or {</li> |
| 73 |
<li>Shortcuts - on PHP pages press [ctrl][shift][space]. Its shortcut to <code>&<b></b>nbsp;</code></li></ul> |
| 74 |
</td> |
| 75 |
</tr> |
| 76 |
</table> |
| 77 |
<input type="hidden" name="action" value="update" /> |
| 78 |
<input type="hidden" name="page_options" value="smart_enable_sh" /> |
| 79 |
<p class="submit"> |
| 80 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 81 |
</p> |
| 82 |
</form> |
| 83 |
<p> |
| 84 |
<a href="http://www.smartlogix.co.in/"><img src="http://www.smartlogix.co.in/ads/random/rotate.php" border="0" /></a> |
| 85 |
</p> |
| 86 |
</div> |
| 87 |
<?php } ?> |