diff --git a/src/Post.php b/src/Post.php index 175bbd3c24..db10f2cf86 100644 --- a/src/Post.php +++ b/src/Post.php @@ -64,6 +64,7 @@ public function __construct($pid = null) public function set_data_layer(): void { $is_new_ia = !empty(planet4_get_option('new_ia')); + $new_ia_child_page_DLV = $this->get_new_ia_child_page_DLV(); if (is_front_page()) { $this->data_layer['page_category'] = 'Homepage'; @@ -85,6 +86,8 @@ public function set_data_layer(): void $this->data_layer['page_category'] = 'Actions'; } elseif ($is_new_ia && $this->is_about_us_page()) { $this->data_layer['page_category'] = 'About Us Page'; + } elseif ($is_new_ia && $new_ia_child_page_DLV) { + $this->data_layer['page_category'] = $new_ia_child_page_DLV; } else { $this->data_layer['page_category'] = 'Default Page'; } @@ -209,6 +212,30 @@ public function is_about_us_page(): bool return absint($act_page_id) === $this->id; } + /** + * Checks if post is the children of Get Informed page, and return DLV. + * + * @return String The dataLayer value for get informed child page. + */ + public function get_new_ia_child_page_DLV(): string + { + $get_informed_page_id = (int) planet4_get_option('get_informed_page'); + + if (!$get_informed_page_id) { + return ''; + } + + $parents = get_post_ancestors($this->id); + + if (1 === count($parents) && $parents[0] === $get_informed_page_id) { + return 'High Level Topic'; + } + if (2 === count($parents) && $parents[1] === $get_informed_page_id) { + return 'Deep Dive Topic'; + } + return ''; + } + /** * Loads in context information on the navigation links for Issue pages relevant to current Post's categories. */