Skip to content

Commit 7d9929e

Browse files
committed
Format code + alumni members template
1 parent 8295bc7 commit 7d9929e

12 files changed

+323
-167
lines changed

acf-json/group_5fcdcdae6c85b.json

+45-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"key": "field_5fcdce02342c4",
24-
"label": "Alumni Home Page",
24+
"label": "Home Page",
2525
"name": "alumni_home_page",
2626
"type": "post_object",
2727
"instructions": "",
@@ -43,7 +43,7 @@
4343
},
4444
{
4545
"key": "field_5fcdd19e342c5",
46-
"label": "Alumni Login Page",
46+
"label": "Login Page",
4747
"name": "alumni_login_page",
4848
"type": "post_object",
4949
"instructions": "",
@@ -62,6 +62,48 @@
6262
"multiple": 0,
6363
"return_format": "id",
6464
"ui": 1
65+
},
66+
{
67+
"key": "field_5fcdeaf252853",
68+
"label": "Members Page",
69+
"name": "alumni_members_page",
70+
"type": "post_object",
71+
"instructions": "",
72+
"required": 0,
73+
"conditional_logic": 0,
74+
"wrapper": {
75+
"width": "",
76+
"class": "",
77+
"id": ""
78+
},
79+
"post_type": "",
80+
"taxonomy": "",
81+
"allow_null": 0,
82+
"multiple": 0,
83+
"return_format": "id",
84+
"ui": 1
85+
},
86+
{
87+
"key": "field_5fcdf22240823",
88+
"label": "Forum",
89+
"name": "alumni_forum_page",
90+
"type": "post_object",
91+
"instructions": "",
92+
"required": 0,
93+
"conditional_logic": 0,
94+
"wrapper": {
95+
"width": "",
96+
"class": "",
97+
"id": ""
98+
},
99+
"post_type": [
100+
"forum"
101+
],
102+
"taxonomy": "",
103+
"allow_null": 0,
104+
"multiple": 0,
105+
"return_format": "object",
106+
"ui": 1
65107
}
66108
],
67109
"location": [
@@ -81,5 +123,5 @@
81123
"hide_on_screen": "",
82124
"active": true,
83125
"description": "",
84-
"modified": 1607324834
126+
"modified": 1607332442
85127
}

assets/css/child-styles.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/src/styles/shame.scss

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ main {
141141
background-color: #fef6d8;
142142
}
143143

144+
.main-content {
145+
min-height: 70vh;
146+
}
144147
.single,
145148
.page {
146149
.main-content {

inc/acf.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function get_faqs_by_titles( $titles = array() ) {
9090
**/
9191
public static function get_testimonials_by_cite( $citations = array() ) {
9292
// @todo: FAQ page id is hardcoded here, find a way to make this dynamic
93-
$testimonials = get_field( 'testimonials', 16 );
93+
$testimonials = get_field( 'testimonials', 16 );
9494
$filtered_testimonials = array();
9595

9696
foreach ( $testimonials as $testimonial ) {

inc/alumni.php

+111-85
Original file line numberDiff line numberDiff line change
@@ -2,110 +2,136 @@
22
/**
33
* Class for working with BB Press and alumni.
44
*/
5-
class CC_Alumni {
6-
private static $instance;
5+
class CC_Alumni {
6+
private static $instance;
77

8-
public $alumni_home_id;
9-
public $alumni_login_id;
10-
public $alumni;
8+
public $home_page_id;
9+
public $login_page_id;
10+
public $members_page_id;
11+
public $forum_page_id;
1112

12-
function __construct() {
13-
$this->alumni_home_id = get_field( 'alumni_home_page', 'options' );
14-
$this->alumni_login_id = get_field( 'alumni_login_page', 'options' );
15-
$this->alumni = $this->get_alumni();
16-
$this->actions_manager();
17-
}
13+
public $alumni;
1814

19-
public static function get_instance() {
15+
function __construct() {
16+
$this->home_page_id = get_field( 'alumni_home_page', 'options' );
17+
$this->login_page_id = get_field( 'alumni_login_page', 'options' );
18+
$this->members_page_id = get_field( 'alumni_members_page', 'options' );
19+
$this->forum_page_id = get_field( 'alumni_forum_page', 'options' );
20+
21+
$this->alumni = $this->get_alumni();
22+
$this->actions_manager();
23+
}
24+
25+
public static function get_instance() {
2026
if ( ! isset( self::$instance ) ) {
2127
$c = __CLASS__;
2228
self::$instance = new $c();
2329
}
2430
return self::$instance;
2531
}
2632

27-
public static function get_alumni() {
28-
$key = 'cc_alumni';
33+
public static function get_alumni() {
34+
$key = 'cc_alumni';
2935

30-
if ( false === ( $results = get_transient( $key ) ) ) {
31-
$results = get_users( array ( 'role__in' => array ( 'bbp_participant' ), 'fields' => array ( 'ID', 'user_email', 'display_name' ) ) );
32-
set_transient( $key, $results, HOUR_IN_SECONDS / 4 );
33-
}
36+
if ( false === ( $results = get_transient( $key ) ) ) {
37+
$results = get_users(
38+
array(
39+
'role__in' => array( 'bbp_participant' ),
40+
'fields' => array(
41+
'ID',
42+
'user_email',
43+
'display_name',
44+
),
45+
)
46+
);
47+
set_transient( $key, $results, HOUR_IN_SECONDS / 4 );
48+
}
3449

35-
return $results;
36-
}
50+
return $results;
51+
}
3752

38-
public function render_alumni() {
39-
?>
40-
<div class="alumni-members">
41-
<?php foreach ($this->alumni as $single_alumni) { ?>
53+
public function render_alumni() {
54+
?>
55+
<div class="alumni-members">
56+
<?php foreach ( $this->alumni as $single_alumni ) { ?>
4257
<a href="<?php echo bbp_get_user_profile_url( $single_alumni->ID ); ?>" class="alumni-member">
43-
<img class="margin-bottom-small" src="<?php echo get_avatar_url( $single_alumni->ID, array ( 'size' => 120 ) ); ?>" alt="Kitten">
58+
<img class="margin-bottom-small" src="<?php echo get_avatar_url( $single_alumni->ID, array( 'size' => 120 ) ); ?>" alt="Kitten">
4459
<span class="has-text-weight-bold"><?php echo $single_alumni->display_name; ?></span>
4560
</a>
46-
<?php } ?>
47-
</div>
48-
<?php
49-
}
50-
51-
/**
52-
* Display a notice in the WordPress back-end if the alumni pages aren't linked correctly.
53-
*/
54-
public function notify_if_pages_unlinked () {
55-
?>
56-
<div class="update-nag notice">
57-
<p>One or more alumni pages are unlinked. Please go to the <a href="/wp-admin/admin.php?page=acf-options">options</a> page and connect them.</p>
58-
</div>
59-
<?php
60-
}
61-
62-
/**
63-
* Check if there is a logged in alumni
64-
*/
65-
public static function is_alumni () {
66-
if ( function_exists( 'bbp_get_current_user_id' ) ) {
67-
return ! empty( bbp_get_current_user_id() );
68-
} else {
69-
return is_user_logged_in();
70-
}
71-
}
72-
73-
/**
74-
* Redirect from the alumni login page to the alumni home page if the user is already logged in.
75-
*/
76-
public function redirect_if_logged_in () {
77-
if ( empty( $this->alumni_login_id ) || empty( $this->alumni_home_id ) ) return;
78-
79-
if ( $this->is_alumni() && is_page( $this->alumni_login_id ) ) {
80-
wp_redirect( get_permalink( $this->alumni_home_id ) );
81-
exit;
82-
}
83-
}
84-
85-
/*
86-
* Render a simple dropdown menu for logged-in alumni
61+
<?php } ?>
62+
</div>
63+
<?php
64+
}
65+
66+
/**
67+
* Display a notice in the WordPress back-end if the alumni pages aren't linked correctly.
68+
*/
69+
public function notify_if_pages_unlinked() {
70+
?>
71+
<div class="update-nag notice">
72+
<p>One or more alumni pages are unlinked. Please go to the <a href="/wp-admin/admin.php?page=acf-options">options</a> page and connect them.</p>
73+
</div>
74+
<?php
75+
}
76+
77+
/**
78+
* Check if there is a logged in alumni
79+
*/
80+
public static function is_alumni() {
81+
if ( function_exists( 'bbp_get_current_user_id' ) ) {
82+
return ! empty( bbp_get_current_user_id() );
83+
} else {
84+
return is_user_logged_in();
85+
}
86+
}
87+
88+
/**
89+
* Redirect from the alumni login page to the alumni home page if the user is already logged in.
8790
*/
88-
public function show_alumni_menu_item () {
89-
if ( $this->is_alumni() ) {
90-
return '<div class="navbar-item has-dropdown is-hoverable"><a class="button alumni is-dropdown"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg" class="margin-right-small"><path d="M5 5.625C6.55273 5.625 7.8125 4.36523 7.8125 2.8125C7.8125 1.25977 6.55273 0 5 0C3.44727 0 2.1875 1.25977 2.1875 2.8125C2.1875 4.36523 3.44727 5.625 5 5.625ZM7.5 6.25H6.42383C5.99023 6.44922 5.50781 6.5625 5 6.5625C4.49219 6.5625 4.01172 6.44922 3.57617 6.25H2.5C1.11914 6.25 0 7.36914 0 8.75V9.0625C0 9.58008 0.419922 10 0.9375 10H9.0625C9.58008 10 10 9.58008 10 9.0625V8.75C10 7.36914 8.88086 6.25 7.5 6.25Z" fill="#767676"/></svg>
91+
public function redirect_if_logged_in() {
92+
if ( $this->is_alumni() && is_page( $this->login_page_id ) ) {
93+
wp_redirect( get_permalink( $this->alumni_home_id ) );
94+
exit;
95+
}
96+
}
97+
98+
/**
99+
* Redirect from alumni pages to the alumni login page if the user is not logged in.
100+
*/
101+
public function redirect_if_not_logged_in() {
102+
$is_alumni_page = is_page( $this->home_page_id ) || is_page( $this->members_page_id ) || is_page( $this->forum_page_id );
103+
104+
if ( ! $this->is_alumni() && $is_alumni_page ) {
105+
wp_redirect( get_permalink( $this->login_page_id ) );
106+
exit;
107+
}
108+
}
91109

92-
'.bbp_get_current_user_name().' <i class="icon caret-down"></i></a>
110+
/*
111+
* Render a simple dropdown menu for logged-in alumni
112+
*/
113+
public function show_alumni_menu_item() {
114+
if ( $this->is_alumni() ) {
115+
return '<div class="navbar-item has-dropdown is-hoverable"><a class="button alumni is-dropdown"><svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg" class="margin-right-small"><path d="M5 5.625C6.55273 5.625 7.8125 4.36523 7.8125 2.8125C7.8125 1.25977 6.55273 0 5 0C3.44727 0 2.1875 1.25977 2.1875 2.8125C2.1875 4.36523 3.44727 5.625 5 5.625ZM7.5 6.25H6.42383C5.99023 6.44922 5.50781 6.5625 5 6.5625C4.49219 6.5625 4.01172 6.44922 3.57617 6.25H2.5C1.11914 6.25 0 7.36914 0 8.75V9.0625C0 9.58008 0.419922 10 0.9375 10H9.0625C9.58008 10 10 9.58008 10 9.0625V8.75C10 7.36914 8.88086 6.25 7.5 6.25Z" fill="#767676"/></svg>
116+
117+
' . bbp_get_current_user_name() . ' <i class="icon caret-down"></i></a>
93118
<div class="alumni-dropdown navbar-dropdown">
94-
<a class="navbar-item" href="'. get_permalink( $this->alumni_home_id ) .'">Alumni</a>
95-
<a class="navbar-item" href="'. bbp_get_user_profile_edit_url( bbp_get_current_user_id() ).'">Edit Profile</a>
96-
<a class="navbar-item" href="'. wp_logout_url( home_url() ) . '">Sign Out</a>
119+
<a class="navbar-item" href="' . get_permalink( $this->home_page_id ) . '">Alumni</a>
120+
<a class="navbar-item" href="' . bbp_get_user_profile_edit_url( bbp_get_current_user_id() ) . '">Edit Profile</a>
121+
<a class="navbar-item" href="' . wp_logout_url( home_url() ) . '">Sign Out</a>
97122
</div>
98123
</div>';
99-
} else {
100-
return '<div class="navbar-item"><a class="button alumni" href="' . get_permalink( $this->alumni_login_id ) . '"><svg class="margin-right-small" width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 5.625C6.55273 5.625 7.8125 4.36523 7.8125 2.8125C7.8125 1.25977 6.55273 0 5 0C3.44727 0 2.1875 1.25977 2.1875 2.8125C2.1875 4.36523 3.44727 5.625 5 5.625ZM7.5 6.25H6.42383C5.99023 6.44922 5.50781 6.5625 5 6.5625C4.49219 6.5625 4.01172 6.44922 3.57617 6.25H2.5C1.11914 6.25 0 7.36914 0 8.75V9.0625C0 9.58008 0.419922 10 0.9375 10H9.0625C9.58008 10 10 9.58008 10 9.0625V8.75C10 7.36914 8.88086 6.25 7.5 6.25Z" fill="#008000"/></svg>Alumni</a></div>';
101-
}
102-
}
103-
104-
public function actions_manager() {
105-
add_action( 'template_redirect', array( $this, 'redirect_if_logged_in' ) );
106-
107-
if ( empty ( $this->alumni_home_id ) || empty( $this->alumni_login_id ) ) {
108-
add_action( 'admin_notices', array( $this, 'notify_if_pages_unlinked' ) );
109-
}
110-
}
124+
} else {
125+
return '<div class="navbar-item"><a class="button alumni" href="' . get_permalink( $this->login_page_id ) . '"><svg class="margin-right-small" width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 5.625C6.55273 5.625 7.8125 4.36523 7.8125 2.8125C7.8125 1.25977 6.55273 0 5 0C3.44727 0 2.1875 1.25977 2.1875 2.8125C2.1875 4.36523 3.44727 5.625 5 5.625ZM7.5 6.25H6.42383C5.99023 6.44922 5.50781 6.5625 5 6.5625C4.49219 6.5625 4.01172 6.44922 3.57617 6.25H2.5C1.11914 6.25 0 7.36914 0 8.75V9.0625C0 9.58008 0.419922 10 0.9375 10H9.0625C9.58008 10 10 9.58008 10 9.0625V8.75C10 7.36914 8.88086 6.25 7.5 6.25Z" fill="#008000"/></svg>Alumni</a></div>';
126+
}
127+
}
128+
129+
public function actions_manager() {
130+
add_action( 'template_redirect', array( $this, 'redirect_if_logged_in' ) );
131+
add_action( 'template_redirect', array( $this, 'redirect_if_not_logged_in' ) );
132+
133+
if ( empty( $this->home_page_id ) || empty( $this->login_page_id ) ) {
134+
add_action( 'admin_notices', array( $this, 'notify_if_pages_unlinked' ) );
135+
}
136+
}
111137
}

inc/certificates-functions.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public static function event_card( $post_id ) {
2020
</clipPath>
2121
</defs>
2222
</svg>
23-
<span class="title is-5"><?php echo get_field('start_date', $post_id ); ?></span>
24-
<span class="title is-5"><?php echo get_field('end_date', $post_id ); ?></span>
23+
<span class="title is-5"><?php echo get_field( 'start_date', $post_id ); ?></span>
24+
<span class="title is-5"><?php echo get_field( 'end_date', $post_id ); ?></span>
2525
</div>
2626
<div class="right">
2727
<h3 class="subtitle is-5 margin-bottom-normal"><?php echo get_the_title( $post_id ); ?></h3>
@@ -51,7 +51,7 @@ public static function get_upcoming_course_events( $post_id = null ) {
5151
'key' => 'start_date',
5252
'compare' => '>=',
5353
'value' => date( 'Ymd' ),
54-
)
54+
),
5555
);
5656

5757
// Filter by course ff we're getting events related to a specific course.
@@ -70,7 +70,7 @@ public static function get_upcoming_course_events( $post_id = null ) {
7070
'meta_key' => 'start_date',
7171
'orderby' => 'meta_value_num',
7272
'order' => 'ASC',
73-
'meta_query' => $meta_query
73+
'meta_query' => $meta_query,
7474
)
7575
);
7676

@@ -180,7 +180,7 @@ function load_org_blog_posts() {
180180
* @return int
181181
*/
182182
function numWeeks( $date_one, $date_two ) {
183-
$first_date = new DateTime( $date_one );
183+
$first_date = new DateTime( $date_one );
184184
$secnd_date = new DateTime( $date_two );
185185

186186
$difference_in_days = $first_date->diff( $secnd_date )->days;

0 commit comments

Comments
 (0)