PluginProbe
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe / trunk
Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe vtrunk
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 / Help / HelpUi.php

HelpUi.php in Stripe Payment Forms by WP Simple Pay – Accept Credit Card Payments + Subscriptions with Stripe trunk, at src/Help/HelpUi.php

146 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin help: UI
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.6
10 */
11
12 namespace SimplePay\Core\Help;
13
14 use SimplePay\Core\EventManagement\SubscriberInterface;
15 use SimplePay\Core\License\LicenseAwareInterface;
16 use SimplePay\Core\License\LicenseAwareTrait;
17
18 /**
19 * HelpUi class.
20 *
21 * @since 4.4.6
22 */
23 class HelpUi implements SubscriberInterface, LicenseAwareInterface {
24
25 use LicenseAwareTrait;
26
27 /**
28 * Documentation context.
29 *
30 * @since 4.4.6
31 * @var \SimplePay\Core\Help\HelpDocsContext
32 */
33 private $context;
34
35 /**
36 * HelpUi.
37 *
38 * @since 4.4.6
39 *
40 * @param \SimplePay\Core\Help\HelpDocsContext $context Documentation context.
41 */
42 public function __construct( HelpDocsContext $context ) {
43 $this->context = $context;
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function get_subscribed_events() {
50 return array(
51 'simpay_admin_branding_bar_actions' => 'output',
52 );
53 }
54
55 /**
56 * Enqueues remote help scripts and styles, creating the UI.
57 *
58 * @since 4.4.6
59 *
60 * @return void
61 */
62 public function output() {
63 if ( is_admin() ) {
64 global $pagenow;
65
66 if ( 'edit.php' === $pagenow && isset( $_GET['page'] ) && 'simpay-setup-wizard' === $_GET['page'] ) {
67 return;
68 }
69 }
70 $docs = $this->context->get_all_docs();
71
72 wp_enqueue_style(
73 'simpay-admin-help',
74 SIMPLE_PAY_INC_URL . 'core/assets/css/simpay-admin-help.min.css',
75 array(
76 'wp-components',
77 ),
78 SIMPLE_PAY_VERSION
79 );
80
81 if ( empty( $docs ) ) {
82 $search_term = $this->context->get_search_term();
83
84 if ( '' === $search_term ) {
85 $url = 'https://wpsimplepay.com/docs/';
86 } else {
87 $url = add_query_arg(
88 array(
89 's' => $this->context->get_search_term(),
90 'docs' => '1',
91 ),
92 'https://wpsimplepay.com/docs/'
93 );
94 }
95
96 $url = simpay_ga_url( $url, 'help', 'Help' );
97
98 echo '<div id="simpay-branding-bar-help"><a href="' . esc_url( $url ) . '" target="_blank" class="simpay-branding-bar__actions-button"><svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.6665 10.0001c0-4.60002 3.73334-8.33335 8.33334-8.33335 4.59996 0 8.33336 3.73333 8.33336 8.33335 0 4.6-3.7334 8.3333-8.33336 8.3333-4.6 0-8.33334-3.7333-8.33334-8.3333Zm9.1667 3.3333v1.6667H9.1665v-1.6667h1.6667Zm-.83336 3.3333c-3.675 0-6.66667-2.9916-6.66667-6.6666 0-3.67502 2.99167-6.66669 6.66667-6.66669 3.67496 0 6.66666 2.99167 6.66666 6.66669 0 3.675-2.9917 6.6666-6.66666 6.6666ZM6.6665 8.33341c0-1.84166 1.49167-3.33333 3.33334-3.33333 1.84166 0 3.33336 1.49167 3.33336 3.33333 0 1.0691-.6584 1.64444-1.2994 2.20459-.6081.5315-1.2006 1.0493-1.2006 1.9621H9.1665c0-1.5177.7851-2.1195 1.4754-2.64862.5415-.41506 1.0246-.78539 1.0246-1.51807 0-.91666-.75-1.66666-1.66666-1.66666-.91667 0-1.66667.75-1.66667 1.66666H6.6665Z" fill="currentColor"/></svg></a></div>';
99 return;
100 }
101
102 $asset_file = SIMPLE_PAY_INC . 'core/assets/js/dist/simpay-admin-help.asset.php';
103
104 // Show an icon and link to external docs.
105 if ( ! file_exists( $asset_file ) ) {
106 return;
107 }
108
109 $asset_data = require $asset_file;
110
111 wp_enqueue_script(
112 'simpay-admin-help',
113 SIMPLE_PAY_INC_URL . 'core/assets/js/dist/simpay-admin-help.js',
114 $asset_data['dependencies'],
115 $asset_data['version'],
116 true
117 );
118
119 $seen_help = get_option( 'simpay_has_seen_help_icon', false );
120
121 wp_localize_script(
122 'simpay-admin-help',
123 'simpayHelp',
124 array(
125 'hasSeen' => $seen_help ? 1 : 0,
126 'isLite' => $this->license->is_lite() ? 1 : 0,
127 'docs' => $this->context->get_all_docs(),
128 'docsSearchTerm' => $this->context->get_search_term(),
129 'docsCategories' => $this->context->get_search_categories(),
130 )
131 );
132
133 wp_set_script_translations(
134 'simpay-admin-help',
135 'stripe',
136 SIMPLE_PAY_DIR . '/languages'
137 );
138
139 if ( ! $seen_help ) {
140 update_option( 'simpay_has_seen_help_icon', true );
141 }
142
143 echo '<div id="simpay-branding-bar-help"></div>';
144 }
145 }
146