PluginProbe
Insert Html Snippet / 1.2.2
Insert Html Snippet v1.2.2
1.4.6 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 All 27 releases
insert-html-snippet / widget.php

widget.php in Insert Html Snippet 1.2.2, at widget.php

93 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) )
3 exit;
4 /**
5 * XYZScripts Insert HTML Snippet Widget Class
6 */
7
8 ////*****************************Sidebar Widget**********************************////
9
10 class Xyz_Insert_Html_Widget extends WP_Widget {
11
12
13 /** constructor -- name this the same as the class above */
14 function __construct() {
15 parent::__construct(false, $name = 'Insert Html Snippet');
16 }
17
18 /** @see WP_Widget::widget -- do not rename this */
19 function widget($args, $instance) {
20 extract( $args );
21 global $wpdb;
22 $title = apply_filters('widget_title', $instance['title']);
23 $xyz_ihs_id = $instance['message'];
24 //echo "SELECT content FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE id='$xyz_ihs_title'";die;
25 $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE id=%d",$xyz_ihs_id ));
26
27 $entry = $entries[0];
28
29 echo $before_widget;
30 if ( $title )
31 echo $before_title . $title . $after_title;
32 echo do_shortcode($entry->content);
33
34 echo $after_widget;
35
36 }
37
38 /** @see WP_Widget::update -- do not rename this */
39 function update($new_instance, $old_instance) {
40 $instance = $old_instance;
41 $instance['title'] = strip_tags($new_instance['title']);
42 $instance['message'] = strip_tags($new_instance['message']);
43 return $instance;
44 }
45
46 /** @see WP_Widget::form -- do not rename this */
47 function form($instance) {
48 global $wpdb;
49 $entries = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status=%d ORDER BY id DESC",1 ));
50
51
52 if(isset($instance['title'])){
53 $title = esc_attr($instance['title']);
54 }else{
55 $title = '';
56 }
57
58 if(isset($instance['message'])){
59 $message = esc_attr($instance['message']);
60 }else{
61 $message = '';
62 }
63
64 ?>
65 <p>
66 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
67 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
68 </p>
69 <p>
70 <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Choose Snippet :'); ?></label>
71
72 <!-- <input class="widefat" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" type="text" value="<?php echo $message; ?>" />-->
73 <select name="<?php echo $this->get_field_name('message'); ?>">
74 <?php
75 if( count($entries)>0 ) {
76 $count=1;
77 $class = '';
78 foreach( $entries as $entry ) {
79 ?>
80 <option value="<?php echo $entry->id;?>" <?php if($message==$entry->id)echo "selected"; ?>><?php echo $entry->title;?></option>
81 <?php
82 }
83 }
84 ?>
85 </select>
86 </p>
87 <?php
88 }
89
90
91 } // end class Xyz_Insert_Html_Widget
92 add_action('widgets_init', create_function('', 'return register_widget("Xyz_Insert_Html_Widget");'));
93 ?>