-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass-meta-boxes.php
More file actions
70 lines (54 loc) · 1.75 KB
/
Copy pathclass-meta-boxes.php
File metadata and controls
70 lines (54 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Add custom meta boxes to GF entries
* Stores & display data around the API call to Fishbowl
* Includes the JSON payload that was sent to Fishbowl, and the API response code & message
*/
namespace GF_Fishbowl;
class Meta_Boxes {
public function __construct() {
add_filter( 'gform_entry_detail_meta_boxes', [ $this, 'register_meta_box' ], 10, 3 );
}
public function register_meta_box( $meta_boxes, $entry, $form ) {
$meta_boxes['fishbowl_meta_box'] = [
'title' => 'Fishbowl Meta Data',
'context' => 'side',
'callback' => [ $this, 'add_fishbowl_meta_box' ],
];
return $meta_boxes;
}
public function add_fishbowl_meta_box( $args ) {
$entry_id = $args['entry']['id'];
$response_code = gform_get_meta( $entry_id, 'fishbowl_response_code' );
$response_message = gform_get_meta( $entry_id, 'fishbowl_response_message' );
// Request data can be in two variables.
$request_data = gform_get_meta( $entry_id, 'fishbowl_request_data' );
$request_data_json = gform_get_meta( $entry_id, 'fishbowl_request_data_json' );
echo '<ul>';
if ( ! empty( $response_code ) ) {
printf(
'<li><strong>Fishbowl Response Code:</strong> <br>%s</li>',
esc_html( $response_code )
);
}
if ( ! empty( $response_message ) ) {
printf(
'<li><strong>Fishbowl Response Message:</strong> <br>%s</li>',
esc_html( $response_message )
);
}
if ( ! empty( $request_data ) ) {
printf(
'<li><strong>PHP Processing Data:</strong> <br><pre>%s</pre></li>',
esc_html( print_r( $request_data, TRUE ) )
);
}
if ( ! empty( $request_data_json ) ) {
printf(
'<li><strong>JSON Payload Sent to Fishbowl:</strong> <br><pre>%s</pre></li>',
esc_html($request_data_json )
);
}
echo '</ul>';
}
}