-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
131 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Define the generic Page class. | ||
*/ | ||
|
||
use TMS\Theme\Base\Traits\Components; | ||
use TMS\Theme\Base\Settings; | ||
|
||
/** | ||
* The Page class. | ||
*/ | ||
class PageExtend extends BaseModel { | ||
|
||
use Components; | ||
|
||
/** | ||
* Hooks | ||
*/ | ||
public function hooks() : void { | ||
\add_filter( 'tms/theme/breadcrumbs/show_breadcrumbs_in_header', fn() => false ); | ||
} | ||
|
||
/** | ||
* Hero image | ||
* | ||
* @return int|null | ||
*/ | ||
public function hero_image() : ?int { | ||
return \has_post_thumbnail() | ||
? \get_post_thumbnail_id() | ||
: null; | ||
} | ||
|
||
/** | ||
* Get post siblings. | ||
* | ||
* @return array|array[]|false | ||
*/ | ||
public function post_siblings() { | ||
$current_post_id = \get_the_ID(); | ||
$parent_post_id = \wp_get_post_parent_id( $current_post_id ); | ||
|
||
if ( ! Settings::get_setting( 'enable_sibling_navigation' ) || $parent_post_id === 0 ) { | ||
return false; | ||
} | ||
|
||
$query_args = [ | ||
'post_type' => 'page', | ||
'posts_per_page' => 100, | ||
'post_parent' => $parent_post_id, | ||
'update_post_meta_cache' => false, | ||
'update_post_term_cache' => false, | ||
'no_found_rows' => true, | ||
'orderby' => 'menu_order title', | ||
'order' => 'ASC', | ||
]; | ||
|
||
$wp_query = new \WP_Query( $query_args ); | ||
|
||
if ( 1 >= count( $wp_query->posts ) ) { | ||
return false; | ||
} | ||
|
||
return array_map( function ( $post ) use ( $current_post_id ) { | ||
$post->permalink = \get_the_permalink( $post->ID ); | ||
$post->is_current = $post->ID === $current_post_id; | ||
|
||
return $post; | ||
}, $wp_query->posts ); | ||
} | ||
|
||
/** | ||
* Use overlay | ||
* | ||
* @return bool | ||
*/ | ||
public function use_overlay() { | ||
return \get_field( 'remove_overlay' ) === true ? false : true; | ||
} | ||
|
||
/** | ||
* Use overlay | ||
* | ||
* @return bool | ||
*/ | ||
public function image_shape() { | ||
return \get_field( 'image_shape' ) ?? 'shape shape--rainbow'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<section class="page__hero section is-relative pt-0 pb-0 has-width-100"> | ||
<div class="image-container"> | ||
{@image id=Page.hero_image size="large" class="shape shape--rainbow" /} | ||
{@image id=Page.hero_image size="large" class="{Page.image_shape|attr}" /} | ||
</div> | ||
</section> |