Code Block

Aegis adds site-wide defaults for the core Code block, plus a few extras. They are on Aegis → Blocks → Code (admin.php?page=aegis-blocks#code).

Updated 2 min read Atmostfear Entertainment

The Code section on the Blocks screen.

A block’s own setting in the editor always wins over these defaults.

Free Settings

Setting Default What it does
Copy Button On Shows a Copy to clipboard button on code blocks. Off: no button unless a block turns it on.
Line Numbers Off Numbers the lines of code blocks by default.
Wrap Long Lines Off Wraps long lines instead of scrolling sideways.
Language Label Off Shows the language in the top left corner. Add a class such as language-php to the block.

The copy button has always been on, so it stays on until you switch it off.

Pro Settings

These need Aegis Pro. Without it the toggles are locked and marked Pro Feature.

Setting How you use it
Collapse Long Blocks Automatic. A block over 20 lines is cut off with a Show more button underneath.
Filename Bar Start the block with a comment line such as // file: functions.php. It becomes a bar above the code, and the line is not shown or copied.
Highlight Lines After the filename line, add a comment such as // highlight: 3,7-9. Those lines get a background. Line numbers count the code that is shown.
Download Button Adds a button that saves the block as a file, named after the filename bar, or code.<language>, or code.txt.
Copy Button Position Add the class copy-left or copy-bottom to the block to move the copy button.

The directive comments can start with //, #, /*, or <!--. The filename line comes first, then the highlight line. If a setting is off, its comment line is shown as ordinary code.

Code Block Pro and Syntax Highlighting

These settings are for the core Code block. If Code Block Pro or Syntax Highlighting Code Block is active, those blocks have their own settings. Connect them on Aegis → Integrations.

For Developers

  • aegis_code_block_default filters each default. It receives the value and the setting name (copy_button, line_numbers, wrap_lines, language_label, collapse, filename, highlight_lines, download, or copy_position).
  • aegis_code_block_collapse_lines changes the 20-line cutoff for Collapse Long Blocks.

Next Steps

Was this article helpful?