| @@ -41,10 +41,17 @@ | ||
| 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 | + | |
| 47 | 54 | } |
| 48 | 55 | |
| 49 | 56 | // If still no reference to a shortcode then slug doesn't exist |
| 50 | 57 | if ( true === empty( $shortcode ) ) { |
| @@ -50,13 +57,10 @@ | ||
| 50 | 57 | if ( true === empty( $shortcode ) ) { |
| 51 | 58 | return ''; |
| 52 | 59 | } |
| 53 | 60 | |
| 54 | - // Cache it! | |
| 55 | - sh_cd_cache_set( $args[ 'slug' ], $shortcode ); | |
| 56 | - | |
| 57 | 61 | // Process other shortcodes within this one |
| 58 | 62 | $shortcode = do_shortcode( $shortcode ); |
| 59 | 63 | |
| 60 | 64 | // Replace placeholders with user defined parameters |
| 61 | 65 | return sh_cd_apply_user_defined_parameters( $shortcode, $args ); |
| 62 | -} | |
| 66 | +} | |