Layout ID => [stage3 fixture file, post type]. */ public const LAYOUTS = [ 1061 => ['tb-header--globaler-header.html', 'et_header_layout'], 1062 => ['tb-body--body-mit-dynamic-content.html', 'et_body_layout'], 1063 => ['tb-footer--footer.html', 'et_footer_layout'], ]; /** @param array $fields */ public static function layout(int $id, array $fields = []): WP_Post { return new WP_Post(array_merge([ 'ID' => $id, 'post_type' => self::LAYOUTS[$id][1], 'post_status' => 'publish', 'post_title' => '[Fixture] ' . $id, 'post_content' => DiviFixtures::markup('stage3/' . self::LAYOUTS[$id][0]), ], $fields)); } /** @param array $fields */ public static function templatePost(int $id = self::TEMPLATE, array $fields = []): WP_Post { return new WP_Post(array_merge([ 'ID' => $id, 'post_type' => DiviThemeBuilder::TEMPLATE, 'post_status' => 'publish', 'post_title' => $id === self::DEFAULT_TEMPLATE ? 'Standard-Website-Template' : '[Fixture] Vorlage Globale Instanzen', 'post_content' => '', ], $fields)); } /** * The template as Divi reads it (et_theme_builder_get_template); $overrides replace keys of that * array and may set status, attached and marked_unused. * * @param array $overrides */ public static function template(int $id = self::TEMPLATE, array $overrides = []): Template { $base = $id === self::DEFAULT_TEMPLATE ? [ 'id' => $id, 'title' => 'Standard-Website-Template', 'default' => true, 'enabled' => false, 'layouts' => [ 'header' => ['id' => self::HEADER, 'enabled' => true], 'body' => ['id' => 0, 'enabled' => true], 'footer' => ['id' => 0, 'enabled' => true], ], 'use_on' => [], 'exclude_from' => [], ] : [ 'id' => $id, 'title' => '[Fixture] Vorlage Globale Instanzen', 'default' => false, 'enabled' => false, 'layouts' => [ 'header' => ['id' => self::HEADER, 'enabled' => true], 'body' => ['id' => self::BODY, 'enabled' => true], 'footer' => ['id' => self::FOOTER, 'enabled' => true], ], 'use_on' => ['singular:post_type:page:id:1053'], 'exclude_from' => [], ]; return Template::fromDivi( array_merge($base, array_intersect_key($overrides, $base)), (string) ($overrides['status'] ?? 'publish'), (bool) ($overrides['attached'] ?? true), isset($overrides['marked_unused']) ? (string) $overrides['marked_unused'] : null ); } /** * A store whose live list is $templates, with a TB draft when $draftId > 0, $detached as templates no * Theme Builder post lists and $byIdOnly as templates template() finds but no list names (e.g. the one a * test lets storeTemplate() create). * * @param list