%s', esc_html($file_name) ); } $parts .= ''; if ($show_language && 'none' !== $language) { $parts .= sprintf( '%s', esc_html($language) ); } if ($show_copy) { $parts .= sprintf( '', esc_attr($copy_label), esc_attr($copied_label) ); } $header_html = sprintf('
%s
', $parts); } $start_line = (int) ($advanced['startLine']['desktop']['value'] ?? 1); if ($start_line < 1) { $start_line = 1; } $highlight = self::sanitize_highlight_lines($advanced['highlightLines']['desktop']['value'] ?? ''); // The block scrolls, so it must be focusable; role="region" plus a name // means a screen-reader user is told what they have landed in. $label = '' !== $file_name /* translators: %s: the snippet's file name. */ ? sprintf(__('Code sample: %s', 'addons-for-divi'), $file_name) : __('Code sample', 'addons-for-divi'); // Prism's line-numbers plugin activates on `pre.line-numbers` — the // wrapper modifier alone does nothing, so the gutter has to be asked // for on the element the plugin actually looks at. $show_numbers = ($advanced['showLineNumbers']['desktop']['value'] ?? 'on') !== 'off'; $pre_html = sprintf( '
'
                . '%6$s
', $show_numbers ? ' line-numbers' : '', esc_attr($label), $start_line, '' !== $highlight ? sprintf(' data-line="%s"', esc_attr($highlight)) : '', esc_attr($language), self::escape_code($code) ); // The copy confirmation is announced rather than only shown. $status_html = $show_copy && $show_header ? '' : ''; $children = sprintf( '
%2$s%3$s%4$s
', esc_attr(self::wrapper_class($advanced)), $header_html, $pre_html, $status_html ); return Module::render( [ 'attrs' => $attrs, 'elements' => $elements, 'id' => $block->parsed_block['id'], 'name' => $block->block_type->name, 'moduleCategory' => $block->block_type->category, 'classnamesFunction' => [self::class, 'module_classnames'], 'stylesComponent' => [self::class, 'module_styles'], 'scriptDataComponent' => [self::class, 'module_script_data'], 'orderIndex' => $block->parsed_block['orderIndex'] ?? 0, 'storeInstance' => $block->parsed_block['storeInstance'] ?? null, 'children' => [ $elements->style_components(['attrName' => 'module']), $children, ], ] ); } }