$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Building a multisite where ACF Gutenberg blocks can either pull from main site, or if a priority flag is marked, pulls block fro|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Building a multisite where ACF Gutenberg blocks can either pull from main site, or if a priority flag is marked, pulls block fro

matteradmin10PV0评论

I'm building a Wordpress multisite where there is a parent site, Site A, which will have several subsites, Site X, Y, Z.

Each site will have the same pages with the same page slugs, and almost the exact same content. I want to write it to where, if there is a change on a page at the parent site, Site A, that change will filter down th the subsites, Sites X, Y, Z, unless the specific gutenberg block is flagged by an ACF field marked 'priority'.

This is the code i have so far:

$slug = $post->post_name;
switch_to_blog( 1 );
$post_exists = get_page_by_path( $slug, OBJECT, 'page' );
$baseblocks  = [];
$microblocks = [];
$finalblocks = [];
if($post_exists){
    setup_postdata($post_exists);
    if ( has_blocks( $post->post_content ) ) {
        $baseblocks = parse_blocks( $post->post_content );
    }
}
restore_current_blog();
wp_reset_postdata();
if ( has_blocks( $post->post_content ) ) {
    $microblocks = parse_blocks( $post->post_content );
}

$microi = 0;
foreach($microblocks as $microblock){
    if(isset($microblock['attrs']['data'])){
        if(isset($microblock['attrs']['data']['priority'])){
            if($microblock['attrs']['data']['priority'] == true){
                render_block($microblock);
            }else{
                render_block($baseblocks[$microi]);
            }
        };
    }
    $microi++;
};

But nothing is rendering, and no errors are throwing. What am I doing wrong?

Post a comment

comment list (0)

  1. No comments so far