| 1 |
<?php |
| 2 |
global $wpdb; |
| 3 |
|
| 4 |
add_shortcode('xyz-ihs','xyz_ihs_display_content'); |
| 5 |
|
| 6 |
function xyz_ihs_display_content($xyz_snippet_name){ |
| 7 |
global $wpdb; |
| 8 |
|
| 9 |
if(is_array($xyz_snippet_name)){ |
| 10 |
$snippet_name = $xyz_snippet_name['snippet']; |
| 11 |
|
| 12 |
$query = $wpdb->get_results($wpdb->prepare( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE title=%s" ,$snippet_name)); |
| 13 |
|
| 14 |
if(count($query)>0){ |
| 15 |
|
| 16 |
foreach ($query as $sippetdetails){ |
| 17 |
// return stripslashes($sippetdetails->content); |
| 18 |
if($sippetdetails->status==1) |
| 19 |
return do_shortcode($sippetdetails->content) ; |
| 20 |
else |
| 21 |
return ''; |
| 22 |
break; |
| 23 |
} |
| 24 |
|
| 25 |
}else{ |
| 26 |
|
| 27 |
return ''; |
| 28 |
/* 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'> |
| 29 |
|
| 30 |
Please use a valid short code to call snippet. |
| 31 |
|
| 32 |
|
| 33 |
</div>"; |
| 34 |
*/ |
| 35 |
} |
| 36 |
|
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
//add_filter('widget_text', 'do_shortcode'); |