/*
Plugin Name: WP-Sidebar-Include
Plugin URI: http://www.skippy.net/blog/plugins/
Description: Lets the admin enter code to be included in the sidebar from manage section in admin
Version: 1.2
Author: Bob Steinberg
Author URI: http://www.skippy.net/

based on core wp-mail.php
released under the terms of the GNU GPL
*/
// If you hardcode a WP.com API key here, all key config screens will be hidden
$wpcom_api_key = '';

function wp_sidebar_init() {
global $wpcom_api_key, $wp_sidebar_api_host, $wp_sidebar_api_port;

if ( $wpcom_api_key ) {
$wp_sidebar_api_host = $wpcom_api_key . '.rest.wp_sidebar.com';
} else {
$wp_sidebar_api_host = get_option('wordpress_api_key') . '.rest.wp_sidebar.com';
}

$wp_sidebar_api_port = 80;
add_action('admin_menu', 'wp_sidebar_config_page');
}

add_action('init', 'wp_sidebar_init');

if ( !function_exists('wp_nonce_field') ) {
function wp_sidebar_nonce_field($action = -1) { return; }
$wp_sidebar_nonce = -1;
} else {
function wp_sidebar_nonce_field($action = -1) { return wp_nonce_field($action); }
$wp_sidebar_nonce = 'wp_sidebar-update-key';
}

function wp_sidebar_config_page() {
if ( function_exists('add_submenu_page') )
add_submenu_page('edit.php', __('wp_sidebar Configuration'), __('Sidebar Include Editor'), 'manage_options', 'wp_sidebar-edit', 'wp_sidebar_conf');
}

function wp_sidebar_conf() {
global $wp_sidebar_nonce, $wpcom_api_key;

$action=$_POST["action"];

$file = ABSPATH.'wp-content/sidebar_box.php';
$real_file = $file;

switch($action) {

case 'update':

$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
}

default:

if (!is_file($real_file))
$error = 1;

if (!$error) {
$f = fopen($real_file, 'r');
$content = fread($f, filesize($real_file));
$content = htmlspecialchars($content);
}

?>

if (is_writeable($real_file)) {
echo '

‘ . sprintf(__(’Editing %s‘), $file) . ‘

‘;
} else {
echo ‘

‘ . sprintf(__(’Browsing %s‘), $file) . ‘

‘;
}
?>

echo "
“;
?>


} else {
echo '

‘ . __(’Oops, no such file exists! Double check the name and try again, merci.’) . ‘

‘;
}
?>

 

break;
}
}
?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Google
  • del.icio.us
  • Digg
  • Facebook
  • Live
  • StumbleUpon
  • Technorati

Post to Twitter Tweet This Post

Tags:

Leave a Reply

You must be logged in to post a comment.