Project Category: WordPress Library

  • WP Package Updater – composer-ready library

    Used to enable updates for plugins and themes distributed via WP Plugin Update Server.

  • Grunt WP plugin tasks

    (formerly barely known as olib-dev)

    Dev libraries that might or might not be useful for WordPress plugins developers.

    See the sister project magicoli/grunt-translation-tasks to use in a generic project (using gettext insttead of WP-specific framework).

    Provides

    • makereadmetxt: Builds or updates the WordPress standard plugin readme.txt compiling and reformatting README.md, INSTALLATION.md, FAQ.md, CHANGELOG.md.
    • i18n: Prepares internationalization assets, updating text domains, generating POT, and converting PO files to MO.
    • makemo: Converts PO files to MO using WP CLI.

    Installation

    1. Clone the repository into your plugin’s subfolder (e.g., at dev/grunt-wp-plugin-tasks).
    2. Exclude this subfolder from distribution (e.g., add dev/grunt-wp-plugin-tasks to your .distignore).
    3. Add the following workspace configuration to your plugin’s package.json:
      "workspaces": {
       "packages": [
         "dev/grunt-wp-plugin-tasks"
       ]
      }
    4. Run "npm install" to install dependencies.
    5. In your plugin’s Gruntfile.js
      • Define your plugin slug name slug (e.g. ‘my-plugin’)
      • Load the custom tasks with:
        // ...existing code...
        const pluginName = 'YOURPLUGINSLUG'; // replace with your slug
        require('./dev/grunt-wp-plugin-tasks/grunt-wp-plugin-tasks.js')(grunt, pluginName);
        // ...existing code...
    6. Run "grunt" or invoke specific tasks (e.g., "grunt i18n") as needed.
  • grunt-translation-tasks

    Grunt tasks for managing translations and internationalization in PHP projects using standard gettext tools.

    Features

    • makepot (xgettext): Extracts translatable strings from PHP files into POT template
    • msgmerge: Updates existing PO files with new strings from POT file
    • makemo (msgfmt): Compiles PO files to binary MO files
    • i18n: Complete workflow – extract, merge, and compile translations

    Installation

    1. Clone this repository into your project’s dev folder:
      git submodule add https://github.com/magicoli/grunt-translation-tasks dev/grunt-translation-tasks
    1. Add workspace configuration to your project’s package.json:
      "workspaces": {
       "packages": [
         "dev/grunt-translation-tasks"
       ]
      }
    1. Install dependencies:
      npm install
    1. Load the tasks in your Gruntfile.js:
      // Load translation tasks
      require('./dev/grunt-translation-tasks/grunt-translation-tasks.js')(grunt);

    Usage

    Available Tasks

    • grunt makepot – Extract strings to POT file
    • grunt msgmerge – Update PO files with new POT content
    • grunt makemo – Compile PO files to MO files
    • grunt i18n – Run complete translation workflow

    Directory Structure

    Uses standard gettext directory structure:

    locale/
    ├── project-name.pot          # Template file
    ├── fr_FR/
    │   └── LC_MESSAGES/
    │       ├── project-name.po   # French translations
    │       └── project-name.mo   # Compiled binary
    ├── nl_NL/
    │   └── LC_MESSAGES/
    │       ├── project-name.po   # Dutch translations
    │       └── project-name.mo   # Compiled binary
    └── ...

    Supported Translation Functions

    Extracts strings from these PHP functions:

    • _(), __() – Basic translation
    • _e() – Echo translation
    • _c(), _x(), _ex() – Context translation
    • _n(), _nx() – Plural translation
    • esc_attr__(), esc_html__() – Escaped translation
    • esc_attr_e(), esc_html_e() – Escaped echo translation

    Requirements

    • Node.js >= 14.0.0
    • Grunt CLI
    • Standard gettext tools (xgettext, msgmerge, msgfmt)

    Configuration

    The project name is automatically detected from your package.json. You can customize paths and options by modifying the task configuration in your Gruntfile.js after loading the tasks.