| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | extract( $args ); |
| 21 | 21 | global $wpdb; |
| 22 | 22 | $title = apply_filters('widget_title', $instance['title']); |
| 23 | 23 | $xyz_ihs_id = $instance['message']; |
| 24 | - //echo "SELECT content FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE id='$xyz_ihs_title'";die; | |
| 24 | + | |
| 25 | 25 | $entries = $wpdb->get_results($wpdb->prepare( "SELECT content FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE id=%d",$xyz_ihs_id )); |
| 26 | 26 | |
| 27 | 27 | $entry = $entries[0]; |
| 28 | 28 | |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | |
| 72 | 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 | 73 | <select name="<?php echo $this->get_field_name('message'); ?>"> |
| 74 | 74 | <?php |
| 75 | - if( count($entries)>0 ) { | |
| 75 | + if(!empty($entries)){ //if( count($entries)>0 ) | |
| 76 | 76 | $count=1; |
| 77 | 77 | $class = ''; |
| 78 | 78 | foreach( $entries as $entry ) { |
| 79 | 79 | ?> |
| @@ -88,6 +88,11 @@ | ||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | } // end class Xyz_Insert_Html_Widget |
| 92 | -add_action('widgets_init', create_function('', 'return register_widget("Xyz_Insert_Html_Widget");')); | |
| 92 | + | |
| 93 | +function xyz_ihs_add_snippet_widget(){ | |
| 94 | + register_widget("Xyz_Insert_Html_Widget"); | |
| 95 | +} | |
| 96 | +add_action('widgets_init','xyz_ihs_add_snippet_widget'); | |
| 97 | + | |
| 93 | 98 | ?> |