| 1 |
<?php |
| 2 |
global $wpdb; |
| 3 |
|
| 4 |
add_shortcode('xyz-ips','xyz_ips_display_content'); |
| 5 |
|
| 6 |
function xyz_ips_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( "SELECT * FROM ".$wpdb->prefix."xyz_ips_short_code WHERE title='$snippet_name'" ); |
| 13 |
|
| 14 |
if(count($query)>0){ |
| 15 |
|
| 16 |
foreach ($query as $sippetdetails){ |
| 17 |
if($sippetdetails->status==1){ |
| 18 |
|
| 19 |
if(is_numeric(ini_get('output_buffering'))){ |
| 20 |
$tmp=ob_get_contents(); |
| 21 |
ob_clean(); |
| 22 |
ob_start(); |
| 23 |
eval($sippetdetails->content); |
| 24 |
$xyz_em_content = ob_get_contents(); |
| 25 |
ob_clean(); |
| 26 |
echo $tmp; |
| 27 |
return $xyz_em_content; |
| 28 |
}else{ |
| 29 |
eval($sippetdetails->content); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
}else{ |
| 35 |
return ''; |
| 36 |
} |
| 37 |
break; |
| 38 |
} |
| 39 |
|
| 40 |
}else{ |
| 41 |
|
| 42 |
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'> |
| 43 |
|
| 44 |
Please use a valid short code to call snippet. |
| 45 |
|
| 46 |
|
| 47 |
</div>"; |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
add_filter('widget_text', 'do_shortcode'); |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|