PluginProbe
Bookit — Booking & Appointment Calendar / 2.6.0.5
Bookit — Booking & Appointment Calendar v2.6.0.5
2.6.0.5 2.6.0.4 2.6.0.3 2.6.0.2 2.6.0.1 2.6.0 trunk 1.2 1.2.2 1.2.3 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 All 62 releases
bookit / includes / helpers / AddonHelper.php

AddonHelper.php in Bookit — Booking & Appointment Calendar 2.6.0.5, at includes/helpers/AddonHelper.php

60 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Bookit\Helpers;
4
5 /**
6 * Bookit Clean Helper
7 */
8
9
10 class AddonHelper {
11
12 public static $paymentAddon = 'bookit' ;
13 private static $renamedAddonPathes = array(
14 'bookit' => array( 'bookit-pro-premium', 'bookit' ),
15 );
16
17 public static function getInstalledPluginBySlug( string $addonSlug ) {
18 $installedPlugins = get_plugins();
19 if ( array_key_exists( $addonSlug, $installedPlugins ) || in_array( $addonSlug, $installedPlugins, true ) ) {
20 return $installedPlugins [ $addonSlug ];
21 }
22 return array();
23 }
24
25 public static function isProPaymentsInstalled() {
26 return defined( 'BOOKIT_PRO_VERSION' ) ? 'true' : 'false';
27 }
28
29 public static function checkIsInstalledPlugin( string $addonSlug ) {
30 $installedPlugins = get_plugins();
31 return array_key_exists( $addonSlug, $installedPlugins ) || in_array( $addonSlug, $installedPlugins, true ) ? 'true' : 'false';
32 }
33
34 public static function getAddonDataByName( string $addon ) {
35 $classNamespacePart = str_replace( '-', '', ucwords( $addon, '-' ) );
36 $addonClass = sprintf( '%s\Classes\Admin\Base', ucwords( $classNamespacePart ) );
37 $addonPath = $addon;
38 if ( self::$paymentAddon == $addon ) {
39 foreach ( self::$renamedAddonPathes[ $addon ] as $maybeAddonPath ) {
40 if ( file_exists( WP_CONTENT_DIR . sprintf( '/plugins/%s/includes/classes/admin/Base.php', $maybeAddonPath ) ) ) {
41 $addonPath = $maybeAddonPath;
42 }
43 }
44 }
45
46 if ( ! file_exists( WP_CONTENT_DIR . sprintf( '/plugins/%s/includes/classes/admin/Base.php', $addonPath ) ) ) {
47 return array( 'isCanUse' => false );
48 }
49
50 if ( is_plugin_active( sprintf( '%s/%s.php', $addonPath, $addon ) ) && FreemiusHelper::get_license( FreemiusHelper::get_addon_id_by_name( $addon ) ) != null ) {
51 require_once WP_CONTENT_DIR . sprintf( '/plugins/%s/includes/classes/admin/Base.php', $addonPath );
52 if ( class_exists( $addonClass ) ) {
53 return $addonClass::getAddonData();
54 }
55 }
56
57 return array( 'isCanUse' => false );
58 }
59 }
60