# insert-html-snippet/1.0/shortcode-handler.php

Insert Html Snippet, version 1.0. 45 lines.

- Page: https://pluginprobe.com/plugins/insert-html-snippet/1.0/code/shortcode-handler.php
- Raw: https://pluginprobe.com/plugins/insert-html-snippet/1.0/raw/shortcode-handler.php
- Modified: 2012-08-16T05:32:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/insert-html-snippet/1.0/code/shortcode-handler.php#L10-L20`.

```php
<?php 
global $wpdb;

// $totalDetails = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE status='1'" );
// if(count($totalDetails)>0){
// 	foreach ($totalDetails as $total){
		add_shortcode('xyz-ihs','xyz_ihs_display_content');		
// 	}
// }

function xyz_ihs_display_content($xyz_snippet_name){
	global $wpdb;

	if(is_array($xyz_snippet_name)){
		$snippet_name = $xyz_snippet_name['snippet'];
		
		$query = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE title='$snippet_name'" );
		
		if(count($query)>0){
			
			foreach ($query as $sippetdetails){
// 				return stripslashes($sippetdetails->content);
			if($sippetdetails->status==1)
				return $sippetdetails->content;
			else 
				return '';
				break;
			}
			
		}else{

			return "<div style='padding:20px; font-size:16px; color:#FA5A6A; width:93%;text-align:center;background:lightyellow;border:1px solid #3FAFE3; margin:20px 0 20px 0'>
			
			Please use a valid short code to call snippet.
			
			
			</div>";
			
		}
		
	}
}


add_filter('widget_text', 'do_shortcode');
```
