Skip to content

Commit 634cd69

Browse files
committed
Fixed phpcs issues
1 parent de16566 commit 634cd69

File tree

3 files changed

+253
-30
lines changed

3 files changed

+253
-30
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"key": "group_672accc71e0c4",
3+
"title": "Supporter fields",
4+
"fields": [
5+
{
6+
"key": "field_672accc74e66e",
7+
"label": "Name",
8+
"name": "name",
9+
"aria-label": "",
10+
"type": "text",
11+
"instructions": "",
12+
"required": 0,
13+
"conditional_logic": 0,
14+
"wrapper": {
15+
"width": "",
16+
"class": "",
17+
"id": ""
18+
},
19+
"relevanssi_exclude": 0,
20+
"default_value": "",
21+
"maxlength": "",
22+
"allow_in_bindings": 0,
23+
"placeholder": "",
24+
"prepend": "",
25+
"append": ""
26+
},
27+
{
28+
"key": "field_672accd44e66f",
29+
"label": "Organization",
30+
"name": "organization",
31+
"aria-label": "",
32+
"type": "text",
33+
"instructions": "",
34+
"required": 0,
35+
"conditional_logic": 0,
36+
"wrapper": {
37+
"width": "",
38+
"class": "",
39+
"id": ""
40+
},
41+
"relevanssi_exclude": 0,
42+
"default_value": "",
43+
"maxlength": "",
44+
"allow_in_bindings": 0,
45+
"placeholder": "",
46+
"prepend": "",
47+
"append": ""
48+
},
49+
{
50+
"key": "field_672ad07b77def",
51+
"label": "Link",
52+
"name": "link",
53+
"aria-label": "",
54+
"type": "url",
55+
"instructions": "",
56+
"required": 0,
57+
"conditional_logic": 0,
58+
"wrapper": {
59+
"width": "",
60+
"class": "",
61+
"id": ""
62+
},
63+
"relevanssi_exclude": 0,
64+
"default_value": "",
65+
"allow_in_bindings": 0,
66+
"placeholder": ""
67+
},
68+
{
69+
"key": "field_672accda4e670",
70+
"label": "Quote",
71+
"name": "quote",
72+
"aria-label": "",
73+
"type": "textarea",
74+
"instructions": "",
75+
"required": 0,
76+
"conditional_logic": 0,
77+
"wrapper": {
78+
"width": "",
79+
"class": "",
80+
"id": ""
81+
},
82+
"relevanssi_exclude": 0,
83+
"default_value": "",
84+
"maxlength": "",
85+
"allow_in_bindings": 0,
86+
"rows": "",
87+
"placeholder": "",
88+
"new_lines": ""
89+
},
90+
{
91+
"key": "field_672ade5b950a0",
92+
"label": "Order",
93+
"name": "order",
94+
"aria-label": "",
95+
"type": "number",
96+
"instructions": "",
97+
"required": 0,
98+
"conditional_logic": 0,
99+
"wrapper": {
100+
"width": "",
101+
"class": "",
102+
"id": ""
103+
},
104+
"relevanssi_exclude": 0,
105+
"default_value": "",
106+
"min": "",
107+
"max": "",
108+
"allow_in_bindings": 0,
109+
"placeholder": "",
110+
"step": "",
111+
"prepend": "",
112+
"append": ""
113+
}
114+
],
115+
"location": [
116+
[
117+
{
118+
"param": "post_type",
119+
"operator": "==",
120+
"value": "supporter"
121+
}
122+
]
123+
],
124+
"menu_order": 0,
125+
"position": "normal",
126+
"style": "default",
127+
"label_placement": "top",
128+
"instruction_placement": "label",
129+
"hide_on_screen": "",
130+
"active": true,
131+
"description": "",
132+
"show_in_rest": 0,
133+
"modified": 1733133647
134+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"key": "post_type_672acc9b32c0c",
3+
"title": "Supporters",
4+
"menu_order": 0,
5+
"active": true,
6+
"post_type": "supporter",
7+
"advanced_configuration": true,
8+
"import_source": "",
9+
"import_date": "",
10+
"labels": {
11+
"name": "Supporters",
12+
"singular_name": "Supporter",
13+
"menu_name": "Supporters",
14+
"all_items": "All Supporters",
15+
"edit_item": "Edit Supporter",
16+
"view_item": "View Supporter",
17+
"view_items": "View Supporters",
18+
"add_new_item": "Add New Supporter",
19+
"add_new": "Add New Supporter",
20+
"new_item": "New Supporter",
21+
"parent_item_colon": "Parent Supporter:",
22+
"search_items": "Search Supporters",
23+
"not_found": "No supporters found",
24+
"not_found_in_trash": "No supporters found in Trash",
25+
"archives": "Supporter Archives",
26+
"attributes": "Supporter Attributes",
27+
"featured_image": "",
28+
"set_featured_image": "",
29+
"remove_featured_image": "",
30+
"use_featured_image": "",
31+
"insert_into_item": "Insert into supporter",
32+
"uploaded_to_this_item": "Uploaded to this supporter",
33+
"filter_items_list": "Filter supporters list",
34+
"filter_by_date": "Filter supporters by date",
35+
"items_list_navigation": "Supporters list navigation",
36+
"items_list": "Supporters list",
37+
"item_published": "Supporter published.",
38+
"item_published_privately": "Supporter published privately.",
39+
"item_reverted_to_draft": "Supporter reverted to draft.",
40+
"item_scheduled": "Supporter scheduled.",
41+
"item_updated": "Supporter updated.",
42+
"item_link": "Supporter Link",
43+
"item_link_description": "A link to a supporter."
44+
},
45+
"description": "",
46+
"public": true,
47+
"hierarchical": false,
48+
"exclude_from_search": false,
49+
"publicly_queryable": true,
50+
"show_ui": true,
51+
"show_in_menu": true,
52+
"admin_menu_parent": "",
53+
"show_in_admin_bar": true,
54+
"show_in_nav_menus": true,
55+
"show_in_rest": true,
56+
"rest_base": "",
57+
"rest_namespace": "wp\/v2",
58+
"rest_controller_class": "WP_REST_Posts_Controller",
59+
"menu_position": "",
60+
"menu_icon": {
61+
"type": "dashicons",
62+
"value": "dashicons-admin-post"
63+
},
64+
"rename_capabilities": false,
65+
"singular_capability_name": "post",
66+
"plural_capability_name": "posts",
67+
"supports": [
68+
"title",
69+
"thumbnail",
70+
"custom-fields"
71+
],
72+
"taxonomies": "",
73+
"has_archive": false,
74+
"has_archive_slug": "",
75+
"rewrite": {
76+
"permalink_rewrite": "custom_permalink",
77+
"slug": "supporter",
78+
"with_front": "1",
79+
"feeds": "0",
80+
"pages": "1"
81+
},
82+
"query_var": "post_type_key",
83+
"query_var_name": "",
84+
"can_export": true,
85+
"delete_with_user": false,
86+
"register_meta_box_cb": "",
87+
"enter_title_here": "",
88+
"modified": 1734435097
89+
}

themes/osi/functions.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -426,38 +426,38 @@ function osi_wpdc_comment_body( string $comment_body ) {
426426
}
427427
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );
428428

429-
/**
430-
* Create a new Supporter in ACF, based on a Contact Forms 7 submission.
431-
*/
432-
433-
add_action( 'wpcf7_before_send_mail', 'save_form_data_to_cpt' );
434-
435429
/**
436430
* Save form data to a custom post type.
437431
*
438432
* @param WPCF7_ContactForm $contact_form The Contact Form 7 instance.
433+
*
434+
* @return void
439435
*/
440-
function save_form_data_to_cpt( $contact_form ) {
441-
$submission = WPCF7_Submission::get_instance();
442-
443-
if ( $submission ) {
444-
$data = $submission->get_posted_data();
445-
446-
$post_id = wp_insert_post(
447-
array(
448-
'post_title' => $data['your-name'],
449-
'post_type' => 'supporter',
450-
'post_status' => 'pending',
451-
)
452-
);
453-
454-
if ( $post_id ) {
455-
update_field( 'name', $data['your-name'], $post_id );
456-
update_field( 'organization', $data['your-org'], $post_id );
457-
update_field( 'endorsement_type', $data['your-endorsement'], $post_id );
458-
update_field( 'quote', $data['your-message'], $post_id );
459-
} else {
460-
error_log( 'Failed to insert post for supporter.' );
461-
}
462-
}
463-
}
436+
function osi_save_form_data_to_cpt( WPCF7_ContactForm $contact_form ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
437+
$submission = WPCF7_Submission::get_instance();
438+
439+
if ( $submission ) {
440+
$data = $submission->get_posted_data();
441+
442+
$post_id = wp_insert_post(
443+
array(
444+
'post_title' => $data['your-name'],
445+
'post_type' => 'supporter',
446+
'post_status' => 'pending',
447+
)
448+
);
449+
450+
// If we have a wp_error, abort.
451+
if ( is_wp_error( $post_id ) ) {
452+
return;
453+
}
454+
455+
if ( $post_id ) {
456+
update_field( 'name', $data['your-name'], $post_id );
457+
update_field( 'organization', $data['your-org'], $post_id );
458+
update_field( 'endorsement_type', $data['your-endorsement'], $post_id );
459+
update_field( 'quote', $data['your-message'], $post_id );
460+
}
461+
}
462+
}
463+
add_action( 'wpcf7_before_send_mail', 'osi_save_form_data_to_cpt' );

0 commit comments

Comments
 (0)