Subdomain Posts
PHP | 463 days ago
PHP | 475 days ago
PHP | 475 days ago
Recent Posts
None | 24 sec ago
None | 34 sec ago
None | 34 sec ago
None | 44 sec ago
None | 1 min ago
PHP | 1 min ago
Bash | 1 min ago
None | 1 min ago
XML | 1 min ago
Bash | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Alex Tingle on the 30th of Nov 2008 01:58:44 PM Download | Raw | Embed | Report
  1. <?php
  2.  
  3. //
  4. // Example MultiWidget. Use this as a template for your own.
  5. //
  6.  
  7. class ExampleMultiWidget extends MultiWidget
  8. {
  9.   function ExampleMultiWidget()
  10.   {
  11.     $this->MultiWidget(
  12.         'example-multi', // id_base
  13.         'ExampleMulti', // name
  14.         array('description'=>__('Widget which allows multiple instances'))
  15.       );
  16.   }
  17.  
  18.  
  19.   // Echo the actual widget content. Subclasses should over-ride this function
  20.   // to generate their widget code.
  21.   function widget($args,$instance)
  22.   {
  23.     extract($args,EXTR_SKIP);
  24.     echo $before_widget;
  25.     echo   $before_title . $instance['title'] . $after_title;
  26.     echo   $instance['content'];
  27.     echo $after_widget;
  28.   }
  29.  
  30.  
  31.   // Update a particular instance.
  32.   // This function should check that $new_instance is set correctly.
  33.   // The newly calculated value of $instance should be returned.
  34.   function control_update($new_instance, $old_instance)
  35.   {
  36.     if( !isset($new_instance['title']) ) // user clicked cancel
  37.         return false;
  38.     $instance = $old_instance;
  39.     $instance['title'] = wp_specialchars( $new_instance['title'] );
  40.     $instance['content'] = wp_specialchars( $new_instance['content'] );
  41.     return $instance;
  42.   }
  43.  
  44.  
  45.   // Echo a control form for the current instance.
  46.   // The form has inputs with names like widget-ID_BASE[$number][FIELD_NAME]
  47.   // so that all data for that instance of the widget are stored in one
  48.   // $_POST variable: $_POST['widget-ID_BASE'][$number]
  49.   function control_form($instance)
  50.   {
  51. ?>
  52.     <p>
  53.  
  54.      <label for="<?php echo $this->get_field_id('title') ?>">
  55.       <?php _e('Title:'); ?>
  56.       <input class="widefat" id="<?php echo $this->get_field_id('title') ?>"
  57.        name="<?php echo $this->get_field_name('title') ?>" type="text"
  58.        value="<?php echo htmlspecialchars($instance['title'],ENT_QUOTES) ?>" />
  59.      </label>
  60.  
  61.      <label for="<?php echo $this->get_field_id('content') ?>">
  62.       <?php _e('Content:'); ?>
  63.       <input class="widefat" id="<?php echo $this->get_field_id('content') ?>"
  64.        name="<?php echo $this->get_field_name('content') ?>" type="text"
  65.        value="<?php echo htmlspecialchars($instance['content'],ENT_QUOTES) ?>" />
  66.      </label>
  67.  
  68.      <input type="hidden" id="<?php echo $this->get_field_id('submit') ?>"
  69.       name="<?php echo $this->get_field_name('submit') ?>" value="1" />
  70.  
  71.     </p>
  72. <?php
  73.   }
  74.  
  75. } // end class ExampleMultiWidget
  76.  
  77.  
  78. // Finally create an object for the widget-type and register it.
  79. $example_multi = new ExampleMultiWidget();
  80. add_action( 'widgets_init', array($example_multi,'register') );
  81.  
  82. ?>
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: