Skip to content

Commit

Permalink
Merge pull request #9 from 10up/feature/add-multisite-support-from-cli
Browse files Browse the repository at this point in the history
Feature/add multisite support from cli
  • Loading branch information
dsawardekar authored Aug 1, 2023
2 parents 856411d + 64f2489 commit d779804
Show file tree
Hide file tree
Showing 7 changed files with 1,033 additions and 152 deletions.
28 changes: 17 additions & 11 deletions includes/classes/CatalogBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,22 @@ public function set_post_block_terms( $post_id, $output ) {
}

foreach ( $output['variations'] ?? [] as $variation ) {
$blockName = $variation['blockName'];
$terms = $variation['terms'] ?? [];
$block_name = $variation['blockName'];
$terms = $variation['terms'] ?? [];

if ( empty( $blockName ) || empty( $terms ) ) {
if ( empty( $block_name ) || empty( $terms ) ) {
continue;
}

foreach ( $terms as $label ) {
$slug = $blockName . '-' . $label;
$slug = $block_name . '-' . $label;

if ( ! term_exists( $slug, BLOCK_CATALOG_TAXONOMY ) ) {
$term_args = [
'slug' => $slug,
];

$parent_id = $this->get_variation_parent_term( $blockName );
$parent_id = $this->get_variation_parent_term( $block_name );

if ( ! empty( $parent_id ) ) {
$term_args['parent'] = $parent_id;
Expand Down Expand Up @@ -253,11 +253,14 @@ public function get_post_block_terms( $post_id, $opts = [] ) {
}

if ( ! empty( $block_terms['variations'] ) ) {
$variations[] = array_merge( $variations, [
'blockName' => $block['blockName'],
'block' => $block,
'terms' => $block_terms['variations'],
] );
$variations[] = array_merge(
$variations,
[
'blockName' => $block['blockName'],
'block' => $block,
'terms' => $block_terms['variations'],
]
);
}
}

Expand Down Expand Up @@ -316,7 +319,10 @@ public function to_block_list( $blocks ) {
*/
public function block_to_terms( $block, $opts = [] ) {
if ( empty( $block ) || empty( $block['blockName'] ) ) {
return [ 'terms' => [], 'variations' => [] ];
return [
'terms' => [],
'variations' => [],
];
}

$terms = [];
Expand Down
Loading

0 comments on commit d779804

Please sign in to comment.