*/ public function report(): array { global $wpdb; $scheduler = \Submex\Plugin::instance()->get( 'scheduler' ); $gateways = \Submex\Plugin::instance()->get( 'gateways' ); $migrator = new Migrator(); $rows = array( 'Submex' => defined( 'SUBMEX_VERSION' ) ? SUBMEX_VERSION : '?', 'Submex Pro' => defined( 'SUBMEX_PRO_VERSION' ) ? SUBMEX_PRO_VERSION : __( 'not installed', 'submex' ), 'WordPress' => get_bloginfo( 'version' ), 'WooCommerce' => defined( 'WC_VERSION' ) ? WC_VERSION : '?', 'PHP' => PHP_VERSION, 'MySQL' => $wpdb->db_version(), 'Theme' => wp_get_theme()->get( 'Name' ) . ' ' . wp_get_theme()->get( 'Version' ), 'Locale' => get_locale(), 'Currency' => get_woocommerce_currency(), 'Timezone' => wp_timezone_string(), 'HPOS' => $this->hpos() ? 'yes' : 'no', 'Site URL' => (string) get_option( 'siteurl' ), ); $rows['Renewal queue'] = $scheduler instanceof Renewal_Scheduler && $scheduler->queue_is_healthy() ? 'healthy' : 'overdue tasks'; $rows['Charge ledger'] = $migrator->charge_slot_guard_intact() ? 'unique index present' : 'MISSING'; $rows['Subscriptions'] = (string) count( Subscription_Query::ids( array( 'limit' => -1, 'status' => null, ) ) ); if ( $gateways instanceof Gateway_Registry ) { $ids = array(); foreach ( $gateways->all() as $gateway ) { $ids[] = $gateway->id(); } $rows['Recurring gateways'] = $ids ? implode( ', ', $ids ) : 'none registered'; } /** * Filter the rows of the support report. * * Never add anything secret: merchants paste this into public forums. * * @param array $rows */ return (array) apply_filters( 'submex_support_report', $rows ); } /** * Every tile lands somewhere inside this site: documentation links would 404 until the docs are public. * * @return array */ public function tiles(): array { return array( array( 'icon' => '1', 'title' => __( 'Run the setup checks', 'submex' ), 'body' => __( 'Home runs a real renewal end to end without charging anyone. If renewals are the problem, that test usually says why.', 'submex' ), 'label' => __( 'Open Home', 'submex' ), 'url' => admin_url( 'admin.php?page=' . Menu::SLUG ), ), array( 'icon' => '2', 'title' => __( 'Read the activity log', 'submex' ), 'body' => __( 'Every subscription records each charge attempt and status change, with the reason. Open one and scroll to Activity.', 'submex' ), 'label' => __( 'All subscriptions', 'submex' ), 'url' => admin_url( 'admin.php?page=' . Menu::LIST_SLUG ), ), array( 'icon' => '3', 'title' => __( 'Check renewal health', 'submex' ), 'body' => __( 'Settings shows whether the renewal queue is running, any charge whose outcome is unknown, and the double-charge safeguard.', 'submex' ), 'label' => __( 'Open settings', 'submex' ), 'url' => admin_url( 'admin.php?page=wc-settings&tab=submex' ), ), ); } /** * The report as the text a merchant pastes. * * @param array $report */ public static function report_text( array $report ): string { $text = ''; foreach ( $report as $label => $value ) { $text .= $label . ': ' . $value . "\n"; } return $text; } public function render(): void { if ( ! current_user_can( Menu::CAPABILITY ) ) { wp_die( esc_html__( 'You do not have permission to manage subscriptions.', 'submex' ) ); } App_Host::start( self::SLUG ); $this->render_screen(); App_Host::end(); } private function render_screen(): void { $report = $this->report(); $text = self::report_text( $report ); Page_Shell::open( __( 'Help', 'submex' ), __( 'Where to look first, and the report to send if you still need a hand.', 'submex' ) ); echo '

' . esc_html__( 'Check these first', 'submex' ) . '

'; echo '
'; foreach ( $this->tiles() as $tile ) { printf( '

%s

%s

', esc_html( $tile['icon'] ), esc_html( $tile['title'] ), esc_html( $tile['body'] ), esc_url( $tile['url'] ), esc_html( $tile['label'] ) ); } echo '
'; echo '

' . esc_html__( 'System report', 'submex' ) . '

'; echo '
'; echo '

' . esc_html__( 'Paste this into your support request. It contains no keys and no customer data.', 'submex' ) . '

'; printf( '
', esc_attr__( 'Copied', 'submex' ), esc_html__( 'Copy report', 'submex' ) ); printf( '', (int) min( 24, count( $report ) + 1 ), esc_textarea( $text ) ); echo '
'; Page_Shell::close(); } private function hpos(): bool { if ( ! class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) { return false; } return \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); } }