Helper.php
61 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Divi Integration helper functions. |
| 4 | * |
| 5 | * @since 3.0.5 |
| 6 | * @package EverestForms\Addons\DiviBuilder |
| 7 | */ |
| 8 | |
| 9 | namespace EverestForms\Addons\DiviBuilder; |
| 10 | |
| 11 | /** |
| 12 | * Oxygen Integration helper functions. |
| 13 | * |
| 14 | * @package EverestForms\Addons\DiviBuilder |
| 15 | * |
| 16 | * @since 3.0.5 |
| 17 | */ |
| 18 | class Helper { |
| 19 | |
| 20 | /** |
| 21 | * Return if Divi is active. |
| 22 | * |
| 23 | * @since 3.0.5 |
| 24 | * |
| 25 | * @return boolean |
| 26 | */ |
| 27 | public static function is_divi_active() { |
| 28 | $active_theme_details = wp_get_theme(); |
| 29 | $theme_name = $active_theme_details->Name; |
| 30 | $parent_theme = $active_theme_details->parent(); |
| 31 | $parent_theme_name = $parent_theme ? $parent_theme->Name : ''; |
| 32 | |
| 33 | if ( 'Divi' === $theme_name || 'Divi' === $parent_theme_name ) { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Notice if the divi is not installed. |
| 42 | * |
| 43 | * @since 3.0.5 |
| 44 | */ |
| 45 | public static function print_admin_notice() { |
| 46 | add_action( |
| 47 | 'admin_notices', |
| 48 | function () { |
| 49 | printf( |
| 50 | '<div class="notice notice-warning is-dismissible"><p><strong>%s </strong>%s</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">%s</span></button></div>', |
| 51 | esc_html( 'Everest Forms:' ), |
| 52 | wp_kses_post( 'Divi Integration addon requires Divi theme to be installed and activated.', 'everest-forms' ), |
| 53 | esc_html__( 'Dismiss this notice.', 'everest-forms' ) |
| 54 | ); |
| 55 | } |
| 56 | ); |
| 57 | |
| 58 | return; |
| 59 | } |
| 60 | } |
| 61 |