PluginProbe
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe / 4.7.7
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe v4.7.7
4.17.3 trunk 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 4.10.0 4.11.1 4.12.2 4.14.1 4.14.2 4.14.3 4.15.0 4.16.0 All 59 releases
stripe / src / FormPreview / FormPreviewOutput.php

FormPreviewOutput.php in Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe 4.7.7, at src/FormPreview/FormPreviewOutput.php

94 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Form preview: Output
4 *
5 * @package SimplePay
6 * @subpackage Core
7 * @copyright Copyright (c) 2022, Sandhills Development, LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 4.4.2
10 */
11
12 namespace SimplePay\Core\FormPreview;
13
14 use SimplePay\Core\EventManagement\SubscriberInterface;
15
16 /**
17 * FormPreviewOutput class.
18 *
19 * @since 4.4.2
20 */
21 class FormPreviewOutput implements SubscriberInterface {
22
23 /**
24 * {@inheritdoc}
25 */
26 public function get_subscribed_events() {
27 return array(
28 'init' => 'maybe_output_preview',
29 );
30 }
31
32 /**
33 * Outputs a payment form preview if the requested URL is correct.
34 *
35 * @since 4.4.2
36 *
37 * @return void
38 */
39 public function maybe_output_preview() {
40 if ( ! isset( $_GET['simpay-preview'] ) ) {
41 return;
42 }
43
44 if ( ! current_user_can( 'manage_options' ) ) {
45 wp_die(
46 esc_html__(
47 'You do not have permission to preview this payment form.',
48 'stripe'
49 )
50 );
51 }
52
53 $id = absint( $_GET['simpay-preview'] );
54 $form = simpay_get_form( $id );
55
56 if ( false === $form ) {
57 wp_safe_redirect(
58 add_query_arg(
59 array(
60 'post_type' => 'simple-pay',
61 ),
62 admin_url( 'edit.php' )
63 )
64 );
65 exit;
66 }
67
68 $edit_form_url = add_query_arg(
69 array(
70 'post' => $id,
71 'action' => 'edit',
72 ),
73 admin_url( 'post.php' )
74 );
75
76 $payment_page_enabled = get_post_meta( $id, '_enable_payment_page', true );
77 $payment_page_url = 'yes' === $payment_page_enabled
78 ? get_permalink( $id )
79 : '';
80
81 wp_enqueue_script( 'clipboard' );
82 wp_enqueue_script( 'wp-a11y' );
83 wp_enqueue_style( 'dashicons' );
84
85 wp_head();
86 ?>
87
88 <?php
89 include_once SIMPLE_PAY_DIR . '/views/admin-form-preview-output.php'; // @phpstan-ignore-line
90 exit;
91 }
92
93 }
94