base, array( 'post', 'post-new' ), true ) ) { return; } // Check if we're editing a overlay. global $post; if ( ! $post || 'gblocks_overlay' !== $post->post_type ) { return; } // Check if we're in overlay iframe context. if ( isset( $_GET['gb_overlay_context'] ) && '1' === $_GET['gb_overlay_context'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $assets = generateblocks_pro_get_enqueue_assets( 'gb-overlay-iframe-context' ); // Enqueue the iframe context script. wp_enqueue_script( 'gb-overlay-iframe-context', GENERATEBLOCKS_PRO_DIR_URL . 'dist/overlay-iframe-context.js', // Use built file. $assets['dependencies'], $assets['version'], true ); // Enqueue the iframe context styles. wp_enqueue_style( 'gb-overlay-iframe-context', GENERATEBLOCKS_PRO_DIR_URL . 'dist/overlay-iframe-context.css', array(), filemtime( GENERATEBLOCKS_PRO_DIR . 'dist/overlay-iframe-context.css' ) // Use built file. ); // Add admin body class for overlay context. add_filter( 'admin_body_class', array( $this, 'add_overlay_context_body_class' ) ); } } /** * Add overlay context body class. * * @param string $classes Existing body classes. * @return string Modified body classes. */ public function add_overlay_context_body_class( $classes ) { return $classes . ' gb-overlay-context'; } } // Initialize the class. new GenerateBlocks_Pro_Overlay_Iframe_Context();