| @@ -22,15 +22,17 @@ | ||
| 22 | 22 | $dynamic_text_css->add_class_styles( |
| 23 | 23 | '{{WRAPPER}} .ablocks-dynamic-text-output', |
| 24 | 24 | $this->get_dynamic_text_css( $attributes ), |
| 25 | 25 | $this->get_dynamic_text_css( $attributes, 'Tablet' ), |
| 26 | - $this->get_dynamic_text_css( $attributes, 'Mobile' ) | |
| 26 | + $this->get_dynamic_text_css( $attributes, 'Mobile' ), | |
| 27 | + $dynamic_text_css->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_dynamic_text_css( $attributes, $device ); } ) | |
| 27 | 28 | ); |
| 28 | 29 | $dynamic_text_css->add_class_styles( |
| 29 | 30 | '{{WRAPPER}} .ablocks-dynamic-text-output a', |
| 30 | 31 | $this->get_dynamic_text_css( $attributes ), |
| 31 | 32 | $this->get_dynamic_text_css( $attributes, 'Tablet' ), |
| 32 | - $this->get_dynamic_text_css( $attributes, 'Mobile' ) | |
| 33 | + $this->get_dynamic_text_css( $attributes, 'Mobile' ), | |
| 34 | + $dynamic_text_css->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_dynamic_text_css( $attributes, $device ); } ) | |
| 33 | 35 | ); |
| 34 | 36 | |
| 35 | 37 | return $dynamic_text_css->generate_css(); |
| 36 | 38 | } |
| @@ -81,14 +83,21 @@ | ||
| 81 | 83 | $url = get_permalink( $post_id ); |
| 82 | 84 | return '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>'; |
| 83 | 85 | case 'core:content': |
| 84 | 86 | static $guard = false; |
| 87 | + static $content_cache = []; | |
| 85 | 88 | if ( $guard ) { |
| 86 | 89 | return ''; |
| 87 | 90 | } |
| 88 | - $guard = true; | |
| 89 | - $content = do_blocks( get_post_field( 'post_content', $post_id ) ); | |
| 90 | - $guard = false; | |
| 91 | + // Render the post's content once per request; multiple dynamic-text | |
| 92 | + // "content" blocks (or a loop/archive) would otherwise re-run | |
| 93 | + // do_blocks() on the full post each time. | |
| 94 | + if ( ! isset( $content_cache[ $post_id ] ) ) { | |
| 95 | + $guard = true; | |
| 96 | + $content_cache[ $post_id ] = do_blocks( get_post_field( 'post_content', $post_id ) ); | |
| 97 | + $guard = false; | |
| 98 | + } | |
| 99 | + $content = $content_cache[ $post_id ]; | |
| 91 | 100 | if ( |
| 92 | 101 | empty( trim( wp_strip_all_tags( $content ) ) ) |
| 93 | 102 | && $this->is_editor_preview() |
| 94 | 103 | ) { |