SubscriptionForm.php
28 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\Newsletter; |
| 4 | |
| 5 | use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable; |
| 6 | |
| 7 | class SubscriptionForm implements Hookable { |
| 8 | |
| 9 | public function hooks(): void { |
| 10 | add_action( 'admin_footer', [ $this, 'add_newsletter_form' ] ); |
| 11 | } |
| 12 | |
| 13 | public function add_newsletter_form() { |
| 14 | if ( isset( $_GET['page'], $_GET['tab'], $_GET['section'] ) && $_GET['page'] === 'wc-settings' && $_GET['tab'] === 'shipping' && $_GET['section'] === 'flexible_shipping_info' ) { |
| 15 | $shipping_analytics_banner_end_date = new \DateTimeImmutable( '2026-06-20 00:00:00', wp_timezone() ); |
| 16 | $show_shipping_analytics_banner = current_datetime() < $shipping_analytics_banner_end_date; |
| 17 | $email = ''; |
| 18 | |
| 19 | if ( ! $show_shipping_analytics_banner ) { |
| 20 | $email = wp_get_current_user()->user_email ?? ''; |
| 21 | } |
| 22 | |
| 23 | require_once __DIR__ . '/views/newsletter-form.php'; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | } |
| 28 |