Skip to content

Commit 56c48d7

Browse files
committed
Format code with phpcbf --standard=WordPress . --ignore=vendor --extensions=php
1 parent 6a4bf3c commit 56c48d7

34 files changed

+661
-570
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"scripts": {
2525
"compat": "phpcs -p --standard=PHPCompatibility --runtime-set testVersion 7.0 -n . --extensions=php --cache",
26-
"fix": "phpcbf --standard=WordPress . --extensions=php --ignore=vendor",
26+
"pecl ": "phpcbf --standard=WordPress . --extensions=php --ignore=vendor",
2727
"lint": "parallel-lint . --blame --exclude vendor",
2828
"sniff": "phpcs --standard=WordPress . --ignore=vendor --extensions=php"
2929
},

functions.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@
1313
/*
1414
Include Custom post types
1515
*/
16-
require STYLESHEETPATH. '/inc/custom-post-types/queulat-cc-course-cpt-plugin/cc-course-cpt-plugin.php';
17-
require STYLESHEETPATH. '/inc/custom-post-types/queulat-cc-events-cpt-plugin/cc-events-cpt-plugin.php';
18-
require STYLESHEETPATH. '/inc/custom-post-types/queulat-cc-scholarships-cpt-plugin/cc-scholarships-cpt-plugin.php';
19-
require STYLESHEETPATH. '/inc/custom-post-types/queulat-cc-testimonials-cpt-plugin/cc-testimonials-cpt-plugin.php';
16+
require STYLESHEETPATH . '/inc/custom-post-types/queulat-cc-course-cpt-plugin/cc-course-cpt-plugin.php';
17+
require STYLESHEETPATH . '/inc/custom-post-types/queulat-cc-events-cpt-plugin/cc-events-cpt-plugin.php';
18+
require STYLESHEETPATH . '/inc/custom-post-types/queulat-cc-scholarships-cpt-plugin/cc-scholarships-cpt-plugin.php';
19+
require STYLESHEETPATH . '/inc/custom-post-types/queulat-cc-testimonials-cpt-plugin/cc-testimonials-cpt-plugin.php';
2020

2121
/* Include local files */
22-
require STYLESHEETPATH. '/inc/certificates-functions.php';
23-
require STYLESHEETPATH. '/inc/widgets.php';
22+
require STYLESHEETPATH . '/inc/certificates-functions.php';
23+
require STYLESHEETPATH . '/inc/widgets.php';
2424

2525
/**
2626
* Theme singleton class
2727
* ---------------------
2828
* Stores various theme and site specific info and groups custom methods
2929
**/
3030
class CC_Certificates_Site {
31+
3132
private static $instance;
3233

3334
const id = __CLASS__;
@@ -62,7 +63,7 @@ public function enqueue_scripts() {
6263
wp_enqueue_script( 'cc_certificates_script', THEME_LOCAL_URI . '/assets/js/script.js', array( 'jquery' ), self::theme_ver, true );
6364
}
6465
public function enqueue_styles() {
65-
wp_enqueue_style( 'cc_current_style', THEME_LOCAL_URI . '/assets/css/child-styles.css', array('cc_base_style'), self::theme_ver );
66+
wp_enqueue_style( 'cc_current_style', THEME_LOCAL_URI . '/assets/css/child-styles.css', array( 'cc_base_style' ), self::theme_ver );
6667
}
6768
}
6869

inc/certificates-functions.php

+67-58
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,53 @@
11
<?php
22
class Certificates_Website {
3-
public static function set_certificates_logo( ) {
3+
4+
public static function set_certificates_logo() {
45
return 'products/certificates.svg#certificates';
56
}
6-
public static function set_certificates_logo_image_size( ) {
7+
public static function set_certificates_logo_image_size() {
78
return '215 40';
89
}
910
// Add a class to the page body to override styles from the base theme
1011
public static function add_body_class( $classes ) {
11-
return array_merge( $classes, array( 'creativecommons-certificate' ) );
12+
return array_merge( $classes, array( 'creativecommons-certificate' ) );
1213
}
13-
public static function modify_breadcrumb_seperator( ) {
14+
public static function modify_breadcrumb_seperator() {
1415
return '<i class="icon chevron-right is-6"></i>';
1516
}
16-
public static function get_upcoming_course_events( ) {
17-
return ['wow'];
17+
public static function get_upcoming_course_events() {
18+
return array( 'wow' );
1819
}
1920
public static function register_columns_shortcode( $atts, $content ) {
20-
$a = shortcode_atts( array( 'cols' => '4' ), $atts );
21-
return '<div class="cols" style="--col-count: ' . $a['cols'] . ';">'. $content .'</div>';
21+
$a = shortcode_atts( array( 'cols' => '4' ), $atts );
22+
return '<div class="cols" style="--col-count: ' . $a['cols'] . ';">' . $content . '</div>';
2223
}
2324
public static function register_stats_shortcode( $atts, $content ) {
24-
return '<div class="stats has-text-black">'.do_shortcode($content).'</div>';
25+
return '<div class="stats has-text-black">' . do_shortcode( $content ) . '</div>';
2526
}
2627
public static function register_stat_shortcode( $atts, $content ) {
27-
$a = shortcode_atts( array( 'title' => '', 'number' => '', 'subtitle' => '' ), $atts );
28-
return '<div class="stat"><h3 class="title is-5">'.$a['title'].'</h3><span class="number has-text-weight-bold is-size-1">'.$a['number'].'</span><p class="caption has-text-weight-bold">'.$a['subtitle'].'</p></div>';
28+
$a = shortcode_atts(
29+
array(
30+
'title' => '',
31+
'number' => '',
32+
'subtitle' => '',
33+
),
34+
$atts
35+
);
36+
return '<div class="stat"><h3 class="title is-5">' . $a['title'] . '</h3><span class="number has-text-weight-bold is-size-1">' . $a['number'] . '</span><p class="caption has-text-weight-bold">' . $a['subtitle'] . '</p></div>';
2937
}
3038
// @todo: Make this do more (add colors)/throw this out and use the card somehow
3139
public static function register_box_shortcode( $atts, $content ) {
32-
return '<div class="has-background-grey-lighter padding-vertical-big padding-horizontal-bigger cc-box margin-bottom-larger">'.$content.'</div>';
40+
return '<div class="has-background-grey-lighter padding-vertical-big padding-horizontal-bigger cc-box margin-bottom-larger">' . $content . '</div>';
3341
}
3442
// Pressbooks hides the WordPress Admin bar, but doesn't remove the empty space :/
35-
public static function remove_admin_bar_top_whitespace( ) {
43+
public static function remove_admin_bar_top_whitespace() {
3644
if ( is_admin_bar_showing() ) {
37-
echo '<style type="text/css">html {margin-top: 0 !important;}</style>';
45+
echo '<style type="text/css">html {margin-top: 0 !important;}</style>';
3846
}
3947
}
4048
public static function add_alumni_login_button( $items, $args ) {
4149
if ( $args->theme_location == 'main-navigation' ) {
42-
$items .= '<div class="navbar-item"><a class="button alumni" href="'. get_page_link(788) .'"><svg class="margin-right-small" width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
50+
$items .= '<div class="navbar-item"><a class="button alumni" href="' . get_page_link( 788 ) . '"><svg class="margin-right-small" width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
4351
<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"/>
4452
</svg>
4553
Alumni</a></div>';
@@ -51,16 +59,16 @@ public static function add_alumni_login_button( $items, $args ) {
5159
// add filters
5260
add_filter( 'cc_theme_base_set_default_size_logo', array( 'Certificates_Website', 'set_certificates_logo_image_size' ) );
5361
add_filter( 'cc_theme_base_set_default_logo', array( 'Certificates_Website', 'set_certificates_logo' ) );
54-
add_filter( 'body_class', array( 'Certificates_Website', 'add_body_class') );
55-
add_filter( 'wpseo_breadcrumb_separator', array( 'Certificates_Website', 'modify_breadcrumb_seperator') );
56-
add_filter( 'wp_head', array( 'Certificates_Website', 'remove_admin_bar_top_whitespace'), 11 );
57-
add_filter( 'wp_nav_menu_items', array( 'Certificates_Website', 'add_alumni_login_button'), 10, 2 );
62+
add_filter( 'body_class', array( 'Certificates_Website', 'add_body_class' ) );
63+
add_filter( 'wpseo_breadcrumb_separator', array( 'Certificates_Website', 'modify_breadcrumb_seperator' ) );
64+
add_filter( 'wp_head', array( 'Certificates_Website', 'remove_admin_bar_top_whitespace' ), 11 );
65+
add_filter( 'wp_nav_menu_items', array( 'Certificates_Website', 'add_alumni_login_button' ), 10, 2 );
5866

5967
// Register shortcodes
60-
add_shortcode( 'columns', array( 'Certificates_Website', 'register_columns_shortcode') );
61-
add_shortcode( 'stats', array( 'Certificates_Website', 'register_stats_shortcode') );
62-
add_shortcode( 'stat', array( 'Certificates_Website', 'register_stat_shortcode') );
63-
add_shortcode( 'box', array( 'Certificates_Website', 'register_box_shortcode') );
68+
add_shortcode( 'columns', array( 'Certificates_Website', 'register_columns_shortcode' ) );
69+
add_shortcode( 'stats', array( 'Certificates_Website', 'register_stats_shortcode' ) );
70+
add_shortcode( 'stat', array( 'Certificates_Website', 'register_stat_shortcode' ) );
71+
add_shortcode( 'box', array( 'Certificates_Website', 'register_box_shortcode' ) );
6472

6573
/**
6674
* Populate the 'Featured FAQs' dropdown on the homepage edit page with the actual FAQs.
@@ -69,29 +77,29 @@ function acf_load_featured_faq_choices( $field ) {
6977
$field['choices'] = array();
7078

7179
// @todo: FAQ page id is hardcoded here, find a way to make this dynamic
72-
$faq_groups = get_field('faq_group', 32);
80+
$faq_groups = get_field( 'faq_group', 32 );
7381

74-
foreach ($faq_groups as $faqGroup) {
75-
foreach ($faqGroup['questions'] as $question) {
76-
$field['choices'][$question['question']] = $question['question'];
82+
foreach ( $faq_groups as $faqGroup ) {
83+
foreach ( $faqGroup['questions'] as $question ) {
84+
$field['choices'][ $question['question'] ] = $question['question'];
7785
}
7886
}
7987

80-
return $field;
88+
return $field;
8189
};
8290

8391
add_filter( 'acf/load_field/name=featured_faqs', 'acf_load_featured_faq_choices' );
8492

8593

86-
function get_faqs_by_titles($titles = array(), $faqs = array()) {
94+
function get_faqs_by_titles( $titles = array(), $faqs = array() ) {
8795
// @todo: FAQ page id is hardcoded here, find a way to make this dynamic
88-
$faq_groups = get_field('faq_group', 32);
96+
$faq_groups = get_field( 'faq_group', 32 );
8997
$filtered_faqs = array();
9098

91-
foreach ($faq_groups as $faq_group) {
92-
foreach ($faq_group['questions'] as $question) {
93-
if(in_array($question['question'], $titles)) {
94-
array_push($filtered_faqs, $question);
99+
foreach ( $faq_groups as $faq_group ) {
100+
foreach ( $faq_group['questions'] as $question ) {
101+
if ( in_array( $question['question'], $titles ) ) {
102+
array_push( $filtered_faqs, $question );
95103
}
96104
}
97105
}
@@ -101,30 +109,30 @@ function get_faqs_by_titles($titles = array(), $faqs = array()) {
101109

102110
// @todo: Also store in transient (even if short)
103111
function load_home_featured_posts() {
104-
$url = 'https://creativecommons.org/wp-json/wp/v2/posts?per_page=50';
105-
$media_url = 'https://creativecommons.org/wp-json/wp/v2/media';
112+
$url = 'https://creativecommons.org/wp-json/wp/v2/posts?per_page=50';
113+
$media_url = 'https://creativecommons.org/wp-json/wp/v2/media';
106114
$author_url = 'https://creativecommons.org/wp-json/wp/v2/users';
107115

108116
$transient_key = 'home_posts' . $url;
109117

110118
foreach ( get_field( 'featured_news', get_option( 'page_on_front' ) ) as $news ) {
111-
if ($news['post_id']) {
119+
if ( $news['post_id'] ) {
112120
$url .= '&include[]=' . $news['post_id'];
113121
}
114122
}
115123

116124
if ( false === ( $results = get_transient( $transient_key ) ) ) {
117125

118-
$posts = query_api($url);
126+
$posts = query_api( $url );
119127

120-
foreach ($posts as $post) {
128+
foreach ( $posts as $post ) {
121129
// Attach featured image info
122130
if ( ! empty( $post->featured_media ) ) {
123131
$api_response = query_api( $media_url . '/' . $post->featured_media );
124132

125133
if ( ! empty( $api_response ) ) {
126-
$post->featured_media_url = $api_response->media_details->sizes->cc_list_post_thumbnail->source_url;
127-
$post->alt_text = $api_response->alt_text;
134+
$post->featured_media_url = $api_response->media_details->sizes->cc_list_post_thumbnail->source_url;
135+
$post->alt_text = $api_response->alt_text;
128136
}
129137
}
130138

@@ -134,17 +142,17 @@ function load_home_featured_posts() {
134142

135143
if ( ! empty( $api_response ) ) {
136144
$post->author_name = $api_response->name;
137-
$post->author_url = $api_response->link;
145+
$post->author_url = $api_response->link;
138146
}
139147
}
140148
}
141149

142-
$results = [];
143-
foreach ($posts as $post) {
144-
$results[$post->id] = $post;
150+
$results = array();
151+
foreach ( $posts as $post ) {
152+
$results[ $post->id ] = $post;
145153
}
146154

147-
set_transient( $transient_key, $results, HOUR_IN_SECONDS ); // @todo Maybe longer?
155+
set_transient( $transient_key, $results, HOUR_IN_SECONDS ); // @todo Maybe longer?
148156
}
149157

150158
return $results;
@@ -163,31 +171,32 @@ function query_api( $url ) {
163171

164172
function load_org_blog_posts() {
165173
$posts_url = 'https://creativecommons.org/wp-json/wp/v2/posts?per_page=50';
166-
$posts = query_api( $posts_url );
174+
$posts = query_api( $posts_url );
167175

168-
if(!$posts) {
169-
return [];
176+
if ( ! $posts ) {
177+
return array();
170178
}
171179

172180
return $posts;
173181
}
174182

175183
/**
176184
* This only runs on the back-end, when editing a page using the page-home.php template.
185+
*
177186
* @todo Maybe add a short transient here? Not sure if necessary since on the back-end only.
178187
* @todo Maybe need to load more than 50 most recent posts? Download multiple pages and build list.
179188
*/
180189
function acf_load_blog_posts( $field ) {
181-
// reset choices
182-
$field['choices'] = array();
183-
$blog_posts = load_org_blog_posts();
190+
// reset choices
191+
$field['choices'] = array();
192+
$blog_posts = load_org_blog_posts();
184193

185-
foreach ($blog_posts as $post) {
186-
$field['choices'][$post->id] = $post->title->rendered;
187-
}
194+
foreach ( $blog_posts as $post ) {
195+
$field['choices'][ $post->id ] = $post->title->rendered;
196+
}
188197

189-
// return the field
190-
return $field;
198+
// return the field
199+
return $field;
191200
}
192201

193-
add_filter('acf/load_field/name=blog_posts', 'acf_load_blog_posts');
202+
add_filter( 'acf/load_field/name=blog_posts', 'acf_load_blog_posts' );

inc/custom-post-types/queulat-cc-course-cpt-plugin/cc-course-cpt-plugin.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
*/
1111

1212
function Cc_Course_Post_Type_register_post_type() {
13-
require_once __DIR__ . '/class-cc-course-post-type.php';
13+
include_once __DIR__ . '/class-cc-course-post-type.php';
1414
Cc_Course_Post_Type::activate_plugin();
15-
require_once __DIR__ . '/class-cc-course-post-type.php';
16-
require_once __DIR__ . '/class-cc-course-post-query.php';
17-
require_once __DIR__ . '/class-cc-course-post-object.php';
15+
include_once __DIR__ . '/class-cc-course-post-type.php';
16+
include_once __DIR__ . '/class-cc-course-post-query.php';
17+
include_once __DIR__ . '/class-cc-course-post-object.php';
1818
// require_once __DIR__ . '/class-cc-course-metabox.php';
1919
}
2020

inc/custom-post-types/queulat-cc-course-cpt-plugin/class-cc-course-metabox.php

+13-12
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,36 @@
77

88
class Course_Metabox extends Metabox {
99

10+
1011
public function __construct( $id = '', $title = '', $post_type = '', array $args = array() ) {
1112
parent::__construct( $id, $title, $post_type, $args );
1213
}
1314
public function get_fields(): array {
14-
return [
15+
return array(
1516
Node_Factory::make(
1617
Input_Text::class,
17-
[
18+
array(
1819
'name' => 'duration',
1920
'label' => 'Course duration',
20-
'attributes' => [
21+
'attributes' => array(
2122
'class' => 'regular-text',
22-
],
23-
]
23+
),
24+
)
2425
),
2526
Node_Factory::make(
2627
Input_Text::class,
27-
[
28+
array(
2829
'name' => 'language',
2930
'label' => 'Course Language',
30-
'attributes' => [
31+
'attributes' => array(
3132
'class' => 'regular-text',
32-
],
33-
]
33+
),
34+
)
3435
),
35-
];
36+
);
3637
}
3738
public function sanitize_data( array $data ): array {
38-
$sanitized = [];
39+
$sanitized = array();
3940
foreach ( $data as $key => $val ) {
4041
switch ( $key ) {
4142
case 'duration':
@@ -48,4 +49,4 @@ public function sanitize_data( array $data ): array {
4849
}
4950
}
5051

51-
new Course_Metabox( 'course', 'Course Related Data', 'cc_course', [ 'context' => 'normal' ] );
52+
new Course_Metabox( 'course', 'Course Related Data', 'cc_course', array( 'context' => 'normal' ) );

inc/custom-post-types/queulat-cc-course-cpt-plugin/class-cc-course-post-object.php

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
class Cc_Course_Post_Object extends Post_Object {
66

7+
78
}

inc/custom-post-types/queulat-cc-course-cpt-plugin/class-cc-course-post-query.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
use Queulat\Post_Query;
44

55
class Cc_Course_Post_Query extends Post_Query {
6+
67
public function get_post_type() : string {
78
return 'cc_course';
89
}
910
public function get_decorator() : string {
1011
return Cc_Course_Post_Object::class;
1112
}
1213
public function get_default_args() : array {
13-
return [];
14+
return array();
1415
}
1516
}

0 commit comments

Comments
 (0)