Skip to content

Commit 2b75482

Browse files
author
Brylie Christopher Oxley
committed
Use theme_mod settings throughout templates
1 parent a190212 commit 2b75482

File tree

8 files changed

+93
-93
lines changed

8 files changed

+93
-93
lines changed

header.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66
<title><?php wp_title( '|' ); ?></title>
77
<?php wp_head(); ?>
88
</head>
9-
<?php
10-
// get site global settings (settings.php)
11-
global $_set;
12-
if ( ! empty( $_set ) ) {
13-
$settings = $_set->settings;
14-
}
15-
?>
9+
1610
<body <?php body_class(); ?>>
1711
<?php do_action( 'cc_theme_before_header' ); ?>
1812
<!--BEGIN HEADER-->

inc/partials/home/home-featured.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
2-
global $_set;
3-
$settings = $_set->settings;
4-
$is_feature_enabled = $settings['enable_featured'];
5-
$is_announcement_enabled = ( $settings['enabled_announcement'] ) ? ' has-notification-enabled' : '';
6-
$featured_image = ( ! empty( $settings['featured_image'] ) ) ? 'style="background-image: url(' . wp_get_attachment_url( $settings['featured_image'], 'landscape-featured' ) . ');"' : false;
7-
$featured_background_color = ( ! empty( $settings['featured_background_color'] ) ) ? 'has-background-' . $settings['featured_background_color'] : '';
2+
$featured_content_is_enabled = get_theme_mod('cc_base_enable_featured_content');
3+
$announcement_is_enabled = ( get_theme_mod('cc_base_enabled_announcement') ) ? ' has-notification-enabled' : '';
4+
$featured_content = get_theme_mod('cc_base_featured_content');
5+
$featured_image_setting = get_theme_mod('cc_base_featured_content_background_image');
6+
$featured_image = ( ! empty( $featured_image_setting ) ) ? 'style="background-image: url(' . wp_get_attachment_url( $featured_image_setting, 'landscape-featured' ) . ');"' : false;
7+
$featured_background_color_setting = get_theme_mod('cc_base_featured_content_background_color');
8+
$featured_background_color = ( ! empty( $featured_background_color_setting ) ) ? 'has-background-' . $featured_background_color_setting : '';
9+
$include_donate_is_enabled = get_theme_mod('cc_base_include_donate');
810
?>
9-
<section class="featured-content <?php echo $featured_background_color . $is_announcement_enabled; ?>" <?php echo $featured_image; ?>>
11+
12+
<!-- TODO: determine what the following line intends to achieve and clean up semantics to make more self-documenting -->
13+
<section class="featured-content <?php echo $featured_background_color . $announcement_is_enabled; ?>" <?php echo $featured_image; ?>>
1014
<div class="container">
1115
<div class="wrap-content padding-vertical-larger">
1216
<div class="columns is-centered">
1317
<div class="column is-6 has-text-centered">
14-
<?php if ( ! empty( $settings['featured_content'] ) ) : ?>
15-
<h3 class="heading-b"><?php echo esc_attr( $settings['featured_content'] ); ?></h3>
18+
<!-- TODO: determine whether this whole <section> should be wrapped in the following if statement -->
19+
<?php if ( $featured_content_is_enabled ) : ?>
20+
<h3 class="heading-b"><?php echo esc_attr( $featured_content ); ?></h3>
21+
1622
<?php
17-
if ( $settings['include_donate'] ) {
23+
if ( $include_donate_is_enabled ) {
1824
echo Components::button( 'Donate now', 'https://creativecommons.org/donate', 'small', 'donate', true, 'cc-letterheart' );
1925
}
2026
?>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<h2><?php the_title(); ?></h2>
22
<?php
3-
global $_set;
4-
$settings = $_set->settings;
5-
if ( $settings['show_authors'] ) {
6-
get_template_part( 'inc/partials/entry/entry', 'author' );
7-
} else {
8-
echo '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
9-
}
3+
$show_authors_is_enabled = get_theme_mod('cc_base_show_authors');
4+
5+
if ($show_authors_is_enabled) {
6+
get_template_part('inc/partials/entry/entry', 'author');
7+
} else {
8+
echo '<span class="entry-date">' . get_the_date(CC_Site::get_date_format()) . '</span>';
9+
}
1010
?>
1111
<?php
12-
if ( function_exists( 'yoast_breadcrumb' ) ) {
13-
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
14-
}
12+
if (function_exists('yoast_breadcrumb')) {
13+
yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
14+
}
1515
?>
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
<?php
2-
$gallery_objects = get_post_meta( get_the_ID(), 'post_gallery', false );
3-
if ( ! empty( $gallery_objects ) ) {
2+
$gallery_objects = get_post_meta(get_the_ID(), 'post_gallery', false);
3+
if (! empty($gallery_objects)) {
44
echo '<div class="glide entry-gallery">';
5-
echo '<div class="glide__track" data-glide-el="track">';
6-
echo '<ul class="glide__slides">';
7-
foreach ( $gallery_objects as $object ) {
5+
echo '<div class="glide__track" data-glide-el="track">';
6+
echo '<ul class="glide__slides">';
7+
foreach ($gallery_objects as $object) {
88
echo '<li class="glide__slide">';
9-
echo wp_get_attachment_image( $object, 'landscape-featured' );
9+
echo wp_get_attachment_image($object, 'landscape-featured');
1010
echo '</li>';
1111
}
12-
echo '</ul>';
13-
echo '</div>';
14-
echo '<div class="glide__arrows" data-glide-el="controls">';
15-
echo '<button class="glide__arrow glide__arrow--left" data-glide-dir="<"><i class="icon chevron-left"></i></button>';
16-
echo '<button class="glide__arrow glide__arrow--right" data-glide-dir=">"><i class="icon chevron-right"></i></button>';
17-
echo '</div>';
18-
echo '</div>';
12+
echo '</ul>';
13+
echo '</div>';
14+
echo '<div class="glide__arrows" data-glide-el="controls">';
15+
echo '<button class="glide__arrow glide__arrow--left" data-glide-dir="<"><i class="icon chevron-left"></i></button>';
16+
echo '<button class="glide__arrow glide__arrow--right" data-glide-dir=">"><i class="icon chevron-right"></i></button>';
17+
echo '</div>';
18+
echo '</div>';
1919
}
2020
?>
2121
<h2><?php the_title(); ?></h2>
2222
<?php
23-
global $_set;
24-
$settings = $_set->settings;
25-
if ( $settings['show_authors'] ) {
26-
get_template_part( 'inc/partials/entry/entry', 'author' );
27-
} else {
28-
echo '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
29-
}
23+
$show_authors_is_enabled = get_theme_mod('cc_base_show_authors');
24+
25+
if ($show_authors_is_enabled) {
26+
get_template_part('inc/partials/entry/entry', 'author');
27+
} else {
28+
echo '<span class="entry-date">' . get_the_date(CC_Site::get_date_format()) . '</span>';
29+
}
3030
?>
3131
<?php
32-
if ( function_exists( 'yoast_breadcrumb' ) ) {
33-
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
34-
}
32+
if (function_exists('yoast_breadcrumb')) {
33+
yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
34+
}
3535
?>
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<?php
2-
if ( has_post_thumbnail() ) {
3-
echo '<figure class="entry-image">';
4-
the_post_thumbnail( 'landscape-featured' );
5-
echo '</figure>';
6-
}
2+
if (has_post_thumbnail()) {
3+
echo '<figure class="entry-image">';
4+
the_post_thumbnail('landscape-featured');
5+
echo '</figure>';
6+
}
77
?>
88
<h2><?php the_title(); ?></h2>
9+
910
<?php
10-
global $_set;
11-
$settings = $_set->settings;
12-
if ( $settings['show_authors'] ) {
13-
get_template_part( 'inc/partials/entry/entry', 'author' );
14-
} else {
15-
echo '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
16-
}
11+
$show_authors_is_enabled = get_theme_mod('cc_base_show_authors');
12+
13+
if ($show_authors_is_enabled) {
14+
get_template_part('inc/partials/entry/entry', 'author');
15+
} else {
16+
echo '<span class="entry-date">' . get_the_date(CC_Site::get_date_format()) . '</span>';
17+
}
1718
?>
1819
<?php
19-
if ( function_exists( 'yoast_breadcrumb' ) ) {
20-
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
21-
}
20+
if (function_exists('yoast_breadcrumb')) {
21+
yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
22+
}
2223
?>
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<?php
2-
$video_url = get_post_meta( get_the_ID(), 'post_video_url', true );
3-
if ( ! empty( $video_url ) ) {
4-
echo '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-' . Videos::get_video_class( $video_url ) . ' wp-embed-aspect-16-9 wp-has-aspect-ratio">';
2+
$video_url = get_post_meta(get_the_ID(), 'post_video_url', true);
3+
if (! empty($video_url)) {
4+
echo '<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-' . Videos::get_video_class($video_url) . ' wp-embed-aspect-16-9 wp-has-aspect-ratio">';
55
echo '<div class="wp-block-embed__wrapper">';
6-
echo Videos::get_video_embed( $video_url );
6+
echo Videos::get_video_embed($video_url);
77
echo '</div>';
8-
echo '</figure>';
9-
}
8+
echo '</figure>';
9+
}
1010
?>
1111
<h2><?php the_title(); ?></h2>
1212
<?php
13-
global $_set;
14-
$settings = $_set->settings;
15-
if ( $settings['show_authors'] ) {
16-
get_template_part( 'inc/partials/entry/entry', 'author' );
17-
} else {
18-
echo '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
19-
}
13+
$show_authors_is_enabled = get_theme_mod('cc_base_show_authors');
14+
15+
if ($show_authors_is_enabled) {
16+
get_template_part('inc/partials/entry/entry', 'author');
17+
} else {
18+
echo '<span class="entry-date">' . get_the_date(CC_Site::get_date_format()) . '</span>';
19+
}
2020
?>
2121
<?php
22-
if ( function_exists( 'yoast_breadcrumb' ) ) {
23-
yoast_breadcrumb( '<p id="breadcrumbs">', '</p>' );
24-
}
22+
if (function_exists('yoast_breadcrumb')) {
23+
yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
24+
}
2525
?>

page-home.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<?php
22
/* Template name: Home Layout */
33
get_header();
4-
global $_set;
5-
$settings = $_set->settings;
6-
$is_feature_enabled = $settings['enable_featured'];
7-
$is_announcement_enabled = $settings['enabled_announcement'];
4+
$featured_content_is_enabled = get_theme_mod('cc_base_enable_featured_content');
5+
$announcement_is_enabled = get_theme_mod('cc_base_enabled_announcement');
86
?>
9-
<section class="main-content">
7+
<section class="main-content another-class">
8+
Main content!
109
<?php
11-
if ( $is_feature_enabled ) {
12-
get_template_part( 'inc/partials/home/home', 'featured' );
13-
}
14-
if ( $is_announcement_enabled ) {
15-
get_template_part( 'inc/partials/home/home', 'notification' );
16-
}
10+
if ( $featured_content_is_enabled ) {
11+
get_template_part( 'inc/partials/home/home', 'featured' );
12+
}
13+
if ( $announcement_is_enabled ) {
14+
get_template_part( 'inc/partials/home/home', 'notification' );
15+
}
1716

1817
get_template_part( 'inc/partials/home/home', 'content' );
1918
?>

page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
get_header();
3-
the_post();
3+
the_post();
44
?>
55
<section class="main-content">
66
<header class="page-header">

0 commit comments

Comments
 (0)