Helper.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPBakery Integration helper functions. |
| 4 | * |
| 5 | * @since 3.0.5 |
| 6 | * @package EverestForms\Addons\WPBakeryBuilder |
| 7 | */ |
| 8 | |
| 9 | namespace EverestForms\Addons\WPBakeryBuilder; |
| 10 | |
| 11 | /** |
| 12 | * WPBakery Integration helper functions. |
| 13 | * |
| 14 | * @package EverestForms\Addons\WPBakeryBuilder |
| 15 | * |
| 16 | * @since 3.0.5 |
| 17 | */ |
| 18 | class Helper { |
| 19 | |
| 20 | /** |
| 21 | * Return if WPBakery is active. |
| 22 | * |
| 23 | * @since 3.0.5 |
| 24 | * |
| 25 | * @return boolean |
| 26 | */ |
| 27 | public static function is_wpbakery_active() { |
| 28 | return in_array( 'js_composer/js_composer.php', get_option( 'active_plugins', array() ), true ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Check if the current request is for WPBakery editor. |
| 33 | * |
| 34 | * @since 3.0.5 |
| 35 | * |
| 36 | * @return boolean |
| 37 | */ |
| 38 | public static function is_WPBakery_editor() { |
| 39 | return isset( $_REQUEST['action'] ) && |
| 40 | ( in_array( $_REQUEST['action'], array( 'vc_load_shortcode', 'vc_inline', 'vc_frontend_editor' ), true ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Notice if the WPBakery is not instaled. |
| 45 | * |
| 46 | * @since 3.0.5 |
| 47 | */ |
| 48 | public static function print_admin_notice() { |
| 49 | |
| 50 | add_action( |
| 51 | 'admin_notices', |
| 52 | function () { |
| 53 | printf( |
| 54 | '<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>', |
| 55 | esc_html( 'Everest Forms:' ), |
| 56 | wp_kses_post( 'WPBakery Integration addon requires WPBakery to be installed and activated.', 'everest-forms' ), |
| 57 | esc_html__( 'Dismiss this notice.', 'everest-forms' ) |
| 58 | ); |
| 59 | } |
| 60 | ); |
| 61 | |
| 62 | return; |
| 63 | } |
| 64 | } |
| 65 |