/** * Plugin Name: Code Blocks * Plugin URI: http://subinsb.com/posting-code-blocks-on-wordpress * Description: Add Code Blocks To Your posts and pages in the Visual Editor or Text Editor. * Version: 0.3 * Author: Subin Siby * Author URI: http://subinsb.com * License: GPLv3 */ function CBS_adminMenu() { add_submenu_page('edit.php', __('Code Blocks'), __('Code Blocks'), 'manage_options', 'CBS_admin', 'CBS_optPage'); } add_action('admin_menu', 'CBS_adminMenu'); function CBSmakeItPretty($s){ $s=str_replace('\"','"',$s); $s=str_replace("\'",'"',$s); return $s; } function CBS_optPage(){ if(isset($_POST['submit'])){ $isV=isset($_POST['visual']) ? "":"off"; update_option("CBS_InVisual",$isV); $isTx=isset($_POST['text']) ? "":"off"; update_option("CBS_InText",$isTx); update_option("CBS_StartCode",$_POST['before']); update_option("CBS_EndCode",$_POST['after']); $isPt=isset($_POST['ptag']) ? "":"off"; update_option("CBS_PTag",$isPt); if(!file_put_contents(WP_PLUGIN_DIR. '/code-blocks/editor-style.css', $_POST['css']) && $_POST['css']!=""){ echo '
Failed To Save Custom CSS. Make Sure you have Write permission in wp-contents/plugins folder.
Saved Settings
":get_option("CBS_StartCode");
 $endCode=get_option("CBS_EndCode")=="" ? "":get_option("CBS_StartCode");
 $endCode=get_option("CBS_EndCode")=="" ? "":get_option("CBS_StartCode");
 $endCode=get_option("CBS_EndCode")=="" ? "