Skip to content

Commit 9748640

Browse files
authored
Merge pull request #22 from creativecommons/widget-cc-org
Widget cc org
2 parents bba82fc + 2de00cf commit 9748640

File tree

15 files changed

+304
-158
lines changed

15 files changed

+304
-158
lines changed

functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@
5151
'Homepage Notification' => array(
5252
'name' => 'home-notification',
5353
),
54-
'Homepage widgets' => array(
54+
'Homepage widgets' => array(
5555
'name' => 'homepage-sidebar',
5656
),
57-
'Single' => array(
57+
'Single' => array(
5858
'name' => 'single',
5959
),
60-
'Page' => array(
60+
'Page' => array(
6161
'name' => 'page',
6262
),
63-
'Page Footer' => array(
63+
'Page Footer' => array(
6464
'name' => 'page-footer',
6565
),
6666
);

inc/class-cc-site.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ static function page_title() {
141141
* @return void
142142
*/
143143
public static function get_current_website_logo() {
144-
$default_logo = 'cc/logomark.svg#logomark';
144+
$default_logo = 'cc/logomark.svg#logomark';
145145
$current_main_logo = apply_filters( 'cc_theme_base_set_default_logo', $default_logo );
146-
return Components::cc_logos($current_main_logo, false);
146+
return Components::cc_logos( $current_main_logo, false );
147147
}
148148
/**
149149
* Get the top parent page of the current navigation level
@@ -152,16 +152,16 @@ public static function get_current_website_logo() {
152152
*/
153153
public static function get_parent_page() {
154154
global $post;
155-
if ($post->post_parent) {
156-
$ancestors = get_post_ancestors($post->ID);
157-
$root = count( $ancestors )-1;
158-
return $ancestors[$root];
155+
if ( $post->post_parent ) {
156+
$ancestors = get_post_ancestors( $post->ID );
157+
$root = count( $ancestors ) - 1;
158+
return $ancestors[ $root ];
159159
} else {
160160
return $post->ID;
161161
}
162162
}
163163
public static function get_date_format() {
164-
$date_format = apply_filters('cc_theme_base_date_format', get_option( 'date_format' ) );
164+
$date_format = apply_filters( 'cc_theme_base_date_format', get_option( 'date_format' ) );
165165
return $date_format;
166166
}
167167
}

inc/class-components.php

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ class Components {
2525
/**
2626
* Genereic card post and its variants
2727
*
28-
* @param int $post_id : post or entry id.
29-
* @param boolean $use_post_data : whether to use data from a post ID
30-
* @param boolean $show_image : whether to show or not the image.
31-
* @param boolean $is_stretch : Should the top image be stretched to fit container.
32-
* @param boolean $is_video : is the post a video.
33-
* @param boolean $has_button : should we show the action button?.
34-
* @param boolean $has_border : should we show the border of the card?.
35-
* @param boolean $has_content : should we show the except of the entry?.
36-
* @param string $pre_title : string showed before the title.
37-
* @param string $description : content of the card if it's not using post data.
38-
* @param string $url : url of card if it's not using post data.
39-
* @param string $title : title of the card if it's not using post data.
40-
* @param string $date : date format of the card if it's not using post data.
41-
* @param int $image_id : image id of the card if it's not using post data.
42-
* @param string $direction : direction of the card `horizontal` or `vertical`.
43-
* @param string $button_text : text of the button.
44-
* @param string $button_size : size of the button big|small|tiny
45-
* @param string $button_color : color of the button is_primary|donate|is-success|is-info|.is-warning|.is-danger
28+
* @param int $post_id : post or entry id.
29+
* @param boolean $use_post_data : whether to use data from a post ID
30+
* @param boolean $show_image : whether to show or not the image.
31+
* @param boolean $is_stretch : Should the top image be stretched to fit container.
32+
* @param boolean $is_video : is the post a video.
33+
* @param boolean $has_button : should we show the action button?.
34+
* @param boolean $has_border : should we show the border of the card?.
35+
* @param boolean $has_content : should we show the except of the entry?.
36+
* @param string $pre_title : string showed before the title.
37+
* @param string $description : content of the card if it's not using post data.
38+
* @param string $url : url of card if it's not using post data.
39+
* @param string $title : title of the card if it's not using post data.
40+
* @param string $date : date format of the card if it's not using post data.
41+
* @param int $image_id : image id of the card if it's not using post data.
42+
* @param string $direction : direction of the card `horizontal` or `vertical`.
43+
* @param string $button_text : text of the button.
44+
* @param string $button_size : size of the button big|small|tiny
45+
* @param string $button_color : color of the button is_primary|donate|is-success|is-info|.is-warning|.is-danger
4646
* @return string component layout
4747
*/
4848
public static function card_post(
@@ -94,12 +94,12 @@ public static function card_post(
9494
$out .= '<span class="subtitle"> ' . $card_date . ' </span>';
9595
}
9696
if ( $has_content ) {
97-
$the_post = ( $use_post_data ) ? get_post( $post_id ) : false;
98-
$the_description = ( $use_post_data ) ? do_excerpt( $the_post, array( 'length' => 110 ) ) : $description;
97+
$the_post = ( $use_post_data ) ? get_post( $post_id ) : false;
98+
$the_description = ( $use_post_data ) ? do_excerpt( $the_post, array( 'length' => 110 ) ) : $description;
9999
$filtered_content = apply_filters( 'cc_theme_base_filter_card_content', $the_description, $post_id );
100-
$out .= '<div class="content">';
101-
$out .= $filtered_content;
102-
$out .= '</div>';
100+
$out .= '<div class="content">';
101+
$out .= $filtered_content;
102+
$out .= '</div>';
103103
}
104104
if ( $has_button ) {
105105
$out .= self::button( $button_text, $card_url, $button_size, $button_color );
@@ -128,12 +128,12 @@ public static function card_post_event( $post_id, $has_content = true ) {
128128
$out .= '<div class="card-content">';
129129
$out .= '<h4 class="card-title"><a href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></h4>';
130130
if ( $has_content ) {
131-
$the_post = get_post( $post_id );
132-
$entry_content = do_excerpt( $the_post );
131+
$the_post = get_post( $post_id );
132+
$entry_content = do_excerpt( $the_post );
133133
$filtered_content = apply_filters( 'cc_theme_base_filter_card_event_content', $entry_content, $post_id );
134-
$out .= '<div class="content">';
135-
$out .= $filtered_content;
136-
$out .= '</div>';
134+
$out .= '<div class="content">';
135+
$out .= $filtered_content;
136+
$out .= '</div>';
137137
}
138138
$out .= '<a href="' . get_permalink( $post_id ) . '" class="read-more">Read more <i class="icon chevron-right"></i></a>';
139139
$out .= '</div>';
@@ -163,12 +163,12 @@ public static function card_statistic( $post_id, $number, $caption, $caption_is_
163163
$out .= '</header>';
164164
$out .= '<div class="card-content">';
165165
if ( $has_content ) {
166-
$the_post = get_post( $post_id );
167-
$entry_content = do_excerpt( $the_post );
166+
$the_post = get_post( $post_id );
167+
$entry_content = do_excerpt( $the_post );
168168
$filtered_content = apply_filters( 'cc_theme_base_filter_card_event_content', $entry_content, $post_id );
169-
$out .= '<div class="content">';
170-
$out .= $filtered_content;
171-
$out .= '</div>';
169+
$out .= '<div class="content">';
170+
$out .= $filtered_content;
171+
$out .= '</div>';
172172
}
173173
if ( $has_link ) {
174174
$out .= '<a href="' . get_permalink( $post_id ) . '" class="read-more">Read more</a>';
@@ -196,20 +196,20 @@ public static function card_quote( $post_id, $show_image = true, $author_name, $
196196
$out .= '</figure>';
197197
$out .= '</header>';
198198
}
199-
$out .= '<div class="card-content">';
200-
$out .= '<span class="quote"></span>';
201-
$the_post = get_post( $post_id );
202-
$entry_content = apply_filters( 'the_content', $the_post->post_content );
199+
$out .= '<div class="card-content">';
200+
$out .= '<span class="quote"></span>';
201+
$the_post = get_post( $post_id );
202+
$entry_content = apply_filters( 'the_content', $the_post->post_content );
203203
$filtered_content = apply_filters( 'cc_theme_base_filter_card_quote_content', $entry_content, $post_id );
204-
$out .= '<div class="content">';
205-
$out .= $filtered_content;
206-
$out .= '<div class="quote-author">';
207-
$out .= '<strong class="title"> ' . $author_name . '</strong>';
208-
$out .= '<p class="description">' . $author_description . '</p>';
209-
$out .= '</div>';
210-
$out .= '</div>';
211-
$out .= '</div>';
212-
$out .= '</article>';
204+
$out .= '<div class="content">';
205+
$out .= $filtered_content;
206+
$out .= '<div class="quote-author">';
207+
$out .= '<strong class="title"> ' . $author_name . '</strong>';
208+
$out .= '<p class="description">' . $author_description . '</p>';
209+
$out .= '</div>';
210+
$out .= '</div>';
211+
$out .= '</div>';
212+
$out .= '</article>';
213213

214214
return $out;
215215
}
@@ -268,19 +268,19 @@ public static function card_link( $post_id = null, $use_post_data = false, $back
268268
$color_class = ( ! $has_border ) ? 'class="has-background-' . $background_color . '"' : '';
269269
$class = ( ! empty( $extra_class ) ) ? ' ' . $extra_class : '';
270270

271-
$out = '<article class="card entry-post link ' . $border_class . $class . '">';
271+
$out = '<article class="card entry-post link ' . $border_class . $class . '">';
272272
$out .= '<a href="' . $the_url . '" ' . $color_class . '>';
273273
$out .= '<span class="card-content has-bottom-link">';
274274
$out .= '<h2 class="card-title">' . $the_title . '</h2>';
275275
if ( $has_content ) {
276276
if ( $use_post_data ) {
277-
$the_post = get_post( $post_id );
278-
$get_content = do_excerpt( $the_post );
277+
$the_post = get_post( $post_id );
278+
$get_content = do_excerpt( $the_post );
279279
$filtered_content = apply_filters( 'cc_theme_base_filter_card_link_content', $get_content, $post_id );
280-
$the_content = $filtered_content;
280+
$the_content = $filtered_content;
281281
} else {
282282
$filtered_content = apply_filters( 'cc_theme_base_filter_card_link_content', $description, $post_id );
283-
$the_content = $filtered_content;
283+
$the_content = $filtered_content;
284284
}
285285
$out .= '<span class="content">' . esc_attr( $description ) . '</span>';
286286
}
@@ -349,33 +349,43 @@ public static function notification( $type = 'warning', $url, $title, $content,
349349
return $out;
350350
}
351351
/**
352-
* Notification
352+
* Simple entry
353353
*
354354
* @param int $post_id : post or entry ID.
355355
* @param boolean $has_content : whether to show or not the content excerpt.
356356
* @param boolean $has_image : whether to show or not the entry thumbnail.
357+
* @param boolean $use_remote_data : whether to use or not remote data providing each element separatedly
358+
* @param string $title : the title of the entry
359+
* @param string $image_url : the url of the entry featured image
360+
* @param string $date : the date of the entry
361+
* @param string $permalink : the permalink of the entry
362+
* @param string $excerpt : the excerpt of the entry
357363
* @return string component layout
358364
*/
359-
public static function simple_entry( $post_id, $has_content = true, $has_image = true ) {
360-
$has_thumb = has_post_thumbnail( $post_id );
361-
$has_thumb_class = ( $has_thumb ) ? ' has-image' : '';
365+
public static function simple_entry( $post_id, $has_content = true, $has_image = true, $use_remote_data = null, $title = null, $image_url = null, $date = null, $permalink = null, $excerpt = null ) {
366+
$has_thumb = ( ! $use_remote_data ) ? has_post_thumbnail( $post_id ) : ! empty( $image_url );
367+
$has_thumb_class = ( ! empty( $has_thumb ) ) ? ' has-image' : '';
368+
$external = ( $use_remote_data ) ? ' target="_blank" ' : '';
362369
$out = '<article class="entry-simple-post' . $has_thumb_class . '">';
363370
$out .= '<div class="columns is-gapless">';
364371
if ( $has_thumb && $has_image ) {
365-
$out .= '<figure class="entry-image column is-4">';
366-
$out .= get_the_post_thumbnail( $post_id, 'landscape-small' );
367-
$out .= '</figure>';
372+
$thumb_image = ( ! $use_remote_data ) ? get_the_post_thumbnail( $post_id, 'landscape-small' ) : '<img src="' . $image_url . '" alt="' . $title . '" />';
373+
$out .= '<figure class="entry-image column is-4">';
374+
$out .= $thumb_image;
375+
$out .= '</figure>';
368376
}
369-
$out .= '<div class="entry-content column">';
370-
$out .= '<h4 class="b-header"><a href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></h4>';
371-
$out .= '<span class="entry-date">' . get_the_date( CC_Site::get_date_format() ) . '</span>';
377+
$the_title = ( ! $use_remote_data ) ? get_the_title( $post_id ) : $title;
378+
$the_permalink = ( ! $use_remote_data ) ? get_permalink( $post_id ) : $permalink;
379+
$the_date = ( ! $use_remote_data ) ? get_the_date( 'd F Y' ) : mysql2date( 'd F Y', $date );
380+
$out .= '<div class="entry-content column">';
381+
$out .= '<h4 class="b-header"><a href="' . $the_permalink . '"' . $external . '>' . $the_title . '</a></h4>';
382+
$out .= '<span class="entry-date">' . $the_date . '</span>';
372383
if ( $has_content ) {
373-
$the_post = get_post( $post_id );
374-
$the_content = do_excerpt( $the_post );
375-
$filtered_content = apply_filters( 'cc_theme_base_filter_card_link_content', $the_content, $post_id );
376-
$out .= '<div class="entry-description">';
377-
$out .= $filtered_content;
378-
$out .= '</div>';
384+
$the_post = get_post( $post_id );
385+
$the_excerpt = ( ! $use_remote_data ) ? do_excerpt( $the_post ) : $excerpt;
386+
$out .= '<div class="entry-description">';
387+
$out .= $the_excerpt;
388+
$out .= '</div>';
379389
}
380390
$out .= '</div>';
381391
$out .= '</div>';
@@ -385,24 +395,24 @@ public static function simple_entry( $post_id, $has_content = true, $has_image =
385395
/**
386396
* cc_logos
387397
*
388-
* @param string $logo_name lettermark|letterheart
398+
* @param string $logo_name lettermark|letterheart
389399
* @param boolean $has_dark_background
390400
* @return void
391401
*/
392-
public static function cc_logos($logo_name = 'cc/logomark.svg#logomark', $has_dark_background = false) {
402+
public static function cc_logos( $logo_name = 'cc/logomark.svg#logomark', $has_dark_background = false ) {
393403
$out = '';
394404
if ( $has_dark_background ) {
395405
$out .= '<div class="has-text-white">';
396406
}
397407
$default_image_size = '304 73';
398-
$image_size = apply_filters('cc_theme_base_set_default_size_logo', $default_image_size);
399-
$out .= '<svg';
400-
$out .= ' class="logo"';
401-
$out .= ' xmlns="http://www.w3.org/2000/svg"';
402-
$out .= ' preserveAspectRatio="xMidyMid meet"';
403-
$out .= ' viewBox="0 0 '.$image_size.'">';
404-
$out .= ' <use href="'.get_bloginfo( 'template_directory' ) . '/assets/img/logos/'.$logo_name.'"></use>';
405-
$out .= '</svg>';
408+
$image_size = apply_filters( 'cc_theme_base_set_default_size_logo', $default_image_size );
409+
$out .= '<svg';
410+
$out .= ' class="logo"';
411+
$out .= ' xmlns="http://www.w3.org/2000/svg"';
412+
$out .= ' preserveAspectRatio="xMidyMid meet"';
413+
$out .= ' viewBox="0 0 ' . $image_size . '">';
414+
$out .= ' <use href="' . get_bloginfo( 'template_directory' ) . '/assets/img/logos/' . $logo_name . '"></use>';
415+
$out .= '</svg>';
406416
if ( $has_dark_background ) {
407417
$out .= '</div>';
408418
}

inc/class-walkers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function start_lvl( &$output, $depth = 0, $args = array() ) {
1818
$output .= "<div class='navbar-dropdown'>";
1919
}
2020
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
21-
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
22-
$classes[] = 'menu-item-' . $item->ID;
23-
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
21+
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
22+
$classes[] = 'menu-item-' . $item->ID;
23+
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
2424
$li_classes = 'navbar-item ' . $item->post_name . ' ' . $class_names;
2525
$has_children = $args->walker->has_children;
2626
$li_classes .= $has_children ? ' has-dropdown is-hoverable' : '';

inc/partials/entry/entry-author.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,40 @@
88
echo '<div class="entry-author">';
99
echo '<div class="author-image">';
1010
$author_bio_avatar_size = apply_filters( 'cc_author_bio_avatar_size', 50 );
11-
if (count($co_authors)){
12-
foreach ($co_authors as $an_author){
13-
if ($an_author->type == 'guest-author') {
14-
echo get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size );
15-
} else {
16-
echo '<a href="' . get_author_posts_url(get_the_author_meta( 'ID', $an_author->ID ), get_the_author_meta( 'user_nicename', $an_author->ID )) . '">' . get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size ) . '</a>';
17-
}
18-
}
11+
if ( count( $co_authors ) ) {
12+
foreach ( $co_authors as $an_author ) {
13+
if ( $an_author->type == 'guest-author' ) {
14+
echo get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size );
1915
} else {
20-
echo '<a href="' . get_author_posts_url(get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' )) . '">' . get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size ) . '</a>';
16+
echo '<a href="' . get_author_posts_url( get_the_author_meta( 'ID', $an_author->ID ), get_the_author_meta( 'user_nicename', $an_author->ID ) ) . '">' . get_avatar( get_the_author_meta( 'user_email', $an_author->ID ), $author_bio_avatar_size ) . '</a>';
2117
}
18+
}
19+
} else {
20+
echo '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) . '">' . get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size ) . '</a>';
21+
}
2222
echo '</div>';
2323
echo '<div class="author-info-group">';
2424
echo '<div class="author-name">';
25-
if ( function_exists( 'coauthors_posts_links' ) ) {
26-
if (count($co_authors)){
27-
$x = 1;
28-
foreach ($co_authors as $an_author){
29-
if ($an_author->type == 'guest-author') {
30-
echo $an_author->display_name;
31-
} else {
32-
echo '<a href="' . get_author_posts_url($an_author->ID, $an_author->user_nicename) . '">' . $an_author->display_name . '</a>';
33-
}
34-
if ($x != count($co_authors)) { echo ' and '; }
35-
$x++;
36-
}
37-
}
25+
if ( function_exists( 'coauthors_posts_links' ) ) {
26+
if ( count( $co_authors ) ) {
27+
$x = 1;
28+
foreach ( $co_authors as $an_author ) {
29+
if ( $an_author->type == 'guest-author' ) {
30+
echo $an_author->display_name;
3831
} else {
39-
the_author_posts_link();
32+
echo '<a href="' . get_author_posts_url( $an_author->ID, $an_author->user_nicename ) . '">' . $an_author->display_name . '</a>';
4033
}
34+
if ( $x != count( $co_authors ) ) {
35+
echo ' and '; }
36+
$x++;
37+
}
38+
}
39+
} else {
40+
the_author_posts_link();
41+
}
4142
echo '</div>';
42-
echo '<div class="author-date">'. get_the_date( CC_Site::get_date_format() ); '</div>';
43+
echo '<div class="author-date">' . get_the_date( CC_Site::get_date_format() );
44+
'</div>';
4345
echo '</div>';
4446
echo '</div>';
4547
echo '</div>';

inc/partials/entry/page-footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php if ( is_active_sidebar( 'page-footer' ) ): ?>
1+
<?php if ( is_active_sidebar( 'page-footer' ) ) : ?>
22
<footer class="entry-footer padding-vertical-bigger">
33
<div class="container">
44
<?php dynamic_sidebar( 'page-footer' ); ?>

0 commit comments

Comments
 (0)