While Winden provides built-in integration, we also provide a collection of custom integration snippets that you can copy-paste into your themes’ function.php
file or use the Code Snippets plugin.
Scripts Organizer – ACF Gutenberg Addon
Scripts Organizer – ACF Gutenberg Addon is an add-on for Scripts Organizer plugin that allows you to Create Gutenberg blocks with ease and extend it with ACF Pro dynamic fields.
Since the Gutenberg integration uses the rendered content, you will probably not need this snippet, but we will keep it here for future reference.
Note: From Winden Version 2.0 we have native integration and you do not need to do anything. It will work without any code snippet.
<?php
add_filter('f!winden/core/worker:compile_content_payload', 'example_scorg_acf_append_content_payload', 10);
/**
* Append the Scripts Organizer – ACF Gutenberg Addon content to the payload.
*/
function example_scorg_acf_append_content_payload(string $content): string
{
$postmeta_key = 'SCORG_GACF_php_script';
$query = new WP_Query([
'posts_per_page' => -1,
'fields' => 'ids',
'post_type' => ['scorg_ga'],
'meta_query' => [
'relation' => 'OR',
['key' => $postmeta_key,],
],
]);
foreach ($query->posts as $post_id) {
$meta_value = get_post_meta($post_id, $postmeta_key, true);
if ($meta_value) {
$content .= base64_decode($meta_value);
}
}
return $content;
}
PHP