Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress widget input bar
    primarykey
    data
    text
    <p>Been working on a wordpress plugin (I've been reading tutorials but they all speak in terms I don't quite understand), it's all part of the learning curve for me.</p> <pre><code>&lt;?php /* Plugin Name: Server status Plugin Plugin URI: http://minepress.co.uk Description: Minepress is a site which allows users to start up a free Minecraft website for their server. This plugin shows the server status Version: 0.01 Author: Bradly Spicer Author URI: http://minepress.co.uk */ ?&gt; </code></pre> <p>Thats obviously the shell, I want to make it so whatever people put into an input it will be put into this html:</p> <pre><code>[b]Server Status:[/b] [img]http://res.public-craft.com/hb.php?ip=YOUR_IP&amp;port=YOUR_PORT&amp;on=OPTIONAL_ONLINE_IMAGE&amp;off=OPTIONAL_OFFLINE_IMAGE[/img] </code></pre> <p>I assume it would be along the lines of:</p> <pre><code>&lt;h3&gt;Server Status:&lt;/h4&gt; &lt;img = "http://res.public-craft.com/hb.php?ip=&lt;?php $Ipaddress?&gt;&amp;port=&lt;?php$Port?&gt;&amp;on=http://minepress.co.uk/images/on.png&amp;off=http://minepress.co.uk/images/off.png"&lt;/img&gt; </code></pre> <p>I don't really know how I'd incorporate it </p> <p>Thanks guys</p> <p>Forgot to mention I followed a tutorial before and came out with this:</p> <pre><code>&lt;?php include('config.php'); Class ServerStatus extends WP_Widget { function ServerStatus() { } function widget($args, $instance) { extract( $args, EXTR_SKIP ); $title = ( $instance['title']) ? $instance['title'] : 'Server Status'; $body = ( $instance['body']) ? $instance['body'] : 'Server Status Body'; ?&gt; &lt;?php echo $before_widget; ?&gt; &lt;?php echo $before_title . $title . $after_title ?&gt; &lt;p&gt;&lt;?php echo $body ?&gt;&lt;/p&gt; error_reporting(E_ALL); add_action("widgets_init", array('Server_Status', 'register')); class Widget_name { function control(){ echo 'I am a control panel'; } function widget($args){ echo $args['before_widget']; echo $args['before_title'] . 'Your widget title' . $args['after_title']; echo 'I am your widget'; echo $args['after_widget']; } function register(){ register_sidebar_widget('Widget name', array('Server_Status', 'widget')); register_widget_control('Widget name', array('Server_Status', 'control')); } } add_option($name, $value); update_option($name, $new_value); delete_option($name); error_reporting(E_ALL); add_action("widgets_init", array('Server_Status', 'register')); register_activation_hook( __FILE__, array('Server_Status', 'activate')); register_deactivation_hook( __FILE__, array('Server_Status', 'deactivate')); class Widget_name { function activate(){ $data = array( 'option1' =&gt; 'Default value' ,'option2' =&gt; 55); if ( ! get_option('Server_Status')){ add_option('Server_Status' , $data); } else { update_option('Server_Status' , $data); } } function deactivate(){ delete_option('widget_name'); } function control(){ echo 'I am a control panel'; } function widget($args){ echo $args['before_widget']; echo $args['before_title'] . 'Your widget title' . $args['after_title']; echo 'I am your widget'; echo $args['after_widget']; } function register(){ register_sidebar_widget('Widget name', array('Server_Status', 'widget')); register_widget_control('Widget name', array('Server_Status', 'control')); } } function control(){ $data = get_option('Server_Status'); ?&gt; &lt;p&gt;&lt;label&gt;Option 1&lt;input name="Server_Status_option1" type="text" value="&lt;?php echo $data['option1']; ?&gt;" /&gt;&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;label&gt;Option 2&lt;input name="Server_Status_option2" type="text" value="&lt;?php echo $data['option2']; ?&gt;" /&gt;&lt;/label&gt;&lt;/p&gt; &lt;?php if (isset($_POST['widget_name_option1'])){ $data['option1'] = attribute_escape($_POST['Server_Status_option1']); $data['option2'] = attribute_escape($_POST['Server_Status_option2']); update_option('Server_Status', $data); } } </code></pre> <p>Goal: the goal is to make it so the user in the admin panel inputs their server ip and port (Two seperate input fields). These are then called and put into either of the scripts above. I assume it would be </p> <pre><code>&lt;h3&gt;Server Status:&lt;/h4&gt; &lt;img = "http://res.public-craft.com/hb.php?ip=&lt;?php $Ipaddress?&gt;&amp;port=&lt;?php$Port?&gt;&amp;on=http://minepress.co.uk/images/on.png&amp;off=http://minepress.co.uk/images/off.png"&lt;/img&gt; </code></pre> <p>But I don't know how to make the $Ipaddress and $Port to be whatever they input.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload