This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 7th, 2012  |  syntax: PHP  |  size: 5.29 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3.  * Plugin Name: SMS Platform Keyword Checker
  4.  * Plugin URI: http://X.com
  5.  * Description: Checks an inputted keyword for usage in the SMS Platform.
  6.  * Version: 0.1
  7.  * Author: X
  8.  * Author URI: http://X.com
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13.  */
  14.  
  15. /**
  16.  * SMS_Platform_Keyword_Checker_Widget Widget class.
  17.  * This class handles everything that needs to be handled with the widget:
  18.  * the settings, form, display, and update.
  19.  *
  20.  * @author X
  21.  */
  22. class SMS_Platform_Keyword_Checker_Widget extends WP_Widget {
  23.  
  24.         /**
  25.          * Widget setup | Constructor
  26.          */
  27.         public function __construct() {
  28.  
  29.                 /* Widget settings. */
  30.                 $widget_ops = array('classname' => 'SMS_Platform_Keyword_Checker_Widget', 'description' => 'Checks an inputted keyword for usage in the SMS Platform.' );
  31.  
  32.                 /* Widget control settings. */
  33.                 $control_ops = array('width' => 300, 'height' => 350);
  34.  
  35.                 parent::WP_Widget('sms_platform_keyword_checker_widget', 'SMS Platform Keyword Checker', $widget_ops, $control_ops);
  36.         }
  37.  
  38.         /**
  39.          * Displays the widget on the screen.
  40.          *
  41.          * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  42.          * @param array $instance The settings for the particular instance of the widget
  43.          */
  44.         public function widget($args, $instance) {
  45.  
  46.                 extract($args);
  47.  
  48.                 /* Our variables from the widget settings. */
  49.                 $title = apply_filters('widget_title', $instance['title'] );
  50.  
  51.  
  52.                 /*$name = $instance['name'];
  53.                 $sex = $instance['sex'];
  54.                 $show_sex = isset( $instance['show_sex'] ) ? $instance['show_sex'] : false;*/
  55.  
  56.                 /* Before widget (defined by themes). */
  57.                 echo $before_widget;
  58.  
  59.                 //ENTER OUTPUT
  60.  
  61.                 /* After widget (defined by themes). */
  62.                 echo $after_widget;
  63.         }
  64.  
  65.         /**
  66.          * The newly calculated value of $instance should be returned.
  67.          * If "false" is returned, the instance won't be saved/updated.
  68.          * @param array $new_instance New settings for this instance as input by the user via form()
  69.          * @param array $old_instance Old settings for this instance
  70.          * @return array Settings to save or bool false to cancel saving
  71.          */
  72.         function update($new_instance, $old_instance) {
  73.  
  74.                 $instance = $old_instance;
  75.  
  76.                 if ( ($new_instance['country'] != 'US') || ($new_instance['country'] != 'CA') ) {
  77.  
  78.                         return false;
  79.                 }
  80.  
  81.                 if ( (empty($new_instance['username'])) || (empty($new_instance['password'])) || (empty($new_instance['customerNumber'])) ) {
  82.  
  83.                         return false;
  84.                 }
  85.  
  86.                 $instance['title'] = strip_tags($new_instance['title']);
  87.  
  88.                 $instance['country'] = strip_tags($new_instance['country']);
  89.  
  90.                 $instance['username'] = strip_tags($new_instance['username']);
  91.  
  92.                 $instance['password'] = strip_tags($new_instance['password']);
  93.  
  94.                 $instance['customerNumber'] = strip_tags($new_instance['customerNumber']);
  95.  
  96.                 return $instance;
  97.         }
  98.  
  99.         /**
  100.          * Displays the widget settings controls on the widget panel.
  101.          * Make use of the get_field_id() and get_field_name() function
  102.          * when creating your form elements.
  103.          */
  104.         function form($instance) {
  105.  
  106.                 ?>
  107.  
  108.                 <!-- Widget Title: Text Input -->
  109.                 <p>
  110.                         <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'hybrid'); ?></label>
  111.                         <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
  112.                 </p>
  113.  
  114.                 <!-- Username: Text Input -->
  115.                 <p>
  116.                         <label for="<?php echo $this->get_field_id('username'); ?>"><?php echo ('SMS Platform Username:'); ?></label>
  117.                         <input id="<?php echo $this->get_field_id('username'); ?>" name="<?php echo $this->get_field_name('username'); ?>" value="<?php echo $instance['username']; ?>" style="width:100%;" />
  118.                 </p>
  119.  
  120.                 <!-- Password: Password Input -->
  121.                 <p>
  122.                         <label for="<?php echo $this->get_field_id('password'); ?>"><?php echo ('Password:'); ?></label>
  123.                         <input id="<?php echo $this->get_field_id('password'); ?>" name="<?php echo $this->get_field_name('password'); ?>" type="password" value="<?php echo $instance['username']; ?>" style="width:100%;" />
  124.                 </p>
  125.                 <!-- Customer Number: Text Input -->
  126.                 <p>
  127.                         <label for="<?php echo $this->get_field_id('customerNumber'); ?>"><?php echo ('Customer Number:'); ?></label>
  128.                         <input id="<?php echo $this->get_field_id('customerNumber'); ?>" name="<?php echo $this->get_field_name('customerNumber'); ?>" value="<?php echo $instance['customerNumber']; ?>" style="width:100%;" />
  129.                 </p>
  130.  
  131.                 <!-- Country: Select -->
  132.                 <p>
  133.                         <label for="<?php echo $this->get_field_id('country'); ?>"><?php echo ('Country:'); ?></label>
  134.                         <select id="<?php echo $this->get_field_id('country'); ?>" name="<?php echo $this->get_field_name('country'); ?>" size="1">
  135.                                 <option value="US">US</option>
  136.                                 <option value="CA">CA</option>
  137.                         </select>
  138.                 </p>
  139.  
  140.         <?php
  141.         }
  142. } //end SMS_Platform_Keyword_Checker_Widget
  143.  
  144. /*
  145. * Register our widget.
  146. * 'SMS_Platform_Keyword_Checker' is the widget class used below.
  147. *
  148. */
  149. function smsplatformkeywordchecker_load_widgets() {
  150.         register_widget('SMS_Platform_Keyword_Checker_Widget');
  151. }
  152.  
  153. /*
  154.  * Add function to widgets_init that'll load our widget.
  155. */
  156. add_action('widgets_init', 'smsplatformkeywordchecker_load_widgets');
  157.  
  158. ?>
clone this paste RAW Paste Data