PluginProbe
wpForo Forum / 3.2.1
wpForo Forum v3.2.1
3.2.1 3.2.0 3.1.7 3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 All 141 releases
wpforo / admin / pages / license / src / AdminPage.php

AdminPage.php in wpForo Forum 3.2.1, at admin/pages/license/src/AdminPage.php

131 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace gVectors\License;
4
5 // Exit if accessed directly
6 if( ! defined( 'ABSPATH' ) ) exit;
7
8 /**
9 * Admin UI: enqueues admin CSS/JS and renders the addon store page.
10 */
11 class AdminPage {
12 private $config;
13
14 public function __construct( Config $config ) {
15 $this->config = $config;
16 $this->init_hooks();
17 }
18
19 private function init_hooks() {
20 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
21 add_action( $this->config->get_dashboard_menu_hook(), function( $parent_slug ) {
22 add_submenu_page(
23 $parent_slug,
24 __( 'Addons', 'gvectors' ),
25 __( 'Addons', 'gvectors' ),
26 'activate_plugins',
27 $this->config->get_dashboard_addons_page_slug(),
28 function() {
29 $this->render_store_page();
30 }
31 );
32 } );
33 }
34
35 /**
36 * Render the addon store page (called from admin/pages/addons.php replacement or new page)
37 */
38 private function render_store_page(): void {
39 if( ! current_user_can( 'activate_plugins' ) ) return;
40 $slug = $this->config->get_core_plugin_slug();
41 require __DIR__ . '/../admin/store-page.php';
42 }
43
44 /**
45 * Enqueue admin assets only on gVectors admin pages
46 */
47 public function enqueue_assets( $hook ): void {
48 if( strpos( $hook, $this->config->get_core_plugin_slug() ) === false ) return;
49
50 $slug = $this->config->get_core_plugin_slug();
51 $module_url = $this->config->get_license_module_url() . '/admin/assets';
52 $module_dir = __DIR__ . '/../admin/assets';
53
54 // Module CSS (handle prefixed per plugin to avoid dedup conflicts)
55 wp_enqueue_style(
56 $slug . '-gvlicense-admin',
57 $module_url . '/css/admin.css',
58 [],
59 filemtime( $module_dir . '/css/admin.css' )
60 );
61
62 // Module JS (handle prefixed per plugin to avoid dedup conflicts)
63 wp_enqueue_script(
64 $slug . '-gvlicense-admin',
65 $module_url . '/js/admin.js',
66 [ 'jquery', 'wp-util' ],
67 filemtime( $module_dir . '/js/admin.js' ),
68 true
69 );
70
71 // Pass config to JS (global name prefixed per plugin: e.g. wpforoLicense, wpdiscuzLicense)
72 wp_localize_script( $slug . '-gvlicense-admin', $slug . 'License', [
73 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
74 'nonce' => wp_create_nonce( $slug . '_gvectors_nonce' ),
75 'ajaxPrefix' => $slug . '_gvectors_',
76 'proxy_server_url' => $this->config->get_proxy_server_url(),
77 'checkout_loading_url' => $this->config->get_proxy_checkout_loading_url(),
78 'checkout_url' => $this->config->get_proxy_checkout_base_url(),
79 'siteDomain' => LicenseModule::get_site_domain(),
80 'i18n' => [
81 'loading' => __( 'Loading...', 'gvectors' ),
82 'buy' => __( 'Buy Now', 'gvectors' ),
83 'startTrial' => __( 'Start Free Trial', 'gvectors' ),
84 'activateLicense' => __( 'Activate License', 'gvectors' ),
85 'deactivateLicense' => __( 'Deactivate', 'gvectors' ),
86 'install' => __( 'Install', 'gvectors' ),
87 'activate' => __( 'Activate', 'gvectors' ),
88 'installed' => __( 'Installed', 'gvectors' ),
89 'active' => __( 'Active', 'gvectors' ),
90 'expired' => __( 'Expired', 'gvectors' ),
91 'trial' => __( 'Trial', 'gvectors' ),
92 'cancelled' => __( 'Cancelled', 'gvectors' ),
93 'enterLicenseKey' => __( 'Enter license key', 'gvectors' ),
94 'enterKeyOrId' => __( 'Enter license key or transaction ID', 'gvectors' ),
95 'activatingByDomain' => __( 'Searching for licenses registered to this domain...', 'gvectors' ),
96 'noLicensesFound' => __( 'No licenses found for this domain', 'gvectors' ),
97 'confirmCancel' => __( 'Are you sure you want to cancel this subscription?', 'gvectors' ),
98 'processing' => __( 'Processing...', 'gvectors' ),
99 'success' => __( 'Success!', 'gvectors' ),
100 'error' => __( 'Error', 'gvectors' ),
101 'perMonth' => __( '/month', 'gvectors' ),
102 'perYear' => __( '/year', 'gvectors' ),
103 'oneTime' => __( 'one-time', 'gvectors' ),
104 'manageSubscription' => __( 'Manage Subscription', 'gvectors' ),
105 'updatePayment' => __( 'Update Payment Method', 'gvectors' ),
106 'cancelSubscription' => __( 'Cancel Subscription', 'gvectors' ),
107 'pauseSubscription' => __( 'Pause Subscription', 'gvectors' ),
108 'resumeSubscription' => __( 'Resume Subscription', 'gvectors' ),
109 'refreshProducts' => __( 'Refresh', 'gvectors' ),
110 'noProducts' => __( 'No products available at this time.', 'gvectors' ),
111 'checkoutError' => __( 'Checkout could not be opened. Please try again.', 'gvectors' ),
112 'downloadZip' => __( 'Download ZIP', 'gvectors' ),
113 'downloadStarted' => __( 'Your download has started.', 'gvectors' ),
114 'manualInstallTitle' => __( 'Manual Installation', 'gvectors' ),
115 'manualInstallIntro' => __( 'WordPress can\'t install plugins on this site, so install this addon manually:', 'gvectors' ),
116 'manualInstallHow' => __( 'To install this addon manually:', 'gvectors' ),
117 'manualStepDownload' => __( 'Download the addon ZIP file.', 'gvectors' ),
118 /* translators: %s: addon folder name */
119 'manualStepUnzip' => __( 'Unzip it on your computer. You will get a folder named %s.', 'gvectors' ),
120 'manualStepUpload' => __( 'Upload the whole folder to wp-content/plugins/ on your server via FTP/SFTP. Use binary transfer mode and make sure the hidden .addon-signatures.json file is uploaded too (enable "show hidden files" in your FTP client) — without it the addon is treated as modified.', 'gvectors' ),
121 'manualStepActivate' => __( 'Reload this page and click "Activate" on the addon (or activate it on the Plugins page).', 'gvectors' ),
122 'manualInstallNote' => __( 'The ZIP is signed for this website only.', 'gvectors' ),
123 'manualUpdatesNotice' => __( 'While WordPress can\'t install plugins on this site, new addon releases can\'t be delivered through the standard WordPress update process.', 'gvectors' ),
124 'manualRecommendTitle' => __( 'Recommended — get updates immediately:', 'gvectors' ),
125 'manualRecommend' => __( 'restore the default WordPress permissions and let the built-in WordPress updater do the work. Remove DISALLOW_FILE_MODS from wp-config.php (or set it to false) and make sure WordPress can write to wp-content/plugins/ — your hosting provider can help with that. New versions then appear in Dashboard → Updates as soon as they are released and install with one click, like any other plugin, while your license is active.', 'gvectors' ),
126 'manualRecommendTip' => __( 'Tip: if you only want to block code editing in the dashboard, DISALLOW_FILE_EDIT does that without blocking updates.', 'gvectors' ),
127 ],
128 ] );
129 }
130 }
131