@@ 173-184 (lines=12) @@ | ||
170 | /* |
|
171 | * Count published projects and flush permalinks when first projects is published |
|
172 | */ |
|
173 | function flush_rules_on_first_project() { |
|
174 | $projects = get_transient( 'jetpack-portfolio-count-cache' ); |
|
175 | ||
176 | if ( false === $projects ) { |
|
177 | flush_rewrite_rules(); |
|
178 | $projects = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish; |
|
179 | ||
180 | if ( ! empty( $projects ) ) { |
|
181 | set_transient( 'jetpack-portfolio-count-cache', $projects, HOUR_IN_SECONDS * 12 ); |
|
182 | } |
|
183 | } |
|
184 | } |
|
185 | ||
186 | /* |
|
187 | * Flush permalinks when CPT supported theme is activated |
@@ 242-253 (lines=12) @@ | ||
239 | /* |
|
240 | * Count published testimonials and flush permalinks when first testimonial is published |
|
241 | */ |
|
242 | function flush_rules_on_first_testimonial() { |
|
243 | $testimonials = get_transient( 'jetpack-testimonial-count-cache' ); |
|
244 | ||
245 | if ( false === $testimonials ) { |
|
246 | flush_rewrite_rules(); |
|
247 | $testimonials = (int) wp_count_posts( self::CUSTOM_POST_TYPE )->publish; |
|
248 | ||
249 | if ( ! empty( $testimonials ) ) { |
|
250 | set_transient( 'jetpack-testimonial-count-cache', $testimonials, HOUR_IN_SECONDS * 12 ); |
|
251 | } |
|
252 | } |
|
253 | } |
|
254 | ||
255 | /* |
|
256 | * Flush permalinks when CPT supported theme is activated |