nathanayling / dmg-read-more

A WordPress plugin that adds a custom Gutenberg block to create stylized anchor links to other posts and a WP-CLI command to search for posts containing these blocks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DMG Read More Plugin

A WordPress plugin that provides a custom Gutenberg block for creating stylized anchor links to other posts, and a WP-CLI command to search for posts containing these blocks.

Features

  1. Gutenberg Block: Adds a custom block that allows editors to search for and select a published post to insert as a stylized anchor link.
  2. WP-CLI Command: Adds a command to search for posts containing the custom Gutenberg block within a specified date range.

Installation

  1. Download and Install the Plugin:

    • Download the plugin ZIP file.
    • Go to your WordPress Admin Dashboard.
    • Navigate to Plugins > Add New > Upload Plugin.
    • Choose the downloaded ZIP file and click Install Now.
    • Activate the plugin after installation.
  2. Manual Installation:

    • Extract the ZIP file.
    • Upload the dmg-read-more folder to the /wp-content/plugins/ directory.
    • Activate the plugin through the Plugins menu in WordPress.

Usage

Gutenberg Block

  1. Add the Block:

    • Create or edit a post/page.
    • In the Gutenberg editor, add a new block and search for "Read More".
    • Select the "Read More" block.
  2. Search and Select a Post:

    • Use the Inspector Controls to search for a post by title.
    • Select a post from the search results.
    • The block will display a stylized anchor link with the text "Read More: {Post Title}" linking to the selected post.

WP-CLI Command

  1. Run the Command:

    • Open your terminal.
    • Navigate to your WordPress installation directory.
    • Use the following command to search for posts containing the custom Gutenberg block:
      wp dmg-read-more search --date-before=<YYYY-MM-DD> --date-after=<YYYY-MM-DD>
    • If the date arguments are omitted, the command defaults to the last 30 days.
  2. Command Arguments:

    • --date-before=<YYYY-MM-DD>: Specify the end date for the search range.
    • --date-after=<YYYY-MM-DD>: Specify the start date for the search range.
  3. Output:

    • The command outputs the post IDs of the matching results.
    • If no posts are found, or any other errors occur, an appropriate message is displayed.

Development

File Structure

dmg-read-more/ |-- dmg-read-more.php |-- includes/ | |-- block.php | |-- cli.php |-- src/ | |-- block.js

Main Plugin File (dmg-read-more.php)

  • Registers the Gutenberg block and WP-CLI command.

Gutenberg Block (includes/block.php)

  • Defines the server-side registration and rendering of the custom Gutenberg block.

Block JavaScript (src/block.js)

  • Defines the client-side functionality of the custom Gutenberg block.

WP-CLI Command (includes/cli.php)

  • Implements the custom WP-CLI command.

About

A WordPress plugin that adds a custom Gutenberg block to create stylized anchor links to other posts and a WP-CLI command to search for posts containing these blocks.


Languages

Language:PHP 56.1%Language:JavaScript 43.9%