| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') or die('Jog on!'); |
| 4 |
|
| 5 |
function sh_cd_shortcode( $atts ) |
| 6 |
{ |
| 7 |
$a = shortcode_atts( array( |
| 8 |
'slug' => false |
| 9 |
), $atts ); |
| 10 |
|
| 11 |
return sh_cd_render_shortcode_from_db($a['slug']); |
| 12 |
|
| 13 |
} |
| 14 |
add_shortcode( SH_CD_SHORTCODE, 'sh_cd_shortcode' ); |
| 15 |
|
| 16 |
function sh_cd_render_shortcode_from_db($slug) |
| 17 |
{ |
| 18 |
if ($slug != false && !empty($slug)) |
| 19 |
{ |
| 20 |
$cached_shortcode = sh_cd_get_cache($slug); |
| 21 |
|
| 22 |
if ($cached_shortcode != false) |
| 23 |
{ |
| 24 |
// Process other shortcodes |
| 25 |
$cached_shortcode = do_shortcode($cached_shortcode); |
| 26 |
|
| 27 |
return $cached_shortcode; |
| 28 |
} |
| 29 |
else |
| 30 |
{ |
| 31 |
$shortcode = sh_cd_get_shortcode_by_slug($slug); |
| 32 |
|
| 33 |
if ($shortcode) |
| 34 |
{ |
| 35 |
sh_cd_set_cache($slug, $shortcode); |
| 36 |
|
| 37 |
$shortcode = do_shortcode($shortcode); |
| 38 |
|
| 39 |
return $shortcode; |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
} |