Using PHP to create a plugin WP

  • minepress
  • Born
  • Born
  • minepress
  • Posts: 1

Post 3+ Months Ago

Hello everyone,

I'm working on MinepressUK a project for me to learn php and release a free alternative of the upcoming minepress (weirdly we both had the same idea at the same time)

I was wondering if there would be any possible way to make it so that when someone inputs into a settings form their server ip that it will show a dynamic map.

Quote:
First time use

When you start CraftBukkit, you should be able to navigate to http://yourserverip:8123/ in your browser. In case you are running CraftBukkit on the PC you are currently working on, you can navigate to http://localhost:8123/. You should be able to see the players who are in-game. Note that the map is not yet rendered, therefore the background will be black.

If you are planning on using the HD renderer, now would be a good time to do so. Enable 'deftemplatesuffix: hires' in the top of configuration.txt. More information about deftemplatesuffix is available at Base plugin settings.

If you just want to see Dynmap work, use the following command in-game: /dynmap fullrender. The wiki contains more information about commands and permissions. The map should reveal itself gradually in the browser, give it some time. Progress messages indicate that Dynmap is working and will show when the render is completed.


so all they have to write in the input box is their http://iphere and it will automatically add the port

Here is what I have so far:

PHP Code: [ Select ]
<?php
/*
Plugin Name: Minepress Dynmap Plugin
Plugin URI: removed
Description: A Minepress plugin which allows the user to integrate the Minecraft
 
Dynmap
Author: Bradly Spicer
Version: 0.02
Author URI: removed
*/
 
/* 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>
  1. <?php
  2. /*
  3. Plugin Name: Minepress Dynmap Plugin
  4. Plugin URI: removed
  5. Description: A Minepress plugin which allows the user to integrate the Minecraft
  6.  
  7. Dynmap
  8. Author: Bradly Spicer
  9. Version: 0.02
  10. Author URI: removed
  11. */
  12.  
  13. /* Runs when plugin is activated */
  14. register_activation_hook(__FILE__,'minecraft_dynmap_install');
  15.  
  16. /* Runs on plugin deactivation*/
  17. register_deactivation_hook( __FILE__, 'minecraft_dynmap_remove' );
  18.  
  19. function minecraft_dynmap_install() {
  20. /* Creates new database field */
  21. add_option("minecraft_dynmap_data", 'Default', '', 'yes');
  22. }
  23.  
  24. function hello_world_remove() {
  25. /* Deletes the database field */
  26. delete_option('minecraft_dynmap_data');
  27.  
  28. if ( is_admin() ){
  29.  
  30. /* Call the html code */
  31. add_action('admin_menu', 'minecraft_dynmap_admin_menu');
  32.  
  33. function minecraft_dynmap_admin_menu() {
  34. add_options_page('Dynmap', 'Dynmap', 'administrator',
  35. 'hello-world', 'hello_world_html_page');
  36. }
  37. }
  38. ?>
  39. The above code, is placed under is_admin() which means it only runs in the wordpress
  40.  
  41. admin area.
  42. The below function has the html code for the settings page, containing the form and
  43.  
  44. notice how the php tag is split to accomodate the html code.
  45.  
  46. and the coding part is..
  47. <?php
  48. function minecraft_dynmap_html_page() {
  49. ?>
  50. <div>
  51. <h2>Dynmap Options</h2>
  52.  
  53. <form method="post" action="options.php">
  54. <?php wp_nonce_field('update-options'); ?>
  55.  
  56. <table width="510">
  57. <tr valign="top">
  58. <th width="92" scope="row">Enter your server Ip:</th>
  59. <td width="406">
  60. <input name="hello_world_data" type="text" id="minecraft_dynmap_data"
  61. value="<?php echo get_option('minecraft_dynmap_data'); ?>" />
  62. (ex. minecraft_dynmap)</td>
  63. </tr>
  64. </table>
  65.  
  66. <input type="hidden" name="action" value="update" />
  67. <input type="hidden" name="page_options" value="minecraft_dynmap_data" />
  68.  
  69. <p>
  70. <input type="submit" value="<?php _e('Save Changes') ?>" />
  71. </p>
  72.  
  73. </form>
  74. </div>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

did you get this sorted?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: Liamw411 and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.