WPInv_Meta_Box_Payment_Form::output_details()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
c 0
b 0
f 0
nc 4
nop 1
dl 0
loc 20
rs 9.9332
1
<?php
2
// MUST have WordPress.
3
if ( ! defined( 'WPINC' ) ) {
4
    exit;
5
}
6
7
class WPInv_Meta_Box_Payment_Form {
8
9
    /**
10
     * Output payment form details.
11
     *
12
     * @param WP_Post $post
13
     */
14
    public static function output_details( $post ) {
15
        $details = get_post_meta( $post->ID, 'payment_form_data', true );
16
17
        if ( ! is_array( $details ) ) {
18
            return;
19
        }
20
21
        echo '<div class="bsui"> <div class="form-row row">';
22
23
        foreach ( $details as $key => $value ) {
24
            $key = esc_html( $key );
25
26
            if ( is_array( $value ) ) {
27
                $value = implode( ',', $value );
28
            }
29
30
            echo wp_kses_post( "<div class='col-12'><strong>$key:</strong></div><div class='col-12 form-group mb-3'>$value</div>" );
31
        }
32
33
        echo '</div></div>';
34
35
    }
36
37
    /**
38
     * Output fields.
39
     *
40
     * @param WP_Post $post
41
     */
42
    public static function output_shortcode( $post ) {
43
44
        if ( ! is_numeric( $post ) ) {
0 ignored issues
show
introduced by
The condition is_numeric($post) is always false.
Loading history...
45
            $post = $post->ID;
46
        }
47
48
        if ( $post == wpinv_get_default_payment_form() ) {
49
            echo '&mdash;';
50
            return;
51
        }
52
53
        echo "<input type='text' style='min-width: 220px;' value='[getpaid form=" . absint( $post ) . "]' disabled>";
54
55
    }
56
57
}
58
59