PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
← All changes | classes/class-parse-blocks.php +41 -1 3.4.33.7.2 View file →
@@ -28,9 +28,9 @@
28 28 */
29 29 public static function init() {
30 30 add_action(
31 31 'wp',
32 - function() {
32 + function () {
33 33 // Parse methods [classic,modern].
34 34 $parse_methods = apply_filters( 'gkt_parse_blocks_methods', current_theme_supports( 'block-templates' ) ? array( 'modern' ) : array( 'classic' ) );
35 35
36 36 // Simple use `render_block` in FSE themes to enqueue assets.
@@ -46,8 +46,11 @@
46 46
47 47 // parse blocks from custom locations, that uses 'the_content' filter.
48 48 add_filter( 'the_content', 'GhostKit_Parse_Blocks::maybe_parse_blocks_from_custom_location', 8 );
49 49 add_filter( 'widget_block_content', 'GhostKit_Parse_Blocks::maybe_parse_blocks_from_custom_location', 8 );
50 + } else {
51 + // FSE / modern-only: extra sources (e.g. Visual Portfolio) are not in the main query.
52 + self::maybe_parse_blocks_from_content_sources();
50 53 }
51 54 }
52 55 );
53 56 }
@@ -83,8 +86,45 @@
83 86 foreach ( $wp_query->posts as $post ) {
84 87 if ( isset( $post->post_content ) ) {
85 88 self::maybe_parse_blocks( $post->post_content, 'content' );
86 89 }
90 + }
91 +
92 + self::maybe_parse_blocks_from_content_sources();
93 + }
94 +
95 + /**
96 + * Parse block content from additional sources (themes, Visual Portfolio, etc.).
97 + *
98 + * Filter `gkt_parse_blocks_content_sources` returns an array of sources:
99 + *
100 + * array(
101 + * array(
102 + * 'content' => string, // Required. Raw post_content–style block markup.
103 + * 'location' => string, // Optional. Default 'content'. Also 'widget'.
104 + * ),
105 + * )
106 + *
107 + * Runs on classic themes with post content and on modern-only themes via `wp`.
108 + */
109 + public static function maybe_parse_blocks_from_content_sources() {
110 + $sources = apply_filters( 'gkt_parse_blocks_content_sources', array() );
111 +
112 + if ( ! is_array( $sources ) || empty( $sources ) ) {
113 + return;
114 + }
115 +
116 + foreach ( $sources as $source ) {
117 + if ( ! is_array( $source ) || empty( $source['content'] ) || ! is_string( $source['content'] ) ) {
118 + continue;
119 + }
120 +
121 + $location = 'content';
122 + if ( ! empty( $source['location'] ) && is_string( $source['location'] ) ) {
123 + $location = $source['location'];
124 + }
125 +
126 + self::maybe_parse_blocks( $source['content'], $location );
87 127 }
88 128 }
89 129
90 130 /**