Making a wordpress Plugin, need help

Discussion in 'HTML & Website Design' started by Xtrapsp, Jun 19, 2012.

  1. #1
    Hey guys,

    So I'm in need of some help. I'm making a new custom Skin/Module for Wordpress (Minecraft servers specifically).

    So this is the error i get

    "Warning: Cannot modify header information - headers already sent by (output started at /home/wwwrhino/public_html/bradsblog/wp-content/plugins/MC-Server-IP/Server-Ip.php:56) in /home/wwwrhino/public_html/bradsblog/wp-includes/pluggable.php on line 866"

    I'm raging because this is the plugin so far:

    That error comes up when I try and add media... However it still adds the media...
     
    Xtrapsp, Jun 19, 2012 IP
  2. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #2
    I'd appreciate some help.
     
    Xtrapsp, Jun 20, 2012 IP
  3. mnmani

    mnmani Well-Known Member

    Messages:
    379
    Likes Received:
    11
    Best Answers:
    6
    Trophy Points:
    195
  4. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #4
    file Server-Ip.php on line No 56 has echo something and to avoid this error either you use @ sign before header like @header(""); or use out put buffer functions.
     
    freelanceinphp, Jun 20, 2012 IP
  5. ashishkg

    ashishkg Active Member

    Messages:
    233
    Likes Received:
    8
    Best Answers:
    3
    Trophy Points:
    68
    #5
    Nothing issue in code please use your own or copy this..
    <?php
    /*
    Plugin Name: Minecraft Server IP
    Plugin URI: http://bradsblog.co.uk
    Description: Want to simply show if your server is up? Look no further
    Author: Bradly Spicer
    Version: 0.1
    Author URI: http://bradsblog.co.uk
    */
    class MinecraftIPWidget extends WP_Widget
    {
    function MinecraftIPWidget()
    {
    $widget_ops = array('classname' => 'MinecraftIPWidget', 'description' => 'Displays your Minecraft IP' );
    $this->WP_Widget('MinecraftIPWidget', 'Show your Minecraft IP', $widget_ops);
    }
    function form($instance)
    {
    $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    $title = $instance['title'];
    ?>
    <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
    <p>
    <label for="<?php echo $this->get_field_id('title'); ?>">IP:
    <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>&nbsp;</p>
    <?php
    }
    function update($new_instance, $old_instance)
    {
    $instance = $old_instance;
    $instance['title'] = $new_instance['title'];
    return $instance;
    }
    function widget($args, $instance)
    {
    extract($args, EXTR_SKIP);


    echo $before_widget;
    $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);

    if (!empty($title))
    echo $before_title . $title . $after_title;;


    // WIDGET CODE GOES HERE
    echo "<h1>This is my new widget!</h1>";
    echo $after_widget;
    }
    }
    add_action( 'widgets_init', create_function('', 'return register_widget("MinecraftIPWidget");') );?>
     
    ashishkg, Jun 23, 2012 IP
  6. Xtrapsp

    Xtrapsp Active Member

    Messages:
    716
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #6

    Tried this, it didn't work

    I didn't think PHP files used echo etc, I swear that was bat files, I will have a go though thanks.


    Does anyone else have advice?
     
    Xtrapsp, Jun 25, 2012 IP