'boolean', 'default' => false, ); return $args; } /** * Add the sticky class to the outermost tag of flagged blocks. * * @param string $content Rendered block HTML. * @param array $block Parsed block. * * @return string */ public static function render( $content, $block ) { if ( empty( $block['attrs'][ self::ATTRIBUTE ] ) || '' === trim( (string) $content ) ) { return $content; } $processor = new \WP_HTML_Tag_Processor( $content ); if ( $processor->next_tag() ) { $processor->add_class( Widgets::CSS_CLASS ); return $processor->get_updated_html(); } return $content; } /** * Inspector toggle in the block editor (posts, site editor and widget editor). */ public static function editor_script() { wp_enqueue_script( 'stayrail-editor', STAYRAIL_URL . 'assets/js/editor.js', array( 'wp-hooks', 'wp-compose', 'wp-element', 'wp-components', 'wp-block-editor', 'wp-i18n' ), STAYRAIL_VERSION, true ); wp_set_script_translations( 'stayrail-editor', 'stayrail' ); } /** * Outline for sticky blocks inside the (iframed) editor canvas only. */ public static function editor_style() { if ( ! is_admin() ) { return; } wp_enqueue_style( 'stayrail-editor', STAYRAIL_URL . 'assets/css/editor.css', array(), STAYRAIL_VERSION ); } }