| 开发者 | onlinecompiler |
|---|---|
| 更新时间 | 2026年11月13日 17:58 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[onlinecompiler] shortcode in the classic editor), write the code, and readers get a code editor with a Run button right in the page. They can change the code and its input and run it again, with no account and nothing to install. Syntax highlighters only show code; this one runs it.
The code runs on OnlineCompiler.io, a code execution service, in an isolated sandbox with no network access. Nothing runs on your WordPress server.
Who it's for
[onlinecompiler lang="python"]print("Hello")[/onlinecompiler]
Attributes, all optional:
lang: a compiler id such as python-3.14 or g++-15, or a short name such as python, cpp, java, js or sql. The site default if left out.stdin: the program's starting input. Use \n for a new line: stdin="3\n4".theme: auto, light or dark.height: the editor's height in pixels.readonly: 1 so readers can run the code but not change it.lang_select: true or false to show or hide the language menu.problem: the id of a problem stored in your account.locale: pt or es for the buttons and messages.< and & (C++ includes, HTML), the block is the safer choice: the classic editor can change such code when it is saved.
Install this plugin, paste your free OnlineCompiler.io widget key in Settings, OnlineCompiler.io, and add a Code runner block to any post or page. Write the starting code in the block and choose its language in the sidebar. Readers can then edit and run it in the page.
Add a Code runner block and leave the language at Python (the default), or use [onlinecompiler lang="python"]print("Hello")[/onlinecompiler] in the classic editor. Readers press Run and see the output under the code.
The plugin is free. Running code uses your OnlineCompiler.io account, which has a free plan with no credit card; see pricing for its monthly runs and the paid plans.
No. Readers edit and run the code without signing in. Only you, the site owner, need an OnlineCompiler.io account, for the widget key.
No. The code runs on OnlineCompiler.io, in a fresh sandbox for each run with no network access, and the sandbox is thrown away afterwards. Your server only serves the page.
Yes, with the [onlinecompiler] shortcode; its attributes are listed above. For code full of < and & (C++ includes, HTML), use the block: the classic editor can change such code when it saves.
The widget script loads only on pages that have a Code runner, and deferred, so it doesn't hold up the page. Each runner connects only when it scrolls into view; one showing a stored problem connects when the page loads.
The code is in the page as text, so readers still see it. Only the Run button needs OnlineCompiler.io.
Readers can check their code against tests. Store a problem with tests in your OnlineCompiler.io account and put its id in the block's Problem setting: readers see the statement and starter code, and Judge checks their code against the problem's sample tests. Grading against hidden tests, with a recorded score, needs a session your own server creates for each student, which this plugin doesn't do; the widget documentation describes it, and tests written into the page with the widget's own markup.
No. Widget keys are made to sit in public pages: they can run code in the widget but can't call the REST API. Set the key's allowed domain to your site so other sites can't use it.
[onlinecompiler] shortcode and the settings page.