PluginProbe
Insert Html Snippet / trunk
Insert Html Snippet vtrunk
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
← All changes | widget.php +74 -95 1.3.4trunk View file →
@@ -1,119 +1,98 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) )
2 +if ( ! defined( 'ABSPATH' ) )
3 3 exit;
4 4 /**
5 -* XYZScripts Insert PHP Snippet Widget Class
6 -*/
5 + * XYZScripts Insert HTML Snippet Widget Class
6 + */
7 +
7 8 ////*****************************Sidebar Widget**********************************////
8 -class Xyz_Insert_Php_Widget extends WP_Widget {
9 +
10 +class Xyz_Insert_Html_Widget extends WP_Widget {
11 +
12 +
9 13 /** constructor -- name this the same as the class above */
10 14 function __construct() {
11 - parent::__construct(false, $name = 'Insert PHP Snippet');
15 + parent::__construct(false, $name = 'Insert Html Snippet');
12 16 }
17 +
13 18 /** @see WP_Widget::widget -- do not rename this */
14 - function widget($args, $instance){
19 + function widget($args, $instance) {
15 20 extract( $args );
16 21 global $wpdb;
17 - $title = apply_filters('widget_title', $instance['title']);
18 - $xyz_ips_id = $instance['message'];
19 - $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ips_short_code WHERE id=%d",$xyz_ips_id ));
22 + $title = apply_filters('widget_title', $instance['title']);
23 + $xyz_ihs_id = $instance['message'];
24 +
25 + $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE id=%d",$xyz_ihs_id ));
26 +
20 27 $entry = $entries[0];
28 +
21 29 echo $before_widget;
22 30 if ( $title )
23 - echo $before_title . $title . $after_title;
24 - $content_to_eval=$entry->content;
25 - /***** to handle old codes : start *****/
26 - if(get_option('xyz_ips_auto_insert')==1){
27 - $xyz_ips_content_start='<?php';
28 - $new_line="\r\n";
29 - $xyz_ips_content_end='?>';
30 - if (stripos($content_to_eval, '<?php') !== false)
31 - $tag_start_position=stripos($content_to_eval,'<?php');
32 - else
33 - $tag_start_position="-1";
34 - if (stripos($content_to_eval, '?>') !== false)
35 - $tag_end_position=stripos($content_to_eval,'?>');
36 - else
37 - $tag_end_position="-1";
38 - if(stripos($content_to_eval, '<?php') === false && stripos($content_to_eval, '?>') === false)
39 - {
40 - $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
41 - }
42 - else if(stripos($content_to_eval, '<?php') !== false)
43 - {
44 - if($tag_start_position>=0 && $tag_end_position>=0 && $tag_start_position>$tag_end_position)
45 - {
46 - $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
47 - }
48 - }
49 - else if(stripos($content_to_eval, '<?php') === false)
50 - {
51 - if (stripos($content_to_eval, '?>') !== false)
52 - {
53 - $content_to_eval=$xyz_ips_content_start.$new_line.$content_to_eval;
54 - }
55 - }
56 - $content_to_eval='?>'.$content_to_eval;
57 - }
58 - /***** to handle old codes : end *****/
59 - else{
60 - if(substr(trim($content_to_eval), 0,5)=='<?php')
61 - $content_to_eval='?>'.$content_to_eval;
62 - }
31 + echo $before_title . $title . $after_title;
32 + echo do_shortcode($entry->content);
33 +
34 + echo $after_widget;
63 35
64 - eval($content_to_eval);
65 - echo $after_widget;
66 36 }
37 +
67 38 /** @see WP_Widget::update -- do not rename this */
68 - function update($new_instance, $old_instance) {
69 - $instance = $old_instance;
70 - $instance['title'] = strip_tags($new_instance['title']);
71 - $instance['message'] = strip_tags($new_instance['message']);
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']);
72 43 return $instance;
73 44 }
45 +
74 46 /** @see WP_Widget::form -- do not rename this */
75 - function form($instance) {
76 - global $wpdb;
77 - $entries = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE status=%d ORDER BY id DESC",1 ));
78 - if(isset($instance['title'])){
79 - $title = esc_attr($instance['title']);
80 - }else{
81 - $title = '';
82 - }
83 - if(isset($instance['message'])){
84 - $message = esc_attr($instance['message']);
85 - }else{
86 - $message = '';
87 - }
88 -?>
89 -<p>
90 - <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
91 - <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; ?>" />
92 -</p>
93 -<p>
94 - <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Choose Snippet :'); ?></label>
95 - <select name="<?php echo $this->get_field_name('message'); ?>">
96 - <?php
97 - if(!empty($entries))//if( count($entries)>0 )
98 - {
99 - $count=1;
100 - $class = '';
101 - foreach( $entries as $entry ) {
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 +
102 64 ?>
103 - <option value="<?php echo $entry->id;?>" <?php if($message==$entry->id)echo "selected"; ?>><?php echo $entry->title;?></option>
104 - <?php
105 - }
106 - }
107 - ?>
108 - </select>
109 -</p>
110 -<?php
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(!empty($entries)){ //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
111 88 }
112 -} // end class Xyz_Insert_Php_Widget
89 +
90 +
91 +} // end class Xyz_Insert_Html_Widget
113 92
114 -function xyz_ips_add_snippet_widget(){
115 - register_widget("Xyz_Insert_Php_Widget");
93 +function xyz_ihs_add_snippet_widget(){
94 + register_widget("Xyz_Insert_Html_Widget");
116 95 }
117 -add_action('widgets_init','xyz_ips_add_snippet_widget');
96 +add_action('widgets_init','xyz_ihs_add_snippet_widget');
118 97
119 -?>
98 +?>