SRL Archive - Web Development

Some help with PHP and forms?


xtrapsp

2012-08-18 08:26:35

Heya,
I want to make a plugin in wordpress which takes whatever the user inputs into the plugin options and makes a page.
For example,
The user puts a webpage inside the settings box and the result is a premade page or shortcode which the user places in creating an iframe of that said page which is shrunk down without sidebars.

Any help?
What I have already:

[PHP]<?php/*
Plugin Name: Minepress Dynmap Plugin
Plugin URI: http://minepress.co.uk
Description: A Minepress plugin which allows the user to integrate the Minecraft


Dynmap
Author: Bradly Spicer
Version: 0.02
Author URI: http://minepress.co.uk
*/


/* Runs when plugin is activated */
register_activation_hook(__FILE__,'minecraft_dynmap_install');


/* Runs on plugin deactivation*/
register_deactivation_hook( __FILE__, 'minecraft_dynmap_remove' );


function minecraft_dynmap_install() {
/* Creates new database field */
add_option("minecraft_dynmap_data", 'Default', '', 'yes');
}


function hello_world_remove() {
/* Deletes the database field */
delete_option('minecraft_dynmap_data');


if ( is_admin() ){


/* Call the html code */
add_action('admin_menu', 'minecraft_dynmap_admin_menu');


function minecraft_dynmap_admin_menu() {
add_options_page('Dynmap', 'Dynmap', 'administrator',
'hello-world', 'hello_world_html_page');
}
}
?>
The above code, is placed under is_admin() which means it only runs in the wordpress


admin area.
The below function has the html code for the settings page, containing the form and


notice how the php tag is split to accomodate the html code.


and the coding part is..
<?php
function minecraft_dynmap_html_page() {
?>
<div>
<h2>Dynmap Options</h2>


<form method="post" action="options.php">
<?php wp_nonce_field('update-options'); ?>


<table width="510">
<tr valign="top">
<th width="92" scope="row">Enter your server Ip:</th>
<td width="406">
<input name="hello_world_data" type="text" id="minecraft_dynmap_data"
value="<?php echo get_option('minecraft_dynmap_data'); ?>" />
(ex. minecraft_dynmap)</td>
</tr>
</table>


<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="minecraft_dynmap_data" />


<p>
<input type="submit" value="<?php _e('Save Changes') ?>" />
</p>


</form>
</div>
<?php
}
?>[/PHP]