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

Insert Html Snippet, version 1.2.3. 36 lines.

- Page: https://pluginprobe.com/plugins/insert-html-snippet/1.2.3/code/shortcode-handler.php
- Raw: https://pluginprobe.com/plugins/insert-html-snippet/1.2.3/raw/shortcode-handler.php
- Modified: 2018-01-15T14:40:16+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.2.3/code/shortcode-handler.php#L10-L20`.

```php
<?php 
if ( ! defined( 'ABSPATH' ) ) 
	exit;
	
global $wpdb;

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($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE title=%s" ,$snippet_name));
		
		if(count($query)>0){
			
			foreach ($query as $sippetdetails){
			if($sippetdetails->status==1)
				return do_shortcode($sippetdetails->content) ;
			else 
				return '';
				break;
			}
			
		}else{

			return '';		
		}
		
	}
}


add_filter('widget_text', 'do_shortcode'); // to run shortcodes in text widgets
```
