PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.6
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.6
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / inc / page-builders / bricks / elements / payment-history-widget.php
sureforms / inc / page-builders / bricks / elements Last commit date
form-widget.php 2 months ago payment-history-widget.php 4 weeks ago
payment-history-widget.php
132 lines
1 <?php
2 /**
3 * Bricks SureForms Payment History element.
4 *
5 * @package sureforms.
6 * @since 2.12.2
7 */
8
9 namespace SRFM\Inc\Page_Builders\Bricks\Elements;
10
11 use SRFM\Inc\Payments\Payment_History_Shortcode;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 /**
18 * SureForms Bricks element that displays the Payment History (parity with the srfm/payment-history block).
19 *
20 * @since 2.12.2
21 */
22 class Payment_History_Widget extends \Bricks\Element {
23 /**
24 * Element category.
25 *
26 * @var string
27 */
28 public $category = 'sureforms';
29
30 /**
31 * Element name.
32 *
33 * @var string
34 */
35 public $name = 'sureforms-payment-history';
36
37 /**
38 * Element icon.
39 *
40 * @var string
41 */
42 public $icon = 'ti-wallet';
43
44 /**
45 * Get element label.
46 *
47 * @since 2.12.2
48 * @return string element label.
49 */
50 public function get_label() {
51 return __( 'Payment History', 'sureforms' );
52 }
53
54 /**
55 * Get element keywords.
56 *
57 * @since 2.12.2
58 * @return array<string> element keywords.
59 */
60 public function get_keywords() {
61 return [
62 'sureforms',
63 'payment',
64 'payment history',
65 'subscription',
66 ];
67 }
68
69 /**
70 * Enqueue the payment-history stylesheet. NOTE: Bricks fires this at render time
71 * (`Frontend::render_element()` → `Element::init()`), which runs after `wp_head`, so
72 * this alone would print the CSS in the footer → FOUC. The head-load is handled
73 * separately by `Service_Provider::maybe_enqueue_payment_history_assets()`, which
74 * detects this element on `wp_enqueue_scripts`; this override stays only as a
75 * belt-and-braces fallback. The handle is registered by
76 * `Payment_History_Shortcode::register_assets()` (priority 1).
77 *
78 * @since 2.12.3
79 * @return void
80 */
81 public function enqueue_scripts() {
82 wp_enqueue_style( 'srfm-payment-history' );
83 }
84
85 /**
86 * Set element controls.
87 *
88 * @since 2.12.2
89 * @return void
90 */
91 public function set_controls() {
92 $this->controls['per_page'] = [
93 'tab' => 'content',
94 'label' => __( 'Items per page', 'sureforms' ),
95 'type' => 'number',
96 'min' => 1,
97 'default' => 10,
98 ];
99
100 $this->controls['show_subscription'] = [
101 'tab' => 'content',
102 'label' => __( 'Show Subscriptions', 'sureforms' ),
103 'type' => 'checkbox',
104 'default' => true,
105 ];
106 }
107
108 /**
109 * Render the element output.
110 *
111 * Delegates to the Payment_History_Shortcode, mirroring the Gutenberg block.
112 *
113 * @since 2.12.2
114 * @return void
115 */
116 public function render() {
117 $per_page = absint( $this->settings['per_page'] ?? 10 );
118 if ( $per_page <= 0 ) {
119 $per_page = 10;
120 }
121
122 $atts = [
123 'per_page' => strval( $per_page ),
124 'show_subscription' => ! empty( $this->settings['show_subscription'] ) ? 'true' : 'false',
125 ];
126
127 echo '<div ' . $this->render_attributes( '_root' ) . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_attributes() returns escaped attributes.
128 echo Payment_History_Shortcode::get_instance()->render( $atts ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is escaped within the shortcode renderer.
129 echo '</div>';
130 }
131 }
132