sdk = is_object($sdk) ? $sdk : null; add_action('pcwp_settings_license', [$this, 'summary']); if ($this->sdk !== null) { $this->sdk->add_filter('show_admin_notice', static function (bool $show, array $notice): bool { return ($_GET['page'] ?? '') === 'pcwp-settings' && in_array($notice['id'] ?? '', ['connect_account', 'premium_activated'], true) ? false : $show; }, 10, 2); $this->sdk->add_filter('connect_url', static fn (string $url): string => add_query_arg('pcwp_connect', '1', $url)); $this->sdk->add_filter('after_connect_url', static fn (): string => SettingsPage::url('license-ai')); $this->sdk->add_filter('after_skip_url', static fn (): string => SettingsPage::url()); $back = static fn (string $html): string => '
' . esc_html__('← Back to License & AI', 'proeventswp') . '
' . $html; $this->sdk->add_filter('templates/account.php', $back); $this->sdk->add_filter('templates/connect.php', $back); } add_action('admin_menu', function (): void { if ($this->sdk !== null) { add_submenu_page('edit.php?post_type=pcwp_event', __('Connection and license', 'proeventswp'), __('Connection and license', 'proeventswp'), 'manage_options', 'pcwp-connection', [$this, 'connection']); } }); } public function summary(): void { if (! current_user_can('manage_options')) { return; } $registered = $this->sdk !== null && $this->sdk->is_registered(); $active = $this->canReceiveUpdates(); $status = $registered ? ($active ? __('Connected · Active Pro license', 'proeventswp') : __('Connected · No active Pro license', 'proeventswp')) : __('Not connected', 'proeventswp'); $license = $registered ? $this->sdk->_get_license() : null; $expiryMessage = __('License term: lifetime.', 'proeventswp'); if ($active && is_object($license) && ! empty($license->expiration)) { /* translators: %s is the license expiry date formatted using the site date format. */ $expiryMessage = sprintf(__('License access until %s (UTC).', 'proeventswp'), wp_date(get_option('date_format'), (int) strtotime($license->expiration), new \DateTimeZone('UTC'))); } ?>' . esc_html__('Free event features work without a connection. Connect to manage your Pro license and account.', 'proeventswp') . '
'; if (method_exists($this->sdk, $method)) { echo '' . esc_html($registered ? __('Manage account', 'proeventswp') : __('Connect', 'proeventswp')) . ''; } echo '