GitHub code embed block/How to get Github token

GitHub code embed block/How to get Github token

The WordPress theme Mone allows you to embed Github code as follows:

WordPress/gutenberg/gutenberg.php

Lines 1 to 13 in df98e37

		
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php /** * Plugin Name: Gutenberg * Plugin URI: https://github.com/WordPress/gutenberg * Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality. * Requires at least: 6.6 * Requires PHP: 7.2 * Version: 19.8.0 * Author: Gutenberg Team * Text Domain: gutenberg * * @package gutenberg */

I will explain how to use this block.

How to use the GitHub code embed block

  1. Open the Github code you want to embed.
  2. Hold down shift and select the range of code you want to embed.
  3. Click Copy Parmalink from the three lines to copy the link.
  4. Embed the copied link in the Github code embed block and you’re done.

How to get a Github token

The Github code embed block uses the Github REST API. The Github REST API has a limit of 60 accesses per hour from the same IP address.

The code is cached when it is displayed, but the limit is quickly reached. We recommend using a Github token, as this will relax the API limit.

1.Create a Github account and go to the Settings screen.

2. Click Developer settings from the menu on the left.

3. Click Generate new token from Personal Access Token > Fine-grained token

4. Set the Token name and Expiration and click Generate Token (you can leave the rest as default).

5. A token will be issued, so copy it.

*Once you close the screen, you will not be able to see the token again, so be sure to save it in a safe place.

6. Return to WordPress and paste your GitHub token from the Mone settings and you’re done.

When writing technical blogs, I hope that pasting code from Github will make the articles easier to understand!