Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Plugin Name: SMS Platform Keyword Checker
- * Plugin URI: http://X.com
- * Description: Checks an inputted keyword for usage in the SMS Platform.
- * Version: 0.1
- * Author: X
- * Author URI: http://X.com
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
- /**
- * SMS_Platform_Keyword_Checker_Widget Widget class.
- * This class handles everything that needs to be handled with the widget:
- * the settings, form, display, and update.
- *
- * @author X
- */
- class SMS_Platform_Keyword_Checker_Widget extends WP_Widget {
- /**
- * Widget setup | Constructor
- */
- public function __construct() {
- /* Widget settings. */
- $widget_ops = array('classname' => 'SMS_Platform_Keyword_Checker_Widget', 'description' => 'Checks an inputted keyword for usage in the SMS Platform.' );
- /* Widget control settings. */
- $control_ops = array('width' => 300, 'height' => 350);
- parent::WP_Widget('sms_platform_keyword_checker_widget', 'SMS Platform Keyword Checker', $widget_ops, $control_ops);
- }
- /**
- * Displays the widget on the screen.
- *
- * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
- * @param array $instance The settings for the particular instance of the widget
- */
- public function widget($args, $instance) {
- extract($args);
- /* Our variables from the widget settings. */
- $title = apply_filters('widget_title', $instance['title'] );
- /*$name = $instance['name'];
- $sex = $instance['sex'];
- $show_sex = isset( $instance['show_sex'] ) ? $instance['show_sex'] : false;*/
- /* Before widget (defined by themes). */
- echo $before_widget;
- //ENTER OUTPUT
- /* After widget (defined by themes). */
- echo $after_widget;
- }
- /**
- * The newly calculated value of $instance should be returned.
- * If "false" is returned, the instance won't be saved/updated.
- * @param array $new_instance New settings for this instance as input by the user via form()
- * @param array $old_instance Old settings for this instance
- * @return array Settings to save or bool false to cancel saving
- */
- function update($new_instance, $old_instance) {
- $instance = $old_instance;
- if ( ($new_instance['country'] != 'US') || ($new_instance['country'] != 'CA') ) {
- return false;
- }
- if ( (empty($new_instance['username'])) || (empty($new_instance['password'])) || (empty($new_instance['customerNumber'])) ) {
- return false;
- }
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['country'] = strip_tags($new_instance['country']);
- $instance['username'] = strip_tags($new_instance['username']);
- $instance['password'] = strip_tags($new_instance['password']);
- $instance['customerNumber'] = strip_tags($new_instance['customerNumber']);
- return $instance;
- }
- /**
- * Displays the widget settings controls on the widget panel.
- * Make use of the get_field_id() and get_field_name() function
- * when creating your form elements.
- */
- function form($instance) {
- ?>
- <!-- Widget Title: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'hybrid'); ?></label>
- <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%;" />
- </p>
- <!-- Username: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id('username'); ?>"><?php echo ('SMS Platform Username:'); ?></label>
- <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%;" />
- </p>
- <!-- Password: Password Input -->
- <p>
- <label for="<?php echo $this->get_field_id('password'); ?>"><?php echo ('Password:'); ?></label>
- <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%;" />
- </p>
- <!-- Customer Number: Text Input -->
- <p>
- <label for="<?php echo $this->get_field_id('customerNumber'); ?>"><?php echo ('Customer Number:'); ?></label>
- <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%;" />
- </p>
- <!-- Country: Select -->
- <p>
- <label for="<?php echo $this->get_field_id('country'); ?>"><?php echo ('Country:'); ?></label>
- <select id="<?php echo $this->get_field_id('country'); ?>" name="<?php echo $this->get_field_name('country'); ?>" size="1">
- <option value="US">US</option>
- <option value="CA">CA</option>
- </select>
- </p>
- <?php
- }
- } //end SMS_Platform_Keyword_Checker_Widget
- /*
- * Register our widget.
- * 'SMS_Platform_Keyword_Checker' is the widget class used below.
- *
- */
- function smsplatformkeywordchecker_load_widgets() {
- register_widget('SMS_Platform_Keyword_Checker_Widget');
- }
- /*
- * Add function to widgets_init that'll load our widget.
- */
- add_action('widgets_init', 'smsplatformkeywordchecker_load_widgets');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement