Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Fix announcement template, add category name to breadcrumb if not set…
Browse files Browse the repository at this point in the history
… from menu and page isn't a category page.
  • Loading branch information
chachasikes committed Jun 16, 2021
1 parent 47a373b commit a4b3929
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 54 deletions.
2 changes: 1 addition & 1 deletion ca-design-system-gutenberg-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Gutenberg blocks to be used in WordPress that are compatible with the California's design system
* Author: Office of Digital Innovation
* Author URI: https://digital.ca.gov
* Version: 1.0.5
* Version: 1.0.6
* License: MIT
* License URI: https://opensource.org/licenses/MIT
* Text Domain: ca-design-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ private function _load_default_page_template_styles()

public function ca_design_system_gutenberg_blocks_default_page_template_styles()
{
wp_register_style('ca-design-system-gutenberg-blocks-page', plugins_url('styles/page.css', __DIR__), false, '1.0.3a');
wp_register_style('ca-design-system-gutenberg-blocks-page', plugins_url('styles/page.css', __DIR__), false, '1.0.6');
wp_enqueue_style('ca-design-system-gutenberg-blocks-page');

wp_register_style('ca-design-system-gutenberg-blocks-announcement', plugins_url('styles/announcement.css', __DIR__), false, '1.0.3');
wp_register_style('ca-design-system-gutenberg-blocks-announcement', plugins_url('styles/announcement.css', __DIR__), false, '1.0.6');
wp_enqueue_style('ca-design-system-gutenberg-blocks-announcement'); // Default post

// wp_register_style('ca-design-system-gutenberg-blocks-event', plugins_url('styles/event.css', __DIR__), false, '1.0.3');
Expand Down
17 changes: 11 additions & 6 deletions includes/class-ca-design-system-gutenberg-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private function __construct()
$this->_load_block_category();

add_action('ca_design_system_breadcrumb', array($this, 'get_breadcrumb_callback'));

}

/**
Expand Down Expand Up @@ -197,6 +196,8 @@ public function get_breadcrumb_callback()
{
/* Quick breadcrumb function, @TODO Register in plugin to call as a shortcode or function */

global $post;

$separator = "<span class=\"crumb separator\">/</span>";
$linkOff = true;
$items = wp_get_nav_menu_items('header-menu');
Expand All @@ -208,6 +209,7 @@ public function get_breadcrumb_callback()
);



foreach ($items as $item) {
if ($item->current_item_ancestor) {
if ($linkOff == true) {
Expand All @@ -216,20 +218,23 @@ public function get_breadcrumb_callback()
$crumbs[] = "<a class=\"crumb\" href=\"{$item->url}\" title=\"{$item->title}\">{$item->title}</a>";
}
} else if ($item->current) {
$crumbs[] = "<span class=\"crumb current\">{$item->title}</>";
$crumbs[] = "<span class=\"crumb current\">{$item->title}</span>";
}
}

if (is_category()) {

if (is_category()) {
global $wp_query;
$category = get_category(get_query_var('cat'), false);
$crumbs[] = "<span class=\"crumb current\">{$category->name}</>";
$crumbs[] = "<span class=\"crumb current\">{$category->name}</span>";
}

if (count($items) == 0 && !is_category()) {
$category = get_the_category($post->ID);
$crumbs[] = "<span class=\"crumb current\">" . $category->name . "</span>";
}


echo implode($separator, $crumbs);
}

}
68 changes: 36 additions & 32 deletions includes/templates/template-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,63 @@
}
?>

<div id="page-container" class="with-sidebar page-container-ds">
<div id="page-container" class="page-container-ds">

<div class="breadcrumb">
<?php
do_action("ca_design_system_breadcrumb");
?>
</div>

<div id="main-content" class="main-content-ds" tabindex="-1">


<div id="main-content" class="main-content-ds single-column" tabindex="-1">
<div>
<main class="main-primary">

<?php
while (have_posts()) :
the_post();
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<category-label><?php the_category(); ?></category-label>
<!-- Page Title-->
<div>

<?php
if ('on' === get_post_meta($post->ID, 'ca_custom_post_title_display', true)) {
$caweb_padding = get_option('ca_default_post_date_display') ? ' pb-0' : '';
while (have_posts()) :
the_post();
?>

esc_html(the_title(sprintf('<h1 class="page-title%1$s">', $caweb_padding), '</h1>'));
}
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<category-label><?php the_category(); ?></category-label>
<!-- Page Title-->
<?php
if ('on' === get_post_meta($post->ID, 'ca_custom_post_title_display', true)) {
$caweb_padding = get_option('ca_default_post_date_display') ? ' pb-0' : '';

if (get_option('ca_default_post_date_display') && !$caweb_is_page_builder_used) {
printf('<p class="page-date published">Published: <time datetime="%1$s">%1$s</time></p>', get_the_date('M d, Y'));
}
esc_html(the_title(sprintf('<h1 class="page-title%1$s">', $caweb_padding), '</h1>'));
}

print '<div class="entry-content">';
// if (get_option('ca_default_post_date_display') && !$caweb_is_page_builder_used) {
printf('<p class="page-date published"><time datetime="%1$s">%1$s</time></p>', get_the_date('M d, Y'));
// }

the_content();

if (!$caweb_is_page_builder_used) {
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__('Pages:', 'Divi'),
'after' => '</div>',
)
);
}

print '</div>';
print '<div class="entry-content">';

?>
the_content();

if (!$caweb_is_page_builder_used) {
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__('Pages:', 'Divi'),
'after' => '</div>',
)
);
}

print '</div>';

?>


</article>
</article>

<?php endwhile; ?>
<?php endwhile; ?>

</main>

Expand Down
3 changes: 0 additions & 3 deletions styles/editor.css
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
body {
background-color: red;
}
41 changes: 34 additions & 7 deletions styles/page.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
margin-top: 1.5rem;
}

/* .page-container-ds .cagov-stack * + * {
margin-top: inherit
} */

.page-container-ds {
max-width: 1280px;
margin: 0 auto;
Expand Down Expand Up @@ -45,6 +41,7 @@
transform: translate(-0%, -0%); */

}

.sidebar-container {
display: block;
width: 276px;
Expand Down Expand Up @@ -79,7 +76,7 @@
.breadcrumb {
display: block;
margin-top: 32px;
margin-bottom: 64px;
margin-bottom: 0px;
background-color: #F9F9FA;
padding: 8px 16px;
font-size: 16px;
Expand All @@ -99,8 +96,39 @@
padding-right: 5px;
}

/* CONTENT NAVIGATION */
.page-container-ds main category-label ul:not([class*="menu"]):not([class*="nav"]):not([class*="footer-links"]),
.page-container-ds main category-label ul {
margin: 0;
text-indent: 0;
padding: 0;
}

category-label {
color: #000;
margin-bottom: 24px;
font-weight: 700;
}

category-label a {
color: #000;
font-weight: 700;
}

time {
margin-top: 24px;
margin-bottom: 24px;
color: #000;
font-weight: 700;
}
}


category-label a {
color: #000;
font-weight: 700;
}

/* CONTENT NAVIGATION */
sidebar cagov-content-navigation .label {
font-weight: 700;
font-size: 24px;
Expand Down Expand Up @@ -139,7 +167,6 @@ sidebar cagov-content-navigation ul li:first-child {
list-style-position: inside !important;
}


/* TYPOGRAPHY */
h1.page-title {
font-weight: 700;
Expand Down
3 changes: 0 additions & 3 deletions styles/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
body {
background-color: red;
}

0 comments on commit a4b3929

Please sign in to comment.