| @@ -41,10 +41,23 @@ | ||
| 41 | 41 | // Cached? |
| 42 | 42 | $shortcode = sh_cd_cache_get( $args[ 'slug' ] ); |
| 43 | 43 | |
| 44 | 44 | // If not in cache, hit the database! |
| 45 | - if ( true === empty( $shortcode ) ) { | |
| 45 | + if ( false === $shortcode ) { | |
| 46 | + | |
| 46 | 47 | $shortcode = sh_cd_db_shortcodes_by_slug( $args[ 'slug' ] ); |
| 48 | + | |
| 49 | + // Cache it! If a multisite, only cache the shortcode for 30 seconds. Otherwise fall back to default cache time. | |
| 50 | + $cache_time = ( true === sh_cd_license_is_premium() && true === in_array( $args[ 'slug' ], sh_cd_multisite_slugs() ) ) ? 30 : NULL; | |
| 51 | + | |
| 52 | + sh_cd_cache_set( $args[ 'slug' ], $shortcode, $cache_time ); | |
| 53 | + | |
| 54 | + } else if ( true === is_page() || true === is_single() ) { | |
| 55 | + printf( '<!-- %s cached: %s / ms: %s -->' . PHP_EOL, | |
| 56 | + SH_CD_SHORTCODE, | |
| 57 | + $args[ 'slug' ], | |
| 58 | + ( true === in_array( $args[ 'slug' ], sh_cd_multisite_slugs() ) ) ? 'y' : 'n' | |
| 59 | + ); | |
| 47 | 60 | } |
| 48 | 61 | |
| 49 | 62 | // If still no reference to a shortcode then slug doesn't exist |
| 50 | 63 | if ( true === empty( $shortcode ) ) { |
| @@ -49,11 +62,8 @@ | ||
| 49 | 62 | // If still no reference to a shortcode then slug doesn't exist |
| 50 | 63 | if ( true === empty( $shortcode ) ) { |
| 51 | 64 | return ''; |
| 52 | 65 | } |
| 53 | - | |
| 54 | - // Cache it! | |
| 55 | - sh_cd_cache_set( $args[ 'slug' ], $shortcode ); | |
| 56 | 66 | |
| 57 | 67 | // Process other shortcodes within this one |
| 58 | 68 | $shortcode = do_shortcode( $shortcode ); |
| 59 | 69 | |