PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.0
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.0, at vendor/codeinwp/themeisle-sdk/src/Modules/About_us.php

415 lines 13.8 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 $this->about_data['upgrade_text'],
128 'manage_options',
129 $this->about_data['upgrade_link'],
130 '',
131 101
132 );
133 }
134
135 /**
136 * Render page content.
137 *
138 * @return void
139 */
140 public function render_about_us_page() {
141 echo '<div id="ti-sdk-about"></div>';
142 }
143
144 /**
145 * Enqueue scripts & styles.
146 *
147 * @return void
148 */
149 public function enqueue_about_page_script() {
150 $current_screen = get_current_screen();
151
152 if ( ! isset( $current_screen->id ) ) {
153 return;
154 }
155
156 if ( strpos( $current_screen->id, $this->get_about_page_slug() ) === false ) {
157 return;
158 }
159 global $themeisle_sdk_max_path;
160 $handle = 'ti-sdk-about-' . $this->product->get_key();
161 $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/about/about.asset.php';
162 $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] );
163
164 wp_register_script( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.js', $deps, $asset_file['version'], true );
165 wp_localize_script( $handle, 'tiSDKAboutData', $this->get_about_localization_data() );
166
167 wp_enqueue_script( $handle );
168 wp_enqueue_style( $handle, $this->get_sdk_uri() . 'assets/js/build/about/about.css', [ 'wp-components' ], $asset_file['version'] );
169 }
170
171 /**
172 * Get localized data.
173 *
174 * @return array
175 */
176 private function get_about_localization_data() {
177 $links = isset( $this->about_data['page_menu'] ) ? $this->about_data['page_menu'] : [];
178 $product_pages = isset( $this->about_data['product_pages'] ) ? $this->about_data['product_pages'] : [];
179
180 return [
181 'links' => $links,
182 'logoUrl' => $this->about_data['logo'],
183 'productPages' => $this->get_product_pages_data( $product_pages ),
184 'products' => $this->get_other_products_data(),
185 'homeUrl' => esc_url( home_url() ),
186 'pageSlug' => $this->get_about_page_slug(),
187 'currentProduct' => [
188 'slug' => $this->product->get_key(),
189 'name' => $this->product->get_name(),
190 ],
191 'teamImage' => $this->get_sdk_uri() . 'assets/images/team.jpg',
192 'strings' => [
193 'aboutUs' => Loader::$labels['about_us']['title'],
194 'heroHeader' => Loader::$labels['about_us']['heroHeader'],
195 'heroTextFirst' => Loader::$labels['about_us']['heroTextFirst'],
196 'heroTextSecond' => Loader::$labels['about_us']['heroTextSecond'],
197 'teamImageCaption' => Loader::$labels['about_us']['teamImageCaption'],
198 'newsHeading' => Loader::$labels['about_us']['newsHeading'],
199 'emailPlaceholder' => Loader::$labels['about_us']['emailPlaceholder'],
200 'signMeUp' => Loader::$labels['about_us']['signMeUp'],
201 'installNow' => Loader::$labels['about_us']['installNow'],
202 'activate' => Loader::$labels['about_us']['activate'],
203 'learnMore' => Loader::$labels['about_us']['learnMore'],
204 'installed' => Loader::$labels['about_us']['installed'],
205 'notInstalled' => Loader::$labels['about_us']['notInstalled'],
206 'active' => Loader::$labels['about_us']['active'],
207 ],
208 'canInstallPlugins' => current_user_can( 'install_plugins' ),
209 'canActivatePlugins' => current_user_can( 'activate_plugins' ),
210 ];
211 }
212
213 /**
214 * Get product pages data.
215 *
216 * @param array $product_pages Product pages.
217 *
218 * @return array
219 */
220 private function get_product_pages_data( $product_pages ) {
221
222 $otter_slug = 'otter-blocks';
223 $otter_plugin = [
224 'status' => 'not-installed',
225 ];
226 $otter_plugin['status'] = $this->is_plugin_installed( $otter_slug ) ? 'installed' : 'not-installed';
227 $otter_plugin['status'] = $this->is_plugin_active( $otter_slug ) ? 'active' : $otter_plugin['status'];
228 $otter_plugin['activationLink'] = $this->get_plugin_activation_link( $otter_slug );
229
230 $pages = [
231 'otter-page' => [
232 'name' => 'Otter Blocks',
233 'hash' => '#otter-page',
234 'product' => $otter_slug,
235 'plugin' => $otter_plugin,
236 'strings' => [
237 'heading' => Loader::$labels['about_us']['otter-page']['heading'],
238 'text' => Loader::$labels['about_us']['otter-page']['text'],
239 'buttons' => [
240 'install_otter_free' => Loader::$labels['about_us']['otter-page']['install_otter_free'],
241 'install_now' => Loader::$labels['about_us']['otter-page']['install_now'],
242 'learn_more' => Loader::$labels['about_us']['otter-page']['learn_more'],
243 'learn_more_link' => tsdk_utmify( 'https://themeisle.com/plugins/otter-blocks/', 'otter-page', 'about-us' ),
244 ],
245 'features' => [
246 'advancedTitle' => Loader::$labels['about_us']['otter-page']['features']['advancedTitle'],
247 'advancedDesc' => Loader::$labels['about_us']['otter-page']['features']['advancedDesc'],
248 'fastTitle' => Loader::$labels['about_us']['otter-page']['features']['fastTitle'],
249 'fastDesc' => Loader::$labels['about_us']['otter-page']['features']['fastDesc'],
250 'mobileTitle' => Loader::$labels['about_us']['otter-page']['features']['mobileTitle'],
251 'mobileDesc' => Loader::$labels['about_us']['otter-page']['features']['mobileDesc'],
252 ],
253 'details' => [
254 's1Title' => Loader::$labels['about_us']['otter-page']['details']['s1Title'],
255 's1Text' => Loader::$labels['about_us']['otter-page']['details']['s1Text'],
256 's2Title' => Loader::$labels['about_us']['otter-page']['details']['s2Title'],
257 's2Text' => Loader::$labels['about_us']['otter-page']['details']['s2Text'],
258 's3Title' => Loader::$labels['about_us']['otter-page']['details']['s3Title'],
259 's3Text' => Loader::$labels['about_us']['otter-page']['details']['s3Text'],
260 's1Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-builder.png',
261 's2Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-patterns.png',
262 's3Image' => $this->get_sdk_uri() . 'assets/images/otter/otter-library.png',
263 ],
264 'testimonials' => [
265 'heading' => Loader::$labels['about_us']['otter-page']['testimonials']['heading'],
266 'users' => [
267 [
268 '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',
269 'name' => 'Michael Burry',
270 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_1'],
271 ],
272 [
273 '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',
274 'name' => 'Maria Gonzales',
275 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_2'],
276 ],
277 [
278 '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',
279 'name' => 'Florian Henckel',
280 'text' => Loader::$labels['about_us']['otter-page']['testimonials']['users']['user_3'],
281 ],
282 ],
283 ],
284 ],
285 ],
286 ];
287
288 return array_filter(
289 $pages,
290 function ( $page_data, $page_key ) use ( $product_pages ) {
291 return in_array( $page_key, $product_pages, true ) &&
292 isset( $page_data['plugin']['status'] ) &&
293 $page_data['plugin']['status'] === 'not-installed';
294 },
295 ARRAY_FILTER_USE_BOTH
296 );
297 }
298
299 /**
300 * Get products data.
301 *
302 * @return array
303 */
304 private function get_other_products_data() {
305 $products = [
306 'optimole-wp' => [
307 'name' => 'Optimole',
308 'description' => Loader::$labels['about_us']['others']['optimole_desc'],
309 ],
310 'neve' => [
311 'skip_api' => true,
312 'name' => 'Neve',
313 'description' => Loader::$labels['about_us']['others']['neve_desc'],
314 'icon' => $this->get_sdk_uri() . 'assets/images/neve.png',
315 ],
316 'otter-blocks' => [
317 'name' => 'Otter',
318 ],
319 'tweet-old-post' => [
320 'name' => 'Revive Old Post',
321 ],
322 'feedzy-rss-feeds' => [
323 'name' => 'Feedzy',
324 ],
325 'woocommerce-product-addon' => [
326 'name' => 'PPOM',
327 'condition' => class_exists( 'WooCommerce', false ),
328 ],
329 'visualizer' => [
330 'name' => 'Visualizer',
331 ],
332 'wp-landing-kit' => [
333 'skip_api' => true,
334 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/wp-landing-kit', $this->get_about_page_slug() ),
335 'name' => 'WP Landing Kit',
336 'description' => Loader::$labels['about_us']['others']['landingkit_desc'],
337 'icon' => $this->get_sdk_uri() . 'assets/images/wplk.png',
338 ],
339 'multiple-pages-generator-by-porthas' => [
340 'name' => 'MPG',
341 ],
342 'sparks-for-woocommerce' => [
343 'skip_api' => true,
344 'premiumUrl' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce', $this->get_about_page_slug() ),
345 'name' => 'Sparks',
346 'description' => Loader::$labels['about_us']['others']['sparks_desc'],
347 'icon' => $this->get_sdk_uri() . 'assets/images/sparks.png',
348 'condition' => class_exists( 'WooCommerce', false ),
349 ],
350 'templates-patterns-collection' => [
351 'name' => 'Templates Cloud',
352 'description' => Loader::$labels['about_us']['others']['tpc_desc'],
353 ],
354 ];
355
356 foreach ( $products as $slug => $product ) {
357 if ( isset( $product['condition'] ) && ! $product['condition'] ) {
358 unset( $products[ $slug ] );
359 continue;
360 }
361
362 if ( $slug === 'neve' ) {
363 $theme = get_template();
364 $themes = wp_get_themes();
365
366 $products[ $slug ]['status'] = isset( $themes['neve'] ) ? 'installed' : 'not-installed';
367 $products[ $slug ]['status'] = $theme === 'neve' ? 'active' : $products[ $slug ]['status'];
368
369 $products[ $slug ]['activationLink'] = add_query_arg(
370 [
371 'stylesheet' => 'neve',
372 'action' => 'activate',
373 '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ),
374 ],
375 admin_url( 'themes.php' )
376 );
377
378 continue;
379 }
380
381 $products[ $slug ]['status'] = $this->is_plugin_installed( $slug ) ? 'installed' : 'not-installed';
382 $products[ $slug ]['status'] = $this->is_plugin_active( $slug ) ? 'active' : $products[ $slug ]['status'];
383 $products[ $slug ]['activationLink'] = $this->get_plugin_activation_link( $slug );
384
385
386 if ( isset( $product['skip_api'] ) ) {
387 continue;
388 }
389
390 $api_data = $this->call_plugin_api( $slug );
391
392 if ( ! isset( $product['icon'] ) ) {
393 $products[ $slug ]['icon'] = isset( $api_data->icons['2x'] ) ? $api_data->icons['2x'] : $api_data->icons['1x'];
394 }
395 if ( ! isset( $product['description'] ) ) {
396 $products[ $slug ]['description'] = $api_data->short_description;
397 }
398 if ( ! isset( $product['name'] ) ) {
399 $products[ $slug ]['name'] = $api_data->name;
400 }
401 }
402
403 return $products;
404 }
405
406 /**
407 * Get the page slug.
408 *
409 * @return string
410 */
411 private function get_about_page_slug() {
412 return 'ti-about-' . $this->product->get_key();
413 }
414 }
415