id ) { return true; } return false; } /** * Constructor. */ private function __construct() { add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_inline_scripts' ), 14 ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'localize_scripts' ) ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'remove_all_scripts' ), 999 ); /* * Remove the emoji script. * We have faced an issue when using emojis with Slate React rich text editor; they were converted to images. * Now after removing this action, they are working correctly. */ // remove_action( 'wp_head', 'print_emoji_detection_script', 20 ); // add_action( 'admin_init', [ $this, 'disable_admin_emojis' ] ); // Remove DNS prefetch s.w.org (used for emojis, since WP 4.7) add_action( 'admin_head', array( __CLASS__, 'remove_notices' ) ); add_action( 'admin_notices', array( __CLASS__, 'inject_before_notices' ), -9999 ); add_action( 'admin_notices', array( __CLASS__, 'inject_after_notices' ), PHP_INT_MAX ); add_filter( 'admin_body_class', array( __CLASS__, 'add_admin_body_class' ), PHP_INT_MAX ); } /** * Add admin body class. * * @since 1.0.0 * * @param string $classes Body classes. */ public static function add_admin_body_class( $classes ) { if ( self::is_admin_page() ) { $classes .= ' js is-fullscreen-mode'; } return $classes; } /** * Localize scripts * * @since 1.0.0 */ public static function localize_scripts() { global $submenu; $user = wp_get_current_user(); $plugins_dir = trailingslashit( dirname( dirname( QUILLFORMS_PLUGIN_FILE ) ) ); // DoubleScale is our partner CRM/mailer. Its free version ships an SMTP // module that Quill Forms relies on to deliver email notifications. // Free version: https://wordpress.org/plugins/doublescale/ $doublescale_plugin_file = $plugins_dir . 'doublescale/doublescale.php'; $doublescale_installed = file_exists( $doublescale_plugin_file ); $doublescale_active = defined( 'DOUBLESCALE_VERSION' ) || is_plugin_active( 'doublescale/doublescale.php' ); $doublescale_smtp = self::get_doublescale_smtp_status( $doublescale_active ); wp_localize_script( 'quillforms-client', 'qfAdmin', array( 'adminUrl' => admin_url(), 'assetsBuildUrl' => QUILLFORMS_PLUGIN_URL, 'submenuPages' => $submenu['quillforms'] ?? array(), // Drives the "New" badge on the MCP Server menu item. Cleared // once the page has been opened, so it stops nagging. 'mcpIsNew' => ! get_option( 'quillforms_mcp_page_seen' ), 'site_store_nonce' => wp_create_nonce( 'quillforms_site_store' ), 'license_nonce' => wp_create_nonce( 'quillforms_license' ), 'duplicate_nonce' => wp_create_nonce( 'quillforms_duplicate' ), 'current_user_name' => $user->display_name, 'current_user_avatar_url' => esc_url( get_avatar_url( $user->ID ) ), // DoubleScale (our partner) provides email delivery via its SMTP module. 'is_doublescale_installed' => $doublescale_installed, 'is_doublescale_active' => $doublescale_active, 'is_doublescale_smtp_module_active' => $doublescale_smtp['module_active'], 'doublescale_smtp_has_connections' => $doublescale_smtp['has_connections'], 'doublescale_smtp_settings_url' => $doublescale_smtp['settings_url'], 'doublescale_wporg_url' => 'https://wordpress.org/plugins/doublescale/', 'settings' => Settings::get_all(), ) ); // DoubleScale integration - check installation and activation status. wp_localize_script( 'quillforms-client', 'quillformsDoubleScaleIntegration', array( 'isInstalled' => $doublescale_installed, 'isActive' => $doublescale_active, 'installNonce' => wp_create_nonce( 'quillforms_install_doublescale' ), 'activateNonce' => wp_create_nonce( 'quillforms_activate_doublescale' ), 'ajaxUrl' => admin_url( 'admin-ajax.php' ), ) ); } /** * Resolve DoubleScale SMTP module status for the admin client. * * Reports whether the bundled SMTP module is active and whether it has at * least one connection configured, so the notifications editor can warn the * user before their email notifications silently fail to deliver. * * @since 3.5.0 * * @param bool $doublescale_active Whether the DoubleScale plugin is active. * @return array{module_active:bool,has_connections:bool,settings_url:string} */ private static function get_doublescale_smtp_status( $doublescale_active ) { $status = array( 'module_active' => false, 'has_connections' => false, 'settings_url' => '', ); if ( ! $doublescale_active ) { return $status; } // Module toggle state (SMTP module lives in the free DoubleScale plugin). if ( function_exists( 'doublescale_is_module_active' ) ) { $status['module_active'] = (bool) doublescale_is_module_active( 'smtp' ); } // Connections are stored in the SMTP module settings option. $settings = get_option( 'doublescale_smtp_settings', array() ); $connections = ( is_array( $settings ) && ! empty( $settings['connections'] ) && is_array( $settings['connections'] ) ) ? $settings['connections'] : array(); $status['has_connections'] = ! empty( $connections ); // Deep link to the SMTP settings screen inside DoubleScale. $slug = apply_filters( 'doublescale_admin_menu_slug', 'doublescale' ); $status['settings_url'] = admin_url( 'admin.php?page=' . rawurlencode( $slug ) . '&path=smtp%2Fsettings' ); return $status; } /** * Remove all scripts * * @since 1.0.0 */ public static function remove_all_scripts() { global $wp_scripts; global $wp_styles; if ( self::is_admin_page() ) { $wp_scripts->queue = array( 'jquery', 'media-audiovideo' ); wp_enqueue_media(); // filter the scripts so they don't have this script: elementor-ai-media-library $wp_scripts->queue = array_filter( $wp_scripts->queue, function( $script ) { return 'elementor-ai-media-library' !== $script; } ); } } /** * Add inline scripts. * * @since 1.0.0 */ public static function add_inline_scripts() { Core::register_block_types_by_js(); Core::set_admin_config(); Core::add_gallery_themes(); // Core::add_tailwind_config(); } /** * Removes notices that should not be displayed on QF Admin pages. * * @since 1.0.0 */ public static function remove_notices() { if ( ! self::is_admin_page() ) { return; } // Hello Dolly. if ( function_exists( 'hello_dolly' ) ) { remove_action( 'admin_notices', 'hello_dolly' ); } } /** * Runs before admin notices action and hides them. * * @since 1.0.0 */ public static function inject_before_notices() { if ( ! self::is_admin_page() ) { return; } // Wrap the notices in a hidden div to prevent flickering before // they are moved elsewhere in the page by WordPress Core. echo ''; } /** * Set up a div for the app to render into. */ public static function page_wrapper() { ?> = 32453 ) // remove_action( 'init', 'smilies_init', 5 ); // This re // Load client script and style. Client is main app entry. wp_enqueue_script( 'quillforms-client' ); wp_enqueue_style( 'quillforms-client' ); // Load builder core package style. wp_enqueue_style( 'quillforms-builder-core' ); // wp_enqueue_script( 'tailwindcss' ); // Important to check for authentication. wp_auth_check_load(); // load all block styles and scripts. foreach ( Blocks_Manager::instance()->get_all_registered() as $block ) { if ( ! empty( $block->block_admin_assets ) ) { if ( ! empty( $block->block_admin_assets['style'] ) ) { wp_enqueue_style( $block->block_admin_assets['style'] ); } if ( ! empty( $block->block_admin_assets['script'] ) ) { wp_enqueue_script( $block->block_admin_assets['script'] ); } } if ( ! empty( $block->block_renderer_assets ) ) { if ( ! empty( $block->block_renderer_assets['style'] ) ) { wp_enqueue_style( $block->block_renderer_assets['style'] ); } if ( ! empty( $block->block_renderer_assets['script'] ) ) { wp_enqueue_script( $block->block_renderer_assets['script'] ); } } } ?>