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