| 1 |
<?php |
| 2 |
/** |
| 3 |
* CartFlows Onboarding Helper. |
| 4 |
* |
| 5 |
* @package CartFlows |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace CartflowsAdmin\AdminCore\Inc; |
| 9 |
|
| 10 |
// Exit if accessed directly. |
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Class OnboardingHelper. |
| 17 |
*/ |
| 18 |
class OnboardingHelper { |
| 19 |
|
| 20 |
/** |
| 21 |
* Determine the active supported page builder. |
| 22 |
* |
| 23 |
* This function checks the list of supported page builders and returns the first active one. |
| 24 |
* If no active page builder is found, it returns false. |
| 25 |
* |
| 26 |
* @param array $supported_page_builders List of supported page builders. |
| 27 |
* @return string|bool The slug of the active page builder or false if none is active. |
| 28 |
*/ |
| 29 |
public static function get_active_supported_builder( $supported_page_builders ) { |
| 30 |
foreach ( $supported_page_builders as $key => $builder ) { |
| 31 |
if ( 'yes' === $builder['install'] && 'yes' === $builder['active'] ) { |
| 32 |
return $key; |
| 33 |
} elseif ( 'divi' === $key && self::is_divi_enabled() ) { |
| 34 |
return $key; |
| 35 |
} elseif ( 'bricks-builder' === $key && self::is_bricks_enabled() ) { |
| 36 |
return $key; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Check if divi builder enabled. |
| 45 |
* |
| 46 |
* @param object $theme theme data. |
| 47 |
* @return boolean |
| 48 |
*/ |
| 49 |
public static function is_divi_enabled( $theme = false ) { |
| 50 |
|
| 51 |
if ( empty( $theme ) ) { |
| 52 |
$theme = wp_get_theme(); |
| 53 |
} |
| 54 |
|
| 55 |
if ( defined( 'ET_BUILDER_THEME' ) || defined( 'ET_BUILDER_PLUGIN_VERSION' ) || 'Divi' === $theme->name || 'Divi' === $theme->parent_theme || 'Extra' === $theme->name || 'Extra' === $theme->parent_theme ) { |
| 56 |
return true; |
| 57 |
} |
| 58 |
|
| 59 |
return false; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Check if bricks builder enabled. |
| 64 |
* |
| 65 |
* @return boolean |
| 66 |
*/ |
| 67 |
public static function is_bricks_enabled() { |
| 68 |
|
| 69 |
$theme = wp_get_theme(); |
| 70 |
if ( 'Bricks' === $theme->name || 'Bricks' === $theme->parent_theme ) { |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
return false; |
| 75 |
} |
| 76 |
} |
| 77 |
|