elementor_builder_is_active(); } /** * Add Elementor font post type to ignored post types. * * @param string[] $post_types Post types to ignore. * @return string[] */ public function post_types_to_ignore( $post_types ) { $post_types[] = 'elementor_font'; $post_types[] = 'elementor_icons'; $post_types[] = 'elementor_library'; $post_types[] = 'elementor_snippet'; return $post_types; } /** * Check if Elementor builder is active. * * @return boolean */ public function elementor_builder_is_active() { // Check if this is the admin theme builder app. // phpcs:ignore WordPress.Security.NonceVerification.Recommended Simple & direct string comparison. if ( is_admin() && // Disable notices as this is a generic string comparison to prevent doing a lot of work. // phpcs:disable WordPress.Security.NonceVerification.Recommended ! empty( $_GET['page'] ) && 'elementor-app' === $_GET['page'] // phpcs:enable WordPress.Security.NonceVerification.Recommended ) { return true; } if ( ! class_exists( '\Elementor\Plugin' ) || ! isset( \Elementor\Plugin::$instance ) ) { return false; } /** * Elementor instance. * * @var \Elementor\Plugin $elementor */ $elementor = \Elementor\Plugin::$instance; /** * Elementor preview instance. * * @var \Elementor\Preview|(object{is_preview_mod:\Closure}&\stdClass)|false $preview */ $preview = isset( $elementor->preview ) ? $elementor->preview : false; if ( false === $preview || ! method_exists( $preview, 'is_preview_mode' ) ) { return false; } // Check if the page builder is active. return $preview->is_preview_mode(); } }