PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / codeinwp / themeisle-sdk / src / Modules / About_us.php

About_us.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.11.10, at vendor/codeinwp/themeisle-sdk/src/Modules/About_us.php

444 lines 14.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The about page model class for ThemeIsle SDK
4 *
5 * Here's how to hook it in your plugin:
6 *
7 * add_filter( <product_slug>_about_us_metadata', 'add_about_meta' );
8 *
9 * function add_about_meta($data) {
10 * return [
11 * 'location' => <top level page - e.g. themes.php>,
12 * 'logo' => <logo url>,
13 * 'page_menu' => [['text' => '', 'url' => '']], // optional
14 * 'has_upgrade_menu' => <condition>,
15 * 'upgrade_link' => <url>,
16 * 'upgrade_text' => 'Get Pro Version',
17 * ]
18 * }
19 *
20 * @package ThemeIsleSDK
21 * @subpackage Modules
22 * @copyright Copyright (c) 2023, Andrei Baicus
23 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
24 * @since 3.2.42
25 */
26
27 namespace ThemeisleSDK\Modules;
28
29 use ThemeisleSDK\Common\Abstract_Module;
30 use ThemeisleSDK\Loader;
31 use ThemeisleSDK\Product;
32
33 // Exit if accessed directly.
34 if ( ! defined( 'ABSPATH' ) ) {
35 exit;
36 }
37
38 /**
39 * Promotions module for ThemeIsle SDK.
40 */
41 class About_Us extends Abstract_Module {
42 /**
43 * About data.
44 *
45 * @var array $about_data About page data, received from the filter.
46 *
47 * Shape of the $about_data property array:
48 * [
49 * 'location' => 'top level page',
50 * 'logo' => 'logo path',
51 * 'page_menu' => [['text' => '', 'url' => '']], // Optional
52 * 'has_upgrade_menu' => !defined('NEVE_PRO_VERSION'),
53 * 'upgrade_link' => 'upgrade url',
54 * 'upgrade_text' => 'Get Pro Version',
55 * ]
56 */
57 private $about_data = array();
58
59 /**
60 * Should we load this module.
61 *
62 * @param Product $product Product object.
63 *
64 * @return bool
65 */
66 public function can_load( $product ) {
67 if ( $this->is_from_partner( $product ) ) {
68 return false;
69 }
70
71 $this->about_data = apply_filters( $product->get_key() . '_about_us_metadata', array() );
72
73 return ! empty( $this->about_data );
74 }
75
76 /**
77 * Registers the hooks.
78 *
79 * @param Product $product Product to load.
80 */
81 public function load( $product ) {
82 $this->product = $product;
83
84 add_action( 'admin_menu', [ $this, 'add_submenu_pages' ] );
85 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_about_page_script' ] );
86 }
87
88 /**
89 * Adds submenu pages.
90 *
91 * @return void
92 */
93 public function add_submenu_pages() {
94 if ( ! isset( $this->about_data['location'] ) ) {
95 return;
96 }
97
98 add_submenu_page(
99 $this->about_data['location'],
100 Loader::$labels['about_us']['title'],
101 Loader::$labels['about_us']['title'],
102 'manage_options',
103 $this->get_about_page_slug(),
104 array( $this, 'render_about_us_page' ),
105 100
106 );
107
108 if ( ! isset( $this->about_data['has_upgrade_menu'] ) ) {
109 return;
110 }
111
112 if ( $this->about_data['has_upgrade_menu'] !== true ) {
113 return;
114 }
115
116 if ( ! isset( $this->about_data['upgrade_link'] ) ) {
117 return;
118 }
119
120 if ( ! isset( $this->about_data['upgrade_text'] ) ) {
121 return;
122 }
123
124 add_submenu_page(
125 $this->about_data['location'],
126 $this->about_data['upgrade_text'],
127 '<span class="tsdk-upg-menu-item">' . $this->about_data['upgrade_text'] . '</span>',
128 'manage_options',
129 $this->about_data['upgrade_link'],
130 '',
131 101
132 );
133 add_action(
134 'admin_footer',
135 function () {
136 ?>
137 <style>
138 .tsdk-upg-menu-item {
139 color: #009528;
140 }
141
142 .tsdk-upg-menu-item:hover {
143 color: #008a20;
144 }
145 </style>
146 <script type="text/javascript">
147 jQuery(document).ready(function ($) {
148 $('.tsdk-upg-menu-item').parent().attr('target', '_blank');
149 });
150 </script>
151 <?php
152 }
153 );
154 }
155
156 /**
157 * Render page content.
158 *
159 * @return void
160 */
161 public function render_about_us_page() {
162 echo '<div id="ti-sdk-about"></div>';
163 }
164
165 /**
166 * Enqueue scripts & styles.
167 *
168 * @return void
169 */
170 public function enqueue_about_page_script() {
171 $current_screen = get_current_screen();
172
173 if ( ! isset( $current_screen->id ) ) {
174 return;
175 }
176
177 if ( strpos( $current_screen->id, $this->get_about_page_slug() ) === false ) {
178 return;
179 }
180 global $themeisle_sdk_max_path;
181 $handle = 'ti-sdk-about-' . $this->product->get_key();
182 $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/about/about.asset.php';
183 $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] );
184
185 wp_register_script( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.js', $deps, $asset_file['version'], true );
186 wp_localize_script( $handle, 'tiSDKAboutData', $this->get_about_localization_data() );
187
188 wp_enqueue_script( $handle );
189 wp_enqueue_style( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.css', [ 'wp-components' ], $asset_file['version'] );
190 }
191
192 /**
193 * Get localized data.
194 *
195 * @return array
196 */
197 private function get_about_localization_data() {
198 $links = isset( $this->about_data['page_menu'] ) ? $this->about_data['page_menu'] : [];
199 $product_pages = isset( $this->about_data['product_pages'] ) ? $this->about_data['product_pages'] : [];
200
201 return [
202 'links' => $links,
203 'logoUrl' => $this->about_data['logo'],
204 'productPages' => $this->get_product_pages_data( $product_pages ),
205 'products' => $this->get_other_products_data(),
206 'homeUrl' => esc_url( home_url() ),
207 'pageSlug' => $this->get_about_page_slug(),
208 'currentProduct' => [
209 'slug' => $this->product->get_key(),
210 'name' => $this->product->get_name(),
211 ],
212 'teamImage' => $this->get_sdk_uri() . 'assets/images/team.jpg',
213 'strings' => [
214 'aboutUs' => Loader::$labels['about_us']['title'],
215 'heroHeader' => Loader::$labels['about_us']['heroHeader'],
216 'heroTextFirst' => Loader::$labels['about_us']['heroTextFirst'],
217 'heroTextSecond' => Loader::$labels['about_us']['heroTextSecond'],
218 'teamImageCaption' => Loader::$labels['about_us']['teamImageCaption'],
219 'newsHeading' => Loader::$labels['about_us']['newsHeading'],
220 'emailPlaceholder' => Loader::$labels['about_us']['emailPlaceholder'],
221 'signMeUp' => Loader::$labels['about_us']['signMeUp'],
222 'installNow' => Loader::$labels['about_us']['installNow'],
223 'activate' => Loader::$labels['about_us']['activate'],
224 'learnMore' => Loader::$labels['about_us']['learnMore'],
225 'installed' => Loader::$labels['about_us']['installed'],
226 'notInstalled' => Loader::$labels['about_us']['notInstalled'],
227 'active' => Loader::$labels['about_us']['active'],
228 ],
229 'canInstallPlugins' => current_user_can( 'install_plugins' ),
230 'canActivatePlugins' => current_user_can( 'activate_plugins' ),
231 ];
232 }
233
234 /**
235 * Get product pages data.
236 *
237 * @param array $product_pages Product pages.
238 *
239 * @return array
240 */
241 private function get_product_pages_data( $product_pages ) {
242
243 $otter_slug = 'otter-blocks';
244 $otter_plugin = [
245 'status' => 'not-installed',
246 ];
247 $otter_plugin['status'] = $this->is_plugin_installed( $otter_slug ) ? 'installed' : 'not-installed';
248 $otter_plugin['status'] = $this->is_plugin_active( $otter_slug ) ? 'active' : $otter_plugin['status'];
249 $otter_plugin['activationLink'] = $this->get_plugin_activation_link( $otter_slug );
250
251 $pages = [
252 'otter-page' => [
253 'name' => 'Otter Blocks',
254 'hash' => '#otter-page',
255 'product' => $otter_slug,
256 'plugin' => $otter_plugin,
257 'strings' => [
258 'heading' => Loader::$labels['about_us']['otter-page']['heading'],
259 'text' => Loader::$labels['about_us']['otter-page']['text'],
260 'buttons' => [
261 'install_otter_free' => Loader::$labels['about_us']['otter-page']['buttons']['install_otter_free'],
262 'install_now' => Loader::$labels['about_us']['otter-page']['buttons']['install_now'],
263 'learn_more' => Loader::$labels['about_us']['otter-page']['buttons']['learn_more'],
264 'learn_more_link' => tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/', 'otter-page', 'about-us' ),
265 ],
266 'features' => [
267 'advancedTitle' => Loader::$labels['about_us']['otter-page']['features']['advancedTitle'],
268 'advancedDesc' => Loader::$labels['about_us']['otter-page']['features']['advancedDesc'],
269 'fastTitle' => Loader::$labels['about_us']['otter-page']['features']['fastTitle'],
270 'fastDesc' => Loader::$labels['about_us']['otter-page']['features']['fastDesc'],
271 'mobileTitle' => Loader::$labels['about_us']['otter-page']['features']['mobileTitle'],
272 'mobileDesc' => Loader::$labels['about_us']['otter-page']['features']['mobileDesc'],
273 ],
274 'details' => [
275 's1Title' => Loader::$labels['about_us']['otter-page']['details']['s1Title'],
276 's1Text' => Loader::$labels['about_us']['otter-page']['details']['s1Text'],
277 's2Title' => Loader::$labels['about_us']['otter-page']['details']['s2Title'],
278 's2Text' => Loader::$labels['about_us']['otter-page']['details']['s2Text'],
279 's3Title' => Loader::$labels['about_us']['otter-page']['details']['s3Title'],
280 's3Text' => Loader::$labels['about_us']['otter-page']['details']['s3Text'],
281 's1Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-builder.png',
282 's2Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-patterns.png',
283 's3Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-library.png',
284 ],
285 'testimonials' => [
286 'heading' => Loader::$labels['about_us']['otter-page']['testimonials']['heading'],
287 'users' => [
288 [
289 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2021/05/avatar-03.png',
290 'name' => 'Michael Burry',
291 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_1'],
292 ],
293 [
294 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2022/04/avatar-04.png',
295 'name' => 'Maria Gonzales',
296 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_2'],
297 ],
298 [
299 'avatar' => 'https://mllj2j8xvfl0.i.optimole.com/cb:3970~373ad/w:80/h:80/q:mauto/https://themeisle.com/wp-content/uploads/2022/04/avatar-05.png',
300 'name' => 'Florian Henckel',
301 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_3'],
302 ],
303 ],
304 ],
305 ],
306 ],
307 ];
308
309 return array_filter(
310 $pages,
311 function ( $page_data, $page_key ) use ( $product_pages ) {
312 return in_array( $page_key, $product_pages, true ) &&
313 isset( $page_data['plugin']['status'] ) &&
314 $page_data['plugin']['status'] === 'not-installed';
315 },
316 ARRAY_FILTER_USE_BOTH
317 );
318 }
319
320 /**
321 * Get products data.
322 *
323 * @return array
324 */
325 private function get_other_products_data() {
326 $products = [
327 'optimole-wp' => [
328 'name' => 'Optimole',
329 'description' => Loader::$labels['about_us']['others']['optimole_desc'],
330 ],
331 'neve' => [
332 'skip_api' => true,
333 'name' => 'Neve',
334 'description' => Loader::$labels['about_us']['others']['neve_desc'],
335 'icon' => $this->get_sdk_uri() . 'assets/images/neve.png',
336 ],
337 'otter-blocks' => [
338 'name' => 'Otter',
339 ],
340 'tweet-old-post' => [
341 'name' => 'Revive Social',
342 ],
343 'feedzy-rss-feeds' => [
344 'name' => 'Feedzy',
345 ],
346 'woocommerce-product-addon' => [
347 'name' => 'PPOM',
348 'condition' => class_exists( 'WooCommerce', false ),
349 ],
350 'visualizer' => [
351 'name' => 'Visualizer',
352 ],
353 'wp-landing-kit' => [
354 'skip_api' => true,
355 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/wp-landing-kit', $this->get_about_page_slug() ),
356 'name' => 'WP Landing Kit',
357 'description' => Loader::$labels['about_us']['others']['landingkit_desc'],
358 'icon' => $this->get_sdk_uri() . 'assets/images/wplk.png',
359 ],
360 'multiple-pages-generator-by-porthas' => [
361 'name' => 'MPG',
362 ],
363 'sparks-for-woocommerce' => [
364 'skip_api' => true,
365 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce', $this->get_about_page_slug() ),
366 'name' => 'Sparks',
367 'description' => Loader::$labels['about_us']['others']['sparks_desc'],
368 'icon' => $this->get_sdk_uri() . 'assets/images/sparks.png',
369 'condition' => class_exists( 'WooCommerce', false ),
370 ],
371 'templates-patterns-collection' => [
372 'name' => 'Templates Cloud',
373 'description' => Loader::$labels['about_us']['others']['tpc_desc'],
374 ],
375 'wp-cloudflare-page-cache' => [
376 'name' => 'Super Page Cache',
377 ],
378 'hyve-lite' => [
379 'name' => 'Hyve Lite',
380 ],
381 'wp-full-stripe-free' => [
382 'name' => 'WP Full Pay',
383 ],
384 ];
385
386 foreach ( $products as $slug => $product ) {
387 if ( isset( $product['condition'] ) && ! $product['condition'] ) {
388 unset( $products[ $slug ] );
389 continue;
390 }
391
392 if ( $slug === 'neve' ) {
393 $theme = get_template();
394 $themes = wp_get_themes();
395
396 $products[ $slug ]['status'] = isset( $themes['neve'] ) ? 'installed' : 'not-installed';
397 $products[ $slug ]['status'] = $theme === 'neve' ? 'active' : $products[ $slug ]['status'];
398
399 $products[ $slug ]['activationLink'] = add_query_arg(
400 [
401 'stylesheet' => 'neve',
402 'action' => 'activate',
403 '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ),
404 ],
405 admin_url( 'themes.php' )
406 );
407
408 continue;
409 }
410
411 $products[ $slug ]['status'] = $this->is_plugin_installed( $slug ) ? 'installed' : 'not-installed';
412 $products[ $slug ]['status'] = $this->is_plugin_active( $slug ) ? 'active' : $products[ $slug ]['status'];
413 $products[ $slug ]['activationLink'] = $this->get_plugin_activation_link( $slug );
414
415
416 if ( isset( $product['skip_api'] ) ) {
417 continue;
418 }
419
420 $api_data = $this->call_plugin_api( $slug );
421 if ( ! isset( $product['icon'] ) && ( isset( $api_data->icons['2x'] ) || $api_data->icons['1x'] ) ) {
422 $products[ $slug ]['icon'] = isset( $api_data->icons['2x'] ) ? $api_data->icons['2x'] : $api_data->icons['1x'];
423 }
424 if ( ! isset( $product['description'] ) && isset( $api_data->short_description ) ) {
425 $products[ $slug ]['description'] = $api_data->short_description;
426 }
427 if ( ! isset( $product['name'] ) && isset( $api_data->name ) ) {
428 $products[ $slug ]['name'] = $api_data->name;
429 }
430 }
431
432 return $products;
433 }
434
435 /**
436 * Get the page slug.
437 *
438 * @return string
439 */
440 private function get_about_page_slug() {
441 return 'ti-about-' . $this->product->get_key();
442 }
443 }
444