/*
Plugin Name: WP-Welcome
Plugin URI: http://www.skippy.net/blog/plugins/
Description: Lets the admin edit welcome text in the site home page
Version: 1.0
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
define("HTMLS_DIR", "blog/html_files");
define("PHP_FILE_HEADER", "“);
define(”PHP_FILE_FOOTER”, ““);
$home_path=str_replace( “/blog”, “”, ABSPATH );
define(”PHP_DIR”, $home_path );
$wpcom_api_key = ”;
global $file_to_edit;
$file_to_edit = $_GET['file_to_edit'];
function wp_welcome_init() {
global $wpcom_api_key, $wp_welcome_api_host, $wp_welcome_api_port;
if ( $wpcom_api_key ) {
$wp_welcom_api_host = $wpcom_api_key . ‘.rest.wp_welcome.com’;
} else {
$wp_welcome_api_host = get_option(’wordpress_api_key’) . ‘.rest.wp_welcome.com’;
}
$wp_welcome_api_port = 80;
add_action(’admin_menu’, ‘wp_welcome_page’);
}
add_action(’init’, ‘wp_welcome_init’);
if ( !function_exists(’wp_nonce_field’) ) {
function wp_welcome_nonce_field($action = -1) { return; }
$wp_sidebar_nonce = -1;
} else {
function wp_welcome_nonce_field($action = -1) { return wp_nonce_field($action); }
$wp_sidebar_nonce = ‘wp_welcome-update-key’;
}
function wp_welcome_page() {
if ( function_exists(’add_submenu_page’) )
add_submenu_page(’edit.php’, __(’wp_welcome Configuration’), __(’File Editor’), ‘manage_options’, ‘wp_welcome-edit’, ‘wp_welcome_edit’);
}
function wp_welcome_edit() {
global $wp_sidebar_nonce, $wpcom_api_key;
$action=$_POST["action"];
$file=$_GET['file_to_edit'];
if($file == “”)
$file = $_POST['file_to_edit'];
//$file = PHP_DIR.’welcome.php’;
$show_file = HTMLS_DIR.”/”.$file;
$file = PHP_DIR.HTMLS_DIR.”/”.$file;
$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‘), $show_file) . ‘
‘;
} else {
echo ‘
‘ . sprintf(__(’Browsing %s‘), $show_file) . ‘
‘;
}
?>
Instructions:
Step1 – Create a new file, name it whatever you want.
Step2 – Edit Your newly created page by clicking "edit" below.
Step3 – There is no Step 3. You’re done adding a new page
to your site outside your blog!
You can link to your new page via ‘http://www.yourdomain.com/newfile.php’
(where you will replace ‘yourdomain’ with your domain, and ‘newfile’ with
the file name you gave to your new page.)
Create a new file:
Files in “” directory:
extract($_GET);
if($file_to_delete)
{
$real_file = PHP_DIR.HTMLS_DIR."/".$file_to_delete;
if(is_file($real_file))
{
if(unlink($real_file))
{
?>
}
else
{
echo '
‘ . __(’Oops, can\’t delete html file.’) . ‘
‘;
}
}
$file_trunc = explode(”.”, $file_to_delete);
$php_file = PHP_DIR.$file_trunc[0].”.php”;
if(is_file($php_file))
{
if(unlink($php_file))
{
?>
}
else
{
echo '
‘ . __(’Oops, can\’t delete php file.’) . ‘
‘;
}
}
}
else if($file_to_create)
{
$real_file = PHP_DIR.HTMLS_DIR.”/”.$file_to_create;
if($f=fopen($real_file,”w”))
{
chmod($real_file,0666);
?>
fclose($f);
}
else
{
echo '
‘ . __(’Oops, can\’t create a new html file.’) . ‘
‘;
}
//
$file_trunc = explode(”.”, $file_to_create);
$php_file = PHP_DIR.$file_trunc[0].”.php”;
if($f=fopen($php_file,”w”))
{
chmod($php_file,0666);
$phpcontent = PHP_FILE_HEADER.”\n\r\n\r”.PHP_FILE_FOOTER;
fwrite($f, $phpcontent);
?>
fclose($f);
}
else
{
echo '
‘ . __(’Oops, can\’t create a new php file.’) . ‘
‘;
}
}
if ($handle = opendir(PHP_DIR.HTMLS_DIR)) {
?>
|
|
while (false !== ($file = readdir($handle))) {
if($file != '.' && $file != '..')
{
?>
| =$file?> |
‘>delete |
$not_empty = 1;
}
}
?>
if($not_empty != 1)
{
echo '
‘ . __(’Oops, there are no files to edit. First of all create a new file for editing.’) . ‘
‘;
}
}
closedir($handle);
?>
break;
}
}
?>
Tweet This Post