mercredi 18 novembre 2015

Create custom widget in wordpress

I am new in wordpress
and need to create custom widget
me create form html this form contain action to
another page and other page contain on php code to show some result
What should I do to become awidget
Code

<form method='post' action="">
<p class="submit">
  <input type="submit" class="button-primary" 
  value="submit" />
</p>
</form>  

Onther page 'action'

 <?php
   ob_start();
    .
    .
    .
   $page = ob_get_contents();
   $fp = fopen("output.html","w");
   fwrite($fp,$page);
   ob_end_flush();
   fclose($fp);
 ?>

Process to create widget

class My_Widget extends WP_Widget {

    /**
    * Sets up the widgets name etc
    */
    public function __construct() {
     // widget actual processes
    }

   /**
   * Outputs the content of the widget
   *
   * @param array $args
   * @param array $instance
   */
   public function widget( $args, $instance ) {
    // outputs the content of the widget
   }

  /**
  * Outputs the options form on admin
  *
  * @param array $instance The widget options
  */
  public function form( $instance ) {
    // outputs the options form on admin
  }

  /**
  * Processing widget options on save
  *
  * @param array $new_instance The new options
  * @param array $old_instance The previous options
  */
  public function update( $new_instance, $old_instance ) {
    // processes widget options to be saved
  }
}  

Thanks in advance to anyone who helps me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire